diff options
Diffstat (limited to 'src/objects/_text-field.scss')
| -rw-r--r-- | src/objects/_text-field.scss | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/src/objects/_text-field.scss b/src/objects/_text-field.scss new file mode 100644 index 0000000..de5bcd1 --- /dev/null +++ b/src/objects/_text-field.scss | |||
| @@ -0,0 +1,209 @@ | |||
| 1 | @use 'iro-sass/src/index' as iro; | ||
| 2 | @use '../functions' as fn; | ||
| 3 | |||
| 4 | @mixin invalid { | ||
| 5 | $focus-border-offset: calc(fn.dim(--border) - fn.dim(--focus --border)); | ||
| 6 | |||
| 7 | @include iro.bem-sibling-elem('bg') { | ||
| 8 | inset-block: $focus-border-offset; | ||
| 9 | inset-inline: $focus-border-offset; | ||
| 10 | border: fn.dim(--focus --border) solid fn.color(--error --border); | ||
| 11 | border-radius: calc(fn.dim(--rounding) - $focus-border-offset); | ||
| 12 | } | ||
| 13 | |||
| 14 | &:hover { | ||
| 15 | @include iro.bem-sibling-elem('bg') { | ||
| 16 | border-color: fn.color(--error --hover --border); | ||
| 17 | } | ||
| 18 | } | ||
| 19 | |||
| 20 | &:focus { | ||
| 21 | @include iro.bem-sibling-elem('bg') { | ||
| 22 | border-color: fn.color(--error --focus --border); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | @mixin keyboard-focus { | ||
| 28 | @include iro.bem-sibling-elem('bg') { | ||
| 29 | border: fn.dim(--key-focus --border) solid fn.color(--key-focus --border); | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | @include iro.props-namespace('text-field') { | ||
| 34 | @include iro.props-store(( | ||
| 35 | --dims: ( | ||
| 36 | --line-height: 1.4, | ||
| 37 | --pad-i: fn.global-dim(--size --125), | ||
| 38 | --pad-b: fn.global-dim(--size --125), | ||
| 39 | --border: fn.global-dim(--border --thin), | ||
| 40 | --rounding: fn.global-dim(--rounding), | ||
| 41 | |||
| 42 | --extended: ( | ||
| 43 | --pad: fn.global-dim(--size --50), | ||
| 44 | ), | ||
| 45 | |||
| 46 | --focus: ( | ||
| 47 | --border: fn.global-dim(--border --medium), | ||
| 48 | ), | ||
| 49 | --key-focus: ( | ||
| 50 | --border: fn.global-dim(--border --thick), | ||
| 51 | ) | ||
| 52 | ), | ||
| 53 | --colors: ( | ||
| 54 | --bg: fn.global-color(--base --50), | ||
| 55 | --placeholder: fn.global-color(--text-mute-more), | ||
| 56 | --text: fn.global-color(--text), | ||
| 57 | --border: fn.global-color(--border-strong), | ||
| 58 | |||
| 59 | --hover: ( | ||
| 60 | --border: fn.global-color(--text-mute-more), | ||
| 61 | ), | ||
| 62 | --focus: ( | ||
| 63 | --border: fn.global-color(--accent --900), | ||
| 64 | ), | ||
| 65 | --key-focus: ( | ||
| 66 | --border: fn.global-color(--yellow-static --400), | ||
| 67 | ), | ||
| 68 | --error: ( | ||
| 69 | --border: fn.global-color(--negative --900), | ||
| 70 | |||
| 71 | --hover: ( | ||
| 72 | --border: fn.global-color(--negative --800), | ||
| 73 | ), | ||
| 74 | --focus: ( | ||
| 75 | --border: fn.global-color(--negative --800), | ||
| 76 | ), | ||
| 77 | ), | ||
| 78 | --disabled: ( | ||
| 79 | --bg: fn.global-color(--border-mute), | ||
| 80 | --placeholder: fn.global-color(--text-disabled), | ||
| 81 | --text: fn.global-color(--text-disabled), | ||
| 82 | --border: fn.global-color(--border-mute), | ||
| 83 | ), | ||
| 84 | ), | ||
| 85 | )); | ||
| 86 | |||
| 87 | @include iro.bem-object(iro.props-namespace()) { | ||
| 88 | $focus-border-offset: calc(fn.dim(--border) - fn.dim(--focus --border)); | ||
| 89 | |||
| 90 | position: relative; | ||
| 91 | min-inline-size: 0; | ||
| 92 | border-radius: fn.dim(--rounding); | ||
| 93 | background-color: fn.color(--bg); | ||
| 94 | |||
| 95 | @include iro.bem-elem('bg') { | ||
| 96 | display: block; | ||
| 97 | position: absolute; | ||
| 98 | inset-block: 0; | ||
| 99 | inset-inline: 0; | ||
| 100 | border: fn.dim(--border) solid fn.color(--border); | ||
| 101 | border-radius: fn.dim(--rounding); | ||
| 102 | pointer-events: none; | ||
| 103 | } | ||
| 104 | |||
| 105 | @include iro.bem-elem('native') { | ||
| 106 | box-sizing: border-box; | ||
| 107 | inline-size: 100%; | ||
| 108 | padding-block: calc(fn.dim(--pad-b) - .5em * (fn.dim(--line-height) - 1)); | ||
| 109 | padding-inline: fn.dim(--pad-i); | ||
| 110 | border: 1px solid transparent; | ||
| 111 | background-color: transparent; | ||
| 112 | color: fn.color(--text); | ||
| 113 | font: inherit; | ||
| 114 | line-height: fn.dim(--line-height); | ||
| 115 | resize: none; | ||
| 116 | appearance: none; | ||
| 117 | |||
| 118 | &::placeholder { | ||
| 119 | opacity: 1; | ||
| 120 | color: fn.color(--placeholder); | ||
| 121 | font-style: italic; | ||
| 122 | } | ||
| 123 | |||
| 124 | &:hover { | ||
| 125 | @include iro.bem-sibling-elem('bg') { | ||
| 126 | border-color: fn.color(--hover --border); | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | &:focus { | ||
| 131 | outline: 0; | ||
| 132 | |||
| 133 | @include iro.bem-sibling-elem('bg') { | ||
| 134 | inset-block: $focus-border-offset; | ||
| 135 | inset-inline: $focus-border-offset; | ||
| 136 | border: fn.dim(--focus --border) solid fn.color(--focus --border); | ||
| 137 | border-radius: calc(fn.dim(--rounding) - $focus-border-offset); | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | &:invalid { | ||
| 142 | @include invalid; | ||
| 143 | } | ||
| 144 | |||
| 145 | &:focus-visible, | ||
| 146 | &:invalid:focus-visible { | ||
| 147 | @include keyboard-focus; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | @include iro.bem-modifier('extended') { | ||
| 152 | padding: fn.dim(--extended --pad); | ||
| 153 | |||
| 154 | @include iro.bem-multi('&', 'elem' 'bg') { | ||
| 155 | border-radius: calc(fn.dim(--rounding) + fn.dim(--extended --pad)); | ||
| 156 | } | ||
| 157 | |||
| 158 | @include iro.bem-elem('native') { | ||
| 159 | &:focus { | ||
| 160 | @include iro.bem-sibling-elem('bg') { | ||
| 161 | border-radius: calc(fn.dim(--rounding) + fn.dim(--extended --pad) - $focus-border-offset); | ||
| 162 | } | ||
| 163 | } | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | @include iro.bem-is('invalid') { | ||
| 168 | @include iro.bem-elem('native') { | ||
| 169 | @include invalid; | ||
| 170 | |||
| 171 | &:focus-visible { | ||
| 172 | @include keyboard-focus; | ||
| 173 | } | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 177 | @include iro.bem-is('disabled') { | ||
| 178 | background-color: fn.color(--disabled --bg); | ||
| 179 | |||
| 180 | @include iro.bem-elem('native') { | ||
| 181 | color: fn.color(--disabled --text); | ||
| 182 | |||
| 183 | &::placeholder { | ||
| 184 | color: fn.color(--disabled --placeholder); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | @include iro.bem-elem('bg') { | ||
| 189 | border-color: fn.color(--disabled --border); | ||
| 190 | } | ||
| 191 | |||
| 192 | @include iro.bem-is('invalid') { | ||
| 193 | @include iro.bem-elem('native') { | ||
| 194 | @include iro.bem-sibling-elem('bg') { | ||
| 195 | border-color: fn.color(--disabled --border); | ||
| 196 | } | ||
| 197 | } | ||
| 198 | } | ||
| 199 | |||
| 200 | @include iro.bem-elem('native') { | ||
| 201 | &:invalid { | ||
| 202 | @include iro.bem-sibling-elem('bg') { | ||
| 203 | border-color: fn.color(--disabled --border); | ||
| 204 | } | ||
| 205 | } | ||
| 206 | } | ||
| 207 | } | ||
| 208 | } | ||
| 209 | } | ||
