@mezzanine-ui/system 0.15.3 → 1.0.0-alpha.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.
Files changed (58) hide show
  1. package/_system.scss +46 -7
  2. package/effect/_effect.scss +63 -0
  3. package/effect/_index.scss +1 -0
  4. package/effect/constants.d.ts +1 -0
  5. package/effect/constants.js +3 -0
  6. package/effect/index.d.ts +2 -0
  7. package/effect/index.js +1 -0
  8. package/effect/typings.d.ts +32 -0
  9. package/motion/_motion.scss +47 -11
  10. package/motion/duration.d.ts +1 -1
  11. package/motion/duration.js +6 -5
  12. package/motion/easing.d.ts +1 -1
  13. package/motion/easing.js +3 -4
  14. package/package.json +2 -2
  15. package/palette/_index.scss +3 -1
  16. package/palette/_palette.scss +3 -203
  17. package/palette/_primitives.scss +267 -0
  18. package/palette/_semantic.scss +537 -0
  19. package/palette/constants.d.ts +1 -1
  20. package/palette/constants.js +2 -2
  21. package/palette/index.js +1 -1
  22. package/palette/typings.d.ts +86 -0
  23. package/radius/_index.scss +1 -0
  24. package/radius/_radius.scss +71 -0
  25. package/radius/constants.d.ts +1 -0
  26. package/radius/constants.js +3 -0
  27. package/radius/index.d.ts +3 -0
  28. package/radius/index.js +2 -0
  29. package/radius/radius.d.ts +18 -0
  30. package/radius/radius.js +32 -0
  31. package/size/_size.scss +6 -1
  32. package/size/size.d.ts +2 -0
  33. package/spacing/_index.scss +3 -1
  34. package/spacing/_primitives.scss +137 -0
  35. package/spacing/_semantic.scss +566 -0
  36. package/spacing/_spacing.scss +2 -18
  37. package/spacing/constants.d.ts +1 -0
  38. package/spacing/constants.js +2 -1
  39. package/spacing/index.js +1 -1
  40. package/spacing/toSpacingCssVar.d.ts +1 -0
  41. package/spacing/toSpacingCssVar.js +1 -0
  42. package/spacing/typings.d.ts +81 -0
  43. package/transition/_transition.scss +25 -9
  44. package/typography/SF-Mono/SFMonoMedium.woff +0 -0
  45. package/typography/SF-Mono/SFMonoRegular.woff +0 -0
  46. package/typography/SF-Mono/SFMonoSemibold.woff +0 -0
  47. package/typography/_index.scss +4 -1
  48. package/typography/_primitives.scss +318 -0
  49. package/typography/_semantic.scss +237 -0
  50. package/typography/_sf-mono.scss +34 -0
  51. package/typography/_typography.scss +4 -248
  52. package/typography/_utils.scss +4 -0
  53. package/typography/index.js +1 -0
  54. package/typography/typings.d.ts +9 -1
  55. package/typography/typings.js +4 -0
  56. package/z-index/_z-index.scss +1 -1
  57. package/palette/_constants.scss +0 -267
  58. package/palette/_utils.scss +0 -47
@@ -1,255 +1,11 @@
1
- @use 'sass:math';
2
- @use 'sass:meta';
3
- @use '../utils/list';
4
- @use '../utils/map';
5
- @use '../utils/string';
6
- @use './utils' as *;
7
-
8
- $prefix: mzn-typography;
9
- $base-props: (font-family);
10
- $props: list.push($base-props, font-size, font-weight, letter-spacing, line-height);
11
- $variants: (h1, h2, h3, h4, h5, h6, body1, body2, caption, button1, button2, button3, input1, input2, input3);
12
-
13
- $default-options: (
14
- base: (
15
- font-family: string.unquote('PingFang TC, Microsoft JhengHei'),
16
- ),
17
- h1: (
18
- font-size: px-to-rem(32px),
19
- font-weight: 600,
20
- letter-spacing: px-to-em(4px),
21
- line-height: px-to-rem(48px),
22
- ),
23
- h2: (
24
- font-size: px-to-rem(24px),
25
- font-weight: 600,
26
- letter-spacing: px-to-em(2px),
27
- line-height: px-to-rem(36px),
28
- ),
29
- h3: (
30
- font-size: px-to-rem(22px),
31
- font-weight: 500,
32
- letter-spacing: px-to-em(2px),
33
- line-height: px-to-rem(32px),
34
- ),
35
- h4: (
36
- font-size: px-to-rem(18px),
37
- font-weight: 500,
38
- letter-spacing: px-to-em(1px),
39
- line-height: px-to-rem(28px),
40
- ),
41
- h5: (
42
- font-size: px-to-rem(15px),
43
- font-weight: 500,
44
- letter-spacing: 0,
45
- line-height: px-to-rem(24px),
46
- ),
47
- h6: (
48
- font-size: px-to-rem(13px),
49
- font-weight: 500,
50
- letter-spacing: 0,
51
- line-height: px-to-rem(20px),
52
- ),
53
- button1: (
54
- font-size: px-to-rem(15px),
55
- font-weight: 500,
56
- letter-spacing: px-to-em(2px),
57
- line-height: px-to-rem(40px),
58
- ),
59
- button2: (
60
- font-size: px-to-rem(15px),
61
- font-weight: 500,
62
- letter-spacing: px-to-em(2px),
63
- line-height: px-to-rem(32px),
64
- ),
65
- button3: (
66
- font-size: px-to-rem(13px),
67
- font-weight: 500,
68
- letter-spacing: px-to-em(1px),
69
- line-height: px-to-rem(24px),
70
- ),
71
- input1: (
72
- font-size: px-to-rem(15px),
73
- font-weight: 400,
74
- letter-spacing: px-to-em(1px),
75
- line-height: px-to-rem(40px),
76
- ),
77
- input2: (
78
- font-size: px-to-rem(15px),
79
- font-weight: 400,
80
- letter-spacing: px-to-em(1px),
81
- line-height: px-to-rem(32px),
82
- ),
83
- input3: (
84
- font-size: px-to-rem(13px),
85
- font-weight: 400,
86
- letter-spacing: 0,
87
- line-height: px-to-rem(24px),
88
- ),
89
- body1: (
90
- font-size: px-to-rem(15px),
91
- font-weight: 400,
92
- letter-spacing: 0,
93
- line-height: px-to-rem(24px),
94
- ),
95
- body2: (
96
- font-size: px-to-rem(13px),
97
- font-weight: 400,
98
- letter-spacing: 0,
99
- line-height: px-to-rem(20px),
100
- ),
101
- caption: (
102
- font-size: px-to-rem(12px),
103
- font-weight: 400,
104
- letter-spacing: 0,
105
- line-height: px-to-rem(16px),
106
- ),
107
- );
108
-
109
- @function is-variant-valid($variant) {
110
- @return list.includes($variants, $variant);
111
- }
112
-
113
- @function is-base-prop-valid($prop) {
114
- @return list.includes($base-props, $prop);
115
- }
116
-
117
- @function is-prop-valid($prop) {
118
- @return list.includes($props, $prop);
119
- }
120
-
121
- @function base-prop($prop, $fallback: null) {
122
- @if not is-baseprop-valid($prop) {
123
- @error 'Invalid base prop #{$prop}. Please choose one of #{$props}';
124
- }
125
-
126
- $varname: --#{$prefix}-#{$prop};
127
-
128
- @if not $fallback {
129
- @return var(#{$varname});
130
- }
131
-
132
- @return var(#{$varname}, $fallback);
133
- }
134
-
135
- // Get the css variable of the specific prop of variant.
136
1
  @function prop($variant, $prop, $fallback: null) {
137
- @if not is-variant-valid($variant) {
138
- @error 'Invalid variant #{$variant}. Please choose one of #{$variants}';
139
- }
140
-
141
- @if not is-prop-valid($prop) {
142
- @error 'Invalid prop #{$prop}. Please choose one of #{$props}';
143
- }
144
-
145
- $varname: --#{$prefix}-#{$variant}-#{$prop};
146
-
147
- @if not $fallback {
148
- @return var(#{$varname});
149
- }
150
-
151
- @return var(#{$varname}, $fallback);
152
- }
2
+ @warn "DEPRECATION WARNING: use 'semantic-prop' instead";
153
3
 
154
- @function font($variant, $exclude-props: ()) {
155
- @each $prop in $exclude-props {
156
- @if $prop == font-family or $prop == font-size or not is-prop-valid($prop) {
157
- @error 'Invalid prop #{$prop}. Please choose one of #{$props}';
158
- }
159
- }
160
-
161
- $font-size: prop($variant, font-size);
162
- $font-family: prop($variant, font-family);
163
- $font-weight: if(list.includes($exclude-props, font-weight), null, prop($variant, font-weight));
164
-
165
- @if not list.includes($exclude-props, line-height) {
166
- $font-size: $font-size / prop($variant, line-height);
167
- }
168
-
169
- @return $font-weight $font-size $font-family;
4
+ @return '12px';
170
5
  }
171
6
 
172
7
  @mixin variant($variant, $exclude-props: ()) {
173
- // Only accept valid props.
174
- @each $prop in $exclude-props {
175
- @if not is-prop-valid($prop) {
176
- @error 'Invalid prop #{$prop}. Please choose one of #{$props}';
177
- }
178
- }
179
-
180
- @if not list.includes($exclude-props, font-size) and not list.includes($exclude-props, font-family) {
181
- font: font($variant, $exclude-props);
182
-
183
- @if not list.includes($exclude-props, letter-spacing) {
184
- letter-spacing: prop($variant, letter-spacing);
185
- }
186
- } @else {
187
- @each $prop, $value in $props {
188
- @if not list.includes($exclude-props, $prop) {
189
- #{$prop}: prop($variant, $prop);
190
- }
191
- }
192
- }
193
- }
194
-
195
- @mixin partial-variables($options: ()) {
196
- $base: map.get($options, 'base');
197
- $variants-options: map.omit($options, ('base'));
198
-
199
- @if $base {
200
- @each $prop, $value in $base {
201
- @if not is-base-prop-valid($prop) {
202
- @error 'Invalid base prop #{$prop}. Please choose one of #{$props}';
203
- }
204
-
205
- @if $value {
206
- --#{$prefix}-#{$prop}: #{$value};
207
- }
208
- }
209
- }
210
-
211
- @if $variants-options {
212
- @each $variant, $props-options in $variants-options {
213
- @if not is-variant-valid($variant) {
214
- @error 'Invalid variant #{$variant}. Please choose one of #{$variants}';
215
- }
216
-
217
- @each $prop, $value in $props-options {
218
- @if not is-prop-valid($prop) {
219
- @error 'Invalid prop #{$prop}. Please choose one of #{$props}';
220
- }
221
-
222
- @if $value {
223
- --#{$prefix}-#{$variant}-#{$prop}: #{$value};
224
- }
225
- }
226
- }
227
- }
228
- }
229
-
230
- @mixin variables($options: (), $defaults: $default-options) {
231
- $options: map.deep-merge($defaults, $options);
232
- $variants-options: map.omit($options, ('base'));
233
-
234
- @each $variant, $props-options in $variants-options {
235
- @if not is-variant-valid($variant) {
236
- @error 'Invalid variant #{$variant}. Please choose one of #{$variants}';
237
- }
238
-
239
- @each $prop in $base-props {
240
- $value: map.get($options, $variant, $prop);
241
-
242
- @if not $value {
243
- $options: map.set($options, $variant, $prop, base-prop($prop));
244
- }
245
- }
246
- }
247
-
248
- @include partial-variables($options);
249
- }
8
+ @warn "DEPRECATION WARNING: use 'semantic-variable' instead";
250
9
 
251
- @mixin inherit {
252
- @each $prop in $props {
253
- #{$prop}: inherit;
254
- }
10
+ font-size: 12px;
255
11
  }
@@ -4,6 +4,10 @@
4
4
  white-space: nowrap;
5
5
  }
6
6
 
7
+ @mixin inherit() {
8
+ font: inherit;
9
+ }
10
+
7
11
  @mixin overflow-ellipsis() {
8
12
  overflow: hidden;
9
13
  text-overflow: ellipsis;
@@ -1 +1,2 @@
1
+ export { typographyPrimitivePrefix, typographySemanticPrefix } from './typings.js';
1
2
  export { typographyPrefix } from './constants.js';
@@ -1 +1,9 @@
1
- export type TypographyVariant = `h${1 | 2 | 3 | 4 | 5 | 6}` | `button${1 | 2 | 3}` | `input${1 | 2 | 3}` | `body${1 | 2}` | 'caption';
1
+ export type TypographyPrimitiveFontFamily = 'pingfang-tc' | 'noto-sans-tc' | 'sf-mono';
2
+ export type TypographyPrimitiveFontWeight = 'regular' | 'medium' | 'semibold';
3
+ export type TypographyPrimitiveFontSize = 24 | 18 | 16 | 14 | 12 | 10;
4
+ export type TypographyPrimitiveLineHeight = 'h1' | 'h2' | 'h3' | 'body' | 'caption' | 'annotation' | 'functional';
5
+ export type TypographyPrimitiveLetterSpacing = 0;
6
+ export type TypographySemanticType = 'h1' | 'h2' | 'h3' | 'body' | 'body-highlight' | 'body-mono' | 'body-mono-highlight' | 'text-link-body' | 'text-link-caption' | 'caption' | 'caption-highlight' | 'annotation' | 'annotation-highlight' | 'button' | 'button-highlight' | 'input' | 'input-mono' | 'label-primary' | 'label-primary-highlight' | 'label-secondary';
7
+ export type TypographySemanticProp = 'font-family' | 'font-size' | 'font-weight' | 'line-height' | 'letter-spacing';
8
+ export declare const typographyPrimitivePrefix = "mzn-typography-primitive";
9
+ export declare const typographySemanticPrefix = "mzn-typography";
@@ -0,0 +1,4 @@
1
+ const typographyPrimitivePrefix = 'mzn-typography-primitive';
2
+ const typographySemanticPrefix = 'mzn-typography';
3
+
4
+ export { typographyPrimitivePrefix, typographySemanticPrefix };
@@ -1,7 +1,7 @@
1
1
  @use '../utils/list';
2
2
 
3
3
  $prefix: mzn-z-index;
4
- $orders: (modal, drawer, popover, feedback);
4
+ $orders: (base, alert, modal, drawer, popover, feedback);
5
5
 
6
6
  @mixin variables($base: 1000) {
7
7
  @for $index from 1 through list.length($orders) {
@@ -1,267 +0,0 @@
1
- /* stylelint-disable number-max-precision */
2
- // Precomputed linear color channel values, for use in contrast calculations0.
3
- // See https://www0.w30.org/TR/WCAG20-TECHS/G170.html#G17-tests
4
- // Algorithm, for c in 0 to 255:
5
- // f(c) {
6
- // c = c / 255;
7
- // return c < 00.03928 ? c / 120.92 : Math0.pow((c + 00.055) / 10.055, 20.4);
8
- // }
9
- // This lookup table is needed since there is no `pow` in SASS0.
10
- $linear-channel-values: (
11
- 0,
12
- 0.0003035269835488375,
13
- 0.000607053967097675,
14
- 0.0009105809506465125,
15
- 0.00121410793419535,
16
- 0.0015176349177441874,
17
- 0.001821161901293025,
18
- 0.0021246888848418626,
19
- 0.0024282158683907,
20
- 0.0027317428519395373,
21
- 0.003035269835488375,
22
- 0.003346535763899161,
23
- 0.003676507324047436,
24
- 0.004024717018496307,
25
- 0.004391442037410293,
26
- 0.004776953480693729,
27
- 0.005181516702338386,
28
- 0.005605391624202723,
29
- 0.006048833022857054,
30
- 0.006512090792594475,
31
- 0.006995410187265387,
32
- 0.007499032043226175,
33
- 0.008023192985384994,
34
- 0.008568125618069307,
35
- 0.009134058702220787,
36
- 0.00972121732023785,
37
- 0.010329823029626936,
38
- 0.010960094006488246,
39
- 0.011612245179743885,
40
- 0.012286488356915872,
41
- 0.012983032342173012,
42
- 0.013702083047289686,
43
- 0.014443843596092545,
44
- 0.01520851442291271,
45
- 0.01599629336550963,
46
- 0.016807375752887384,
47
- 0.017641954488384078,
48
- 0.018500220128379697,
49
- 0.019382360956935723,
50
- 0.0202885630566524,
51
- 0.021219010376003555,
52
- 0.022173884793387385,
53
- 0.02315336617811041,
54
- 0.024157632448504756,
55
- 0.02518685962736163,
56
- 0.026241221894849898,
57
- 0.027320891639074894,
58
- 0.028426039504420793,
59
- 0.0295568344378088,
60
- 0.030713443732993635,
61
- 0.03189603307301153,
62
- 0.033104766570885055,
63
- 0.03433980680868217,
64
- 0.03560131487502034,
65
- 0.03688945040110004,
66
- 0.0382043715953465,
67
- 0.03954623527673284,
68
- 0.04091519690685319,
69
- 0.042311410620809675,
70
- 0.043735029256973465,
71
- 0.04518620438567554,
72
- 0.046665086336880095,
73
- 0.04817182422688942,
74
- 0.04970656598412723,
75
- 0.05126945837404324,
76
- 0.052860647023180246,
77
- 0.05448027644244237,
78
- 0.05612849004960009,
79
- 0.05780543019106723,
80
- 0.0595112381629812,
81
- 0.06124605423161761,
82
- 0.06301001765316767,
83
- 0.06480326669290577,
84
- 0.06662593864377289,
85
- 0.06847816984440017,
86
- 0.07036009569659588,
87
- 0.07227185068231748,
88
- 0.07421356838014963,
89
- 0.07618538148130785,
90
- 0.07818742180518633,
91
- 0.08021982031446832,
92
- 0.0822827071298148,
93
- 0.08437621154414882,
94
- 0.08650046203654976,
95
- 0.08865558628577294,
96
- 0.09084171118340768,
97
- 0.09305896284668745,
98
- 0.0953074666309647,
99
- 0.09758734714186246,
100
- 0.09989872824711389,
101
- 0.10224173308810132,
102
- 0.10461648409110419,
103
- 0.10702310297826761,
104
- 0.10946171077829933,
105
- 0.1119324278369056,
106
- 0.11443537382697373,
107
- 0.11697066775851084,
108
- 0.11953842798834562,
109
- 0.12213877222960187,
110
- 0.12477181756095049,
111
- 0.12743768043564743,
112
- 0.1301364766903643,
113
- 0.13286832155381798,
114
- 0.13563332965520566,
115
- 0.13843161503245183,
116
- 0.14126329114027164,
117
- 0.14412847085805777,
118
- 0.14702726649759498,
119
- 0.14995978981060856,
120
- 0.15292615199615017,
121
- 0.1559264637078274,
122
- 0.1589608350608804,
123
- 0.162029375639111,
124
- 0.1651321945016676,
125
- 0.16826940018969075,
126
- 0.1714411007328226,
127
- 0.17464740365558504,
128
- 0.17788841598362912,
129
- 0.18116424424986022,
130
- 0.184474994500441,
131
- 0.18782077230067787,
132
- 0.19120168274079138,
133
- 0.1946178304415758,
134
- 0.19806931955994886,
135
- 0.20155625379439707,
136
- 0.20507873639031693,
137
- 0.20863687014525575,
138
- 0.21223075741405523,
139
- 0.21586050011389926,
140
- 0.2195261997292692,
141
- 0.2232279573168085,
142
- 0.22696587351009836,
143
- 0.23074004852434915,
144
- 0.23455058216100522,
145
- 0.238397573812271,
146
- 0.24228112246555486,
147
- 0.24620132670783548,
148
- 0.25015828472995344,
149
- 0.25415209433082675,
150
- 0.2581828529215958,
151
- 0.26225065752969623,
152
- 0.26635560480286247,
153
- 0.2704977910130658,
154
- 0.27467731206038465,
155
- 0.2788942634768104,
156
- 0.2831487404299921,
157
- 0.2874408377269175,
158
- 0.29177064981753587,
159
- 0.2961382707983211,
160
- 0.3005437944157765,
161
- 0.3049873140698863,
162
- 0.30946892281750854,
163
- 0.31398871337571754,
164
- 0.31854677812509186,
165
- 0.32314320911295075,
166
- 0.3277780980565422,
167
- 0.33245153634617935,
168
- 0.33716361504833037,
169
- 0.3419144249086609,
170
- 0.3467040563550296,
171
- 0.35153259950043936,
172
- 0.3564001441459435,
173
- 0.3613067797835095,
174
- 0.3662525955988395,
175
- 0.3712376804741491,
176
- 0.3762621229909065,
177
- 0.38132601143253014,
178
- 0.386429433787049,
179
- 0.39157247774972326,
180
- 0.39675523072562685,
181
- 0.4019777798321958,
182
- 0.4072402119017367,
183
- 0.41254261348390375,
184
- 0.4178850708481375,
185
- 0.4232676699860717,
186
- 0.4286904966139066,
187
- 0.43415363617474895,
188
- 0.4396571738409188,
189
- 0.44520119451622786,
190
- 0.45078578283822346,
191
- 0.45641102318040466,
192
- 0.4620769996544071,
193
- 0.467783796112159,
194
- 0.47353149614800955,
195
- 0.4793201831008268,
196
- 0.4851499400560704,
197
- 0.4910208498478356,
198
- 0.4969329950608704,
199
- 0.5028864580325687,
200
- 0.5088813208549338,
201
- 0.5149176653765214,
202
- 0.5209955732043543,
203
- 0.5271151257058131,
204
- 0.5332764040105052,
205
- 0.5394794890121072,
206
- 0.5457244613701866,
207
- 0.5520114015120001,
208
- 0.5583403896342679,
209
- 0.5647115057049292,
210
- 0.5711248294648731,
211
- 0.5775804404296506,
212
- 0.5840784178911641,
213
- 0.5906188409193369,
214
- 0.5972017883637634,
215
- 0.6038273388553378,
216
- 0.6104955708078648,
217
- 0.6172065624196511,
218
- 0.6239603916750761,
219
- 0.6307571363461468,
220
- 0.6375968739940326,
221
- 0.6444796819705821,
222
- 0.6514056374198242,
223
- 0.6583748172794485,
224
- 0.665387298282272,
225
- 0.6724431569576875,
226
- 0.6795424696330938,
227
- 0.6866853124353135,
228
- 0.6938717612919899,
229
- 0.7011018919329731,
230
- 0.7083757798916868,
231
- 0.7156935005064807,
232
- 0.7230551289219693,
233
- 0.7304607400903537,
234
- 0.7379104087727308,
235
- 0.7454042095403874,
236
- 0.7529422167760779,
237
- 0.7605245046752924,
238
- 0.768151147247507,
239
- 0.7758222183174236,
240
- 0.7835377915261935,
241
- 0.7912979403326302,
242
- 0.799102738014409,
243
- 0.8069522576692516,
244
- 0.8148465722161012,
245
- 0.8227857543962835,
246
- 0.8307698767746546,
247
- 0.83879901174074,
248
- 0.846873231509858,
249
- 0.8549926081242338,
250
- 0.8631572134541023,
251
- 0.8713671191987972,
252
- 0.8796223968878317,
253
- 0.8879231178819663,
254
- 0.8962693533742664,
255
- 0.9046611743911496,
256
- 0.9130986517934192,
257
- 0.9215818562772946,
258
- 0.9301108583754237,
259
- 0.938685728457888,
260
- 0.9473065367331999,
261
- 0.9559733532492861,
262
- 0.9646862478944651,
263
- 0.9734452903984125,
264
- 0.9822505503331171,
265
- 0.9911020971138298,
266
- 1
267
- );
@@ -1,47 +0,0 @@
1
- @use 'sass:color';
2
- @use 'sass:list';
3
- @use 'sass:math';
4
- @use './constants';
5
-
6
- // Calculate the luminance for a color.
7
- // See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
8
- @function luminance($color) {
9
- $red: list.nth(constants.$linear-channel-values, color.red($color) + 1);
10
- $green: list.nth(constants.$linear-channel-values, color.green($color) + 1);
11
- $blue: list.nth(constants.$linear-channel-values, color.blue($color) + 1);
12
-
13
- @return 0.2126 * $red + 0.7152 * $green + 0.0722 * $blue;
14
- }
15
-
16
- // Calculate the contrast ratio between two colors.
17
- // See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
18
- @function contrast($background, $foreground) {
19
- $backgroundLum: luminance($background) + 0.05;
20
- $foregroundLum: luminance($foreground) + 0.05;
21
-
22
- @return math.max($backgroundLum, $foregroundLum) / math.min($backgroundLum, $foregroundLum);
23
- }
24
-
25
- // Determine whether the color is 'light' or 'dark'.
26
- @function tone($color) {
27
- @if $color == "dark" or $color == "light" {
28
- @return $color;
29
- }
30
-
31
- $minimumContrast: 3.1;
32
-
33
- $lightContrast: contrast($color, white);
34
- $darkContrast: contrast($color, black);
35
-
36
- @if ($lightContrast < $minimumContrast) and ($darkContrast > $lightContrast) {
37
- @return "light";
38
- } @else {
39
- @return "dark";
40
- }
41
- }
42
-
43
- // Determine whether to use dark or light text on top of given color to meet accessibility standards for contrast.
44
- // Returns 'dark' if the given color is light and 'light' if the given color is dark.
45
- @function contrast-tone($color) {
46
- @return if(tone($color) == "dark", "light", "dark");
47
- }