Skip to content

Commit 7555b40

Browse files
devversionmmalerba
authored andcommitted
refactor: reposition ripple container dynamically (#9773)
Right now, the ripple container for the checkbox, radio and slide-toggle are positioned using SCSS calculations. This works fine, but limits people, who want to resize the inner container (e.g. smaller checkbox). Since resizing the checkbox to be smaller is reasonable, because MDC and the specs seem to have smaller boxes (18x18), the ripple container position can be determined using a simple CSS `calc`. References #9244. References #9210.
1 parent 38fddfe commit 7555b40

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/lib/checkbox/checkbox.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
413413

414414
.mat-checkbox-ripple {
415415
position: absolute;
416-
left: $mat-checkbox-size / 2 - $_mat-checkbox-ripple-radius;
417-
top: $mat-checkbox-size / 2 - $_mat-checkbox-ripple-radius;
416+
left: calc(50% - #{$_mat-checkbox-ripple-radius});
417+
top: calc(50% - #{$_mat-checkbox-ripple-radius});
418418
height: $_mat-checkbox-ripple-radius * 2;
419419
width: $_mat_checkbox-ripple-radius * 2;
420420
z-index: 1;

src/lib/radio/radio.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ $mat-radio-ripple-radius: 25px;
101101

102102
.mat-radio-ripple {
103103
position: absolute;
104-
left: $mat-radio-size / 2 - $mat-radio-ripple-radius;
105-
top: $mat-radio-size / 2 - $mat-radio-ripple-radius;
104+
left: calc(50% - #{$mat-radio-ripple-radius});
105+
top: calc(50% - #{$mat-radio-ripple-radius});
106106
height: $mat-radio-ripple-radius * 2;
107107
width: $mat-radio-ripple-radius * 2;
108108
z-index: 1;

src/lib/slide-toggle/slide-toggle.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
167167
// Ripple positioning for the slide-toggle. Moves the ripple container into the center of the thumb.
168168
.mat-slide-toggle-ripple {
169169
position: absolute;
170-
top: $mat-slide-toggle-thumb-size / 2 - $mat-slide-toggle-ripple-radius;
171-
left: $mat-slide-toggle-thumb-size / 2 - $mat-slide-toggle-ripple-radius;
170+
top: calc(50% - #{$mat-slide-toggle-ripple-radius});
171+
left: calc(50% - #{$mat-slide-toggle-ripple-radius});
172172
height: $mat-slide-toggle-ripple-radius * 2;
173173
width: $mat-slide-toggle-ripple-radius * 2;
174174
z-index: 1;

0 commit comments

Comments
 (0)