diff options
author | sadbeast <sadbeast@sadbeast.com> | 2024-01-31 17:47:56 -0800 |
---|---|---|
committer | sadbeast <sadbeast@sadbeast.com> | 2024-01-31 17:47:56 -0800 |
commit | 332ec93366315fa1ed7b4acd7a3407c96e8ddfa7 (patch) | |
tree | 6ae553317f12a7a6a29c849c8805ffab96436dc2 /app/assets/stylesheets/content/_form-checkbox-radio.scss | |
download | td-main.tar.gz td-main.tar.bz2 |
Diffstat (limited to 'app/assets/stylesheets/content/_form-checkbox-radio.scss')
-rw-r--r-- | app/assets/stylesheets/content/_form-checkbox-radio.scss | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/app/assets/stylesheets/content/_form-checkbox-radio.scss b/app/assets/stylesheets/content/_form-checkbox-radio.scss new file mode 100644 index 0000000..c83d35e --- /dev/null +++ b/app/assets/stylesheets/content/_form-checkbox-radio.scss @@ -0,0 +1,138 @@ +/** + * Form elements + * Checkboxes & Radios + */ + +[type="checkbox"], +[type="radio"] { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + width: 1.25em; + height: 1.25em; + margin-top: -0.125em; + margin-right: 0.375em; + margin-left: 0; + margin-inline-start: 0; + margin-inline-end: 0.375em; + border-width: var(--border-width); + font-size: inherit; + vertical-align: middle; + cursor: pointer; + + &::-ms-check { + display: none; // unstyle IE checkboxes + } + + &:checked, + &:checked:active, + &:checked:focus { + --background-color: var(--primary); + --border-color: var(--primary); + background-image: var(--icon-checkbox); + background-position: center; + background-size: 0.75em auto; + background-repeat: no-repeat; + } + + & ~ label { + display: inline-block; + margin-right: 0.375em; + margin-bottom: 0; + cursor: pointer; + } +} + +// Checkboxes +[type="checkbox"] { + &:indeterminate { + --background-color: var(--primary); + --border-color: var(--primary); + background-image: var(--icon-minus); + background-position: center; + background-size: 0.75em auto; + background-repeat: no-repeat; + } +} + +// Radios +[type="radio"] { + border-radius: 50%; + + &:checked, + &:checked:active, + &:checked:focus { + --background-color: var(--primary-inverse); + border-width: 0.35em; + background-image: none; + } +} + +// Switchs +[type="checkbox"][role="switch"] { + --background-color: var(--switch-background-color); + --border-color: var(--switch-background-color); + --color: var(--switch-color); + + // Config + $switch-height: 1.25em; + $switch-width: 2.25em; + $switch-transition: 0.1s ease-in-out; + + // Styles + width: $switch-width; + height: $switch-height; + border: var(--border-width) solid var(--border-color); + border-radius: $switch-height; + background-color: var(--background-color); + line-height: $switch-height; + + &:focus { + --background-color: var(--switch-background-color); + --border-color: var(--switch-background-color); + } + + &:checked { + --background-color: var(--switch-checked-background-color); + --border-color: var(--switch-checked-background-color); + } + + &:before { + display: block; + width: calc(#{$switch-height} - (var(--border-width) * 2)); + height: 100%; + border-radius: 50%; + background-color: var(--color); + content: ""; + + @if $enable-transitions { + transition: margin $switch-transition; + } + } + + &:checked { + background-image: none; + + &::before { + margin-left: calc(#{$switch-width * 0.5} - var(--border-width)); + margin-inline-start: calc(#{$switch-width * 0.5} - var(--border-width)); + } + } +} + +// Aria-invalid +[type="checkbox"], +[type="checkbox"]:checked, +[type="radio"], +[type="radio"]:checked, +[type="checkbox"][role="switch"], +[type="checkbox"][role="switch"]:checked { + + &[aria-invalid="false"] { + --border-color: var(--form-element-valid-border-color); + } + + &[aria-invalid="true"] { + --border-color: var(--form-element-invalid-border-color); + } +}
\ No newline at end of file |