summaryrefslogtreecommitdiffstats
path: root/src/components/molecules/forms/radio-group.module.scss
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-05-31 19:40:23 +0200
committerArmand Philippot <git@armandphilippot.com>2022-06-01 22:32:09 +0200
commit8320b1d39ea6402c32e907dbb35082efc6af9f5a (patch)
treeb5ee9586a4ec91aa15c92dcb513b551716fd4416 /src/components/molecules/forms/radio-group.module.scss
parent994ad1bec193b2d1a6e0d38d6ef3f3d2bd66c3ea (diff)
chore: replace the toggle component
Diffstat (limited to 'src/components/molecules/forms/radio-group.module.scss')
-rw-r--r--src/components/molecules/forms/radio-group.module.scss111
1 files changed, 105 insertions, 6 deletions
diff --git a/src/components/molecules/forms/radio-group.module.scss b/src/components/molecules/forms/radio-group.module.scss
index feda9bd..0bd34b9 100644
--- a/src/components/molecules/forms/radio-group.module.scss
+++ b/src/components/molecules/forms/radio-group.module.scss
@@ -1,13 +1,112 @@
-.option {
- &:not(:last-of-type) {
- margin-right: var(--spacing-xs);
- }
-}
+@use "@styles/abstracts/functions" as fun;
+@use "@styles/abstracts/mixins" as mix;
.wrapper {
- &--inline {
+ &--inline#{&}--regular {
.option:first-of-type {
margin-left: var(--spacing-2xs);
}
}
+
+ &--regular {
+ .option {
+ &:not(:last-of-type) {
+ margin-right: var(--spacing-xs);
+ }
+ }
+ }
+}
+
+.toggle {
+ display: inline-flex;
+ flex-flow: row wrap;
+ align-items: center;
+ width: fit-content;
+ position: relative;
+ background: var(--color-shadow-light);
+ border: fun.convert-px(2) solid var(--color-primary);
+ border-radius: fun.convert-px(32);
+ box-shadow: inset 0 0 fun.convert-px(1) fun.convert-px(1)
+ var(--color-shadow-dark),
+ inset 0 0 fun.convert-px(3) fun.convert-px(2) var(--color-shadow);
+
+ .label {
+ display: flex;
+ align-items: center;
+ min-height: 5ex;
+ padding: fun.convert-px(6) var(--spacing-2xs);
+ border-top: fun.convert-px(2) solid var(--color-border);
+ border-bottom: fun.convert-px(2) solid var(--color-border);
+ transition: all 0.15s linear 0s;
+
+ @include mix.pointer("fine") {
+ min-height: 3ex;
+ }
+ }
+
+ &:focus-within {
+ outline: fun.convert-px(2) solid var(--color-primary-light);
+ }
+
+ .option:first-of-type {
+ .label {
+ border-left: fun.convert-px(2) solid var(--color-border);
+ border-top-left-radius: fun.convert-px(32);
+ border-bottom-left-radius: fun.convert-px(32);
+ }
+ }
+
+ .option:last-of-type {
+ .label {
+ border-right: fun.convert-px(2) solid var(--color-border);
+ border-top-right-radius: fun.convert-px(32);
+ border-bottom-right-radius: fun.convert-px(32);
+ }
+ }
+
+ .radio {
+ &:checked + .label {
+ background: var(--color-primary);
+ box-shadow: inset 0 0 fun.convert-px(1) fun.convert-px(2)
+ var(--color-primary-dark),
+ inset 0 0 fun.convert-px(3) fun.convert-px(2)
+ var(--color-primary-darker);
+ color: var(--color-fg-inverted);
+
+ svg {
+ fill: var(--color-fg-inverted);
+ stroke: var(--color-fg-inverted);
+ }
+ }
+
+ &:not(:checked) + .label {
+ svg {
+ fill: var(--color-primary-darker);
+ }
+ }
+
+ &:checked + .label:hover {
+ background: var(--color-primary-lighter);
+ box-shadow: inset 0 0 fun.convert-px(1) fun.convert-px(2)
+ var(--color-primary-light),
+ inset 0 0 fun.convert-px(3) fun.convert-px(2) var(--color-primary);
+ }
+
+ &:not(:checked) + .label:hover {
+ background: var(--color-shadow-light);
+ box-shadow: inset 0 0 0 fun.convert-px(1) var(--color-shadow-dark),
+ inset 0 0 fun.convert-px(3) fun.convert-px(2) var(--color-shadow);
+ }
+
+ &:not(:checked):focus + .label {
+ background: var(--color-shadow-light);
+ }
+
+ &:checked:focus + .label {
+ background: var(--color-primary-lighter);
+ box-shadow: inset 0 0 fun.convert-px(1) fun.convert-px(2)
+ var(--color-primary-light),
+ inset 0 0 fun.convert-px(3) fun.convert-px(2) var(--color-primary);
+ }
+ }
}