|
| 1 | +@import '../../shared/colors.css'; |
| 2 | + |
| 3 | +/* Various inputs use styling from button. */ |
| 4 | +@import '../button.css'; |
| 5 | + |
| 6 | +/* |
| 7 | + * These are default values and styles for checkbox and radio inputs, which |
| 8 | + * have much of the same implementation, with some variation. These values are |
| 9 | + * default for checkbox, and radio modifies values. |
| 10 | + * |
| 11 | + * The input-checkbox.css and input-radio.css files contain only the small |
| 12 | + * differences. |
| 13 | + */ |
| 14 | + |
| 15 | +input[type='checkbox' i], |
| 16 | +input[type='radio' i] { |
| 17 | + --checkable-size: 14px; |
| 18 | + |
| 19 | + /** The value has to be an RGB number triplet, f.e. `--checkable-color: 20, 30, 40;`. */ |
| 20 | + --checkable-color: var(--cornflowerblue); |
| 21 | + |
| 22 | + /** The value has to be an RGB number triplet, f.e. `--checkable-mark-color: 20, 30, 40;`. */ |
| 23 | + --checkable-mark-color: var(--checkable-color); |
| 24 | + --checkable-mark-scale: 1; |
| 25 | + --checkable-mark-stroke-width: calc(0.1275 * var(--checkable-size)); |
| 26 | + |
| 27 | + /** The value has to be an RGB number triplet, f.e. `--checkable-border-color: 20, 30, 40;`. */ |
| 28 | + --checkable-border-color: var(--checkable-color); |
| 29 | + --checkable-border-width: calc(0.08 * var(--checkable-size)); |
| 30 | + --checkable-border-radius: 100%; |
| 31 | + |
| 32 | + /** The value has to be an RGB number triplet, f.e. `--checkable-background-color: 20, 30, 40;`. */ |
| 33 | + --checkable-background-color: var(--checkable-color); |
| 34 | + --checkable-background-opacity: 0.15; |
| 35 | +} |
| 36 | + |
| 37 | +input[type='checkbox' i], |
| 38 | +input[type='radio' i] { |
| 39 | + -moz-appearance: none; |
| 40 | + -webkit-appearance: none; |
| 41 | + appearance: none; |
| 42 | + |
| 43 | + font-size: unset; |
| 44 | + box-sizing: border-box; |
| 45 | + position: relative; |
| 46 | + width: var(--checkable-size); |
| 47 | + height: var(--checkable-size); |
| 48 | + margin: 3px 4px 0px 3px; |
| 49 | +} |
| 50 | + |
| 51 | +input[type='checkbox' i][disabled], |
| 52 | +input[type='radio' i][disabled] { |
| 53 | + opacity: 0.5; |
| 54 | +} |
| 55 | + |
| 56 | +input[type='checkbox' i]:focus, |
| 57 | +input[type='radio' i]:focus { |
| 58 | + outline: none; |
| 59 | + outline-offset: 0; |
| 60 | +} |
| 61 | + |
| 62 | +input[type='checkbox' i]:before, |
| 63 | +input[type='radio' i]:before { |
| 64 | + /* vars ending with -- are "private", not intended for end users. */ |
| 65 | + --checkable-transform--: translate(-50%, -50%); |
| 66 | + content: ''; |
| 67 | + display: block; |
| 68 | + position: absolute; |
| 69 | + top: 50%; |
| 70 | + left: 50%; |
| 71 | + transition: 0.1s all; |
| 72 | + transform: var(--checkable-transform--) scale(0); |
| 73 | + border-bottom: calc(var(--checkable-mark-scale) * var(--checkable-mark-stroke-width)) solid |
| 74 | + rgba(var(--checkable-mark-color), 1); |
| 75 | + border-right: calc(var(--checkable-mark-scale) * var(--checkable-mark-stroke-width)) solid |
| 76 | + rgba(var(--checkable-mark-color), 1); |
| 77 | +} |
| 78 | + |
| 79 | +input[type='checkbox' i]:checked:before, |
| 80 | +input[type='radio' i]:checked:before { |
| 81 | + transform: var(--checkable-transform--) scale(1); |
| 82 | +} |
| 83 | + |
| 84 | +input[type='checkbox' i]:after, |
| 85 | +input[type='radio' i]:after { |
| 86 | + content: ''; |
| 87 | + box-sizing: content-box; |
| 88 | + position: absolute; |
| 89 | + top: 50%; |
| 90 | + left: 50%; |
| 91 | + transform: translate(-50%, -50%); |
| 92 | + z-index: -1; |
| 93 | + width: calc(100% - var(--checkable-border-width)); |
| 94 | + height: calc(100% - var(--checkable-border-width)); |
| 95 | + background: rgba(var(--checkable-background-color), var(--checkable-background-opacity)); |
| 96 | + border: 0 solid rgba(var(--checkable-border-color), 1); |
| 97 | + border-width: var(--checkable-border-width); |
| 98 | + border-radius: var(--checkable-border-radius); |
| 99 | +} |
| 100 | + |
| 101 | +input[type='checkbox' i]:focus:after, |
| 102 | +input[type='checkbox' i]:not([disabled]):hover:after, |
| 103 | +input[type='radio' i]:focus:after, |
| 104 | +input[type='radio' i]:not([disabled]):hover:after { |
| 105 | + border-width: calc(1.5 * var(--checkable-border-width)); |
| 106 | +} |
0 commit comments