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