|
106 | 106 | }
|
107 | 107 |
|
108 | 108 | $theme: digest-schema($chip-schema);
|
109 |
| - $meta: map.get($theme, '_meta'); |
| 109 | + $variant: map.get($theme, '_meta', 'theme'); |
110 | 110 |
|
111 | 111 | @if not($text-color) and $background {
|
112 |
| - $text-color: text-contrast($background); |
| 112 | + $text-color: adaptive-contrast(var(--background)); |
113 | 113 | }
|
114 | 114 |
|
115 |
| - @if not($hover-background) and $background { |
116 |
| - $luminance: luminance($background); |
| 115 | + @if not($border-color) and $background { |
| 116 | + $border-color: var(--background); |
| 117 | + } |
117 | 118 |
|
118 |
| - @if meta.type-of($luminance) == 'color' and $luminance + .05 < .5 { |
119 |
| - $hover-background: color.scale($background, $lightness: 14%); |
120 |
| - } @else { |
121 |
| - $hover-background: color.scale($background, $lightness: -4%); |
122 |
| - } |
| 119 | + @if not($hover-background) and $background { |
| 120 | + $hover-background: hsl(from var(--background) h s calc(l * 0.9)); |
123 | 121 | }
|
124 | 122 |
|
125 | 123 | @if not($hover-text-color) and $hover-background {
|
126 |
| - $hover-text-color: text-contrast(to-opaque($hover-background)); |
| 124 | + $hover-text-color: adaptive-contrast(var(--hover-background)); |
127 | 125 | }
|
128 | 126 |
|
129 | 127 | @if not($focus-background) and $background {
|
130 |
| - $luminance: luminance($background); |
| 128 | + $focus-background: hsl(from var(--background) h s calc(l * 0.8)); |
| 129 | + } |
131 | 130 |
|
132 |
| - @if meta.type-of($luminance) == 'color' and $luminance + .05 < .5 { |
133 |
| - $focus-background: color.scale($background, $lightness: 22%); |
134 |
| - } @else { |
135 |
| - $focus-background: color.scale($background, $lightness: -8%); |
| 131 | + @if $variant == 'fluent' { |
| 132 | + @if not($focus-background) and $selected-background { |
| 133 | + $focus-background: var(--selected-background); |
136 | 134 | }
|
137 | 135 | }
|
138 | 136 |
|
139 | 137 | @if not($focus-text-color) and $focus-background {
|
140 |
| - $focus-text-color: text-contrast(to-opaque($focus-background)); |
| 138 | + $focus-text-color: adaptive-contrast(var(--focus-background)); |
141 | 139 | }
|
142 | 140 |
|
143 |
| - @if not($selected-background) and $background { |
144 |
| - $luminance: luminance($background); |
145 |
| - |
146 |
| - @if meta.type-of($luminance) == 'color' and $luminance + .05 < .5 { |
147 |
| - $selected-background: color.scale($background, $lightness: 22%); |
148 |
| - } @else { |
149 |
| - $selected-background: color.scale($background, $lightness: -8%); |
| 141 | + @if $variant != 'indigo' and $variant != 'fluent' { |
| 142 | + @if not($selected-background) and $background { |
| 143 | + $selected-background: var(--background); |
| 144 | + } |
| 145 | + } @else { |
| 146 | + @if not($selected-background) and $background { |
| 147 | + $selected-background: hsl(from var(--background) h s calc(l * 1.1)); |
150 | 148 | }
|
151 | 149 | }
|
152 | 150 |
|
153 | 151 | @if not($selected-text-color) and $selected-background {
|
154 |
| - $selected-text-color: text-contrast(to-opaque($selected-background)); |
| 152 | + $selected-text-color: adaptive-contrast(var(--selected-background)); |
155 | 153 | }
|
156 | 154 |
|
157 |
| - @if not($hover-selected-background) and $hover-background { |
158 |
| - $hover-selected-background: $hover-background; |
| 155 | + @if not($hover-selected-background) and $selected-background { |
| 156 | + $hover-selected-background: hsl(from var(--selected-background) h s calc(l * 0.9)); |
159 | 157 | }
|
160 | 158 |
|
161 | 159 | @if not($hover-selected-text-color) and $hover-selected-background {
|
162 |
| - $hover-selected-text-color: text-contrast(to-opaque($hover-selected-background)); |
| 160 | + $hover-selected-text-color: adaptive-contrast(var(--hover-selected-background)); |
163 | 161 | }
|
164 | 162 |
|
165 |
| - @if not($focus-selected-background) and $selected-background { |
166 |
| - $luminance: luminance($selected-background); |
167 |
| - |
168 |
| - @if meta.type-of($luminance) == 'color' and $luminance + .05 < .5 { |
169 |
| - $focus-selected-background: color.scale($background, $lightness: 32%); |
170 |
| - } @else { |
171 |
| - $focus-selected-background: color.scale($background, $lightness: -16%); |
| 163 | + @if $variant != 'indigo' { |
| 164 | + @if not($focus-selected-background) and $selected-background { |
| 165 | + $focus-selected-background: hsl(from var(--selected-background) h s calc(l * 0.8)); |
| 166 | + } |
| 167 | + } @else { |
| 168 | + @if not($focus-selected-background) and $selected-background { |
| 169 | + $focus-selected-background: var(--selected-background); |
172 | 170 | }
|
173 | 171 | }
|
174 | 172 |
|
175 | 173 | @if not($focus-selected-text-color) and $focus-selected-background {
|
176 |
| - $focus-selected-text-color: text-contrast(to-opaque($focus-selected-background)); |
| 174 | + $focus-selected-text-color: adaptive-contrast(var(--focus-selected-background)); |
177 | 175 | }
|
178 | 176 |
|
179 | 177 | @if not($hover-border-color) and $border-color {
|
180 |
| - $hover-border-color: $border-color; |
| 178 | + $hover-border-color: var(--border-color); |
181 | 179 | }
|
182 | 180 |
|
183 | 181 | @if not($focus-border-color) and $border-color {
|
184 |
| - $focus-border-color: $border-color; |
| 182 | + $focus-border-color: var(--border-color); |
185 | 183 | }
|
186 | 184 |
|
187 | 185 | @if not($selected-border-color) and $border-color {
|
188 |
| - $selected-border-color: $border-color; |
| 186 | + $selected-border-color: var(--border-color); |
189 | 187 | }
|
190 | 188 |
|
191 | 189 | @if not($hover-selected-border-color) and $border-color {
|
192 |
| - $hover-selected-border-color: $border-color; |
| 190 | + $hover-selected-border-color: var(--border-color); |
193 | 191 | }
|
194 | 192 |
|
195 | 193 | @if not($focus-selected-border-color) and $border-color {
|
196 |
| - $focus-selected-border-color: $border-color; |
| 194 | + $focus-selected-border-color: var(--border-color); |
| 195 | + } |
| 196 | + |
| 197 | + @if $variant == 'indigo' { |
| 198 | + @if not($selected-border-color) and $selected-background { |
| 199 | + $selected-border-color: var(--selected-background); |
| 200 | + } |
| 201 | + |
| 202 | + @if not($hover-selected-border-color) and $hover-selected-background { |
| 203 | + $hover-selected-border-color: var(--hover-selected-background); |
| 204 | + } |
| 205 | + |
| 206 | + @if not($focus-selected-border-color) and $focus-selected-background { |
| 207 | + $focus-selected-border-color: var(--focus-selected-background); |
| 208 | + } |
| 209 | + } |
| 210 | + |
| 211 | + @if $variant == 'bootstrap' or $variant == 'indigo' { |
| 212 | + @if not($focus-outline-color) and $focus-background { |
| 213 | + $focus-outline-color: hsla(from var(--focus-background) h s l / 0.4); |
| 214 | + } |
| 215 | + |
| 216 | + @if not($focus-selected-outline-color) and $focus-selected-background { |
| 217 | + $focus-selected-outline-color: hsla(from var(--focus-selected-background) h s l / 0.4); |
| 218 | + } |
197 | 219 | }
|
198 | 220 |
|
199 | 221 | @if not($ghost-shadow) {
|
|
240 | 262 | remove-icon-color-focus: $remove-icon-color-focus,
|
241 | 263 | focus-selected-outline-color: $focus-selected-outline-color,
|
242 | 264 | focus-outline-color: $focus-outline-color,
|
243 |
| - theme: map.get($schema, '_meta', 'theme'), |
244 |
| - _meta: map.merge(if($meta, $meta, ()), ( |
245 |
| - variant: map.get($schema, '_meta', 'theme'), |
246 |
| - theme-variant: map.get($schema, '_meta', 'variant') |
247 |
| - )), |
248 | 265 | size: $size,
|
249 | 266 | ));
|
250 | 267 | }
|
|
256 | 273 | @include css-vars($theme);
|
257 | 274 | $chip-max-width: 32ch;
|
258 | 275 |
|
259 |
| - $variant: map.get($theme, '_meta', 'variant'); |
260 |
| - $theme-variant: map.get($theme, '_meta', 'theme-variant'); |
| 276 | + $variant: map.get($theme, '_meta', 'theme'); |
| 277 | + $theme-variant: map.get($theme, '_meta', 'variant'); |
261 | 278 |
|
262 | 279 | $chip-padding: (
|
263 | 280 | comfortable: rem(if($variant != 'indigo', 12px, 7px)),
|
|
0 commit comments