@daffodil/design 0.90.0 → 0.91.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/accordion/index.d.ts +8 -5
- package/article/README.md +1 -1
- package/article/index.d.ts +20 -0
- package/article/src/article-theme.scss +10 -0
- package/button/index.d.ts +4 -4
- package/button/src/button/button-base.scss +3 -3
- package/button/src/button/raised/raised-theme.scss +2 -2
- package/card/README.md +0 -8
- package/card/index.d.ts +7 -41
- package/card/src/card-base-theme.scss +2 -5
- package/card/src/card-base.scss +2 -2
- package/checkbox/README.md +0 -0
- package/checkbox/index.d.ts +177 -0
- package/fesm2022/daffodil-design-accordion.mjs +23 -14
- package/fesm2022/daffodil-design-accordion.mjs.map +1 -1
- package/fesm2022/daffodil-design-article.mjs +129 -5
- package/fesm2022/daffodil-design-article.mjs.map +1 -1
- package/fesm2022/daffodil-design-button.mjs +24 -20
- package/fesm2022/daffodil-design-button.mjs.map +1 -1
- package/fesm2022/daffodil-design-card.mjs +16 -63
- package/fesm2022/daffodil-design-card.mjs.map +1 -1
- package/fesm2022/daffodil-design-checkbox.mjs +317 -0
- package/fesm2022/daffodil-design-checkbox.mjs.map +1 -0
- package/fesm2022/daffodil-design-form-field.mjs +35 -65
- package/fesm2022/daffodil-design-form-field.mjs.map +1 -1
- package/fesm2022/daffodil-design-form.mjs +62 -0
- package/fesm2022/daffodil-design-form.mjs.map +1 -0
- package/fesm2022/daffodil-design-image.mjs +12 -4
- package/fesm2022/daffodil-design-image.mjs.map +1 -1
- package/fesm2022/daffodil-design-modal.mjs +55 -56
- package/fesm2022/daffodil-design-modal.mjs.map +1 -1
- package/fesm2022/daffodil-design-notification.mjs +14 -50
- package/fesm2022/daffodil-design-notification.mjs.map +1 -1
- package/fesm2022/daffodil-design-paginator.mjs +6 -11
- package/fesm2022/daffodil-design-paginator.mjs.map +1 -1
- package/fesm2022/daffodil-design-quantity-field.mjs +3 -5
- package/fesm2022/daffodil-design-quantity-field.mjs.map +1 -1
- package/fesm2022/daffodil-design-radio.mjs +13 -42
- package/fesm2022/daffodil-design-radio.mjs.map +1 -1
- package/fesm2022/daffodil-design-sidebar.mjs +6 -36
- package/fesm2022/daffodil-design-sidebar.mjs.map +1 -1
- package/fesm2022/daffodil-design-switch.mjs +48 -105
- package/fesm2022/daffodil-design-switch.mjs.map +1 -1
- package/fesm2022/daffodil-design-tabs.mjs +22 -14
- package/fesm2022/daffodil-design-tabs.mjs.map +1 -1
- package/fesm2022/daffodil-design-toast.mjs +56 -55
- package/fesm2022/daffodil-design-toast.mjs.map +1 -1
- package/fesm2022/daffodil-design-tree.mjs +4 -13
- package/fesm2022/daffodil-design-tree.mjs.map +1 -1
- package/fesm2022/daffodil-design.mjs +250 -461
- package/fesm2022/daffodil-design.mjs.map +1 -1
- package/form/README.md +75 -0
- package/form/index.d.ts +27 -0
- package/form-field/README.md +49 -39
- package/form-field/index.d.ts +56 -36
- package/image/README.md +27 -19
- package/image/index.d.ts +6 -1
- package/index.d.ts +180 -259
- package/input/README.md +32 -12
- package/modal/README.md +106 -16
- package/modal/index.d.ts +50 -21
- package/native-select/README.md +52 -15
- package/notification/index.d.ts +7 -38
- package/package.json +1 -1
- package/paginator/index.d.ts +1 -7
- package/radio/index.d.ts +0 -16
- package/scss/layout/_breakpoint.scss +1 -1
- package/scss/theme.scss +2 -4
- package/scss/theming/_color-palettes.scss +21 -7
- package/scss/theming/_configure-theme.scss +11 -10
- package/scss/theming/_daff-theme.scss +5 -14
- package/scss/theming/_get-base-color.scss +2 -2
- package/scss/theming/_get-palette.scss +2 -2
- package/scss/theming/_get-theme-mode.scss +3 -3
- package/scss/theming/_index.scss +2 -1
- package/scss/theming/contrast/max-contrast/max-contrast.scss +3 -3
- package/scss/theming/contrast/text-contrast/text-contrast.scss +22 -16
- package/scss/theming/contrast/text-contrast/text-contrast.spec.scss +57 -0
- package/scss/theming/create-theme/_create-theme.scss +330 -0
- package/scss/theming/create-theme/_create-theme.spec.scss +122 -0
- package/scss/theming/create-theme/_index.scss +1 -0
- package/scss/theming/get-font-colors/_get-font-colors.scss +36 -0
- package/scss/theming/get-font-colors/_get-font-colors.spec.scss +72 -0
- package/scss/typography/mixins/_font-weight.scss +8 -14
- package/select/README.md +107 -4
- package/sidebar/README.md +0 -8
- package/sidebar/index.d.ts +3 -15
- package/switch/README.md +19 -27
- package/switch/index.d.ts +18 -48
- package/switch/src/switch-theme.scss +26 -18
- package/tabs/index.d.ts +7 -4
- package/tag/src/tag-theme.scss +11 -9
- package/textarea/README.md +35 -5
- package/tree/index.d.ts +0 -6
- package/tree/src/tree-theme.scss +0 -4
- package/accordion/examples/index.d.ts +0 -20
- package/article/examples/index.d.ts +0 -50
- package/breadcrumb/examples/index.d.ts +0 -10
- package/button/examples/index.d.ts +0 -67
- package/callout/examples/index.d.ts +0 -41
- package/card/examples/index.d.ts +0 -62
- package/card/src/card/raised/raised-theme.scss +0 -28
- package/checkbox/examples/index.d.ts +0 -32
- package/container/examples/index.d.ts +0 -16
- package/fesm2022/daffodil-design-accordion-examples.mjs +0 -50
- package/fesm2022/daffodil-design-accordion-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-article-examples.mjs +0 -134
- package/fesm2022/daffodil-design-article-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-breadcrumb-examples.mjs +0 -46
- package/fesm2022/daffodil-design-breadcrumb-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-button-examples.mjs +0 -178
- package/fesm2022/daffodil-design-button-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-callout-examples.mjs +0 -116
- package/fesm2022/daffodil-design-callout-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-card-examples.mjs +0 -168
- package/fesm2022/daffodil-design-card-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-checkbox-examples.mjs +0 -76
- package/fesm2022/daffodil-design-checkbox-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-container-examples.mjs +0 -41
- package/fesm2022/daffodil-design-container-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-form-field-examples.mjs +0 -96
- package/fesm2022/daffodil-design-form-field-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-hero-examples.mjs +0 -121
- package/fesm2022/daffodil-design-hero-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-image-examples.mjs +0 -58
- package/fesm2022/daffodil-design-image-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-input-examples.mjs +0 -108
- package/fesm2022/daffodil-design-input-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-list-examples.mjs +0 -77
- package/fesm2022/daffodil-design-list-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-loading-icon-examples.mjs +0 -44
- package/fesm2022/daffodil-design-loading-icon-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-media-gallery-examples.mjs +0 -104
- package/fesm2022/daffodil-design-media-gallery-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-menu-examples.mjs +0 -50
- package/fesm2022/daffodil-design-menu-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-modal-examples.mjs +0 -51
- package/fesm2022/daffodil-design-modal-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-native-select-examples.mjs +0 -71
- package/fesm2022/daffodil-design-native-select-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-navbar-examples.mjs +0 -88
- package/fesm2022/daffodil-design-navbar-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-notification-examples.mjs +0 -102
- package/fesm2022/daffodil-design-notification-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-paginator-examples.mjs +0 -59
- package/fesm2022/daffodil-design-paginator-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-progress-bar-examples.mjs +0 -57
- package/fesm2022/daffodil-design-progress-bar-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-quantity-field-examples.mjs +0 -85
- package/fesm2022/daffodil-design-quantity-field-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-radio-examples.mjs +0 -34
- package/fesm2022/daffodil-design-radio-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-select-examples.mjs +0 -117
- package/fesm2022/daffodil-design-select-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-sidebar-examples.mjs +0 -109
- package/fesm2022/daffodil-design-sidebar-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-sticky-examples.mjs +0 -25
- package/fesm2022/daffodil-design-sticky-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-switch-examples.mjs +0 -110
- package/fesm2022/daffodil-design-switch-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-tabs-examples.mjs +0 -115
- package/fesm2022/daffodil-design-tabs-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-tag-examples.mjs +0 -125
- package/fesm2022/daffodil-design-tag-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-text-snippet-examples.mjs +0 -25
- package/fesm2022/daffodil-design-text-snippet-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-textarea-examples.mjs +0 -66
- package/fesm2022/daffodil-design-textarea-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-toast-examples.mjs +0 -147
- package/fesm2022/daffodil-design-toast-examples.mjs.map +0 -1
- package/fesm2022/daffodil-design-tree-examples.mjs +0 -104
- package/fesm2022/daffodil-design-tree-examples.mjs.map +0 -1
- package/form-field/examples/index.d.ts +0 -18
- package/hero/examples/index.d.ts +0 -45
- package/image/examples/index.d.ts +0 -10
- package/input/examples/index.d.ts +0 -10
- package/list/examples/index.d.ts +0 -29
- package/loading-icon/examples/index.d.ts +0 -16
- package/media-gallery/examples/index.d.ts +0 -38
- package/menu/examples/index.d.ts +0 -20
- package/modal/examples/index.d.ts +0 -15
- package/native-select/examples/index.d.ts +0 -10
- package/navbar/examples/index.d.ts +0 -31
- package/notification/examples/index.d.ts +0 -12
- package/paginator/examples/index.d.ts +0 -26
- package/progress-bar/examples/index.d.ts +0 -10
- package/quantity-field/examples/index.d.ts +0 -30
- package/radio/examples/index.d.ts +0 -13
- package/select/examples/index.d.ts +0 -28
- package/sidebar/examples/index.d.ts +0 -10
- package/sticky/examples/index.d.ts +0 -10
- package/switch/examples/index.d.ts +0 -46
- package/tabs/examples/index.d.ts +0 -12
- package/tag/examples/index.d.ts +0 -50
- package/text-snippet/examples/index.d.ts +0 -10
- package/textarea/examples/index.d.ts +0 -10
- package/toast/examples/index.d.ts +0 -56
- package/tree/examples/index.d.ts +0 -18
- /package/{form-field → form}/src/error-message/error-message-theme.scss +0 -0
- /package/{form-field → form}/src/hint/hint-theme.scss +0 -0
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
////
|
|
2
|
+
/// @group color-palettes
|
|
3
|
+
////
|
|
4
|
+
|
|
1
5
|
// Base colors
|
|
2
|
-
|
|
6
|
+
/// @access private
|
|
7
|
+
$white: #ffffff;
|
|
8
|
+
/// @access private
|
|
9
|
+
$black: #070707;
|
|
10
|
+
// need to deprecate
|
|
11
|
+
/// @access private
|
|
3
12
|
$error: #dd0000;
|
|
4
13
|
|
|
5
|
-
|
|
6
|
-
// 50 apart passes AA level for any size text (except for 10/60)
|
|
7
|
-
|
|
14
|
+
/// @access private
|
|
8
15
|
$daff-blue: (
|
|
9
16
|
10: #ebf1ff,
|
|
10
17
|
20: #c4d8ff,
|
|
@@ -18,8 +25,10 @@ $daff-blue: (
|
|
|
18
25
|
100: #000033
|
|
19
26
|
);
|
|
20
27
|
|
|
28
|
+
/// @access private
|
|
21
29
|
$daff-primary: $daff-blue;
|
|
22
30
|
|
|
31
|
+
/// @access private
|
|
23
32
|
$daff-purple: (
|
|
24
33
|
10: #ebebff,
|
|
25
34
|
20: #d4d3ff,
|
|
@@ -33,8 +42,10 @@ $daff-purple: (
|
|
|
33
42
|
100: #110033
|
|
34
43
|
);
|
|
35
44
|
|
|
45
|
+
/// @access private
|
|
36
46
|
$daff-accent: $daff-purple;
|
|
37
47
|
|
|
48
|
+
/// @access private
|
|
38
49
|
$daff-turquoise: (
|
|
39
50
|
10: #d6fcea,
|
|
40
51
|
20: #9dfbd3,
|
|
@@ -48,6 +59,7 @@ $daff-turquoise: (
|
|
|
48
59
|
100: #082218
|
|
49
60
|
);
|
|
50
61
|
|
|
62
|
+
/// @access private
|
|
51
63
|
$daff-yellow: (
|
|
52
64
|
10: #fffaeb,
|
|
53
65
|
20: #fff1c2,
|
|
@@ -61,6 +73,7 @@ $daff-yellow: (
|
|
|
61
73
|
100: #7a5e00
|
|
62
74
|
);
|
|
63
75
|
|
|
76
|
+
/// @access private
|
|
64
77
|
$daff-red: (
|
|
65
78
|
10: #fcf1f1,
|
|
66
79
|
20: #fae0e0,
|
|
@@ -74,6 +87,7 @@ $daff-red: (
|
|
|
74
87
|
100: #3f0809,
|
|
75
88
|
);
|
|
76
89
|
|
|
90
|
+
/// @access private
|
|
77
91
|
$daff-bronze: (
|
|
78
92
|
10: #fcf2eb,
|
|
79
93
|
20: #f7dac6,
|
|
@@ -87,6 +101,7 @@ $daff-bronze: (
|
|
|
87
101
|
100: #1a0f00,
|
|
88
102
|
);
|
|
89
103
|
|
|
104
|
+
/// @access private
|
|
90
105
|
$daff-green: (
|
|
91
106
|
10: #d1fbd6,
|
|
92
107
|
20: #97f8a5,
|
|
@@ -100,8 +115,8 @@ $daff-green: (
|
|
|
100
115
|
100: #07230d,
|
|
101
116
|
);
|
|
102
117
|
|
|
118
|
+
/// @access private
|
|
103
119
|
$daff-neutral: (
|
|
104
|
-
0: #ffffff,
|
|
105
120
|
10: #fafafa,
|
|
106
121
|
20: #e8e8e8,
|
|
107
122
|
30: #d3d3d3,
|
|
@@ -111,6 +126,5 @@ $daff-neutral: (
|
|
|
111
126
|
70: #5e5e5e,
|
|
112
127
|
80: #474747,
|
|
113
128
|
90: #323232,
|
|
114
|
-
100: #1a1a1a
|
|
115
|
-
110: #070707
|
|
129
|
+
100: #1a1a1a
|
|
116
130
|
);
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
|
|
6
6
|
$daff-light-theme: (
|
|
7
7
|
'mode': 'light',
|
|
8
|
-
'font-color':
|
|
9
|
-
'base':
|
|
10
|
-
'base-contrast':
|
|
11
|
-
'white':
|
|
12
|
-
'black':
|
|
8
|
+
'font-color': palette.$black,
|
|
9
|
+
'base': palette.$white,
|
|
10
|
+
'base-contrast': palette.$black,
|
|
11
|
+
'white': palette.$white,
|
|
12
|
+
'black': palette.$black,
|
|
13
13
|
'neutral': configure-palette.daff-configure-palette(palette.$daff-neutral, 60),
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
$daff-dark-theme: (
|
|
17
17
|
'mode': 'dark',
|
|
18
|
-
'font-color':
|
|
19
|
-
'base':
|
|
20
|
-
'base-contrast':
|
|
21
|
-
'white':
|
|
22
|
-
'black':
|
|
18
|
+
'font-color': palette.$white,
|
|
19
|
+
'base': palette.$black,
|
|
20
|
+
'base-contrast': palette.$white,
|
|
21
|
+
'white': palette.$white,
|
|
22
|
+
'black': palette.$black,
|
|
23
23
|
'neutral': configure-palette.daff-configure-palette(palette.$daff-neutral, 50),
|
|
24
24
|
);
|
|
25
25
|
|
|
@@ -28,6 +28,7 @@ $supported-theme-modes: (
|
|
|
28
28
|
'dark': $daff-dark-theme
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
+
/// @deprecated Use `daff-create-theme` instead.
|
|
31
32
|
/// Create a theme object given some initial settings.
|
|
32
33
|
///
|
|
33
34
|
/// Sets light and dark mode defaults for `$info`, `$warn`, `$critical`, and `$success`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@use 'configure-palette';
|
|
2
|
-
@use '
|
|
2
|
+
@use './create-theme/create-theme';
|
|
3
3
|
@use 'color-palettes' as palette;
|
|
4
4
|
@use '../core';
|
|
5
5
|
|
|
@@ -7,23 +7,14 @@ $primary: configure-palette.daff-configure-palette(palette.$daff-blue, 60);
|
|
|
7
7
|
$secondary: configure-palette.daff-configure-palette(palette.$daff-purple, 60);
|
|
8
8
|
$tertiary: configure-palette.daff-configure-palette(palette.$daff-turquoise, 60);
|
|
9
9
|
|
|
10
|
-
$theme:
|
|
11
|
-
$primary,
|
|
12
|
-
$secondary,
|
|
13
|
-
$tertiary,
|
|
14
|
-
'light'
|
|
10
|
+
$theme: create-theme.daff-create-theme(
|
|
11
|
+
('primary': $primary, 'secondary': $secondary, 'tertiary': $tertiary, 'mode': 'light')
|
|
15
12
|
);
|
|
16
13
|
|
|
17
14
|
$primary-dark: configure-palette.daff-configure-palette(palette.$daff-blue, 50);
|
|
18
15
|
$secondary-dark: configure-palette.daff-configure-palette(palette.$daff-purple, 50);
|
|
19
16
|
$tertiary-dark: configure-palette.daff-configure-palette(palette.$daff-turquoise, 50);
|
|
20
17
|
|
|
21
|
-
$theme-dark:
|
|
22
|
-
$primary-dark,
|
|
23
|
-
$secondary-dark,
|
|
24
|
-
$tertiary-dark,
|
|
25
|
-
'dark'
|
|
18
|
+
$theme-dark: create-theme.daff-create-theme(
|
|
19
|
+
('primary': $primary-dark, 'secondary': $secondary-dark, 'tertiary': $tertiary-dark, 'mode': 'dark')
|
|
26
20
|
);
|
|
27
|
-
|
|
28
|
-
$black: core.daff-map-get($theme, 'core', 'black');
|
|
29
|
-
$white: core.daff-map-get($theme, 'core', 'white');
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
/// Retrieves a core base color from a configured theme.
|
|
4
4
|
///
|
|
5
5
|
/// If you are not using Daffodil's default theme, a theme **must** be
|
|
6
|
-
/// created with `daff-
|
|
6
|
+
/// created with `daff-create-theme` before this function can be used.
|
|
7
7
|
/// See the [customize your own theme](daff.io/docs/design/theming/customize-your-own-theme)
|
|
8
8
|
/// guide for more information.
|
|
9
9
|
///
|
|
10
10
|
/// @group Theming
|
|
11
11
|
///
|
|
12
|
-
/// @param {Map} $theme — A theme map created with the `daff-
|
|
12
|
+
/// @param {Map} $theme — A theme map created with the `daff-create-theme` function.
|
|
13
13
|
/// @param {String} $color — The core color to retrieve. Supported colors: `white`, `black`, `base`, or `base-contrast`.
|
|
14
14
|
///
|
|
15
15
|
/// @throws Will throw an error if `$color` is not supported as part of Daffodil's core colors.
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
/// Retrieves a specific color palette from a configured theme.
|
|
4
4
|
///
|
|
5
5
|
/// If you are not using Daffodil's default theme, a theme **must** be
|
|
6
|
-
/// created with `daff-
|
|
6
|
+
/// created with `daff-create-theme` before this function can be used.
|
|
7
7
|
/// See the [customize your own theme](daff.io/docs/design/theming/customize-your-own-theme)
|
|
8
8
|
/// guide for more information.
|
|
9
9
|
///
|
|
10
10
|
/// @group Theming
|
|
11
11
|
///
|
|
12
|
-
/// @param {Map} $theme — A theme map created with with `daff-
|
|
12
|
+
/// @param {Map} $theme — A theme map created with with `daff-create-theme` function.
|
|
13
13
|
/// @param {Map} $palette — The palette being retrieved.
|
|
14
14
|
/// Supported values: `primary`, `secondary`, `tertiary`, `informational`, `warn`, `critical`, `success`, or `neutral`.
|
|
15
15
|
///
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
@use '../core/map/map-get/map-get';
|
|
2
2
|
|
|
3
|
-
/// Retrieves the mode (`light` or `dark`) from a configured theme created with `daff-
|
|
3
|
+
/// Retrieves the mode (`light` or `dark`) from a configured theme created with `daff-create-theme`.
|
|
4
4
|
/// It should only be used if your app supports **both light and dark themes**.
|
|
5
5
|
///
|
|
6
6
|
/// If you are not using Daffodil's default theme, a theme **must** be
|
|
7
|
-
/// created with `daff-
|
|
7
|
+
/// created with `daff-create-theme` before this function can be used.
|
|
8
8
|
///
|
|
9
9
|
/// See the [customize your own theme](daff.io/docs/design/theming/customize-your-own-theme)
|
|
10
10
|
/// guide for more information.
|
|
11
11
|
///
|
|
12
12
|
/// @group Theming
|
|
13
13
|
///
|
|
14
|
-
/// @param {Map} $theme — A theme map created with the `daff-
|
|
14
|
+
/// @param {Map} $theme — A theme map created with the `daff-create-theme` function.
|
|
15
15
|
///
|
|
16
16
|
/// @example scss
|
|
17
17
|
/// @use '@daffodil/design/scss/theme' as daff-theme;
|
package/scss/theming/_index.scss
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
@forward 'contrast';
|
|
4
4
|
@forward 'illuminate/illuminate';
|
|
5
5
|
@forward 'configure-palette';
|
|
6
|
-
@forward '
|
|
6
|
+
@forward 'create-theme/create-theme';
|
|
7
7
|
@forward 'light-dark';
|
|
8
8
|
@forward 'daff-theme';
|
|
9
9
|
@forward 'get-palette';
|
|
10
10
|
@forward 'get-base-color';
|
|
11
11
|
@forward 'get-theme-mode';
|
|
12
|
+
@forward 'configure-theme' show daff-configure-theme;
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
/// @return {Color} The color with the highest contrast ratio between the reference color and the color list
|
|
13
13
|
///
|
|
14
14
|
/// @example scss
|
|
15
|
-
/// .
|
|
16
|
-
/// background: daff-color($
|
|
17
|
-
/// color: daff-max-contrast(daff-color($
|
|
15
|
+
/// .card {
|
|
16
|
+
/// background: daff-color($primary, 30);
|
|
17
|
+
/// border-color: daff-max-contrast(daff-color($primary, 30), (daff-color($secondary, 70), daff-color($accent, 50)));
|
|
18
18
|
/// }
|
|
19
19
|
///
|
|
20
20
|
@function daff-max-contrast(
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
@use '
|
|
1
|
+
@use 'sass:list';
|
|
2
|
+
@use '../max-contrast/max-contrast' as mc;
|
|
3
|
+
@use '../../get-font-colors/get-font-colors' as fc;
|
|
2
4
|
@use '../../get-color';
|
|
3
5
|
@use '../../color-palettes' as palette;
|
|
4
6
|
|
|
5
7
|
/// Determines the color to use against the initial given color.
|
|
6
8
|
/// It returns the one that provides the higher contrast, ensuring better readability.
|
|
7
|
-
/// By default, the function tests against `$black` (#000`, and `$white` (#fff).
|
|
8
9
|
///
|
|
9
10
|
/// @group Theming
|
|
10
11
|
///
|
|
11
|
-
/// @param {Color} $color — The color to test against.
|
|
12
|
+
/// @param {Color} $reference-color — The color to test against.
|
|
13
|
+
/// @param {Map} $theme — Optional. The theme map to pull `$black` and `$white` from.
|
|
14
|
+
/// @return {Color} Either `$black` or `$white`, whichever has the highest contrast ratio against the reference color.
|
|
12
15
|
///
|
|
13
16
|
/// For an interesting read, see more about the topic:
|
|
14
17
|
/// https:///robots.thoughtbot.com/closer-look-color-lightness
|
|
@@ -17,22 +20,25 @@
|
|
|
17
20
|
/// [Sergio Gomes](https://sgom.es/posts/2016-12-21-using-sass-to-automatically-pick-text-colors/).
|
|
18
21
|
///
|
|
19
22
|
/// @example scss
|
|
20
|
-
/// .
|
|
21
|
-
///
|
|
23
|
+
/// .body {
|
|
24
|
+
/// background: daff-color($primary, 80);
|
|
25
|
+
/// color: daff-text-contrast(daff-color($primary, 80), $theme);
|
|
26
|
+
/// }
|
|
27
|
+
/// @example scss
|
|
28
|
+
/// .body {
|
|
29
|
+
/// background: daff-color($primary, 80);
|
|
30
|
+
/// color: daff-text-contrast(daff-color($primary, 80));
|
|
22
31
|
/// }
|
|
23
32
|
///
|
|
24
33
|
@function daff-text-contrast(
|
|
25
|
-
$color,
|
|
26
|
-
$
|
|
27
|
-
$white: palette.$daff-white
|
|
34
|
+
$reference-color,
|
|
35
|
+
$theme: null
|
|
28
36
|
) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
@return $white;
|
|
34
|
-
}
|
|
35
|
-
@else {
|
|
36
|
-
@return $black;
|
|
37
|
+
@if ($theme == null) {
|
|
38
|
+
$default-black: palette.$black;
|
|
39
|
+
$default-white: palette.$white;
|
|
40
|
+
@return mc.daff-max-contrast($reference-color, ($default-black, $default-white));
|
|
37
41
|
}
|
|
42
|
+
$theme-font-colors: fc.daff-get-font-colors($theme);
|
|
43
|
+
@return mc.daff-max-contrast($reference-color, $theme-font-colors);
|
|
38
44
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
@use 'true' as *;
|
|
2
|
+
@use './text-contrast' as *;
|
|
3
|
+
@use '../../get-color';
|
|
4
|
+
@use '../../color-palettes' as palette;
|
|
5
|
+
@use '../../configure-palette';
|
|
6
|
+
@use '../../create-theme/create-theme' as ct;
|
|
7
|
+
|
|
8
|
+
@include describe('daff-text-contrast') {
|
|
9
|
+
$light-theme: ct.daff-create-theme(
|
|
10
|
+
('mode': 'light',
|
|
11
|
+
'primary': configure-palette.daff-configure-palette(palette.$daff-blue, 60),
|
|
12
|
+
'secondary': configure-palette.daff-configure-palette(palette.$daff-purple, 60),
|
|
13
|
+
'tertiary': configure-palette.daff-configure-palette(palette.$daff-turquoise, 60))
|
|
14
|
+
);
|
|
15
|
+
$dark-theme: ct.daff-create-theme(
|
|
16
|
+
('mode': 'dark',
|
|
17
|
+
'primary': configure-palette.daff-configure-palette(palette.$daff-blue, 60),
|
|
18
|
+
'secondary': configure-palette.daff-configure-palette(palette.$daff-purple, 60),
|
|
19
|
+
'tertiary': configure-palette.daff-configure-palette(palette.$daff-turquoise, 60))
|
|
20
|
+
);
|
|
21
|
+
$white: palette.$white;
|
|
22
|
+
$black: palette.$black;
|
|
23
|
+
$dark-gray: get-color.daff-color(palette.$daff-neutral, 80);
|
|
24
|
+
$light-gray: get-color.daff-color(palette.$daff-neutral, 20);
|
|
25
|
+
$blue: get-color.daff-color(palette.$daff-blue, 60);
|
|
26
|
+
$yellow: get-color.daff-color(palette.$daff-yellow, 60);
|
|
27
|
+
|
|
28
|
+
@include it('returns white for dark reference colors in light theme') {
|
|
29
|
+
@include assert-equal(daff-text-contrast($black, $light-theme), $white);
|
|
30
|
+
@include assert-equal(daff-text-contrast($dark-gray, $light-theme), $white);
|
|
31
|
+
@include assert-equal(daff-text-contrast($blue, $light-theme), $white);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@include it('returns black for light reference colors in light theme') {
|
|
35
|
+
@include assert-equal(daff-text-contrast($white, $light-theme), $black);
|
|
36
|
+
@include assert-equal(daff-text-contrast($light-gray, $light-theme), $black);
|
|
37
|
+
@include assert-equal(daff-text-contrast($yellow, $light-theme), $black);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@include it('returns white for dark reference colors in dark theme') {
|
|
41
|
+
@include assert-equal(daff-text-contrast($black, $dark-theme), $white);
|
|
42
|
+
@include assert-equal(daff-text-contrast($dark-gray, $dark-theme), $white);
|
|
43
|
+
@include assert-equal(daff-text-contrast($blue, $dark-theme), $white);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@include it('returns black for light reference colors in dark theme') {
|
|
47
|
+
@include assert-equal(daff-text-contrast($white, $dark-theme), $black);
|
|
48
|
+
@include assert-equal(daff-text-contrast($light-gray, $dark-theme), $black);
|
|
49
|
+
@include assert-equal(daff-text-contrast($yellow, $dark-theme), $black);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@include it('returns a text color given only a reference color but no theme') {
|
|
53
|
+
@include assert-equal(daff-text-contrast($black), $white);
|
|
54
|
+
@include assert-equal(daff-text-contrast($dark-gray), $white);
|
|
55
|
+
@include assert-equal(daff-text-contrast($light-gray), $black);
|
|
56
|
+
}
|
|
57
|
+
}
|