Skip to content

Commit 32ae3b0

Browse files
committed
Remove data url from progress-bar.
1 parent ff0e612 commit 32ae3b0

File tree

5 files changed

+29
-41
lines changed

5 files changed

+29
-41
lines changed

src/lib/progress-bar/_progress-bar-theme.scss

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$warn: map-get($theme, warn);
99

1010
.mat-progress-bar-background {
11-
background-image: #{_mat-progress-bar-buffer($primary, lighter)};
11+
fill: mat-color($primary, lighter);
1212
}
1313

1414
.mat-progress-bar-buffer {
@@ -21,7 +21,7 @@
2121

2222
.mat-progress-bar.mat-accent {
2323
.mat-progress-bar-background {
24-
background-image: #{_mat-progress-bar-buffer($accent, lighter)};
24+
fill: mat-color($accent, lighter);
2525
}
2626

2727
.mat-progress-bar-buffer {
@@ -35,7 +35,7 @@
3535

3636
.mat-progress-bar.mat-warn {
3737
.mat-progress-bar-background {
38-
background-image: #{_mat-progress-bar-buffer($warn, lighter)};
38+
fill: mat-color($warn, lighter);
3939
}
4040

4141
.mat-progress-bar-buffer {
@@ -50,33 +50,3 @@
5050

5151
@mixin mat-progress-bar-typography($config) { }
5252

53-
// TODO(josephperrott): Find better way to inline svgs.
54-
// In buffer mode a repeated SVG object is used as a background.
55-
// Each of the following defines the SVG object for each of the class defined colors.
56-
//
57-
// The string is a URL encoded version of:
58-
//
59-
// <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
60-
// version="1.1" x="0px" y="0px" enable-background="new 0 0 5 2"
61-
// xml:space="preserve" viewBox="0 0 5 2" preserveAspectRatio="none slice">
62-
// <circle cx="1" cy="1" r="1" fill="{INJECTED_COLOR}"/>
63-
// </svg>
64-
@function _mat-progress-bar-buffer($palette, $hue) {
65-
$color: mat-color($palette, $hue) + '';
66-
67-
// We also need to escape the hash in hex colors,
68-
// otherwise IE will throw an XML error.
69-
@if str-index($color, '#') == 1 {
70-
$color: '%23' + str-slice($color, 2);
71-
}
72-
73-
$result: '' +
74-
'data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%271.1%27%20xmlns%3D%27http%3A%2F%2F' +
75-
'www.w3.org%2F2000%2Fsvg%27%20xmlns%3Axlink%3D%27http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%2' +
76-
'7%20x%3D%270px%27%20y%3D%270px%27%20enable-background%3D%27new%200%200%205%202%27%20xml%' +
77-
'3Aspace%3D%27preserve%27%20viewBox%3D%270%200%205%202%27%20preserveAspectRatio%3D%27none' +
78-
'%20slice%27%3E%3Ccircle%20cx%3D%271%27%20cy%3D%271%27%20r%3D%271%27%20fill%3D%27' +
79-
$color + '%27%2F%3E%3C%2Fsvg%3E';
80-
81-
@return url($result);
82-
}
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
<!-- The background div is named as such because it appears below the other divs and is not sized based on values. -->
2-
<div class="mat-progress-bar-background mat-progress-bar-element"></div>
1+
<!--
2+
The background div is named as such because it appears below the other divs and is not sized based
3+
on values.
4+
-->
5+
<svg width="100%" height="5" class="mat-progress-bar-background mat-progress-bar-element">
6+
<defs>
7+
<pattern [id]="progressbarId" x="5" y="0" width="10" height="5" patternUnits="userSpaceOnUse">
8+
<circle cx="2.5" cy="2.5" r="2.5"/>
9+
</pattern>
10+
</defs>
11+
<rect [attr.fill]="'url(#' + progressbarId + ')'" width="100%" height="100%"/>
12+
</svg>
313
<div class="mat-progress-bar-buffer mat-progress-bar-element" [ngStyle]="_bufferTransform()"></div>
414
<div class="mat-progress-bar-primary mat-progress-bar-fill mat-progress-bar-element" [ngStyle]="_primaryTransform()"></div>
515
<div class="mat-progress-bar-secondary mat-progress-bar-fill mat-progress-bar-element"></div>

src/lib/progress-bar/progress-bar.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ $mat-progress-bar-piece-animation-duration: 250ms !default;
2525
// The progress bar background is used to show the bubble animation scrolling behind a
2626
// buffering progress bar.
2727
.mat-progress-bar-background {
28-
background-repeat: repeat-x;
29-
background-size: 10px 4px;
30-
display: none;
28+
// The width is set to be 10px longer than the container as it will be translated 10px
29+
// during the background scroll animation.
30+
width: calc(100% + 10px);
3131
}
3232

3333
// The progress bar buffer is the bar indicator showing the buffer value and is only visible
@@ -113,7 +113,6 @@ $mat-progress-bar-piece-animation-duration: 250ms !default;
113113
@include backface-visibility(hidden);
114114
animation: mat-progress-bar-background-scroll
115115
$mat-progress-bar-piece-animation-duration infinite linear;
116-
display: block;
117116
}
118117
}
119118
}

src/lib/progress-bar/progress-bar.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
98
import {
109
Component,
1110
ChangeDetectionStrategy,
@@ -26,6 +25,8 @@ export class MatProgressBarBase {
2625

2726
export const _MatProgressBarMixinBase = mixinColor(MatProgressBarBase, 'primary');
2827

28+
/** Counter used to generate unique IDs for progress bars. */
29+
let progressbarId = 0;
2930

3031
/**
3132
* <mat-progress-bar> component.
@@ -56,6 +57,7 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements CanColor
5657
}
5758

5859
/** Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. */
60+
/** Value of the progressbar. Defaults to zero. Mirrored to aria-valuenow. */
5961
@Input()
6062
get value(): number { return this._value; }
6163
set value(v: number) { this._value = clamp(v || 0); }
@@ -76,6 +78,9 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements CanColor
7678
*/
7779
@Input() mode: 'determinate' | 'indeterminate' | 'buffer' | 'query' = 'determinate';
7880

81+
/** The id of the progress bar. */
82+
progressbarId = `mat-progress-bar-${progressbarId++}`;
83+
7984
/** Gets the current transform value for the progress bar's primary indicator. */
8085
_primaryTransform() {
8186
const scale = this.value / 100;

src/lib/tabs/tab-nav-bar/tab-nav-bar.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export const _MatTabLinkMixinBase =
186186
host: {
187187
'class': 'mat-tab-link',
188188
'[attr.aria-disabled]': 'disabled.toString()',
189-
'[attr.tabIndex]': 'tabIndex',
189+
'[attr.tabindex]': '_getTabIndex()',
190190
'[class.mat-tab-disabled]': 'disabled',
191191
'[class.mat-tab-label-active]': 'active',
192192
'(click)': '_handleClick($event)'
@@ -246,6 +246,10 @@ export class MatTabLink extends _MatTabLinkMixinBase
246246
}
247247
}
248248

249+
_getTabIndex(): number | null {
250+
return this.disabled ? null : this.tabIndex;
251+
}
252+
249253
ngOnDestroy() {
250254
this._tabLinkRipple._removeTriggerEvents();
251255
}

0 commit comments

Comments
 (0)