diff --git a/src/lib/components/ui/checkbox/Checkbox.svelte b/src/lib/components/ui/checkbox/Checkbox.svelte new file mode 100644 index 00000000..3f88a28b --- /dev/null +++ b/src/lib/components/ui/checkbox/Checkbox.svelte @@ -0,0 +1,71 @@ + + + + + + {#if checked === 'indeterminate'} + + {:else} + + {/if} + + \ No newline at end of file diff --git a/src/lib/components/ui/checkbox/checkbox.module.scss b/src/lib/components/ui/checkbox/checkbox.module.scss new file mode 100644 index 00000000..fc1b9424 --- /dev/null +++ b/src/lib/components/ui/checkbox/checkbox.module.scss @@ -0,0 +1,99 @@ +@use 'themes/spacing'; +@use 'themes/colors'; +@use 'themes/layout'; +@use 'themes/typography'; + +.checkbox { + background-color: var(--input-bg); + border: 2px solid var(--separator-bg); + border-radius: layout.$item-corner-small; + cursor: pointer; + display: inline-flex; + align-items: center; + justify-content: center; + transition: all 0.18s ease-out; + + &:hover:not(:disabled) { + background-color: var(--input-bg-hover); + border-color: var(--separator-bg-hover); + } + + &:focus, + &:focus-visible { + outline: none; + border-color: colors.$blue; + box-shadow: 0 0 0 2px rgba(colors.$blue, 0.2); + } + + &[data-state='checked'], + &[data-state='indeterminate'] { + background-color: var(--accent-blue); + border-color: var(--accent-blue); + + &:hover:not(:disabled) { + background-color: var(--accent-blue-hover); + border-color: var(--accent-blue-hover); + } + } + + &:disabled { + cursor: not-allowed; + opacity: 0.5; + } + + &.bound { + background-color: var(--input-bound-bg); + + &:hover:not(:disabled) { + background-color: var(--input-bound-bg-hover); + } + + &[data-state='checked'], + &[data-state='indeterminate'] { + background-color: var(--accent-blue); + border-color: var(--accent-blue); + } + } +} + +// Size variations +.small { + width: 16px; + height: 16px; + + .icon { + width: 12px; + height: 12px; + } +} + +.medium { + width: 20px; + height: 20px; + + .icon { + width: 14px; + height: 14px; + } +} + +.large { + width: 24px; + height: 24px; + + .icon { + width: 18px; + height: 18px; + } +} + +.indicator { + display: flex; + align-items: center; + justify-content: center; + color: white; +} + +.icon { + stroke-width: 3; +} \ No newline at end of file diff --git a/src/lib/components/ui/switch/Switch.svelte b/src/lib/components/ui/switch/Switch.svelte new file mode 100644 index 00000000..ecb9b317 --- /dev/null +++ b/src/lib/components/ui/switch/Switch.svelte @@ -0,0 +1,46 @@ + + + + + + \ No newline at end of file diff --git a/src/lib/components/ui/switch/switch.module.scss b/src/lib/components/ui/switch/switch.module.scss new file mode 100644 index 00000000..9f1c4479 --- /dev/null +++ b/src/lib/components/ui/switch/switch.module.scss @@ -0,0 +1,54 @@ +@use 'themes/spacing'; +@use 'themes/colors'; +@use 'themes/layout'; + +.switch { + $height: 34px; + background: colors.$grey-70; + border-radius: calc($height / 2); + border: none; + padding-left: spacing.$unit-half; + padding-right: spacing.$unit-half; + position: relative; + width: 58px; + height: $height; + cursor: pointer; + transition: background-color 100ms ease-out; + + &:focus, + &:focus-visible { + box-shadow: 0 0 0 2px var(--accent-blue-focus); + outline: none; + } + + &[data-state='checked'] { + background: var(--accent-blue); + } + + &:disabled { + box-shadow: none; + cursor: not-allowed; + opacity: 0.5; + + .thumb { + background: colors.$grey-80; + cursor: not-allowed; + } + } +} + +.thumb { + background: colors.$grey-100; + border-radius: 13px; + display: block; + height: 26px; + width: 26px; + transition: transform 100ms; + transform: translateX(0px); + cursor: pointer; + + &[data-state='checked'] { + background: colors.$grey-100; + transform: translateX(24px); + } +} \ No newline at end of file