Skip to content

Commit eb9d5b8

Browse files
authored
feat(mistica-css): checkbox (#1367)
WEB-2195
1 parent 9644cd5 commit eb9d5b8

2 files changed

Lines changed: 241 additions & 42 deletions

File tree

css/mistica-common.css

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
--vcolor-accordionActive: var(--mistica-color-backgroundContainerBrandPressed);
3939

4040
--vcolor-divider: var(--mistica-color-dividerInverse);
41+
42+
--vcolor-control: var(--mistica-color-controlInverse);
43+
--vcolor-controlActivated: var(--mistica-color-controlActivatedInverse);
44+
--vcolor-checkbox-tick: var(--mistica-color-controlKnobInverse);
45+
--vcolor-checkbox-background: transparent;
4146
}
4247

4348
[data-mistica-skin] > *,
@@ -82,6 +87,11 @@
8287
--vcolor-accordionActive: var(--mistica-color-backgroundContainerPressed);
8388

8489
--vcolor-divider: var(--mistica-color-divider);
90+
91+
--vcolor-control: var(--mistica-color-control);
92+
--vcolor-controlActivated: var(--mistica-color-controlActivated);
93+
--vcolor-checkbox-tick: var(--mistica-color-inverse);
94+
--vcolor-checkbox-background: var(--mistica-color-background);
8595
}
8696

8797
@media (prefers-color-scheme: dark) {
@@ -1164,3 +1174,71 @@ button.mistica-display-card:has(.mistica-card__media):active:after {
11641174
margin-top: 24px;
11651175
}
11661176
}
1177+
1178+
/* Checkbox */
1179+
.mistica-checkbox {
1180+
appearance: none;
1181+
position: relative;
1182+
display: inline-flex;
1183+
justify-content: center;
1184+
align-items: center;
1185+
flex-shrink: 0;
1186+
user-select: none;
1187+
vertical-align: middle;
1188+
width: 18px;
1189+
height: 18px;
1190+
margin: 0;
1191+
border-radius: var(--mistica-border-radius-checkbox);
1192+
background: var(--vcolor-checkbox-background);
1193+
box-shadow: inset 0 0 0 2px var(--vcolor-control);
1194+
cursor: pointer;
1195+
transition: box-shadow 0.3s;
1196+
}
1197+
1198+
.mistica-checkbox:not(:focus-visible) {
1199+
outline: 1px solid transparent;
1200+
}
1201+
1202+
.mistica-checkbox:checked {
1203+
box-shadow: inset 0 0 0 12px var(--vcolor-controlActivated);
1204+
}
1205+
1206+
.mistica-checkbox:disabled {
1207+
cursor: default;
1208+
opacity: 0.5;
1209+
}
1210+
1211+
.mistica-checkbox:before {
1212+
content: '';
1213+
width: 12px;
1214+
height: 7px;
1215+
border-bottom: 2px solid var(--vcolor-checkbox-tick);
1216+
border-left: 2px solid var(--vcolor-checkbox-tick);
1217+
transform: scale(0) rotate(-45deg) translate(1.5px, -1.5px);
1218+
transform-origin: center;
1219+
transition: transform 0.3s cubic-bezier(0.68, -0.6, 0.32, 1.6);
1220+
}
1221+
1222+
.mistica-checkbox:checked:before {
1223+
transform: scale(1) rotate(-45deg) translate(1.5px, -1.5px);
1224+
}
1225+
1226+
.mistica-checkbox-label {
1227+
display: inline-flex;
1228+
align-items: center;
1229+
gap: 16px;
1230+
color: var(--vcolor-textPrimary);
1231+
font-size: var(--mistica-font-size-3);
1232+
line-height: var(--mistica-line-height-3);
1233+
font-weight: var(--mistica-font-weight-3);
1234+
cursor: pointer;
1235+
}
1236+
1237+
.mistica-checkbox-label:has(.mistica-checkbox:disabled) {
1238+
cursor: default;
1239+
opacity: 0.5;
1240+
}
1241+
1242+
.mistica-checkbox-label:has(.mistica-checkbox:disabled) > .mistica-checkbox {
1243+
opacity: initial; /* avoid applying 0.5 opacity twice */
1244+
}

0 commit comments

Comments
 (0)