@daffodil/design 0.42.3 → 0.43.1
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/esm2020/molecules/callout/callout/callout.component.mjs +2 -2
- package/esm2020/molecules/card/card/card.component.mjs +2 -2
- package/esm2020/molecules/hero/hero/hero.component.mjs +2 -2
- package/esm2020/molecules/image-list/image-list.component.mjs +2 -2
- package/esm2020/molecules/list/list/list.component.mjs +2 -2
- package/esm2020/molecules/paginator/paginator.component.mjs +2 -2
- package/fesm2015/daffodil-design.mjs +12 -12
- package/fesm2015/daffodil-design.mjs.map +1 -1
- package/fesm2020/daffodil-design.mjs +12 -12
- package/fesm2020/daffodil-design.mjs.map +1 -1
- package/package.json +1 -1
- package/{src/scss → scss}/README.md +0 -0
- package/scss/accessibility/_errors.scss +12 -0
- package/scss/accessibility/_index.scss +1 -0
- package/scss/core/_index.scss +4 -0
- package/scss/core/map/map-deep-check/map-deep-check.scss +26 -0
- package/scss/core/map/map-deep-check/map-deep-check.spec.scss +43 -0
- package/scss/core/map/map-deep-get/map-deep-get.scss +27 -0
- package/scss/core/map/map-deep-get/map-deep-get.spec.scss +25 -0
- package/scss/core/string/split/string-split.scss +33 -0
- package/scss/core/string/split/string-split.spec.scss +35 -0
- package/scss/daff-global.scss +49 -0
- package/scss/daff-typography.scss +55 -0
- package/scss/daff-util.scss +21 -0
- package/scss/interactions/_index.scss +1 -0
- package/scss/interactions/mouse/_clickable.scss +22 -0
- package/scss/layout/_breakpoint.scss +21 -0
- package/scss/layout/_index.scss +2 -0
- package/scss/layout/_variables.scss +13 -0
- package/scss/theme.scss +77 -0
- package/scss/theming/README.md +59 -0
- package/scss/theming/_color-palettes.scss +116 -0
- package/scss/theming/_configure-palette.scss +20 -0
- package/scss/theming/_configure-theme.scss +68 -0
- package/scss/theming/_get-color.scss +18 -0
- package/scss/theming/_index.scss +6 -0
- package/scss/theming/_theme-css-variables.scss +43 -0
- package/scss/theming/contrast/_index.scss +5 -0
- package/scss/theming/contrast/contrast-ratio/contrast-ratio.scss +11 -0
- package/scss/theming/contrast/contrast-ratio/contrast-ratio.spec.scss +0 -0
- package/scss/theming/contrast/luminance/_variables.scss +268 -0
- package/scss/theming/contrast/luminance/luminance.scss +19 -0
- package/scss/theming/contrast/luminance/luminance.spec.scss +24 -0
- package/scss/theming/contrast/text-contrast/text-contrast.scss +34 -0
- package/scss/theming/contrast/text-contrast/text-contrast.spec.scss +0 -0
- package/scss/theming/illuminate/illuminate.scss +145 -0
- package/scss/theming/illuminate/illuminate.spec.scss +15 -0
- package/scss/theming/prebuilt/internal-theme.scss +13 -0
- package/scss/typography/README.md +88 -0
- package/scss/typography/_classes.scss +20 -0
- package/scss/typography/_index.scss +5 -0
- package/scss/typography/mixins/_font-weight.scss +18 -0
- package/scss/typography/mixins/_sizes.scss +84 -0
- package/scss/typography/mixins/_text-transform.scss +4 -0
- package/scss/typography/mixins/_text-truncate.scss +23 -0
- package/scss/typography/utilities/_index.scss +1 -0
- package/scss/typography/utilities/_variables.scss +12 -0
- package/src/atoms/button/button-theme-variants/button.scss +35 -0
- package/src/atoms/button/button-theme-variants/focus.scss +6 -0
- package/src/atoms/button/button-theme-variants/icon.scss +21 -0
- package/src/atoms/button/button-theme-variants/raised.scss +56 -0
- package/src/atoms/button/button-theme-variants/stroked.scss +36 -0
- package/src/atoms/button/button-theme-variants/underline.scss +9 -0
- package/src/atoms/button/button-theme.scss +570 -0
- package/src/atoms/form/error-message/error-message-theme.scss +7 -0
- package/src/atoms/form/form-field/form-field/form-field-theme.scss +38 -0
- package/src/atoms/form/input/input-theme.scss +16 -0
- package/src/atoms/form/radio/radio.scss +0 -0
- package/src/atoms/form/select/select/select-theme.scss +19 -0
- package/src/atoms/loading-icon/loading-icon-theme.scss +57 -0
- package/src/atoms/progress-indicator/progress-indicator-theme.scss +60 -0
- package/src/molecules/accordion/accordion-item/accordion-item-theme.scss +12 -0
- package/src/molecules/article/article/_stops-article-cascade.scss +7 -0
- package/src/molecules/article/article/article-theme.scss +78 -0
- package/src/molecules/callout/callout-theme.scss +59 -0
- package/src/molecules/card/card/card-theme-variants/basic-card.scss +6 -0
- package/src/molecules/card/card/card-theme-variants/linkable-card.scss +23 -0
- package/src/molecules/card/card/card-theme-variants/stroked-card.scss +3 -0
- package/src/molecules/card/card/card-theme.scss +186 -0
- package/src/molecules/hero/hero-theme.scss +59 -0
- package/src/molecules/list/list/list-theme.scss +68 -0
- package/src/molecules/media-gallery/media-gallery-theme.scss +20 -0
- package/src/molecules/modal/modal-theme.scss +9 -0
- package/src/molecules/navbar/navbar-theme.scss +57 -0
- package/src/molecules/paginator/paginator-theme.scss +72 -0
- package/src/molecules/sidebar/sidebar/sidebar-theme.scss +13 -0
- package/src/molecules/sidebar/sidebar-viewport/sidebar-viewport-theme.scss +11 -0
- package/daff-global.scss +0 -2
- package/daff-theme.scss +0 -3634
- package/daff-typography.scss +0 -505
- package/daff-util.scss +0 -377
@@ -0,0 +1,20 @@
|
|
1
|
+
@use 'sass:map';
|
2
|
+
@use 'get-color';
|
3
|
+
|
4
|
+
// @docs
|
5
|
+
//
|
6
|
+
// Configures the default color of a palette. It will set the
|
7
|
+
// "default" to 60 if $hue isn't specified.
|
8
|
+
//
|
9
|
+
// @usage
|
10
|
+
// ```scss
|
11
|
+
// daff-configure-palette($daff-yellow, 50);
|
12
|
+
// ```
|
13
|
+
@function daff-configure-palette($color-palette, $hue: 60) {
|
14
|
+
@return map.merge(
|
15
|
+
$color-palette,
|
16
|
+
(
|
17
|
+
'default': get-color.daff-color($color-palette, $hue)
|
18
|
+
)
|
19
|
+
);
|
20
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
@use 'sass:map';
|
2
|
+
@use 'configure-palette';
|
3
|
+
@use 'color-palettes' as palette;
|
4
|
+
@use 'get-color';
|
5
|
+
|
6
|
+
$daff-light-theme: (
|
7
|
+
'font-color': get-color.daff-color(palette.$daff-gray, 110),
|
8
|
+
'base': get-color.daff-color(palette.$daff-gray, 0),
|
9
|
+
'base-contrast': get-color.daff-color(palette.$daff-gray, 110),
|
10
|
+
'white': get-color.daff-color(palette.$daff-gray, 0),
|
11
|
+
'black': get-color.daff-color(palette.$daff-gray, 110),
|
12
|
+
'gray': configure-palette.daff-configure-palette(palette.$daff-gray, 60),
|
13
|
+
);
|
14
|
+
|
15
|
+
$daff-dark-theme: (
|
16
|
+
'font-color': get-color.daff-color(palette.$daff-gray, 0),
|
17
|
+
'base': get-color.daff-color(palette.$daff-gray, 100),
|
18
|
+
'base-contrast': get-color.daff-color(palette.$daff-gray, 0),
|
19
|
+
'white': get-color.daff-color(palette.$daff-gray, 0),
|
20
|
+
'black': get-color.daff-color(palette.$daff-gray, 110),
|
21
|
+
'gray': configure-palette.daff-configure-palette(palette.$daff-gray, 50),
|
22
|
+
);
|
23
|
+
|
24
|
+
$supported-theme-types: (
|
25
|
+
'light': $daff-light-theme,
|
26
|
+
'dark': $daff-dark-theme
|
27
|
+
);
|
28
|
+
|
29
|
+
// @docs
|
30
|
+
//
|
31
|
+
// Create a theme object given some initial settings
|
32
|
+
//
|
33
|
+
// @usage
|
34
|
+
// ```
|
35
|
+
// daff-configure-theme($daff-yellow, $daff-blue, $daff-purple)
|
36
|
+
// ```
|
37
|
+
@function daff-configure-theme(
|
38
|
+
$primary,
|
39
|
+
$secondary,
|
40
|
+
$tertiary,
|
41
|
+
$type: 'light'
|
42
|
+
) {
|
43
|
+
@return (
|
44
|
+
'primary': $primary,
|
45
|
+
'secondary': $secondary,
|
46
|
+
'tertiary': $tertiary,
|
47
|
+
'core': daff-build-theme-core($type)
|
48
|
+
);
|
49
|
+
}
|
50
|
+
|
51
|
+
//
|
52
|
+
// @docs
|
53
|
+
//
|
54
|
+
// Create a core theme given a theme type
|
55
|
+
// $type | ThemeType : "light" | "dark"
|
56
|
+
//
|
57
|
+
// ```
|
58
|
+
// @usage
|
59
|
+
// daff-build-theme-core("light")
|
60
|
+
// ```
|
61
|
+
@function daff-build-theme-core($type: 'light') {
|
62
|
+
$error-msg: 'is not a valid theme type - valid types:';
|
63
|
+
@if (not map.has-key($supported-theme-types, $type)) {
|
64
|
+
@error '`#{$type}` `#{$error-msg}` `#{map-keys($supported-theme-types)}`';
|
65
|
+
}
|
66
|
+
|
67
|
+
@return map.get($supported-theme-types, $type);
|
68
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
@use 'sass:map';
|
2
|
+
|
3
|
+
//
|
4
|
+
// Takes a color palette and retrieves the hue from the palette
|
5
|
+
// If no color is selected, it will retrieve the default
|
6
|
+
// color from the palette
|
7
|
+
//
|
8
|
+
// @usage
|
9
|
+
// ```
|
10
|
+
// daff-color($daff-yellow, 60);
|
11
|
+
// ```
|
12
|
+
@function daff-color($palette, $color: 'default') {
|
13
|
+
@if (not(map.has-key($palette, $color))) {
|
14
|
+
@error 'Color: `#{$color}` does not exist in palette';
|
15
|
+
}
|
16
|
+
|
17
|
+
@return map.get($palette, $color);
|
18
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
@use 'sass:map';
|
2
|
+
@use '../core';
|
3
|
+
@use 'theming';
|
4
|
+
|
5
|
+
@mixin daff-root($theme) {
|
6
|
+
$base: core.daff-map-deep-get($theme, 'core.base');
|
7
|
+
$base-contrast: core.daff-map-deep-get($theme, 'core.base-contrast');
|
8
|
+
$primary: map.get($theme, primary);
|
9
|
+
$secondary: map.get($theme, secondary);
|
10
|
+
$tertiary: map.get($theme, tertiary);
|
11
|
+
$gray: core.daff-map-deep-get($theme, 'core.gray');
|
12
|
+
$white: core.daff-map-deep-get($theme, 'core.white');
|
13
|
+
$black: core.daff-map-deep-get($theme, 'core.black');
|
14
|
+
|
15
|
+
--daff-theme-rgb: #{red($base), green($base), blue($base)};
|
16
|
+
--daff-theme-contrast-rgb: #{red($base-contrast), green($base-contrast),
|
17
|
+
blue($base-contrast)};
|
18
|
+
--daff-theme: #{$base};
|
19
|
+
--daff-theme-contrast: #{$base-contrast};
|
20
|
+
--daff-theme-primary: #{theming.daff-color($primary)};
|
21
|
+
--daff-theme-secondary: #{theming.daff-color($secondary)};
|
22
|
+
--daff-theme-tertiary: #{theming.daff-color($tertiary)};
|
23
|
+
--daff-theme-warn: #{theming.daff-color(theming.$daff-bronze, 60)};
|
24
|
+
--daff-theme-success: #{theming.daff-color(theming.$daff-green, 60)};
|
25
|
+
--daff-theme-danger: #{theming.daff-color(theming.$daff-red, 60)};
|
26
|
+
--daff-theme-white: #{$white};
|
27
|
+
--daff-theme-black: #{$black};
|
28
|
+
--daff-theme-gray: #{theming.daff-color($gray)};
|
29
|
+
}
|
30
|
+
|
31
|
+
@mixin daff-theme-css-variables($theme, $asRoot: true) {
|
32
|
+
// @docs
|
33
|
+
//
|
34
|
+
// Global theming css variables
|
35
|
+
@if ($asRoot) {
|
36
|
+
:root {
|
37
|
+
@include daff-root($theme);
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
@include daff-root($theme);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
@use 'sass:math';
|
2
|
+
@use '../luminance/luminance';
|
3
|
+
|
4
|
+
// Calculate the contrast ratio between two colors.
|
5
|
+
// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
6
|
+
@function daff-contrast-ratio($back, $front) {
|
7
|
+
$back-lum: luminance.daff-luminance($back) + 0.05;
|
8
|
+
$fore-lum: luminance.daff-luminance($front) + 0.05;
|
9
|
+
|
10
|
+
@return math.div(max($back-lum, $fore-lum), min($back-lum, $fore-lum));
|
11
|
+
}
|
File without changes
|
@@ -0,0 +1,268 @@
|
|
1
|
+
// Precomputed linear color channel values, for use in contrast calculations.
|
2
|
+
// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
3
|
+
//
|
4
|
+
// Algorithm, for c in 0 to 255:
|
5
|
+
// f(c) {
|
6
|
+
// c = c / 255;
|
7
|
+
// return c < 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
8
|
+
// }
|
9
|
+
//
|
10
|
+
// This lookup table is needed since there is no `pow` in SASS.
|
11
|
+
$linear-channel-values: (
|
12
|
+
0,
|
13
|
+
0.0003035269835488375,
|
14
|
+
0.000607053967097675,
|
15
|
+
0.0009105809506465125,
|
16
|
+
0.00121410793419535,
|
17
|
+
0.0015176349177441874,
|
18
|
+
0.001821161901293025,
|
19
|
+
0.0021246888848418626,
|
20
|
+
0.0024282158683907,
|
21
|
+
0.0027317428519395373,
|
22
|
+
0.003035269835488375,
|
23
|
+
0.003346535763899161,
|
24
|
+
0.003676507324047436,
|
25
|
+
0.004024717018496307,
|
26
|
+
0.004391442037410293,
|
27
|
+
0.004776953480693729,
|
28
|
+
0.005181516702338386,
|
29
|
+
0.005605391624202723,
|
30
|
+
0.006048833022857054,
|
31
|
+
0.006512090792594475,
|
32
|
+
0.006995410187265387,
|
33
|
+
0.007499032043226175,
|
34
|
+
0.008023192985384994,
|
35
|
+
0.008568125618069307,
|
36
|
+
0.009134058702220787,
|
37
|
+
0.00972121732023785,
|
38
|
+
0.010329823029626936,
|
39
|
+
0.010960094006488246,
|
40
|
+
0.011612245179743885,
|
41
|
+
0.012286488356915872,
|
42
|
+
0.012983032342173012,
|
43
|
+
0.013702083047289686,
|
44
|
+
0.014443843596092545,
|
45
|
+
0.01520851442291271,
|
46
|
+
0.01599629336550963,
|
47
|
+
0.016807375752887384,
|
48
|
+
0.017641954488384078,
|
49
|
+
0.018500220128379697,
|
50
|
+
0.019382360956935723,
|
51
|
+
0.0202885630566524,
|
52
|
+
0.021219010376003555,
|
53
|
+
0.022173884793387385,
|
54
|
+
0.02315336617811041,
|
55
|
+
0.024157632448504756,
|
56
|
+
0.02518685962736163,
|
57
|
+
0.026241221894849898,
|
58
|
+
0.027320891639074894,
|
59
|
+
0.028426039504420793,
|
60
|
+
0.0295568344378088,
|
61
|
+
0.030713443732993635,
|
62
|
+
0.03189603307301153,
|
63
|
+
0.033104766570885055,
|
64
|
+
0.03433980680868217,
|
65
|
+
0.03560131487502034,
|
66
|
+
0.03688945040110004,
|
67
|
+
0.0382043715953465,
|
68
|
+
0.03954623527673284,
|
69
|
+
0.04091519690685319,
|
70
|
+
0.042311410620809675,
|
71
|
+
0.043735029256973465,
|
72
|
+
0.04518620438567554,
|
73
|
+
0.046665086336880095,
|
74
|
+
0.04817182422688942,
|
75
|
+
0.04970656598412723,
|
76
|
+
0.05126945837404324,
|
77
|
+
0.052860647023180246,
|
78
|
+
0.05448027644244237,
|
79
|
+
0.05612849004960009,
|
80
|
+
0.05780543019106723,
|
81
|
+
0.0595112381629812,
|
82
|
+
0.06124605423161761,
|
83
|
+
0.06301001765316767,
|
84
|
+
0.06480326669290577,
|
85
|
+
0.06662593864377289,
|
86
|
+
0.06847816984440017,
|
87
|
+
0.07036009569659588,
|
88
|
+
0.07227185068231748,
|
89
|
+
0.07421356838014963,
|
90
|
+
0.07618538148130785,
|
91
|
+
0.07818742180518633,
|
92
|
+
0.08021982031446832,
|
93
|
+
0.0822827071298148,
|
94
|
+
0.08437621154414882,
|
95
|
+
0.08650046203654976,
|
96
|
+
0.08865558628577294,
|
97
|
+
0.09084171118340768,
|
98
|
+
0.09305896284668745,
|
99
|
+
0.0953074666309647,
|
100
|
+
0.09758734714186246,
|
101
|
+
0.09989872824711389,
|
102
|
+
0.10224173308810132,
|
103
|
+
0.10461648409110419,
|
104
|
+
0.10702310297826761,
|
105
|
+
0.10946171077829933,
|
106
|
+
0.1119324278369056,
|
107
|
+
0.11443537382697373,
|
108
|
+
0.11697066775851084,
|
109
|
+
0.11953842798834562,
|
110
|
+
0.12213877222960187,
|
111
|
+
0.12477181756095049,
|
112
|
+
0.12743768043564743,
|
113
|
+
0.1301364766903643,
|
114
|
+
0.13286832155381798,
|
115
|
+
0.13563332965520566,
|
116
|
+
0.13843161503245183,
|
117
|
+
0.14126329114027164,
|
118
|
+
0.14412847085805777,
|
119
|
+
0.14702726649759498,
|
120
|
+
0.14995978981060856,
|
121
|
+
0.15292615199615017,
|
122
|
+
0.1559264637078274,
|
123
|
+
0.1589608350608804,
|
124
|
+
0.162029375639111,
|
125
|
+
0.1651321945016676,
|
126
|
+
0.16826940018969075,
|
127
|
+
0.1714411007328226,
|
128
|
+
0.17464740365558504,
|
129
|
+
0.17788841598362912,
|
130
|
+
0.18116424424986022,
|
131
|
+
0.184474994500441,
|
132
|
+
0.18782077230067787,
|
133
|
+
0.19120168274079138,
|
134
|
+
0.1946178304415758,
|
135
|
+
0.19806931955994886,
|
136
|
+
0.20155625379439707,
|
137
|
+
0.20507873639031693,
|
138
|
+
0.20863687014525575,
|
139
|
+
0.21223075741405523,
|
140
|
+
0.21586050011389926,
|
141
|
+
0.2195261997292692,
|
142
|
+
0.2232279573168085,
|
143
|
+
0.22696587351009836,
|
144
|
+
0.23074004852434915,
|
145
|
+
0.23455058216100522,
|
146
|
+
0.238397573812271,
|
147
|
+
0.24228112246555486,
|
148
|
+
0.24620132670783548,
|
149
|
+
0.25015828472995344,
|
150
|
+
0.25415209433082675,
|
151
|
+
0.2581828529215958,
|
152
|
+
0.26225065752969623,
|
153
|
+
0.26635560480286247,
|
154
|
+
0.2704977910130658,
|
155
|
+
0.27467731206038465,
|
156
|
+
0.2788942634768104,
|
157
|
+
0.2831487404299921,
|
158
|
+
0.2874408377269175,
|
159
|
+
0.29177064981753587,
|
160
|
+
0.2961382707983211,
|
161
|
+
0.3005437944157765,
|
162
|
+
0.3049873140698863,
|
163
|
+
0.30946892281750854,
|
164
|
+
0.31398871337571754,
|
165
|
+
0.31854677812509186,
|
166
|
+
0.32314320911295075,
|
167
|
+
0.3277780980565422,
|
168
|
+
0.33245153634617935,
|
169
|
+
0.33716361504833037,
|
170
|
+
0.3419144249086609,
|
171
|
+
0.3467040563550296,
|
172
|
+
0.35153259950043936,
|
173
|
+
0.3564001441459435,
|
174
|
+
0.3613067797835095,
|
175
|
+
0.3662525955988395,
|
176
|
+
0.3712376804741491,
|
177
|
+
0.3762621229909065,
|
178
|
+
0.38132601143253014,
|
179
|
+
0.386429433787049,
|
180
|
+
0.39157247774972326,
|
181
|
+
0.39675523072562685,
|
182
|
+
0.4019777798321958,
|
183
|
+
0.4072402119017367,
|
184
|
+
0.41254261348390375,
|
185
|
+
0.4178850708481375,
|
186
|
+
0.4232676699860717,
|
187
|
+
0.4286904966139066,
|
188
|
+
0.43415363617474895,
|
189
|
+
0.4396571738409188,
|
190
|
+
0.44520119451622786,
|
191
|
+
0.45078578283822346,
|
192
|
+
0.45641102318040466,
|
193
|
+
0.4620769996544071,
|
194
|
+
0.467783796112159,
|
195
|
+
0.47353149614800955,
|
196
|
+
0.4793201831008268,
|
197
|
+
0.4851499400560704,
|
198
|
+
0.4910208498478356,
|
199
|
+
0.4969329950608704,
|
200
|
+
0.5028864580325687,
|
201
|
+
0.5088813208549338,
|
202
|
+
0.5149176653765214,
|
203
|
+
0.5209955732043543,
|
204
|
+
0.5271151257058131,
|
205
|
+
0.5332764040105052,
|
206
|
+
0.5394794890121072,
|
207
|
+
0.5457244613701866,
|
208
|
+
0.5520114015120001,
|
209
|
+
0.5583403896342679,
|
210
|
+
0.5647115057049292,
|
211
|
+
0.5711248294648731,
|
212
|
+
0.5775804404296506,
|
213
|
+
0.5840784178911641,
|
214
|
+
0.5906188409193369,
|
215
|
+
0.5972017883637634,
|
216
|
+
0.6038273388553378,
|
217
|
+
0.6104955708078648,
|
218
|
+
0.6172065624196511,
|
219
|
+
0.6239603916750761,
|
220
|
+
0.6307571363461468,
|
221
|
+
0.6375968739940326,
|
222
|
+
0.6444796819705821,
|
223
|
+
0.6514056374198242,
|
224
|
+
0.6583748172794485,
|
225
|
+
0.665387298282272,
|
226
|
+
0.6724431569576875,
|
227
|
+
0.6795424696330938,
|
228
|
+
0.6866853124353135,
|
229
|
+
0.6938717612919899,
|
230
|
+
0.7011018919329731,
|
231
|
+
0.7083757798916868,
|
232
|
+
0.7156935005064807,
|
233
|
+
0.7230551289219693,
|
234
|
+
0.7304607400903537,
|
235
|
+
0.7379104087727308,
|
236
|
+
0.7454042095403874,
|
237
|
+
0.7529422167760779,
|
238
|
+
0.7605245046752924,
|
239
|
+
0.768151147247507,
|
240
|
+
0.7758222183174236,
|
241
|
+
0.7835377915261935,
|
242
|
+
0.7912979403326302,
|
243
|
+
0.799102738014409,
|
244
|
+
0.8069522576692516,
|
245
|
+
0.8148465722161012,
|
246
|
+
0.8227857543962835,
|
247
|
+
0.8307698767746546,
|
248
|
+
0.83879901174074,
|
249
|
+
0.846873231509858,
|
250
|
+
0.8549926081242338,
|
251
|
+
0.8631572134541023,
|
252
|
+
0.8713671191987972,
|
253
|
+
0.8796223968878317,
|
254
|
+
0.8879231178819663,
|
255
|
+
0.8962693533742664,
|
256
|
+
0.9046611743911496,
|
257
|
+
0.9130986517934192,
|
258
|
+
0.9215818562772946,
|
259
|
+
0.9301108583754237,
|
260
|
+
0.938685728457888,
|
261
|
+
0.9473065367331999,
|
262
|
+
0.9559733532492861,
|
263
|
+
0.9646862478944651,
|
264
|
+
0.9734452903984125,
|
265
|
+
0.9822505503331171,
|
266
|
+
0.9911020971138298,
|
267
|
+
1
|
268
|
+
);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
@use 'variables' as v;
|
2
|
+
|
3
|
+
// Calculate the luminance of a color.
|
4
|
+
// Luminance is defined as a decimal value between 0 and 1
|
5
|
+
// with "0" corresponding to "no brightness"
|
6
|
+
// and "1" corresponding to "full brightness".
|
7
|
+
//
|
8
|
+
// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
|
9
|
+
|
10
|
+
@function daff-luminance($color) {
|
11
|
+
$red-index: red($color) + 1;
|
12
|
+
$green-index: green($color) + 1;
|
13
|
+
$blue-index: blue($color) + 1;
|
14
|
+
|
15
|
+
$red: nth(v.$linear-channel-values, $red-index);
|
16
|
+
$green: nth(v.$linear-channel-values, $green-index);
|
17
|
+
$blue: nth(v.$linear-channel-values, $blue-index);
|
18
|
+
@return 0.2126 * $red + 0.7152 * $green + 0.0722 * $blue;
|
19
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
@use 'true' as *;
|
2
|
+
@use 'luminance';
|
3
|
+
|
4
|
+
@include describe('luminance') {
|
5
|
+
@include it('should return 0 for black') {
|
6
|
+
@include assert-equal(luminance.daff-luminance(#000000), 0);
|
7
|
+
}
|
8
|
+
|
9
|
+
@include it('should return 1 for white') {
|
10
|
+
@include assert-equal(luminance.daff-luminance(#fff), 1);
|
11
|
+
}
|
12
|
+
|
13
|
+
@include it('should return 0.2126 for pure red') {
|
14
|
+
@include assert-equal(luminance.daff-luminance(#ff0000), 0.2126);
|
15
|
+
}
|
16
|
+
|
17
|
+
@include it('should return 0.7152 for pure green') {
|
18
|
+
@include assert-equal(luminance.daff-luminance(#00ff00), 0.7152);
|
19
|
+
}
|
20
|
+
|
21
|
+
@include it('should return 0.0722 for pure blue') {
|
22
|
+
@include assert-equal(luminance.daff-luminance(#0000ff), 0.0722);
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
@use '../contrast-ratio/contrast-ratio' as cr;
|
2
|
+
@use '../../get-color';
|
3
|
+
@use '../../color-palettes' as palette;
|
4
|
+
|
5
|
+
// @docs
|
6
|
+
//
|
7
|
+
// Given a color, get the font color that would be
|
8
|
+
// easily visible on top of that color
|
9
|
+
//
|
10
|
+
// For an interesting read, see more about the topic:
|
11
|
+
// https://robots.thoughtbot.com/closer-look-color-lightness
|
12
|
+
//
|
13
|
+
// Based on the code outlined by Sergio Gomes here:
|
14
|
+
// https://medium.com/dev-channel/using-sass-to-automatically-pick-text-colors-4ba7645d2796
|
15
|
+
//
|
16
|
+
// @usage
|
17
|
+
// ```
|
18
|
+
// daff-text-contrast("#777777")
|
19
|
+
// ```
|
20
|
+
@function daff-text-contrast(
|
21
|
+
$color,
|
22
|
+
$black: get-color.daff-color(palette.$daff-gray, 110),
|
23
|
+
$white: palette.$daff-white
|
24
|
+
) {
|
25
|
+
$light-contrast: cr.daff-contrast-ratio($color, $white);
|
26
|
+
$dark-contrast: cr.daff-contrast-ratio($color, $black);
|
27
|
+
|
28
|
+
@if ($light-contrast > $dark-contrast) {
|
29
|
+
@return $white;
|
30
|
+
}
|
31
|
+
@else {
|
32
|
+
@return $black;
|
33
|
+
}
|
34
|
+
}
|
File without changes
|
@@ -0,0 +1,145 @@
|
|
1
|
+
@use 'sass:map';
|
2
|
+
@use '../contrast/luminance/luminance';
|
3
|
+
|
4
|
+
// @docs
|
5
|
+
// Take a numeric map and sort it.
|
6
|
+
//
|
7
|
+
// https://gist.github.com/Jakobud/a0ac11e80a1de453cd86f0d3fc0a1410
|
8
|
+
// Credit to: https://gist.github.com/iamandrewluca
|
9
|
+
//
|
10
|
+
@function _daff-illuminate-sort($map) {
|
11
|
+
// Transform map to zipped list
|
12
|
+
$keys: ();
|
13
|
+
$values: ();
|
14
|
+
|
15
|
+
@each $key, $val in $map {
|
16
|
+
$keys: append($keys, $key);
|
17
|
+
$values: append($values, $val);
|
18
|
+
}
|
19
|
+
|
20
|
+
$list: zip($keys, $values);
|
21
|
+
|
22
|
+
$sorted-map: ();
|
23
|
+
|
24
|
+
@while length($list) > 0 {
|
25
|
+
// Find smallest pair
|
26
|
+
$smallest-pair: nth($list, 1);
|
27
|
+
|
28
|
+
@each $pair in $list {
|
29
|
+
$value: nth($pair, 2);
|
30
|
+
$smallest-value: nth($smallest-pair, 2);
|
31
|
+
|
32
|
+
@if $value < $smallest-value {
|
33
|
+
$smallest-pair: $pair;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
// Add smallest pair to sorted map
|
38
|
+
$key: nth($smallest-pair, 1);
|
39
|
+
$value: nth($smallest-pair, 2);
|
40
|
+
$sorted-map: map.merge(
|
41
|
+
$sorted-map,
|
42
|
+
(
|
43
|
+
$key: $value
|
44
|
+
)
|
45
|
+
);
|
46
|
+
|
47
|
+
// Remove from list smallest pair
|
48
|
+
$smallest-pair-index: index($list, $smallest-pair);
|
49
|
+
$new-list: ();
|
50
|
+
|
51
|
+
@for $i from 1 through length($list) {
|
52
|
+
@if $i != $smallest-pair-index {
|
53
|
+
$new-list: append($new-list, nth($list, $i), 'space');
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
$list: $new-list;
|
58
|
+
}
|
59
|
+
|
60
|
+
@return $sorted-map;
|
61
|
+
}
|
62
|
+
|
63
|
+
// Given a map of key, luminance pairs, find the key
|
64
|
+
// of the value that is "nth" away from zero.
|
65
|
+
//
|
66
|
+
// @param $map: a map of key, luminance pairs,
|
67
|
+
// @param $nth: nth steps away from zero
|
68
|
+
@function _daff-illuminate-get-key($map, $nth: 1) {
|
69
|
+
//Cap off "nth" to prevent going out-of-bounds.
|
70
|
+
@if ($nth > length($map)) {
|
71
|
+
$nth: length(map);
|
72
|
+
}
|
73
|
+
|
74
|
+
$map: _daff-illuminate-sort($map);
|
75
|
+
@return nth(nth($map, $nth), 1);
|
76
|
+
}
|
77
|
+
|
78
|
+
// Takes a $color and palette and returns the color in
|
79
|
+
// the palette which would "illuminate" against that color.
|
80
|
+
//
|
81
|
+
// @usage
|
82
|
+
// ```
|
83
|
+
// daff-illuminate($palette);
|
84
|
+
// ```
|
85
|
+
//
|
86
|
+
@function daff-illuminate($color, $palette, $nth: 1) {
|
87
|
+
$luminance-map: ();
|
88
|
+
|
89
|
+
//Validate
|
90
|
+
@each $key, $palette-color in $palette {
|
91
|
+
@if (type-of($key) == 'string') {
|
92
|
+
$palette: map.remove($palette, $key);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
//Transform into usable values
|
97
|
+
@each $key, $palette-color in $palette {
|
98
|
+
$luminance-map: map.merge(
|
99
|
+
$luminance-map,
|
100
|
+
(
|
101
|
+
$key: (
|
102
|
+
luminance.daff-luminance($palette-color) - luminance.daff-luminance($color)
|
103
|
+
)
|
104
|
+
)
|
105
|
+
);
|
106
|
+
}
|
107
|
+
|
108
|
+
|
109
|
+
//Calculate which color to get
|
110
|
+
$brighter-colors: ();
|
111
|
+
$darker-colors: ();
|
112
|
+
|
113
|
+
@each $key, $luminance in $luminance-map {
|
114
|
+
@if ($luminance > 0) {
|
115
|
+
$brighter-colors: map.merge(
|
116
|
+
$brighter-colors,
|
117
|
+
(
|
118
|
+
$key: $luminance
|
119
|
+
)
|
120
|
+
);
|
121
|
+
}
|
122
|
+
|
123
|
+
@if ($luminance < 0) {
|
124
|
+
$darker-colors: map.merge(
|
125
|
+
$darker-colors,
|
126
|
+
(
|
127
|
+
$key: abs($luminance)
|
128
|
+
)
|
129
|
+
);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
$key: null;
|
134
|
+
|
135
|
+
@if (luminance.daff-luminance($color) >= 0.5) {
|
136
|
+
//If the color is bright
|
137
|
+
$key: _daff-illuminate-get-key($darker-colors, $nth);
|
138
|
+
}
|
139
|
+
@else {
|
140
|
+
//If the color is dark
|
141
|
+
$key: _daff-illuminate-get-key($brighter-colors, $nth);
|
142
|
+
}
|
143
|
+
|
144
|
+
@return map.get($palette, $key);
|
145
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
@use 'true' as *;
|
2
|
+
|
3
|
+
@include describe('illuminate') {
|
4
|
+
//stylelint-disable
|
5
|
+
@include it('should return a lighter color if the color is dark') {
|
6
|
+
|
7
|
+
}
|
8
|
+
@include it('should return a darker color if the color is light') {
|
9
|
+
|
10
|
+
}
|
11
|
+
@include it('should return the expected color for given scenarios') {
|
12
|
+
|
13
|
+
}
|
14
|
+
//stylelint-enable
|
15
|
+
}
|