Skip to content

Commit 347110f

Browse files
allan-chencopybara-github
authored andcommitted
feat(circular-progress): support track color
PiperOrigin-RevId: 334177072
1 parent 394fd3f commit 347110f

File tree

7 files changed

+26
-6
lines changed

7 files changed

+26
-6
lines changed

packages/circular-progress-four-color/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Name | Default
8484
`--mdc-circular-progress-bar-color-2` | `--mdc-theme-primary` | Sets the second of the four rotating colors.
8585
`--mdc-circular-progress-bar-color-3` | `--mdc-theme-primary` | Sets the third of the four rotating colors.
8686
`--mdc-circular-progress-bar-color-4` | `--mdc-theme-primary` | Sets the last of the four rotating colors.
87+
`--mdc-circular-progress-track-color` | transparent | Sets the track color of the determinate progress bar.
8788

8889
#### Global Custom Properties
8990

packages/circular-progress-four-color/_circular-progress-four-color-theme.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ $light-theme: (
2828
theme-color.prop-value(primary),
2929
theme-color.prop-value(primary),
3030
theme-color.prop-value(primary)
31-
)
31+
),
32+
track-color: transparent
3233
);
3334

3435
@mixin theme($theme: $light-theme) {
3536
$bar-color: map.get($theme, bar-color);
3637
$bar-indeterminate-colors: map.get($theme, bar-indeterminate-colors);
38+
$track-color: map.get($theme, track-color);
3739

3840
@include css.declaration(--mdc-theme-primary, $bar-color);
3941

@@ -47,4 +49,6 @@ $light-theme: (
4749
@include css.declaration(--mdc-circular-progress-bar-color-3, nth($bar-indeterminate-colors, 3));
4850
@include css.declaration(--mdc-circular-progress-bar-color-4, nth($bar-indeterminate-colors, 4));
4951
}
52+
53+
@include css.declaration(--mdc-circular-progress-track-color, $track-color);
5054
}

packages/circular-progress-four-color/_circular-progress-four-color.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
17-
@use '@material/circular-progress' as circularprogress;
17+
@use '@material/circular-progress' as circular-progress;
1818
@use '@material/theme/theme-color';
1919
@use '@material/theme/custom-properties';
20+
@use '@material/mwc-circular-progress/circular-progress' as mwc-circular-progress;
2021

2122
@mixin core-styles() {
22-
@include circularprogress.core-styles();
23+
@include mwc-circular-progress.core-styles();
2324

2425
$primary: custom-properties.create(--mdc-theme-primary, theme-color.prop-value(primary));
25-
@include circularprogress.indeterminate-colors((
26+
@include circular-progress.indeterminate-colors((
2627
custom-properties.create(--mdc-circular-progress-bar-color-1, $primary),
2728
custom-properties.create(--mdc-circular-progress-bar-color-2, $primary),
2829
custom-properties.create(--mdc-circular-progress-bar-color-3, $primary),

packages/circular-progress/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ None
7373

7474
### CSS Custom Properties
7575

76+
Name | Default | Description
77+
------------------------------------- | ------------ | -----------
78+
`--mdc-circular-progress-track-color` | transparent | Sets the track color of the determinate progress bar.
79+
7680
#### Global Custom Properties
7781

7882
This component exposes the following global [theming](https://github.com/material-components/material-components-web-components/blob/master/docs/theming.md)

packages/circular-progress/_circular-progress-theme.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ limitations under the License.
2222

2323
$light-theme: (
2424
bar-color: theme-color.prop-value(primary),
25+
track-color: transparent,
2526
);
2627

2728
@mixin theme($theme: $light-theme) {
28-
$bar-color: map.get($theme, bar-color);
29-
@include css.declaration(--mdc-theme-primary, $bar-color);
29+
@include css.declaration(--mdc-theme-primary, map.get($theme, bar-color));
30+
@include css.declaration(--mdc-circular-progress-track-color, map.get($theme, track-color));
3031
}
32+
33+

packages/circular-progress/_circular-progress.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ limitations under the License.
2323
:host {
2424
display: inline-flex;
2525
}
26+
27+
@include circularprogress.track-color(custom-properties.create(
28+
--mdc-circular-progress-track-color,
29+
transparent));
2630
}

packages/circular-progress/mwc-circular-progress-base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export class CircularProgressBase extends LitElement {
8787
<div class="mdc-circular-progress__determinate-container">
8888
<svg class="mdc-circular-progress__determinate-circle-graphic"
8989
viewBox="0 0 ${sideLength} ${sideLength}">
90+
<circle class="mdc-circular-progress__determinate-track"
91+
cx="${center}" cy="${center}" r="${circleRadius}"
92+
stroke-width="${strokeWidth}"></circle>
9093
<circle class="mdc-circular-progress__determinate-circle"
9194
cx="${center}" cy="${center}" r="${circleRadius}"
9295
stroke-dasharray="${2 * 3.1415926 * circleRadius}"

0 commit comments

Comments
 (0)