@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.
Files changed (200) hide show
  1. package/accordion/index.d.ts +8 -5
  2. package/article/README.md +1 -1
  3. package/article/index.d.ts +20 -0
  4. package/article/src/article-theme.scss +10 -0
  5. package/button/index.d.ts +4 -4
  6. package/button/src/button/button-base.scss +3 -3
  7. package/button/src/button/raised/raised-theme.scss +2 -2
  8. package/card/README.md +0 -8
  9. package/card/index.d.ts +7 -41
  10. package/card/src/card-base-theme.scss +2 -5
  11. package/card/src/card-base.scss +2 -2
  12. package/checkbox/README.md +0 -0
  13. package/checkbox/index.d.ts +177 -0
  14. package/fesm2022/daffodil-design-accordion.mjs +23 -14
  15. package/fesm2022/daffodil-design-accordion.mjs.map +1 -1
  16. package/fesm2022/daffodil-design-article.mjs +129 -5
  17. package/fesm2022/daffodil-design-article.mjs.map +1 -1
  18. package/fesm2022/daffodil-design-button.mjs +24 -20
  19. package/fesm2022/daffodil-design-button.mjs.map +1 -1
  20. package/fesm2022/daffodil-design-card.mjs +16 -63
  21. package/fesm2022/daffodil-design-card.mjs.map +1 -1
  22. package/fesm2022/daffodil-design-checkbox.mjs +317 -0
  23. package/fesm2022/daffodil-design-checkbox.mjs.map +1 -0
  24. package/fesm2022/daffodil-design-form-field.mjs +35 -65
  25. package/fesm2022/daffodil-design-form-field.mjs.map +1 -1
  26. package/fesm2022/daffodil-design-form.mjs +62 -0
  27. package/fesm2022/daffodil-design-form.mjs.map +1 -0
  28. package/fesm2022/daffodil-design-image.mjs +12 -4
  29. package/fesm2022/daffodil-design-image.mjs.map +1 -1
  30. package/fesm2022/daffodil-design-modal.mjs +55 -56
  31. package/fesm2022/daffodil-design-modal.mjs.map +1 -1
  32. package/fesm2022/daffodil-design-notification.mjs +14 -50
  33. package/fesm2022/daffodil-design-notification.mjs.map +1 -1
  34. package/fesm2022/daffodil-design-paginator.mjs +6 -11
  35. package/fesm2022/daffodil-design-paginator.mjs.map +1 -1
  36. package/fesm2022/daffodil-design-quantity-field.mjs +3 -5
  37. package/fesm2022/daffodil-design-quantity-field.mjs.map +1 -1
  38. package/fesm2022/daffodil-design-radio.mjs +13 -42
  39. package/fesm2022/daffodil-design-radio.mjs.map +1 -1
  40. package/fesm2022/daffodil-design-sidebar.mjs +6 -36
  41. package/fesm2022/daffodil-design-sidebar.mjs.map +1 -1
  42. package/fesm2022/daffodil-design-switch.mjs +48 -105
  43. package/fesm2022/daffodil-design-switch.mjs.map +1 -1
  44. package/fesm2022/daffodil-design-tabs.mjs +22 -14
  45. package/fesm2022/daffodil-design-tabs.mjs.map +1 -1
  46. package/fesm2022/daffodil-design-toast.mjs +56 -55
  47. package/fesm2022/daffodil-design-toast.mjs.map +1 -1
  48. package/fesm2022/daffodil-design-tree.mjs +4 -13
  49. package/fesm2022/daffodil-design-tree.mjs.map +1 -1
  50. package/fesm2022/daffodil-design.mjs +250 -461
  51. package/fesm2022/daffodil-design.mjs.map +1 -1
  52. package/form/README.md +75 -0
  53. package/form/index.d.ts +27 -0
  54. package/form-field/README.md +49 -39
  55. package/form-field/index.d.ts +56 -36
  56. package/image/README.md +27 -19
  57. package/image/index.d.ts +6 -1
  58. package/index.d.ts +180 -259
  59. package/input/README.md +32 -12
  60. package/modal/README.md +106 -16
  61. package/modal/index.d.ts +50 -21
  62. package/native-select/README.md +52 -15
  63. package/notification/index.d.ts +7 -38
  64. package/package.json +1 -1
  65. package/paginator/index.d.ts +1 -7
  66. package/radio/index.d.ts +0 -16
  67. package/scss/layout/_breakpoint.scss +1 -1
  68. package/scss/theme.scss +2 -4
  69. package/scss/theming/_color-palettes.scss +21 -7
  70. package/scss/theming/_configure-theme.scss +11 -10
  71. package/scss/theming/_daff-theme.scss +5 -14
  72. package/scss/theming/_get-base-color.scss +2 -2
  73. package/scss/theming/_get-palette.scss +2 -2
  74. package/scss/theming/_get-theme-mode.scss +3 -3
  75. package/scss/theming/_index.scss +2 -1
  76. package/scss/theming/contrast/max-contrast/max-contrast.scss +3 -3
  77. package/scss/theming/contrast/text-contrast/text-contrast.scss +22 -16
  78. package/scss/theming/contrast/text-contrast/text-contrast.spec.scss +57 -0
  79. package/scss/theming/create-theme/_create-theme.scss +330 -0
  80. package/scss/theming/create-theme/_create-theme.spec.scss +122 -0
  81. package/scss/theming/create-theme/_index.scss +1 -0
  82. package/scss/theming/get-font-colors/_get-font-colors.scss +36 -0
  83. package/scss/theming/get-font-colors/_get-font-colors.spec.scss +72 -0
  84. package/scss/typography/mixins/_font-weight.scss +8 -14
  85. package/select/README.md +107 -4
  86. package/sidebar/README.md +0 -8
  87. package/sidebar/index.d.ts +3 -15
  88. package/switch/README.md +19 -27
  89. package/switch/index.d.ts +18 -48
  90. package/switch/src/switch-theme.scss +26 -18
  91. package/tabs/index.d.ts +7 -4
  92. package/tag/src/tag-theme.scss +11 -9
  93. package/textarea/README.md +35 -5
  94. package/tree/index.d.ts +0 -6
  95. package/tree/src/tree-theme.scss +0 -4
  96. package/accordion/examples/index.d.ts +0 -20
  97. package/article/examples/index.d.ts +0 -50
  98. package/breadcrumb/examples/index.d.ts +0 -10
  99. package/button/examples/index.d.ts +0 -67
  100. package/callout/examples/index.d.ts +0 -41
  101. package/card/examples/index.d.ts +0 -62
  102. package/card/src/card/raised/raised-theme.scss +0 -28
  103. package/checkbox/examples/index.d.ts +0 -32
  104. package/container/examples/index.d.ts +0 -16
  105. package/fesm2022/daffodil-design-accordion-examples.mjs +0 -50
  106. package/fesm2022/daffodil-design-accordion-examples.mjs.map +0 -1
  107. package/fesm2022/daffodil-design-article-examples.mjs +0 -134
  108. package/fesm2022/daffodil-design-article-examples.mjs.map +0 -1
  109. package/fesm2022/daffodil-design-breadcrumb-examples.mjs +0 -46
  110. package/fesm2022/daffodil-design-breadcrumb-examples.mjs.map +0 -1
  111. package/fesm2022/daffodil-design-button-examples.mjs +0 -178
  112. package/fesm2022/daffodil-design-button-examples.mjs.map +0 -1
  113. package/fesm2022/daffodil-design-callout-examples.mjs +0 -116
  114. package/fesm2022/daffodil-design-callout-examples.mjs.map +0 -1
  115. package/fesm2022/daffodil-design-card-examples.mjs +0 -168
  116. package/fesm2022/daffodil-design-card-examples.mjs.map +0 -1
  117. package/fesm2022/daffodil-design-checkbox-examples.mjs +0 -76
  118. package/fesm2022/daffodil-design-checkbox-examples.mjs.map +0 -1
  119. package/fesm2022/daffodil-design-container-examples.mjs +0 -41
  120. package/fesm2022/daffodil-design-container-examples.mjs.map +0 -1
  121. package/fesm2022/daffodil-design-form-field-examples.mjs +0 -96
  122. package/fesm2022/daffodil-design-form-field-examples.mjs.map +0 -1
  123. package/fesm2022/daffodil-design-hero-examples.mjs +0 -121
  124. package/fesm2022/daffodil-design-hero-examples.mjs.map +0 -1
  125. package/fesm2022/daffodil-design-image-examples.mjs +0 -58
  126. package/fesm2022/daffodil-design-image-examples.mjs.map +0 -1
  127. package/fesm2022/daffodil-design-input-examples.mjs +0 -108
  128. package/fesm2022/daffodil-design-input-examples.mjs.map +0 -1
  129. package/fesm2022/daffodil-design-list-examples.mjs +0 -77
  130. package/fesm2022/daffodil-design-list-examples.mjs.map +0 -1
  131. package/fesm2022/daffodil-design-loading-icon-examples.mjs +0 -44
  132. package/fesm2022/daffodil-design-loading-icon-examples.mjs.map +0 -1
  133. package/fesm2022/daffodil-design-media-gallery-examples.mjs +0 -104
  134. package/fesm2022/daffodil-design-media-gallery-examples.mjs.map +0 -1
  135. package/fesm2022/daffodil-design-menu-examples.mjs +0 -50
  136. package/fesm2022/daffodil-design-menu-examples.mjs.map +0 -1
  137. package/fesm2022/daffodil-design-modal-examples.mjs +0 -51
  138. package/fesm2022/daffodil-design-modal-examples.mjs.map +0 -1
  139. package/fesm2022/daffodil-design-native-select-examples.mjs +0 -71
  140. package/fesm2022/daffodil-design-native-select-examples.mjs.map +0 -1
  141. package/fesm2022/daffodil-design-navbar-examples.mjs +0 -88
  142. package/fesm2022/daffodil-design-navbar-examples.mjs.map +0 -1
  143. package/fesm2022/daffodil-design-notification-examples.mjs +0 -102
  144. package/fesm2022/daffodil-design-notification-examples.mjs.map +0 -1
  145. package/fesm2022/daffodil-design-paginator-examples.mjs +0 -59
  146. package/fesm2022/daffodil-design-paginator-examples.mjs.map +0 -1
  147. package/fesm2022/daffodil-design-progress-bar-examples.mjs +0 -57
  148. package/fesm2022/daffodil-design-progress-bar-examples.mjs.map +0 -1
  149. package/fesm2022/daffodil-design-quantity-field-examples.mjs +0 -85
  150. package/fesm2022/daffodil-design-quantity-field-examples.mjs.map +0 -1
  151. package/fesm2022/daffodil-design-radio-examples.mjs +0 -34
  152. package/fesm2022/daffodil-design-radio-examples.mjs.map +0 -1
  153. package/fesm2022/daffodil-design-select-examples.mjs +0 -117
  154. package/fesm2022/daffodil-design-select-examples.mjs.map +0 -1
  155. package/fesm2022/daffodil-design-sidebar-examples.mjs +0 -109
  156. package/fesm2022/daffodil-design-sidebar-examples.mjs.map +0 -1
  157. package/fesm2022/daffodil-design-sticky-examples.mjs +0 -25
  158. package/fesm2022/daffodil-design-sticky-examples.mjs.map +0 -1
  159. package/fesm2022/daffodil-design-switch-examples.mjs +0 -110
  160. package/fesm2022/daffodil-design-switch-examples.mjs.map +0 -1
  161. package/fesm2022/daffodil-design-tabs-examples.mjs +0 -115
  162. package/fesm2022/daffodil-design-tabs-examples.mjs.map +0 -1
  163. package/fesm2022/daffodil-design-tag-examples.mjs +0 -125
  164. package/fesm2022/daffodil-design-tag-examples.mjs.map +0 -1
  165. package/fesm2022/daffodil-design-text-snippet-examples.mjs +0 -25
  166. package/fesm2022/daffodil-design-text-snippet-examples.mjs.map +0 -1
  167. package/fesm2022/daffodil-design-textarea-examples.mjs +0 -66
  168. package/fesm2022/daffodil-design-textarea-examples.mjs.map +0 -1
  169. package/fesm2022/daffodil-design-toast-examples.mjs +0 -147
  170. package/fesm2022/daffodil-design-toast-examples.mjs.map +0 -1
  171. package/fesm2022/daffodil-design-tree-examples.mjs +0 -104
  172. package/fesm2022/daffodil-design-tree-examples.mjs.map +0 -1
  173. package/form-field/examples/index.d.ts +0 -18
  174. package/hero/examples/index.d.ts +0 -45
  175. package/image/examples/index.d.ts +0 -10
  176. package/input/examples/index.d.ts +0 -10
  177. package/list/examples/index.d.ts +0 -29
  178. package/loading-icon/examples/index.d.ts +0 -16
  179. package/media-gallery/examples/index.d.ts +0 -38
  180. package/menu/examples/index.d.ts +0 -20
  181. package/modal/examples/index.d.ts +0 -15
  182. package/native-select/examples/index.d.ts +0 -10
  183. package/navbar/examples/index.d.ts +0 -31
  184. package/notification/examples/index.d.ts +0 -12
  185. package/paginator/examples/index.d.ts +0 -26
  186. package/progress-bar/examples/index.d.ts +0 -10
  187. package/quantity-field/examples/index.d.ts +0 -30
  188. package/radio/examples/index.d.ts +0 -13
  189. package/select/examples/index.d.ts +0 -28
  190. package/sidebar/examples/index.d.ts +0 -10
  191. package/sticky/examples/index.d.ts +0 -10
  192. package/switch/examples/index.d.ts +0 -46
  193. package/tabs/examples/index.d.ts +0 -12
  194. package/tag/examples/index.d.ts +0 -50
  195. package/text-snippet/examples/index.d.ts +0 -10
  196. package/textarea/examples/index.d.ts +0 -10
  197. package/toast/examples/index.d.ts +0 -56
  198. package/tree/examples/index.d.ts +0 -18
  199. /package/{form-field → form}/src/error-message/error-message-theme.scss +0 -0
  200. /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
- $daff-white: #ffffff;
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
- // 60 apart passes AAA level for any size text (except for 10/70)
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': get-color.daff-color(palette.$daff-neutral, 110),
9
- 'base': get-color.daff-color(palette.$daff-neutral, 0),
10
- 'base-contrast': get-color.daff-color(palette.$daff-neutral, 110),
11
- 'white': get-color.daff-color(palette.$daff-neutral, 0),
12
- 'black': get-color.daff-color(palette.$daff-neutral, 110),
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': get-color.daff-color(palette.$daff-neutral, 0),
19
- 'base': get-color.daff-color(palette.$daff-neutral, 100),
20
- 'base-contrast': get-color.daff-color(palette.$daff-neutral, 0),
21
- 'white': get-color.daff-color(palette.$daff-neutral, 0),
22
- 'black': get-color.daff-color(palette.$daff-neutral, 110),
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 'configure-theme';
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: configure-theme.daff-configure-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: configure-theme.daff-configure-theme(
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-configure-theme` before this function can be used.
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-configure-theme` function.
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-configure-theme` before this function can be used.
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-configure-theme` function.
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-configure-theme`.
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-configure-theme` before this function can be used.
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-configure-theme` function.
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;
@@ -3,9 +3,10 @@
3
3
  @forward 'contrast';
4
4
  @forward 'illuminate/illuminate';
5
5
  @forward 'configure-palette';
6
- @forward 'configure-theme';
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
- /// .body {
16
- /// background: daff-color($neutral, 10);
17
- /// color: daff-max-contrast(daff-color($neutral, 10), (daff-color($primary, 20), daff-color($secondary, 40)));
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 '../contrast-ratio/contrast-ratio' as cr;
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
- /// .heading {
21
- /// color: daff-text-contrast(#000);
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
- $black: get-color.daff-color(palette.$daff-neutral, 110),
27
- $white: palette.$daff-white
34
+ $reference-color,
35
+ $theme: null
28
36
  ) {
29
- $light-contrast: cr.daff-contrast-ratio($color, $white);
30
- $dark-contrast: cr.daff-contrast-ratio($color, $black);
31
-
32
- @if ($light-contrast > $dark-contrast) {
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
+ }