Skip to content

Commit 84f2c1a

Browse files
devversionandrewseguin
authored andcommitted
feat(material-experimental/mdc-checkbox): support density scaling
1 parent 9500e75 commit 84f2c1a

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/material-experimental/mdc-checkbox/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ sass_binary(
5252
deps = [
5353
"//src/material-experimental/mdc-helpers:mdc_helpers_scss_lib",
5454
"//src/material-experimental/mdc-helpers:mdc_scss_deps_lib",
55+
"//src/material/core:core_scss_lib",
5556
],
5657
)
5758

src/material-experimental/mdc-checkbox/_checkbox-theme.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@
7777
}
7878
}
7979

80-
@mixin mat-mdc-checkbox-density($density-scale) {}
80+
@mixin mat-mdc-checkbox-density($density-scale) {
81+
.mat-mdc-checkbox .mdc-checkbox {
82+
@include mdc-checkbox-density($density-scale);
83+
}
84+
}
8185

8286
@mixin mat-mdc-checkbox-theme($theme) {
8387
$color: mat-get-color-config($theme);

src/material-experimental/mdc-checkbox/checkbox.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
[matRippleTrigger]="checkbox"
3232
[matRippleDisabled]="disableRipple || disabled"
3333
[matRippleCentered]="true"
34-
[matRippleRadius]="20"
3534
[matRippleAnimation]="_rippleAnimation"></div>
3635
</div>
3736
<label #label

src/material-experimental/mdc-checkbox/checkbox.scss

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@import '@material/form-field/mixins.import';
44
@import '@material/ripple/variables.import';
55
@import '../mdc-helpers/mdc-helpers';
6+
@import '../../material/core/style/_layout-common.scss';
67

78
@include mdc-checkbox-without-ripple($query: $mat-base-styles-query);
89
@include mdc-form-field-core-styles($query: $mat-base-styles-query);
@@ -51,13 +52,18 @@
5152
}
5253
}
5354

54-
.mat-mdc-checkbox-ripple, .mat-mdc-checkbox .mdc-checkbox__background::before {
55-
$ripple-size: 40px;
56-
position: absolute;
57-
width: $ripple-size;
58-
height: $ripple-size;
59-
top: 50%;
60-
left: 50%;
61-
margin: (-$ripple-size / 2) 0 0 (-$ripple-size / 2);
55+
.mat-mdc-checkbox-ripple {
56+
@include mat-fill();
57+
58+
// Usually the ripple radius would be specified through the MatRipple input, but
59+
// since we dynamically adjust the size of the ripple container, we cannot use a
60+
// fixed ripple radius.
61+
border-radius: 50%;
6262
pointer-events: none;
63+
64+
// Fixes the ripples not clipping to the border radius on Safari. Uses `:not(:empty)`
65+
// in order to avoid creating extra layers when there aren't any ripples.
66+
&:not(:empty) {
67+
transform: translateZ(0);
68+
}
6369
}

0 commit comments

Comments
 (0)