@progress/kendo-theme-core 9.1.1-dev.2 → 10.0.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.css +715 -712
- package/dist/all.scss +1 -6420
- package/dist/meta/sassdoc-data.json +3879 -3710
- package/dist/meta/sassdoc-raw-data.json +1844 -2568
- package/dist/meta/variables.json +430 -1219
- package/package.json +2 -3
- package/scss/_variables.scss +5 -3
- package/scss/all.scss +3 -2
- package/scss/border-radii/index.import.scss +13 -10
- package/scss/color-system/_functions.import.scss +182 -33
- package/scss/color-system/_mixins.import.scss +8 -2
- package/scss/color-system/_palettes.scss +272 -972
- package/scss/color-system/_swatch.scss +161 -159
- package/scss/color-system/index.import.scss +5 -6
- package/scss/elevation/index.import.scss +3 -3
- package/scss/functions/_color.import.scss +529 -0
- package/scss/functions/_list.import.scss +11 -9
- package/scss/functions/_map.import.scss +14 -11
- package/scss/functions/_math.import.scss +15 -13
- package/scss/functions/_meta.import.scss +9 -7
- package/scss/functions/_string.import.scss +36 -15
- package/scss/functions/index.import.scss +8 -12
- package/scss/index.import.scss +27 -10
- package/scss/mixins/_border-radius.scss +2 -0
- package/scss/mixins/_box-shadow.scss +2 -0
- package/scss/mixins/_decoration.scss +6 -13
- package/scss/mixins/_focus-indicator.scss +3 -0
- package/scss/mixins/_gradient.scss +2 -0
- package/scss/mixins/_import-once.scss +5 -3
- package/scss/mixins/index.import.scss +8 -8
- package/scss/spacing/index.import.scss +5 -4
- package/scss/styles/_base.scss +10 -6
- package/scss/styles/_selection.scss +6 -6
- package/scss/styles/index.import.scss +34 -22
- package/scss/typography/index.import.scss +10 -8
- package/dist/index.css +0 -0
- package/scss/color-system/_swatch-legacy.scss +0 -90
- package/scss/functions/_color-contrast.import.scss +0 -393
- package/scss/functions/_color-manipulation.import.scss +0 -134
- package/scss/functions/_color-system.import.scss +0 -138
- package/scss/functions/_escape-string.import.scss +0 -48
- package/scss/module-system/_components.scss +0 -240
- package/scss/module-system/_dependencies.scss +0 -731
- package/scss/module-system/index.import.scss +0 -55
- package/scss/styles/_colors.scss +0 -5
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
@use "sass:math";
|
|
2
|
+
@use "sass:list";
|
|
3
|
+
@use "sass:meta";
|
|
4
|
+
@use "../_variables.scss" as *;
|
|
5
|
+
|
|
6
|
+
$kendo-light-color-level-step: 8% !default;
|
|
7
|
+
$kendo-dark-color-level-step: 16% !default;
|
|
8
|
+
|
|
1
9
|
/// Returns the alpha channel of a color.
|
|
2
10
|
/// @param {Color} $color - The color to get the alpha channel for.
|
|
3
11
|
/// @return {Number} - The alpha channel of the color.
|
|
@@ -166,3 +174,524 @@
|
|
|
166
174
|
@function k-color-invert( $color ) {
|
|
167
175
|
@return invert( $color );
|
|
168
176
|
}
|
|
177
|
+
|
|
178
|
+
/// Set a specific jump point for requesting color jumps
|
|
179
|
+
/// @group color-system
|
|
180
|
+
/// @access private
|
|
181
|
+
$kendo-color-level-step: 8% !default;
|
|
182
|
+
|
|
183
|
+
@function k-color-level( $color, $level: 0, $_is-dark-theme: $kendo-is-dark-theme ) {
|
|
184
|
+
$_dark-theme: if( meta.variable-exists( kendo-is-dark-theme ), $_is-dark-theme, false );
|
|
185
|
+
$_color-level-step: if( $_dark-theme, $kendo-dark-color-level-step, $kendo-light-color-level-step );
|
|
186
|
+
|
|
187
|
+
@if ( $level == 0 ) or ( $level == 0% ) {
|
|
188
|
+
@return $color;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
$base: if( $level < 0, #ffffff, #000000 );
|
|
192
|
+
$level: math.abs( $level );
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
@if ( math.unit($level) == "%" ) {
|
|
196
|
+
@return k-color-mix( $base, $color, $level );
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@return k-color-mix( $base, $color, math.max( 0%, math.min( 100%, $level * $_color-level-step ) ) );
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/// Makes a color lighter by mixing it with white
|
|
203
|
+
/// @param {Color} $color - The color to lighten
|
|
204
|
+
/// @param {Number} $level - The amount to lighten the color
|
|
205
|
+
/// @return {Color} - The lightened color
|
|
206
|
+
///
|
|
207
|
+
/// @group color-system
|
|
208
|
+
///
|
|
209
|
+
/// @example scss - Usage
|
|
210
|
+
/// @debug k-color-tint( #f00, 1 ); // => #ff1a1a
|
|
211
|
+
@function k-color-tint( $color, $level: 1 ) {
|
|
212
|
+
@return k-color-level( $color, -$level );
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/// Makes a color darker by mixing it with black
|
|
216
|
+
/// @param {Color} $color - The color to darken
|
|
217
|
+
/// @param {Number} $level - The amount to darken the color
|
|
218
|
+
/// @return {Color} - The darkened color
|
|
219
|
+
///
|
|
220
|
+
/// @group color-system
|
|
221
|
+
///
|
|
222
|
+
/// @example scss - Usage
|
|
223
|
+
/// @debug k-color-shade( #f00, 1 ); // => #e60000
|
|
224
|
+
@function k-color-shade( $color, $level: 1 ) {
|
|
225
|
+
@return k-color-level( $color, $level );
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/// Shades the color in light themes and tints it in dark themes
|
|
229
|
+
/// @param {Color} $color - The color to shade or tint
|
|
230
|
+
/// @param {Number} $level - The amount to shade or tint the color
|
|
231
|
+
/// @return {Color} - The shaded or tinted color
|
|
232
|
+
///
|
|
233
|
+
/// @group color-system
|
|
234
|
+
@function k-try-shade( $color, $level: 1, $_is-dark-theme: $kendo-is-dark-theme ) {
|
|
235
|
+
$_dark-theme: if( meta.variable-exists( kendo-is-dark-theme ), $_is-dark-theme, false );
|
|
236
|
+
|
|
237
|
+
@if $_dark-theme {
|
|
238
|
+
@return k-color-tint( $color, $level );
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
@return k-color-shade( $color, $level );
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/// Tints the color in light themes and shades it in dark themes
|
|
245
|
+
/// @param {Color} $color - The color to tint or shade
|
|
246
|
+
/// @param {Number} $level - The amount to tint or shade the color
|
|
247
|
+
/// @return {Color} - The tinted or shaded color
|
|
248
|
+
///
|
|
249
|
+
/// @group color-system
|
|
250
|
+
@function k-try-tint( $color, $level: 1, $_is-dark-theme: $kendo-is-dark-theme ) {
|
|
251
|
+
$_dark-theme: if( meta.variable-exists( kendo-is-dark-theme ), $_is-dark-theme, false );
|
|
252
|
+
|
|
253
|
+
@if $_dark-theme {
|
|
254
|
+
@return k-color-shade( $color, $level );
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@return k-color-tint( $color, $level );
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/// Darkens the color in light themes and lightens it in dark themes
|
|
261
|
+
/// @param {Color} $color - The color to darken or lighten
|
|
262
|
+
/// @param {Number} $level - The amount to darken or lighten the color
|
|
263
|
+
/// @return {Color} - The darkened or lightened color
|
|
264
|
+
///
|
|
265
|
+
/// @group color-system
|
|
266
|
+
@function k-try-darken( $color, $amount, $_is-dark-theme: $kendo-is-dark-theme ) {
|
|
267
|
+
$_dark-theme: if( meta.variable-exists( kendo-is-dark-theme ), $_is-dark-theme, false );
|
|
268
|
+
|
|
269
|
+
@if $_dark-theme {
|
|
270
|
+
@return k-color-lighten( $color, $amount );
|
|
271
|
+
}
|
|
272
|
+
@return k-color-darken( $color, $amount );
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/// Lightens the color in light themes and darkens it in dark themes
|
|
276
|
+
/// @param {Color} $color - The color to lighten or darken
|
|
277
|
+
/// @param {Number} $level - The amount to lighten or darken the color
|
|
278
|
+
/// @return {Color} - The lightened or darkened color
|
|
279
|
+
///
|
|
280
|
+
/// @group color-system
|
|
281
|
+
@function k-try-lighten( $color, $amount, $_is-dark-theme: $kendo-is-dark-theme ) {
|
|
282
|
+
$_dark-theme: if( meta.variable-exists( kendo-is-dark-theme ), $_is-dark-theme, false );
|
|
283
|
+
|
|
284
|
+
@if $_dark-theme {
|
|
285
|
+
@return k-color-darken( $color, $amount );
|
|
286
|
+
}
|
|
287
|
+
@return k-color-lighten( $color, $amount );
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/// Converts a color with alpha to solid color mixed with a background color
|
|
291
|
+
/// @param {Color} $color - The color to convert
|
|
292
|
+
/// @param {Color} $bg - The background color
|
|
293
|
+
/// @return {Color} - The converted color
|
|
294
|
+
///
|
|
295
|
+
/// @group color-system
|
|
296
|
+
///
|
|
297
|
+
/// @example scss - Usage
|
|
298
|
+
/// @debug k-rgba-to-mix( rgba( #f00, 0.5 ), #fff ); // => #ff8080
|
|
299
|
+
@function k-rgba-to-mix( $color, $bg ) {
|
|
300
|
+
$percent: k-color-alpha( $color ) * 100%;
|
|
301
|
+
|
|
302
|
+
@return k-color-mix( rgba( $color, 1 ), $bg, $percent );
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// TODO: Remove this function or rethink the logic
|
|
306
|
+
@function k-true-mix( $color1, $color2, $weight: 50% ) {
|
|
307
|
+
@return k-color-mix( rgba( $color1, 1 ), rgba( $color2, 1 ), $weight );
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// Adapted from https://gist.github.com/sgomes/ccc72f71137fe29039c92c0a9fe9b657
|
|
311
|
+
// Adapted from https://github.com/twbs/bootstrap/commit/03908ea37a55eaa44c12ce5694dddc1630c980b3
|
|
312
|
+
|
|
313
|
+
// Precomputed linear color channel values, for use in contrast calculations.
|
|
314
|
+
// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
315
|
+
// Algorithm, for c in 0 to 255:
|
|
316
|
+
// f(c) {
|
|
317
|
+
// c = c / 255;
|
|
318
|
+
// return c < 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
|
319
|
+
// }
|
|
320
|
+
// This lookup table is needed since there is no `pow` in SASS.
|
|
321
|
+
// stylelint-disable number-max-precision
|
|
322
|
+
$_linear-channel-values: (
|
|
323
|
+
0
|
|
324
|
+
.0003035269835488375
|
|
325
|
+
.000607053967097675
|
|
326
|
+
.0009105809506465125
|
|
327
|
+
.00121410793419535
|
|
328
|
+
.0015176349177441874
|
|
329
|
+
.001821161901293025
|
|
330
|
+
.0021246888848418626
|
|
331
|
+
.0024282158683907
|
|
332
|
+
.0027317428519395373
|
|
333
|
+
.003035269835488375
|
|
334
|
+
.003346535763899161
|
|
335
|
+
.003676507324047436
|
|
336
|
+
.004024717018496307
|
|
337
|
+
.004391442037410293
|
|
338
|
+
.004776953480693729
|
|
339
|
+
.005181516702338386
|
|
340
|
+
.005605391624202723
|
|
341
|
+
.006048833022857054
|
|
342
|
+
.006512090792594475
|
|
343
|
+
.006995410187265387
|
|
344
|
+
.007499032043226175
|
|
345
|
+
.008023192985384994
|
|
346
|
+
.008568125618069307
|
|
347
|
+
.009134058702220787
|
|
348
|
+
.00972121732023785
|
|
349
|
+
.010329823029626936
|
|
350
|
+
.010960094006488246
|
|
351
|
+
.011612245179743885
|
|
352
|
+
.012286488356915872
|
|
353
|
+
.012983032342173012
|
|
354
|
+
.013702083047289686
|
|
355
|
+
.014443843596092545
|
|
356
|
+
.01520851442291271
|
|
357
|
+
.01599629336550963
|
|
358
|
+
.016807375752887384
|
|
359
|
+
.017641954488384078
|
|
360
|
+
.018500220128379697
|
|
361
|
+
.019382360956935723
|
|
362
|
+
.0202885630566524
|
|
363
|
+
.021219010376003555
|
|
364
|
+
.022173884793387385
|
|
365
|
+
.02315336617811041
|
|
366
|
+
.024157632448504756
|
|
367
|
+
.02518685962736163
|
|
368
|
+
.026241221894849898
|
|
369
|
+
.027320891639074894
|
|
370
|
+
.028426039504420793
|
|
371
|
+
.0295568344378088
|
|
372
|
+
.030713443732993635
|
|
373
|
+
.03189603307301153
|
|
374
|
+
.033104766570885055
|
|
375
|
+
.03433980680868217
|
|
376
|
+
.03560131487502034
|
|
377
|
+
.03688945040110004
|
|
378
|
+
.0382043715953465
|
|
379
|
+
.03954623527673284
|
|
380
|
+
.04091519690685319
|
|
381
|
+
.042311410620809675
|
|
382
|
+
.043735029256973465
|
|
383
|
+
.04518620438567554
|
|
384
|
+
.046665086336880095
|
|
385
|
+
.04817182422688942
|
|
386
|
+
.04970656598412723
|
|
387
|
+
.05126945837404324
|
|
388
|
+
.052860647023180246
|
|
389
|
+
.05448027644244237
|
|
390
|
+
.05612849004960009
|
|
391
|
+
.05780543019106723
|
|
392
|
+
.0595112381629812
|
|
393
|
+
.06124605423161761
|
|
394
|
+
.06301001765316767
|
|
395
|
+
.06480326669290577
|
|
396
|
+
.06662593864377289
|
|
397
|
+
.06847816984440017
|
|
398
|
+
.07036009569659588
|
|
399
|
+
.07227185068231748
|
|
400
|
+
.07421356838014963
|
|
401
|
+
.07618538148130785
|
|
402
|
+
.07818742180518633
|
|
403
|
+
.08021982031446832
|
|
404
|
+
.0822827071298148
|
|
405
|
+
.08437621154414882
|
|
406
|
+
.08650046203654976
|
|
407
|
+
.08865558628577294
|
|
408
|
+
.09084171118340768
|
|
409
|
+
.09305896284668745
|
|
410
|
+
.0953074666309647
|
|
411
|
+
.09758734714186246
|
|
412
|
+
.09989872824711389
|
|
413
|
+
.10224173308810132
|
|
414
|
+
.10461648409110419
|
|
415
|
+
.10702310297826761
|
|
416
|
+
.10946171077829933
|
|
417
|
+
.1119324278369056
|
|
418
|
+
.11443537382697373
|
|
419
|
+
.11697066775851084
|
|
420
|
+
.11953842798834562
|
|
421
|
+
.12213877222960187
|
|
422
|
+
.12477181756095049
|
|
423
|
+
.12743768043564743
|
|
424
|
+
.1301364766903643
|
|
425
|
+
.13286832155381798
|
|
426
|
+
.13563332965520566
|
|
427
|
+
.13843161503245183
|
|
428
|
+
.14126329114027164
|
|
429
|
+
.14412847085805777
|
|
430
|
+
.14702726649759498
|
|
431
|
+
.14995978981060856
|
|
432
|
+
.15292615199615017
|
|
433
|
+
.1559264637078274
|
|
434
|
+
.1589608350608804
|
|
435
|
+
.162029375639111
|
|
436
|
+
.1651321945016676
|
|
437
|
+
.16826940018969075
|
|
438
|
+
.1714411007328226
|
|
439
|
+
.17464740365558504
|
|
440
|
+
.17788841598362912
|
|
441
|
+
.18116424424986022
|
|
442
|
+
.184474994500441
|
|
443
|
+
.18782077230067787
|
|
444
|
+
.19120168274079138
|
|
445
|
+
.1946178304415758
|
|
446
|
+
.19806931955994886
|
|
447
|
+
.20155625379439707
|
|
448
|
+
.20507873639031693
|
|
449
|
+
.20863687014525575
|
|
450
|
+
.21223075741405523
|
|
451
|
+
.21586050011389926
|
|
452
|
+
.2195261997292692
|
|
453
|
+
.2232279573168085
|
|
454
|
+
.22696587351009836
|
|
455
|
+
.23074004852434915
|
|
456
|
+
.23455058216100522
|
|
457
|
+
.238397573812271
|
|
458
|
+
.24228112246555486
|
|
459
|
+
.24620132670783548
|
|
460
|
+
.25015828472995344
|
|
461
|
+
.25415209433082675
|
|
462
|
+
.2581828529215958
|
|
463
|
+
.26225065752969623
|
|
464
|
+
.26635560480286247
|
|
465
|
+
.2704977910130658
|
|
466
|
+
.27467731206038465
|
|
467
|
+
.2788942634768104
|
|
468
|
+
.2831487404299921
|
|
469
|
+
.2874408377269175
|
|
470
|
+
.29177064981753587
|
|
471
|
+
.2961382707983211
|
|
472
|
+
.3005437944157765
|
|
473
|
+
.3049873140698863
|
|
474
|
+
.30946892281750854
|
|
475
|
+
.31398871337571754
|
|
476
|
+
.31854677812509186
|
|
477
|
+
.32314320911295075
|
|
478
|
+
.3277780980565422
|
|
479
|
+
.33245153634617935
|
|
480
|
+
.33716361504833037
|
|
481
|
+
.3419144249086609
|
|
482
|
+
.3467040563550296
|
|
483
|
+
.35153259950043936
|
|
484
|
+
.3564001441459435
|
|
485
|
+
.3613067797835095
|
|
486
|
+
.3662525955988395
|
|
487
|
+
.3712376804741491
|
|
488
|
+
.3762621229909065
|
|
489
|
+
.38132601143253014
|
|
490
|
+
.386429433787049
|
|
491
|
+
.39157247774972326
|
|
492
|
+
.39675523072562685
|
|
493
|
+
.4019777798321958
|
|
494
|
+
.4072402119017367
|
|
495
|
+
.41254261348390375
|
|
496
|
+
.4178850708481375
|
|
497
|
+
.4232676699860717
|
|
498
|
+
.4286904966139066
|
|
499
|
+
.43415363617474895
|
|
500
|
+
.4396571738409188
|
|
501
|
+
.44520119451622786
|
|
502
|
+
.45078578283822346
|
|
503
|
+
.45641102318040466
|
|
504
|
+
.4620769996544071
|
|
505
|
+
.467783796112159
|
|
506
|
+
.47353149614800955
|
|
507
|
+
.4793201831008268
|
|
508
|
+
.4851499400560704
|
|
509
|
+
.4910208498478356
|
|
510
|
+
.4969329950608704
|
|
511
|
+
.5028864580325687
|
|
512
|
+
.5088813208549338
|
|
513
|
+
.5149176653765214
|
|
514
|
+
.5209955732043543
|
|
515
|
+
.5271151257058131
|
|
516
|
+
.5332764040105052
|
|
517
|
+
.5394794890121072
|
|
518
|
+
.5457244613701866
|
|
519
|
+
.5520114015120001
|
|
520
|
+
.5583403896342679
|
|
521
|
+
.5647115057049292
|
|
522
|
+
.5711248294648731
|
|
523
|
+
.5775804404296506
|
|
524
|
+
.5840784178911641
|
|
525
|
+
.5906188409193369
|
|
526
|
+
.5972017883637634
|
|
527
|
+
.6038273388553378
|
|
528
|
+
.6104955708078648
|
|
529
|
+
.6172065624196511
|
|
530
|
+
.6239603916750761
|
|
531
|
+
.6307571363461468
|
|
532
|
+
.6375968739940326
|
|
533
|
+
.6444796819705821
|
|
534
|
+
.6514056374198242
|
|
535
|
+
.6583748172794485
|
|
536
|
+
.665387298282272
|
|
537
|
+
.6724431569576875
|
|
538
|
+
.6795424696330938
|
|
539
|
+
.6866853124353135
|
|
540
|
+
.6938717612919899
|
|
541
|
+
.7011018919329731
|
|
542
|
+
.7083757798916868
|
|
543
|
+
.7156935005064807
|
|
544
|
+
.7230551289219693
|
|
545
|
+
.7304607400903537
|
|
546
|
+
.7379104087727308
|
|
547
|
+
.7454042095403874
|
|
548
|
+
.7529422167760779
|
|
549
|
+
.7605245046752924
|
|
550
|
+
.768151147247507
|
|
551
|
+
.7758222183174236
|
|
552
|
+
.7835377915261935
|
|
553
|
+
.7912979403326302
|
|
554
|
+
.799102738014409
|
|
555
|
+
.8069522576692516
|
|
556
|
+
.8148465722161012
|
|
557
|
+
.8227857543962835
|
|
558
|
+
.8307698767746546
|
|
559
|
+
.83879901174074
|
|
560
|
+
.846873231509858
|
|
561
|
+
.8549926081242338
|
|
562
|
+
.8631572134541023
|
|
563
|
+
.8713671191987972
|
|
564
|
+
.8796223968878317
|
|
565
|
+
.8879231178819663
|
|
566
|
+
.8962693533742664
|
|
567
|
+
.9046611743911496
|
|
568
|
+
.9130986517934192
|
|
569
|
+
.9215818562772946
|
|
570
|
+
.9301108583754237
|
|
571
|
+
.938685728457888
|
|
572
|
+
.9473065367331999
|
|
573
|
+
.9559733532492861
|
|
574
|
+
.9646862478944651
|
|
575
|
+
.9734452903984125
|
|
576
|
+
.9822505503331171
|
|
577
|
+
.9911020971138298
|
|
578
|
+
1
|
|
579
|
+
);
|
|
580
|
+
// stylelint-enable number-max-precision
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
/// @link https://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast
|
|
584
|
+
/// @link https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
585
|
+
/// Default dark color for WCAG 2.0.
|
|
586
|
+
/// @type Color
|
|
587
|
+
/// @group accessibility
|
|
588
|
+
$wcag-dark: black !default;
|
|
589
|
+
/// Default light color for WCAG 2.0.
|
|
590
|
+
/// @type Color
|
|
591
|
+
/// @group accessibility
|
|
592
|
+
$wcag-light: white !default;
|
|
593
|
+
|
|
594
|
+
/// Calculate the relative luminance for a color.
|
|
595
|
+
/// @param {Color} $color - The color to calculate the relative luminance for.
|
|
596
|
+
/// @return {Number} - The relative luminance for the color.
|
|
597
|
+
///
|
|
598
|
+
/// @group accessibility
|
|
599
|
+
///
|
|
600
|
+
/// @link https://www.w3.org/TR/WCAG/#dfn-relative-luminance
|
|
601
|
+
/// @link https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
602
|
+
@function k-color-luminance( $color ) {
|
|
603
|
+
$red: list.nth( $_linear-channel-values, k-color-red( $color ) + 1 );
|
|
604
|
+
$green: list.nth( $_linear-channel-values, k-color-green( $color ) + 1 );
|
|
605
|
+
$blue: list.nth( $_linear-channel-values, k-color-blue( $color ) + 1 );
|
|
606
|
+
|
|
607
|
+
@return .2126 * $red + .7152 * $green + .0722 * $blue;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/// Calculates contrast ratio between two colors
|
|
611
|
+
/// @param {Color} $background - The background color
|
|
612
|
+
/// @param {Color} $foreground - The foreground color
|
|
613
|
+
/// @return {Number} - The contrast ratio between the two colors
|
|
614
|
+
///
|
|
615
|
+
/// @group accessibility
|
|
616
|
+
///
|
|
617
|
+
/// @link https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
|
|
618
|
+
/// @link https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
|
619
|
+
@function k-color-contrast-ratio( $background, $foreground ) {
|
|
620
|
+
$backLum: k-color-luminance( $background ) + .05;
|
|
621
|
+
$foreLum: k-color-luminance( $foreground ) + .05;
|
|
622
|
+
|
|
623
|
+
@return math.div( math.max( $backLum, $foreLum ), math.min( $backLum, $foreLum ) );
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/// Checks if a color is dark
|
|
627
|
+
/// @param {Color} $color - The color to check
|
|
628
|
+
/// @return {Boolean} - True if the color is dark, false otherwise
|
|
629
|
+
///
|
|
630
|
+
/// @group accessibility
|
|
631
|
+
@function k-is-dark( $color ) {
|
|
632
|
+
@return if( k-color-luminance( $color ) < .5, true, false );
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/// Checks if a color is light
|
|
636
|
+
/// @param {Color} $color - The color to check
|
|
637
|
+
/// @return {Boolean} - True if the color is light, false otherwise
|
|
638
|
+
///
|
|
639
|
+
/// @group accessibility
|
|
640
|
+
@function k-is-light( $color ) {
|
|
641
|
+
@return if( k-color-luminance( $color ) < .5, false, true );
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
/// Calculates the contrast ratio between a background color and a foreground color.
|
|
646
|
+
/// If the contrast ratio is not high enough, it will return the color with the highest contrast ratio.
|
|
647
|
+
/// @param {Color} $background - The background color
|
|
648
|
+
/// @param {Color} $dark - The dark color to use as a fallback
|
|
649
|
+
/// @param {Color} $light - The light color to use as a fallback
|
|
650
|
+
/// @param {Number} $min-ratio - The minimum contrast ratio to reach
|
|
651
|
+
/// @return {Color} - The color with the highest contrast ratio
|
|
652
|
+
///
|
|
653
|
+
/// @group accessibility
|
|
654
|
+
@function k-contrast-color( $background, $dark: $wcag-dark, $light: $wcag-light, $min-ratio: $wcag-min-contrast-ratio ) {
|
|
655
|
+
$foregrounds: $light, $dark, #ffffff, #000000;
|
|
656
|
+
$max-ratio: 0;
|
|
657
|
+
$max-ratio-color: null;
|
|
658
|
+
|
|
659
|
+
@each $color in $foregrounds {
|
|
660
|
+
$contrast-ratio: k-color-contrast-ratio( $background, $color );
|
|
661
|
+
|
|
662
|
+
@if ( $contrast-ratio > $min-ratio ) {
|
|
663
|
+
@return $color;
|
|
664
|
+
} @else if ( $contrast-ratio > $max-ratio ) {
|
|
665
|
+
$max-ratio: $contrast-ratio;
|
|
666
|
+
$max-ratio-color: $color;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
@warn "Found no color leading to #{$min-ratio}:1 contrast ratio against #{$background}...";
|
|
671
|
+
|
|
672
|
+
@return $max-ratio-color;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
// Legacy functions
|
|
677
|
+
@function k-yiq-luma-information($color) {
|
|
678
|
+
$r: k-color-red($color);
|
|
679
|
+
$g: k-color-green($color);
|
|
680
|
+
$b: k-color-blue($color);
|
|
681
|
+
|
|
682
|
+
$yiq: math.div( (($r * 299) + ($g * 587) + ($b * 114)), 1000 );
|
|
683
|
+
|
|
684
|
+
@return $yiq;
|
|
685
|
+
}
|
|
686
|
+
@function k-contrast-yiq($color, $dark: $yiq-dark, $light: $yiq-light) {
|
|
687
|
+
$yiq: k-yiq-luma-information($color);
|
|
688
|
+
$out: if($yiq >= $yiq-threshold, $dark, $light);
|
|
689
|
+
// @debug yiq;
|
|
690
|
+
@return $out;
|
|
691
|
+
}
|
|
692
|
+
@function k-contrast-legacy($color, $dark: $wcag-dark, $light: $wcag-light) {
|
|
693
|
+
$luma: k-color-luminance($color);
|
|
694
|
+
$out: if($luma < .5, $light, $dark);
|
|
695
|
+
// @debug $luma;
|
|
696
|
+
@return $out;
|
|
697
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use "sass:list";
|
|
2
|
+
|
|
1
3
|
/// Returns a copy of `$list` with `$val` appended to the end.
|
|
2
4
|
/// @param {List} $list - The list to process.
|
|
3
5
|
/// @param {Any} $val - The value to append to `$list`.
|
|
@@ -7,7 +9,7 @@
|
|
|
7
9
|
/// @example scss - Usage
|
|
8
10
|
/// @debug k-list-append( ( "foo", "bar" ), "baz" ); // => "foo, bar, baz"
|
|
9
11
|
@function k-list-append( $list, $val, $separator: auto ) {
|
|
10
|
-
@return append( $list, $val, $separator );
|
|
12
|
+
@return list.append( $list, $val, $separator );
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/// Checks whether `$list` contains `$value`.
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
/// @example scss - Usage
|
|
31
33
|
/// @debug k-list-index( ( "foo", "bar" ), "foo" ); // => 1
|
|
32
34
|
@function k-list-index( $list, $value ) {
|
|
33
|
-
@return index( $list, $value );
|
|
35
|
+
@return list.index( $list, $value );
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/// Returns whether `$list` is bracketed.
|
|
@@ -41,7 +43,7 @@
|
|
|
41
43
|
/// @debug k-list-is-bracketed( ( "foo", "bar" ) ); // => false
|
|
42
44
|
/// @debug k-list-is-bracketed( [ "foo", "bar" ] ); // => true
|
|
43
45
|
@function k-list-is-bracketed( $list ) {
|
|
44
|
-
@return is-bracketed( $list );
|
|
46
|
+
@return list.is-bracketed( $list );
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
/// Joins two lists together.
|
|
@@ -55,7 +57,7 @@
|
|
|
55
57
|
/// @debug k-list-join( ( "foo", "bar" ), ( "baz", "qux" ) ); // => "foo, bar, baz, qux"
|
|
56
58
|
/// @debug k-list-join( ( "foo", "bar" ), ( "baz", "qux" ), " " ); // => "foo bar baz qux"
|
|
57
59
|
@function k-list-join( $list1, $list2, $separator: auto, $bracketed: auto ) {
|
|
58
|
-
@return join( $list1, $list2, $separator, $bracketed );
|
|
60
|
+
@return list.join( $list1, $list2, $separator, $bracketed );
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
/// Returns the length of `$list`.
|
|
@@ -65,7 +67,7 @@
|
|
|
65
67
|
/// @example scss - Usage
|
|
66
68
|
/// @debug k-list-length( ( "foo", "bar" ) ); // => 2
|
|
67
69
|
@function k-list-length( $list ) {
|
|
68
|
-
@return length( $list );
|
|
70
|
+
@return list.length( $list );
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
/// Returns the nth item in `$list`.
|
|
@@ -76,7 +78,7 @@
|
|
|
76
78
|
/// @example scss - Usage
|
|
77
79
|
/// @debug k-list-nth( ( "foo", "bar" ), 1 ); // => "foo"
|
|
78
80
|
@function k-list-nth( $list, $n ) {
|
|
79
|
-
@return nth( $list, $n );
|
|
81
|
+
@return list.nth( $list, $n );
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
/// Reverse the order of items in `$list`.
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
/// @example scss - Usage
|
|
110
112
|
/// @debug k-list-separator( ( "foo", "bar" ) ); // => ","
|
|
111
113
|
@function k-list-separator( $list ) {
|
|
112
|
-
@return list-separator( $list );
|
|
114
|
+
@return list.list-separator( $list );
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
/// Returns a copy of `$list` with `$val` inserted at `$n`.
|
|
@@ -121,7 +123,7 @@
|
|
|
121
123
|
/// @example scss - Usage
|
|
122
124
|
/// @debug k-list-set-nth( ( "foo", "bar" ), 1, "baz" ); // => "baz, bar"
|
|
123
125
|
@function k-list-set-nth( $list, $n, $value ) {
|
|
124
|
-
@return set-nth( $list, $n, $value );
|
|
126
|
+
@return list.set-nth( $list, $n, $value );
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
/// Combines two lists into a single list of two-item lists.
|
|
@@ -132,5 +134,5 @@
|
|
|
132
134
|
/// @example scss - Usage
|
|
133
135
|
/// @debug k-list-zip( ( "foo", "bar" ), ( "baz", "qux" ) ); // => ((foo, baz), (bar, qux))
|
|
134
136
|
@function k-list-zip( $lists... ) {
|
|
135
|
-
@return zip( $lists... );
|
|
137
|
+
@return list.zip( $lists... );
|
|
136
138
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
@use "sass:meta";
|
|
2
|
+
@use "sass:map";
|
|
3
|
+
|
|
1
4
|
/// Returns the value at `$key` in `$map`.
|
|
2
5
|
/// @param {Map} $map - The map to get the value from.
|
|
3
6
|
/// @param {Any} $key - The key to get the value for.
|
|
@@ -6,7 +9,7 @@
|
|
|
6
9
|
/// @debug k-map-get( ( "foo": "bar" ), "foo" ); // => "bar"
|
|
7
10
|
@function k-map-get( $map, $keys... ) {
|
|
8
11
|
@each $key in $keys {
|
|
9
|
-
$map: map
|
|
12
|
+
$map: map.get( $map, $key ); // stylelint-disable-line
|
|
10
13
|
}
|
|
11
14
|
@return $map;
|
|
12
15
|
}
|
|
@@ -20,7 +23,7 @@
|
|
|
20
23
|
/// @debug k-map-has( ( "foo": "bar" ), "foo" ); // => true
|
|
21
24
|
/// @debug k-map-has( ( "foo": "bar" ), "bar" ); // => false
|
|
22
25
|
@function k-map-has-key( $map, $key ) {
|
|
23
|
-
@return map
|
|
26
|
+
@return map.has-key( $map, $key );
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
/// Returns a comma separated list of the keys in `$map`.
|
|
@@ -30,7 +33,7 @@
|
|
|
30
33
|
/// @example scss - Usage
|
|
31
34
|
/// @debug k-map-keys( ( "foo": "bar", "baz": "qux" ) ); // => "foo, baz"
|
|
32
35
|
@function k-map-keys( $map ) {
|
|
33
|
-
@return map
|
|
36
|
+
@return map.keys( $map );
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
/// Returns a map with the keys and values from `$map` and `$args`.
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
/// @debug k-map-merge( ( "foo": "bar" ), ( "baz": "qux" ) ); // => ( "foo": "bar", "baz": "qux" )
|
|
43
46
|
@function k-map-merge( $map, $args... ) {
|
|
44
47
|
@each $arg in $args {
|
|
45
|
-
$map: map
|
|
48
|
+
$map: map.merge( $map, $arg ); // stylelint-disable-line
|
|
46
49
|
}
|
|
47
50
|
@return $map;
|
|
48
51
|
}
|
|
@@ -58,9 +61,9 @@
|
|
|
58
61
|
|
|
59
62
|
@each $map in $maps {
|
|
60
63
|
@each $key, $val in $map {
|
|
61
|
-
@if (
|
|
64
|
+
@if (meta.type-of($val) == 'map') {
|
|
62
65
|
$current: k-map-get($merged, $key);
|
|
63
|
-
@if (
|
|
66
|
+
@if (meta.type-of($current) == 'map') {
|
|
64
67
|
$val: k-map-deep-merge($current, $val);
|
|
65
68
|
$map: k-map-merge(
|
|
66
69
|
$map,
|
|
@@ -85,7 +88,7 @@
|
|
|
85
88
|
/// @example scss - Usage
|
|
86
89
|
/// @debug k-map-remove( ( "foo": "bar", "baz": "qux" ), "foo" ); // => ( "baz": "qux" )
|
|
87
90
|
@function k-map-remove( $map, $keys... ) {
|
|
88
|
-
@return map
|
|
91
|
+
@return map.remove( $map, $keys... );
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
/// Sets a single key and value in `$map`.
|
|
@@ -107,7 +110,7 @@
|
|
|
107
110
|
/// @example scss - Usage
|
|
108
111
|
/// @debug k-map-values( ( "foo": "bar", "baz": "qux" ) ); // => "bar, qux"
|
|
109
112
|
@function k-map-values( $map ) {
|
|
110
|
-
@return map
|
|
113
|
+
@return map.values( $map );
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
/// Returns negative values of a number or numbers in a list.
|
|
@@ -119,13 +122,13 @@
|
|
|
119
122
|
@function k-map-negate($map) {
|
|
120
123
|
$_map-neg: ();
|
|
121
124
|
|
|
122
|
-
@if(
|
|
123
|
-
@error "expected type of #{$map} is map, was #{
|
|
125
|
+
@if( meta.type-of($map) != map ) {
|
|
126
|
+
@error "expected type of #{$map} is map, was #{meta.type-of($map)}";
|
|
124
127
|
};
|
|
125
128
|
@each $key, $value in $map {
|
|
126
129
|
$_key-neg: "-" + $key;
|
|
127
130
|
|
|
128
|
-
@if(
|
|
131
|
+
@if( meta.type-of($value) == number and $value != 0 and $_key-neg != "-0" ) {
|
|
129
132
|
$_map-neg: k-map-set($_map-neg, $_key-neg, -1 * $value );
|
|
130
133
|
}
|
|
131
134
|
}
|