Skip to content

Commit 7d835fc

Browse files
didimmovasimeonoff
andauthored
feat(checkbox): update checkbox implementation and slotted checkbox styles (#1489)
Co-authored-by: Simeon Simeonoff <[email protected]>
1 parent 7538b71 commit 7d835fc

File tree

7 files changed

+35
-31
lines changed

7 files changed

+35
-31
lines changed

src/components/checkbox/themes/checkbox.base.scss

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ $mark-length: 24;
1616
[part~='control'] {
1717
--size: #{rem(20px)};
1818

19+
width: var(--size);
20+
height: var(--size);
21+
min-width: var(--size);
1922
position: relative;
2023
display: inline-flex;
2124
user-select: none;
@@ -45,22 +48,25 @@ $mark-length: 24;
4548
}
4649

4750
[part~='indicator'] {
51+
--indicator-size: #{rem(18px)};
52+
4853
display: flex;
54+
align-items: center;
55+
justify-content: center;
4956
position: absolute;
5057
inset: 0;
5158
stroke-linecap: square;
52-
stroke-width: 3;
59+
stroke-width: var(--mark-stroke, 3);
5360
stroke-dasharray: $mark-length;
5461
stroke-dashoffset: $mark-length;
5562
fill: none;
5663
opacity: 0;
5764
z-index: 1;
58-
transform: scale(.45);
5965
transform-origin: center;
6066

6167
svg {
62-
width: 100%;
63-
height: 100%;
68+
width: var(--indicator-size);
69+
height: var(--indicator-size);
6470
}
6571
}
6672

@@ -82,6 +88,11 @@ label {
8288
stroke-dashoffset: 41;
8389
opacity: 1;
8490
transform: rotate(45deg) scale(.45) translateX(-.25rem);
91+
92+
svg {
93+
width: 100%;
94+
height: 100%;
95+
}
8596
}
8697
}
8798

src/components/checkbox/themes/shared/checkbox/checkbox.bootstrap.scss

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,15 @@ $theme: $bootstrap;
1919
}
2020

2121
[part~='indicator'] {
22-
stroke-width: 3;
23-
transform: scale(.7);
22+
--indicator-size: #{rem(11px)};
23+
2424
transition: none;
2525
}
2626

2727
[part~='control'] {
2828
--size: #{rem(16px)};
2929

3030
border-radius: var-get($theme, 'border-radius-ripple');
31-
width: var(--size);
32-
height: var(--size);
33-
min-width: var(--size);
3431
transition: all .15s ease-in-out;
3532
background: var-get($theme, 'empty-fill-color');
3633

@@ -92,8 +89,6 @@ $theme: $bootstrap;
9289
}
9390

9491
[part~='indicator'] {
95-
stroke-dashoffset: 41;
96-
opacity: 1;
9792
transform: rotate(45deg) translateX(-.075rem) scale(.7);
9893
}
9994
}

src/components/checkbox/themes/shared/checkbox/checkbox.fluent.scss

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ $disabled-color: var-get($theme, 'disabled-color');
1919
}
2020

2121
[part~='control'] {
22-
width: var(--size, rem(20px));
23-
height: var(--size, rem(20px));
24-
min-width: var(--size, rem(20px));
25-
2622
// Removing visual artifacts, to understand the problem see
2723
// https://stackoverflow.com/questions/69658462/inset-box-shadow-visual-artifacts-in-google-chrome
2824
transform: translate3d(0, 0, 0);
@@ -42,8 +38,8 @@ $disabled-color: var-get($theme, 'disabled-color');
4238
}
4339

4440
[part~='indicator'] {
45-
stroke-width: 1.5;
46-
transform: scale(.8);
41+
--indicator-size: #{rem(16px)};
42+
--mark-stroke: 1.5;
4743
}
4844

4945
:host(:hover) {

src/components/checkbox/themes/shared/checkbox/checkbox.indigo.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ $error-color-hover: var-get($theme, 'error-color-hover');
2525
--size: #{rem(16px)};
2626

2727
border-radius: var-get($theme, 'border-radius-ripple');
28-
width: var(--size, rem(16px));
29-
height: var(--size, rem(16px));
30-
min-width: var(--size, rem(16px));
3128

3229
&::after {
3330
border-radius: var-get($theme, 'border-radius');
@@ -41,14 +38,15 @@ $error-color-hover: var-get($theme, 'error-color-hover');
4138
}
4239

4340
[part~='indicator'] {
41+
--indicator-size: #{rem(13px)};
42+
4443
stroke: unset;
4544
stroke-linecap: unset;
4645
stroke-width: unset;
4746
stroke-dasharray: unset;
4847
stroke-dashoffset: unset;
4948
fill: var-get($theme, 'tick-color');
5049
transition: none;
51-
transform: scale(.8);
5250

5351
rect {
5452
fill: none;

src/components/checkbox/themes/shared/checkbox/checkbox.material.scss

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,10 @@ $theme: $material;
1616
@include type-style('subtitle-1');
1717
}
1818

19-
label {
20-
gap: rem(2px);
21-
}
22-
2319
[part~='control'] {
24-
--size: #{rem(20px)};
25-
26-
width: calc(var(--size) * 2);
27-
height: calc(var(--size) * 2);
28-
min-width: calc(var(--size) * 2);
20+
// We expose that css variable to override the padding of
21+
// the checkbox control in components that we nest it in like List and Tree.
22+
padding: var(--control-padding, rem(20px));
2923
transition: background .15s ease-in;
3024

3125
&::after {
@@ -52,6 +46,8 @@ label {
5246
}
5347

5448
[part~='base'] {
49+
gap: rem(2px);
50+
5551
&:hover {
5652
[part~='control'] {
5753
&::before {

src/components/list/themes/item.base.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
}
1616

1717
::slotted(*) {
18+
// We're not able to target the control part of the checkbox
19+
// that's why we exposed that css variable (https://github.com/w3c/csswg-drafts/issues/3896)
20+
--control-padding: 0;
21+
1822
margin: 0;
1923
font: inherit;
2024
opacity: inherit;
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
@use 'styles/utilities' as *;
22

3+
igc-checkbox {
4+
--control-padding: 0;
5+
}
6+
37
[part~='select'] {
4-
margin-inline-end: rem(4px);
8+
margin-inline: rem(10px) rem(14px);
59
}

0 commit comments

Comments
 (0)