Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(checkbox): implement-dark-themes #158

Merged
merged 4 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 5 additions & 73 deletions src/components/checkbox/checkbox.dark.fluent.scss
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
@use '../../styles/utilities' as utils;
@use 'checkbox.fluent.scss' as light-checkbox;

@include light-checkbox.theme();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should rather be included in the theme mixin.


@mixin theme() {
igc-checkbox::part(control) {
width: var(--size, utils.rem(20px));
height: var(--size, utils.rem(20px));
min-width: var(--size, utils.rem(20px));
background: transparent;
transition: none;

&::after {
border: none;
background: transparent;
box-shadow: inset 0 0 0 1px #{utils.color(gray, 500)};
box-shadow: inset 0 0 0 1px #{utils.color(gray, 700)};
}
}

igc-checkbox::part(indicator) {
stroke-width: 1.5;
transform: scale(.8);
stroke: #{utils.color(surface, 500)};
}

igc-checkbox:hover {
&::part(indicator) {
opacity: 1;
stroke: #{utils.color(gray, 700)};
stroke-dashoffset: 0;
transition: opacity .1s ease-out;
}

&::part(indicator checked) {
stroke: #{utils.color(surface, 500)};
}
Expand All @@ -37,33 +23,7 @@
igc-checkbox:hover,
igc-checkbox:focus-within {
&::part(control)::after {
box-shadow: inset 0 0 0 1px #{utils.color(gray, 800)};
}
}

igc-checkbox[indeterminate] {
&::part(indicator) {
display: none;
}

&::part(control)::before {
display: block;
width: inherit;
height: inherit;
content: '';
transform: scale(.5);
transition-duration: .1s;
background: #{utils.color(primary, 500)};
border-radius: utils.rem(2px);
z-index: 1;
}

&::part(control)::after {
box-shadow: inset 0 0 0 1px #{utils.color(primary, 500)};
}

&::part(control checked)::after {
background: transparent;
box-shadow: inset 0 0 0 1px #{utils.color(gray, 900)};
}
}

Expand All @@ -81,7 +41,6 @@

igc-checkbox::part(control checked) {
&::after {
background: #{utils.color(primary, 500)};
box-shadow: inset 0 0 0 1px #{utils.color(primary, 500)};
}
}
Expand Down Expand Up @@ -154,31 +113,4 @@
box-shadow: inset 0 0 0 1px #{utils.color(error, 100)};
}
}

igc-checkbox[disabled]::part(control),
igc-checkbox[disabled][invalid]::part(control) {
&::after {
box-shadow: inset 0 0 0 1px #{utils.color(gray, 400)};
background: transparent;
}
}

igc-checkbox[disabled]::part(control checked),
igc-checkbox[disabled][invalid]::part(control checked) {
&::after {
background: #{utils.color(gray, 400)};
}
}

igc-checkbox[disabled][indeterminate]::part(control),
igc-checkbox[disabled][indeterminate][invalid]::part(control) {
&::before {
background: #{utils.color(gray, 400)};
}

&::after {
box-shadow: inset 0 0 0 1px #{utils.color(gray, 400)};
background: transparent;
}
}
}
91 changes: 7 additions & 84 deletions src/components/checkbox/checkbox.dark.indigo.scss
Original file line number Diff line number Diff line change
@@ -1,101 +1,30 @@
@use '../../styles/utilities' as utils;
@use 'checkbox.indigo.scss' as light-checkbox;

@mixin theme() {
igc-checkbox {
font-weight: 600;
}

igc-checkbox::part(control) {
width: var(--size, utils.rem(20px));
height: var(--size, utils.rem(20px));
min-width: var(--size, utils.rem(20px));
transition: none;
background: none;
border-radius: utils.rem(3px);
border: none;
box-shadow: inset 0 0 0 2px #{utils.color(gray, 500)};

&::after {
border-radius: inherit;
}
}

igc-checkbox::part(indicator) {
transform: scale(.8);
stroke: #{utils.color(surface, 500)};
}

igc-checkbox[indeterminate]::part(indicator) {
transform: rotate(45deg) translateX(-.125rem) scale(.8);
stroke-dashoffset: 41;
}

igc-checkbox:hover::part(control) {
box-shadow: 0 0 0 4px #{utils.color(gray, 200, .87)};
}

igc-checkbox:focus-within::part(control) {
box-shadow: 0 0 0 4px #{utils.color(gray, 300, .87)};
}
@include light-checkbox.theme();

@mixin theme() {
igc-checkbox::part(control)::after {
border-color: #{utils.color(gray, 700)};
transition: none;
}

igc-checkbox::part(control checked),
igc-checkbox[indeterminate]::part(control) {
background: #{utils.color(primary, 500)};
box-shadow: inset 0 0 0 4px #{utils.color(secondary, 500)};
}

igc-checkbox:hover::part(control checked),
igc-checkbox[indeterminate]:hover::part(control) {
box-shadow: 0 0 0 4px #{utils.color(secondary, 100, .87)};
}

igc-checkbox:focus-within::part(control checked),
igc-checkbox[indeterminate]:focus-within::part(control) {
box-shadow: 0 0 0 4px #{utils.color(secondary, 200, .87)};
}

igc-checkbox:not([invalid])::part(control checked)::after {
igc-checkbox:not([invalid])::part(control checked)::after,
igc-checkbox:not([invalid])[indeterminate]::part(control)::after {
background: #{utils.color(gray, 900)};
}

igc-checkbox[invalid]::part(control checked),
igc-checkbox[invalid][indeterminate]::part(control) {
box-shadow: inset 0 0 0 4px #{utils.color(error, 500)};
background: #{utils.color(error, 500)};
border-color: #{utils.color(gray, 900)};
}

igc-checkbox[invalid]::part(control)::after {
border-color: #{utils.color(error, 500)};
}

igc-checkbox[invalid]:hover::part(control),
igc-checkbox[invalid]:hover::part(control checked),
igc-checkbox[invalid][indeterminate]:hover::part(control) {
box-shadow: 0 0 0 4px #{utils.color(error, 100, .87)};
}

igc-checkbox[invalid]:focus-within::part(control),
igc-checkbox[invalid]:focus-within::part(control checked),
igc-checkbox[invalid][indeterminate]:focus-within::part(control) {
box-shadow: 0 0 0 4px #{utils.color(error, 200, .87)};
}

igc-checkbox[disabled],
igc-checkbox[disabled][invalid] {
&::part(control)::after {
border-color: #{utils.color(gray, 400)};
}

&::part(control checked) {
background: transparent;
box-shadow: none;
}

&::part(control checked)::after {
background: #{utils.color(gray, 400)};
}
Expand All @@ -104,13 +33,7 @@
igc-checkbox[disabled][indeterminate] {
&::part(control)::after {
background: #{utils.color(gray, 400)};
}
}

igc-checkbox[disabled][invalid][indeterminate] {
&::part(control) {
background: transparent;
box-shadow: none;
border-color: #{utils.color(gray, 400)};
}
}
}
6 changes: 0 additions & 6 deletions src/components/checkbox/checkbox.indigo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@
box-shadow: 0 0 0 4px #{utils.color(gray, 300, .87)};
}

igc-checkbox::part(control checked),
igc-checkbox[indeterminate]::part(control) {
background: #{utils.color(primary, 500)};
box-shadow: inset 0 0 0 4px #{utils.color(secondary, 500)};
}

igc-checkbox:hover::part(control checked),
igc-checkbox[indeterminate]:hover::part(control) {
box-shadow: 0 0 0 4px #{utils.color(secondary, 100, .87)};
Expand Down
4 changes: 2 additions & 2 deletions src/styles/themes/dark/fluent.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@use '../../../components/button/button.fluent' as button;
@use '../../../components/button/icon-button.fluent' as icon-button;
@use '../../../components/card/card.fluent' as card;
@use '../../../components/checkbox/checkbox.dark.fluent' as checkbox;
@use '../../../components/checkbox/checkbox.dark.fluent' as dark-checkbox;
@use '../../../components/radio/radio.fluent' as radio;
@use '../../../components/list/list.fluent' as list;
@use '../../../components/checkbox/switch.fluent' as switch;
Expand Down Expand Up @@ -157,7 +157,7 @@ $type-scale: utils.extend($fluent-type-scale);

@include button.theme();
@include card.theme();
@include checkbox.theme();
@include dark-checkbox.theme();
@include radio.theme();
@include list.theme();
@include switch.theme();
Expand Down
4 changes: 2 additions & 2 deletions src/styles/themes/dark/indigo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@use '../../../components/button/button.indigo' as button;
@use '../../../components/button/icon-button.indigo' as icon-button;
@use '../../../components/card/card.indigo' as card;
@use '../../../components/checkbox/checkbox.dark.indigo' as checkbox;
@use '../../../components/checkbox/checkbox.dark.indigo' as dark-checkbox;
@use '../../../components/radio/radio.indigo' as radio;
@use '../../../components/checkbox/switch.indigo' as switch;
@use '../../../components/navbar/navbar.indigo' as navbar;
Expand Down Expand Up @@ -183,7 +183,7 @@ $type-scale: utils.extend($indigo-type-scale);

@include button.theme();
@include card.theme();
@include checkbox.theme();
@include dark-checkbox.theme();
@include radio.theme();
@include switch.theme();
@include navbar.theme();
Expand Down