@daffodil/design 0.90.0 → 0.92.3-rc.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 (277) hide show
  1. package/accordion/README.md +26 -38
  2. package/accordion/index.d.ts +9 -6
  3. package/article/README.md +66 -46
  4. package/article/index.d.ts +41 -0
  5. package/article/src/article-theme.scss +22 -0
  6. package/breadcrumb/README.md +6 -1
  7. package/breadcrumb/index.d.ts +65 -11
  8. package/breadcrumb/src/breadcrumb-theme.scss +1 -1
  9. package/button/README.md +36 -33
  10. package/button/index.d.ts +27 -6
  11. package/button/src/button/basic/button-theme.scss +4 -2
  12. package/button/src/button/button-base.scss +29 -6
  13. package/button/src/button/icon/icon-theme.scss +10 -6
  14. package/button/src/button/raised/raised-theme.scss +6 -4
  15. package/callout/README.md +15 -27
  16. package/card/README.md +36 -69
  17. package/card/index.d.ts +7 -41
  18. package/card/src/card-base-theme.scss +2 -5
  19. package/card/src/card-base.scss +2 -2
  20. package/checkbox/README.md +0 -0
  21. package/checkbox/index.d.ts +177 -0
  22. package/container/README.md +18 -23
  23. package/fesm2022/daffodil-design-accordion.mjs +34 -25
  24. package/fesm2022/daffodil-design-accordion.mjs.map +1 -1
  25. package/fesm2022/daffodil-design-article.mjs +283 -17
  26. package/fesm2022/daffodil-design-article.mjs.map +1 -1
  27. package/fesm2022/daffodil-design-breadcrumb.mjs +180 -28
  28. package/fesm2022/daffodil-design-breadcrumb.mjs.map +1 -1
  29. package/fesm2022/daffodil-design-button.mjs +90 -45
  30. package/fesm2022/daffodil-design-button.mjs.map +1 -1
  31. package/fesm2022/daffodil-design-callout.mjs +23 -23
  32. package/fesm2022/daffodil-design-callout.mjs.map +1 -1
  33. package/fesm2022/daffodil-design-card.mjs +43 -90
  34. package/fesm2022/daffodil-design-card.mjs.map +1 -1
  35. package/fesm2022/daffodil-design-checkbox.mjs +317 -0
  36. package/fesm2022/daffodil-design-checkbox.mjs.map +1 -0
  37. package/fesm2022/daffodil-design-container.mjs +8 -8
  38. package/fesm2022/daffodil-design-container.mjs.map +1 -1
  39. package/fesm2022/daffodil-design-form-field.mjs +56 -86
  40. package/fesm2022/daffodil-design-form-field.mjs.map +1 -1
  41. package/fesm2022/daffodil-design-form.mjs +62 -0
  42. package/fesm2022/daffodil-design-form.mjs.map +1 -0
  43. package/fesm2022/daffodil-design-hero.mjs +23 -23
  44. package/fesm2022/daffodil-design-hero.mjs.map +1 -1
  45. package/fesm2022/daffodil-design-image.mjs +19 -11
  46. package/fesm2022/daffodil-design-image.mjs.map +1 -1
  47. package/fesm2022/daffodil-design-input.mjs +18 -14
  48. package/fesm2022/daffodil-design-input.mjs.map +1 -1
  49. package/fesm2022/daffodil-design-link-set.mjs +25 -17
  50. package/fesm2022/daffodil-design-link-set.mjs.map +1 -1
  51. package/fesm2022/daffodil-design-list.mjs +16 -16
  52. package/fesm2022/daffodil-design-list.mjs.map +1 -1
  53. package/fesm2022/daffodil-design-loading-icon.mjs +8 -8
  54. package/fesm2022/daffodil-design-loading-icon.mjs.map +1 -1
  55. package/fesm2022/daffodil-design-media-gallery.mjs +13 -13
  56. package/fesm2022/daffodil-design-media-gallery.mjs.map +1 -1
  57. package/fesm2022/daffodil-design-menu.mjs +223 -60
  58. package/fesm2022/daffodil-design-menu.mjs.map +1 -1
  59. package/fesm2022/daffodil-design-modal.mjs +86 -83
  60. package/fesm2022/daffodil-design-modal.mjs.map +1 -1
  61. package/fesm2022/daffodil-design-native-select.mjs +47 -41
  62. package/fesm2022/daffodil-design-native-select.mjs.map +1 -1
  63. package/fesm2022/daffodil-design-navbar.mjs +25 -21
  64. package/fesm2022/daffodil-design-navbar.mjs.map +1 -1
  65. package/fesm2022/daffodil-design-notification.mjs +28 -64
  66. package/fesm2022/daffodil-design-notification.mjs.map +1 -1
  67. package/fesm2022/daffodil-design-paginator.mjs +11 -16
  68. package/fesm2022/daffodil-design-paginator.mjs.map +1 -1
  69. package/fesm2022/daffodil-design-progress-bar.mjs +10 -10
  70. package/fesm2022/daffodil-design-progress-bar.mjs.map +1 -1
  71. package/fesm2022/daffodil-design-quantity-field.mjs +19 -18
  72. package/fesm2022/daffodil-design-quantity-field.mjs.map +1 -1
  73. package/fesm2022/daffodil-design-radio.mjs +27 -56
  74. package/fesm2022/daffodil-design-radio.mjs.map +1 -1
  75. package/fesm2022/daffodil-design-select.mjs +6 -6
  76. package/fesm2022/daffodil-design-select.mjs.map +1 -1
  77. package/fesm2022/daffodil-design-sidebar.mjs +30 -60
  78. package/fesm2022/daffodil-design-sidebar.mjs.map +1 -1
  79. package/fesm2022/daffodil-design-spinner.mjs +99 -0
  80. package/fesm2022/daffodil-design-spinner.mjs.map +1 -0
  81. package/fesm2022/daffodil-design-switch.mjs +49 -106
  82. package/fesm2022/daffodil-design-switch.mjs.map +1 -1
  83. package/fesm2022/daffodil-design-tabs.mjs +35 -27
  84. package/fesm2022/daffodil-design-tabs.mjs.map +1 -1
  85. package/fesm2022/daffodil-design-tag.mjs +7 -7
  86. package/fesm2022/daffodil-design-tag.mjs.map +1 -1
  87. package/fesm2022/daffodil-design-text-snippet.mjs +6 -8
  88. package/fesm2022/daffodil-design-text-snippet.mjs.map +1 -1
  89. package/fesm2022/daffodil-design-textarea.mjs +6 -3
  90. package/fesm2022/daffodil-design-textarea.mjs.map +1 -1
  91. package/fesm2022/daffodil-design-toast.mjs +79 -80
  92. package/fesm2022/daffodil-design-toast.mjs.map +1 -1
  93. package/fesm2022/daffodil-design-tree.mjs +152 -112
  94. package/fesm2022/daffodil-design-tree.mjs.map +1 -1
  95. package/fesm2022/daffodil-design-youtube-player.mjs +6 -6
  96. package/fesm2022/daffodil-design-youtube-player.mjs.map +1 -1
  97. package/fesm2022/daffodil-design.mjs +559 -711
  98. package/fesm2022/daffodil-design.mjs.map +1 -1
  99. package/form/README.md +75 -0
  100. package/form/index.d.ts +27 -0
  101. package/form-field/README.md +74 -99
  102. package/form-field/index.d.ts +64 -42
  103. package/hero/README.md +5 -5
  104. package/image/README.md +27 -19
  105. package/image/index.d.ts +6 -1
  106. package/index.d.ts +282 -447
  107. package/input/README.md +36 -16
  108. package/input/index.d.ts +4 -3
  109. package/link-set/index.d.ts +9 -1
  110. package/list/README.md +2 -2
  111. package/loading-icon/README.md +1 -1
  112. package/loading-icon/index.d.ts +1 -1
  113. package/media-gallery/README.md +3 -3
  114. package/menu/README.md +107 -10
  115. package/menu/index.d.ts +143 -11
  116. package/modal/README.md +107 -17
  117. package/modal/index.d.ts +72 -35
  118. package/native-select/README.md +52 -15
  119. package/native-select/index.d.ts +8 -7
  120. package/navbar/README.md +23 -17
  121. package/navbar/index.d.ts +12 -2
  122. package/navbar/src/navbar-theme.scss +4 -46
  123. package/notification/README.md +4 -4
  124. package/notification/index.d.ts +7 -38
  125. package/package.json +1 -1
  126. package/paginator/README.md +42 -6
  127. package/paginator/index.d.ts +5 -9
  128. package/progress-bar/README.md +3 -3
  129. package/quantity-field/README.md +4 -4
  130. package/quantity-field/index.d.ts +4 -1
  131. package/radio/README.md +1 -1
  132. package/radio/index.d.ts +0 -16
  133. package/scss/layout/_breakpoint.scss +1 -1
  134. package/scss/theme.scss +9 -5
  135. package/scss/theming/_color-palettes.scss +19 -11
  136. package/scss/theming/_configure-theme.scss +11 -10
  137. package/scss/theming/_daff-theme.scss +5 -14
  138. package/scss/theming/_get-base-color.scss +2 -2
  139. package/scss/theming/_get-palette.scss +2 -2
  140. package/scss/theming/_get-theme-mode.scss +3 -3
  141. package/scss/theming/_index.scss +2 -1
  142. package/scss/theming/contrast/max-contrast/max-contrast.scss +3 -3
  143. package/scss/theming/contrast/text-contrast/text-contrast.scss +22 -16
  144. package/scss/theming/contrast/text-contrast/text-contrast.spec.scss +57 -0
  145. package/scss/theming/create-theme/_create-theme.scss +330 -0
  146. package/scss/theming/create-theme/_create-theme.spec.scss +122 -0
  147. package/scss/theming/create-theme/_index.scss +1 -0
  148. package/scss/theming/get-font-colors/_get-font-colors.scss +36 -0
  149. package/scss/theming/get-font-colors/_get-font-colors.spec.scss +72 -0
  150. package/scss/typography/mixins/_font-weight.scss +8 -14
  151. package/select/README.md +107 -4
  152. package/sidebar/README.md +6 -14
  153. package/sidebar/index.d.ts +3 -15
  154. package/spinner/README.md +57 -0
  155. package/spinner/index.d.ts +53 -0
  156. package/spinner/src/spinner-theme.scss +62 -0
  157. package/switch/README.md +21 -29
  158. package/switch/index.d.ts +18 -48
  159. package/switch/src/switch-theme.scss +26 -18
  160. package/tabs/README.md +1 -1
  161. package/tabs/index.d.ts +8 -5
  162. package/tag/README.md +24 -30
  163. package/tag/index.d.ts +1 -1
  164. package/tag/src/tag-theme.scss +11 -9
  165. package/text-snippet/README.md +1 -1
  166. package/text-snippet/src/text-snippet-theme.scss +12 -0
  167. package/textarea/README.md +36 -6
  168. package/textarea/index.d.ts +4 -4
  169. package/toast/README.md +4 -4
  170. package/tree/README.md +39 -22
  171. package/tree/index.d.ts +57 -96
  172. package/tree/src/tree-theme.scss +0 -4
  173. package/accordion/examples/index.d.ts +0 -20
  174. package/article/examples/index.d.ts +0 -50
  175. package/breadcrumb/examples/index.d.ts +0 -10
  176. package/button/examples/index.d.ts +0 -67
  177. package/callout/examples/index.d.ts +0 -41
  178. package/card/examples/index.d.ts +0 -62
  179. package/card/src/card/raised/raised-theme.scss +0 -28
  180. package/checkbox/examples/index.d.ts +0 -32
  181. package/container/examples/index.d.ts +0 -16
  182. package/fesm2022/daffodil-design-accordion-examples.mjs +0 -50
  183. package/fesm2022/daffodil-design-accordion-examples.mjs.map +0 -1
  184. package/fesm2022/daffodil-design-article-examples.mjs +0 -134
  185. package/fesm2022/daffodil-design-article-examples.mjs.map +0 -1
  186. package/fesm2022/daffodil-design-breadcrumb-examples.mjs +0 -46
  187. package/fesm2022/daffodil-design-breadcrumb-examples.mjs.map +0 -1
  188. package/fesm2022/daffodil-design-button-examples.mjs +0 -178
  189. package/fesm2022/daffodil-design-button-examples.mjs.map +0 -1
  190. package/fesm2022/daffodil-design-callout-examples.mjs +0 -116
  191. package/fesm2022/daffodil-design-callout-examples.mjs.map +0 -1
  192. package/fesm2022/daffodil-design-card-examples.mjs +0 -168
  193. package/fesm2022/daffodil-design-card-examples.mjs.map +0 -1
  194. package/fesm2022/daffodil-design-checkbox-examples.mjs +0 -76
  195. package/fesm2022/daffodil-design-checkbox-examples.mjs.map +0 -1
  196. package/fesm2022/daffodil-design-container-examples.mjs +0 -41
  197. package/fesm2022/daffodil-design-container-examples.mjs.map +0 -1
  198. package/fesm2022/daffodil-design-form-field-examples.mjs +0 -96
  199. package/fesm2022/daffodil-design-form-field-examples.mjs.map +0 -1
  200. package/fesm2022/daffodil-design-hero-examples.mjs +0 -121
  201. package/fesm2022/daffodil-design-hero-examples.mjs.map +0 -1
  202. package/fesm2022/daffodil-design-image-examples.mjs +0 -58
  203. package/fesm2022/daffodil-design-image-examples.mjs.map +0 -1
  204. package/fesm2022/daffodil-design-input-examples.mjs +0 -108
  205. package/fesm2022/daffodil-design-input-examples.mjs.map +0 -1
  206. package/fesm2022/daffodil-design-list-examples.mjs +0 -77
  207. package/fesm2022/daffodil-design-list-examples.mjs.map +0 -1
  208. package/fesm2022/daffodil-design-loading-icon-examples.mjs +0 -44
  209. package/fesm2022/daffodil-design-loading-icon-examples.mjs.map +0 -1
  210. package/fesm2022/daffodil-design-media-gallery-examples.mjs +0 -104
  211. package/fesm2022/daffodil-design-media-gallery-examples.mjs.map +0 -1
  212. package/fesm2022/daffodil-design-menu-examples.mjs +0 -50
  213. package/fesm2022/daffodil-design-menu-examples.mjs.map +0 -1
  214. package/fesm2022/daffodil-design-modal-examples.mjs +0 -51
  215. package/fesm2022/daffodil-design-modal-examples.mjs.map +0 -1
  216. package/fesm2022/daffodil-design-native-select-examples.mjs +0 -71
  217. package/fesm2022/daffodil-design-native-select-examples.mjs.map +0 -1
  218. package/fesm2022/daffodil-design-navbar-examples.mjs +0 -88
  219. package/fesm2022/daffodil-design-navbar-examples.mjs.map +0 -1
  220. package/fesm2022/daffodil-design-notification-examples.mjs +0 -102
  221. package/fesm2022/daffodil-design-notification-examples.mjs.map +0 -1
  222. package/fesm2022/daffodil-design-paginator-examples.mjs +0 -59
  223. package/fesm2022/daffodil-design-paginator-examples.mjs.map +0 -1
  224. package/fesm2022/daffodil-design-progress-bar-examples.mjs +0 -57
  225. package/fesm2022/daffodil-design-progress-bar-examples.mjs.map +0 -1
  226. package/fesm2022/daffodil-design-quantity-field-examples.mjs +0 -85
  227. package/fesm2022/daffodil-design-quantity-field-examples.mjs.map +0 -1
  228. package/fesm2022/daffodil-design-radio-examples.mjs +0 -34
  229. package/fesm2022/daffodil-design-radio-examples.mjs.map +0 -1
  230. package/fesm2022/daffodil-design-select-examples.mjs +0 -117
  231. package/fesm2022/daffodil-design-select-examples.mjs.map +0 -1
  232. package/fesm2022/daffodil-design-sidebar-examples.mjs +0 -109
  233. package/fesm2022/daffodil-design-sidebar-examples.mjs.map +0 -1
  234. package/fesm2022/daffodil-design-sticky-examples.mjs +0 -25
  235. package/fesm2022/daffodil-design-sticky-examples.mjs.map +0 -1
  236. package/fesm2022/daffodil-design-switch-examples.mjs +0 -110
  237. package/fesm2022/daffodil-design-switch-examples.mjs.map +0 -1
  238. package/fesm2022/daffodil-design-tabs-examples.mjs +0 -115
  239. package/fesm2022/daffodil-design-tabs-examples.mjs.map +0 -1
  240. package/fesm2022/daffodil-design-tag-examples.mjs +0 -125
  241. package/fesm2022/daffodil-design-tag-examples.mjs.map +0 -1
  242. package/fesm2022/daffodil-design-text-snippet-examples.mjs +0 -25
  243. package/fesm2022/daffodil-design-text-snippet-examples.mjs.map +0 -1
  244. package/fesm2022/daffodil-design-textarea-examples.mjs +0 -66
  245. package/fesm2022/daffodil-design-textarea-examples.mjs.map +0 -1
  246. package/fesm2022/daffodil-design-toast-examples.mjs +0 -147
  247. package/fesm2022/daffodil-design-toast-examples.mjs.map +0 -1
  248. package/fesm2022/daffodil-design-tree-examples.mjs +0 -104
  249. package/fesm2022/daffodil-design-tree-examples.mjs.map +0 -1
  250. package/form-field/examples/index.d.ts +0 -18
  251. package/hero/examples/index.d.ts +0 -45
  252. package/image/examples/index.d.ts +0 -10
  253. package/input/examples/index.d.ts +0 -10
  254. package/list/examples/index.d.ts +0 -29
  255. package/loading-icon/examples/index.d.ts +0 -16
  256. package/media-gallery/examples/index.d.ts +0 -38
  257. package/menu/examples/index.d.ts +0 -20
  258. package/modal/examples/index.d.ts +0 -15
  259. package/native-select/examples/index.d.ts +0 -10
  260. package/navbar/examples/index.d.ts +0 -31
  261. package/notification/examples/index.d.ts +0 -12
  262. package/paginator/examples/index.d.ts +0 -26
  263. package/progress-bar/examples/index.d.ts +0 -10
  264. package/quantity-field/examples/index.d.ts +0 -30
  265. package/radio/examples/index.d.ts +0 -13
  266. package/select/examples/index.d.ts +0 -28
  267. package/sidebar/examples/index.d.ts +0 -10
  268. package/sticky/examples/index.d.ts +0 -10
  269. package/switch/examples/index.d.ts +0 -46
  270. package/tabs/examples/index.d.ts +0 -12
  271. package/tag/examples/index.d.ts +0 -50
  272. package/text-snippet/examples/index.d.ts +0 -10
  273. package/textarea/examples/index.d.ts +0 -10
  274. package/toast/examples/index.d.ts +0 -56
  275. package/tree/examples/index.d.ts +0 -18
  276. /package/{form-field → form}/src/error-message/error-message-theme.scss +0 -0
  277. /package/{form-field → form}/src/hint/hint-theme.scss +0 -0
@@ -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
+ }
@@ -0,0 +1,330 @@
1
+ @use 'sass:list';
2
+ @use 'sass:map';
3
+ @use 'sass:meta';
4
+ @use '../configure-palette';
5
+ @use '../color-palettes' as palette;
6
+ @use '../get-color';
7
+
8
+ $daff-light-theme: (
9
+ 'mode': 'light',
10
+ 'base': palette.$white,
11
+ 'base-contrast': palette.$black,
12
+ 'white': palette.$white,
13
+ 'black': palette.$black,
14
+ );
15
+
16
+ $daff-dark-theme: (
17
+ 'mode': 'dark',
18
+ 'base': get-color.daff-color(palette.$daff-neutral, 100),
19
+ 'base-contrast': palette.$white,
20
+ 'white': palette.$white,
21
+ 'black': palette.$black,
22
+ );
23
+
24
+ $supported-theme-modes: (
25
+ 'light': $daff-light-theme,
26
+ 'dark': $daff-dark-theme,
27
+ );
28
+
29
+ /// Creates a theme with:
30
+ /// - Required palettes: `primary`, `secondary`, `tertiary`
31
+ /// - Optional palettes: `neutral`, `informational`, `warn`, `critical`, `success`, and `neutral`.
32
+ /// - Optional colors: `text-color-default` and `text-color-inverse`.
33
+ ///
34
+ /// Defaults for optional palettes and colors are provided based on the theme mode.
35
+ ///
36
+ /// @group Theming
37
+ ///
38
+ /// @param {Map} $config - A map containing theme configuration
39
+ /// @param {String} $config.mode - Theme mode ('light' or 'dark'). Defaults to 'light' if not provided.
40
+ /// @param {Map} $config.primary - Primary color palette (required)
41
+ /// @param {Map} $config.secondary - Secondary color palette (required)
42
+ /// @param {Map} $config.tertiary - Tertiary color palette (required)
43
+ /// @param {Map} $config.neutral - Neutral color palette (optional, defaults provided)
44
+ /// @param {Map} $config.informational - Informational color palette (optional, defaults provided)
45
+ /// @param {Map} $config.warn - Warning color palette (optional, defaults provided)
46
+ /// @param {Map} $config.critical - Critical/error color palette (optional, defaults provided)
47
+ /// @param {Map} $config.success - Success color palette (optional, defaults provided)
48
+ /// @param {Map} $config.neutral - Neutral color palette (optional, defaults provided)
49
+ /// @param {Color} $config.text-color-default - Default text color (optional, defaults provided)
50
+ /// @param {Color} $config.text-color-inverse - Inverse text color (optional, defaults provided)
51
+ ///
52
+ /// @example scss
53
+ /// $primary: configure-palette.daff-configure-palette(palette.$daff-blue, 60);
54
+ /// $secondary: configure-palette.daff-configure-palette(palette.$daff-purple, 60);
55
+ /// $tertiary: configure-palette.daff-configure-palette(palette.$daff-turquoise, 60);
56
+ /// $theme: daff-create-theme((
57
+ /// 'mode': 'light',
58
+ /// 'primary': $primary,
59
+ /// 'secondary': $secondary,
60
+ /// 'tertiary': $tertiary
61
+ /// ));
62
+ ///
63
+ /// @example scss
64
+ /// $primary: configure-palette.daff-configure-palette(palette.$daff-blue, 60);
65
+ /// $secondary: configure-palette.daff-configure-palette(palette.$daff-purple, 60);
66
+ /// $tertiary: configure-palette.daff-configure-palette(palette.$daff-turquoise, 60);
67
+ /// $informational: configure-palette.daff-configure-palette(palette.$daff-neutral, 60);
68
+ /// $warn: configure-palette.daff-configure-palette(palette.$daff-bronze, 60);
69
+ /// $critical: configure-palette.daff-configure-palette(palette.$daff-red, 60);
70
+ /// $success: configure-palette.daff-configure-palette(palette.$daff-green, 60);
71
+ /// $neutral: configure-palette.daff-configure-palette(palette.$daff-neutral, 60);
72
+ /// $text-color-default: get-color.daff-color(palette.$daff-neutral, 10);
73
+ /// $text-color-inverse: get-color.daff-color(palette.$daff-neutral, 100);
74
+ /// $theme: daff-create-theme((
75
+ /// 'mode': 'light',
76
+ /// 'primary': $primary,
77
+ /// 'secondary': $secondary,
78
+ /// 'tertiary': $tertiary,
79
+ /// 'informational': $informational,
80
+ /// 'warn': $warn,
81
+ /// 'critical': $critical,
82
+ /// 'success': $success,
83
+ /// 'neutral': $neutral,
84
+ /// 'text-color-default': $text-color-default,
85
+ /// 'text-color-inverse': $text-color-inverse
86
+ /// ));
87
+ ///
88
+ @function daff-create-theme($config) {
89
+ $verify: daff-verify-config($config);
90
+
91
+ $mode: map.get($config, 'mode');
92
+ $primary: map.get($config, 'primary');
93
+ $secondary: map.get($config, 'secondary');
94
+ $tertiary: map.get($config, 'tertiary');
95
+
96
+ $text-color-default: map.get($config, 'text-color-default');
97
+ $text-color-inverse: map.get($config, 'text-color-inverse');
98
+
99
+ $informational: map.get($config, 'informational');
100
+ $warn: map.get($config, 'warn');
101
+ $critical: map.get($config, 'critical');
102
+ $success: map.get($config, 'success');
103
+ $neutral: map.get($config, 'neutral');
104
+
105
+ $mode: if($mode == null, 'light', $mode);
106
+
107
+ $optional-palettes: daff-configure-optional-palettes(
108
+ $mode,
109
+ $warn,
110
+ $critical,
111
+ $success,
112
+ $informational,
113
+ $neutral
114
+ );
115
+
116
+ $optional-font-colors: daff-configure-text-colors(
117
+ $mode,
118
+ $text-color-default,
119
+ $text-color-inverse
120
+ );
121
+
122
+ @return (
123
+ 'primary': $primary,
124
+ 'secondary': $secondary,
125
+ 'tertiary': $tertiary,
126
+ 'informational': map.get($optional-palettes, 'informational'),
127
+ 'warn': map.get($optional-palettes, 'warn'),
128
+ 'text-color-default': map.get($optional-font-colors, 'text-color-default'),
129
+ 'text-color-inverse': map.get($optional-font-colors, 'text-color-inverse'),
130
+ 'critical': map.get($optional-palettes, 'critical'),
131
+ 'success': map.get($optional-palettes, 'success'),
132
+ 'neutral': map.get($optional-palettes, 'neutral'),
133
+ 'core': daff-build-theme-core($mode, map.get($optional-palettes, 'neutral'))
134
+ );
135
+ }
136
+
137
+ /// @access private
138
+ ///
139
+ /// Checks if the optional text colors are set, if not it sets them to defaults based on the theme mode.
140
+ ///
141
+ @function daff-configure-text-colors(
142
+ $mode,
143
+ $text-color-default,
144
+ $text-color-inverse
145
+ ) {
146
+ $dark: palette.$black;
147
+ $light: palette.$white;
148
+
149
+ @if ($text-color-default == null) {
150
+ $text-color-default: if($mode == 'light', $dark, $light);
151
+ }
152
+
153
+ @if ($text-color-inverse == null) {
154
+ $text-color-inverse: if($mode == 'light', $light, $dark);
155
+ }
156
+
157
+ @return (
158
+ 'text-color-default': $text-color-default,
159
+ 'text-color-inverse': $text-color-inverse
160
+ );
161
+ }
162
+
163
+ /// @access private
164
+ /// Checks if the optional palettes are set, if not it sets them to defaults based on the theme mode.
165
+ ///
166
+ /// @param {String} $mode - Theme mode ('light' or 'dark')
167
+ /// @param {Color|null} $warn - Warning status color palette
168
+ /// @param {Color|null} $critical - Critical status color palette
169
+ /// @param {Color|null} $success - Success status color palette
170
+ /// @param {Color|null} $informational - Informational status color palette
171
+ /// @param {Color|null} $neutral - Neutral color palette
172
+ ///
173
+ /// @return {Map} Map containing optional color configurations
174
+ ///
175
+ @function daff-configure-optional-palettes(
176
+ $mode,
177
+ $warn,
178
+ $critical,
179
+ $success,
180
+ $informational,
181
+ $neutral
182
+ ) {
183
+ $validate: daff-validate-mode($mode);
184
+ $default-hue: if($mode == 'dark', 50, 60);
185
+ @if ($warn == null) {
186
+ $warn: configure-palette.daff-configure-palette(
187
+ palette.$daff-bronze,
188
+ $default-hue
189
+ );
190
+ }
191
+ @if ($critical == null) {
192
+ $critical: configure-palette.daff-configure-palette(
193
+ palette.$daff-red,
194
+ $default-hue
195
+ );
196
+ }
197
+ @if ($success == null) {
198
+ $success: configure-palette.daff-configure-palette(
199
+ palette.$daff-green,
200
+ $default-hue
201
+ );
202
+ }
203
+ @if ($informational == null) {
204
+ $informational: configure-palette.daff-configure-palette(
205
+ palette.$daff-neutral,
206
+ $default-hue
207
+ );
208
+ }
209
+ @if ($neutral == null) {
210
+ $neutral: configure-palette.daff-configure-palette(
211
+ palette.$daff-neutral,
212
+ $default-hue
213
+ );
214
+ }
215
+ @return (
216
+ 'success': $success,
217
+ 'warn': $warn,
218
+ 'critical': $critical,
219
+ 'informational': $informational,
220
+ 'neutral': $neutral
221
+ );
222
+ }
223
+
224
+ /// @access private
225
+ /// Retrieves and customizes the core theme based on theme mode and optional overrides
226
+ ///
227
+ /// @param {String} $mode - Theme mode ('light' or 'dark')
228
+ /// @param {Map|null} $neutral - Neutral color palette override
229
+ ///
230
+ /// @return {Map} Customized core theme map
231
+ ///
232
+ @function daff-build-theme-core($mode, $neutral) {
233
+ $validate: daff-validate-mode($mode);
234
+ $core: map.get($supported-theme-modes, $mode);
235
+ $core: map.merge(
236
+ $core,
237
+ (
238
+ 'neutral': if($neutral != null, $neutral, map.get($core, 'neutral')),
239
+ )
240
+ );
241
+ @return $core;
242
+ }
243
+
244
+ /// @access private
245
+ /// Validates the configuration map for theme creation
246
+ ///
247
+ /// @param {Map} $config - The theme configuration map to validate
248
+ /// @return {Boolean} True if the configuration is valid
249
+ /// @throws Will throw an error if the configuration is invalid
250
+ ///
251
+ @function daff-verify-config($config) {
252
+ $required-keys: ('primary', 'secondary', 'tertiary');
253
+ $valid-keys: (
254
+ 'mode',
255
+ 'primary',
256
+ 'secondary',
257
+ 'tertiary',
258
+ 'neutral',
259
+ 'informational',
260
+ 'warn',
261
+ 'critical',
262
+ 'success',
263
+ 'text-color-default',
264
+ 'text-color-inverse'
265
+ );
266
+ $color-keys: ('text-color-default', 'text-color-inverse');
267
+
268
+ @each $key in $required-keys {
269
+ @if not map.has-key($config, $key) {
270
+ @error 'The `#{$key}` key is required.';
271
+ }
272
+ }
273
+
274
+ @each $key in map.keys($config) {
275
+ @if not list.index($valid-keys, $key) {
276
+ @error '`#{$key}` is not a valid key.';
277
+ }
278
+
279
+ $value: map.get($config, $key);
280
+ @if $key == 'mode' {
281
+ $validate: daff-validate-mode($value);
282
+ } @else if list.index($color-keys, $key) {
283
+ @if not daff-validate-color($value) {
284
+ @error '"#{$value}" is not a valid color value for the `#{$key}` key.';
285
+ }
286
+ } @else {
287
+ @if not daff-validate-palette($value) {
288
+ @error '"#{$value}" is not a valid color palette for the `#{$key}` key.';
289
+ }
290
+ }
291
+ }
292
+
293
+ @return true;
294
+ }
295
+
296
+ /// @access private
297
+ /// Validates that the theme mode is supported
298
+ ///
299
+ /// @param {String} $value - The theme mode to check
300
+ /// @return {Boolean} True if the value is a valid configured mode, false otherwise
301
+ /// @throws Will throw an error if the mode is not valid
302
+ ///
303
+ @function daff-validate-mode($value) {
304
+ @if (not map.has-key($supported-theme-modes, $value)) {
305
+ @error '`#{$value}` is not a valid theme mode - valid modes: #{map-keys($supported-theme-modes)}';
306
+ }
307
+ @return true;
308
+ }
309
+
310
+ /// @access private
311
+ /// Checks if a value is a properly configured color palette map
312
+ ///
313
+ /// @param {Any} $value - The palette to check
314
+ /// @return {Boolean} True if the value is a valid configured palette, false otherwise
315
+ ///
316
+ @function daff-validate-palette($value) {
317
+ @return meta.type-of($value) == 'map'
318
+ and map.has-key($value, 'default')
319
+ and daff-validate-color(map.get($value, 'default'));
320
+ }
321
+
322
+ /// @access private
323
+ /// Checks if a value is a color
324
+ ///
325
+ /// @param {Any} $value - The value to check
326
+ /// @return {Boolean} True if the value is a valid color, false otherwise
327
+ ///
328
+ @function daff-validate-color($value) {
329
+ @return meta.type-of($value) == 'color';
330
+ }
@@ -0,0 +1,122 @@
1
+ @use 'true' as *;
2
+ @use './create-theme' as *;
3
+ @use '../color-palettes' as palette;
4
+ @use '../get-color';
5
+ @use '../configure-palette';
6
+ @use 'sass:map';
7
+
8
+ @include describe('daff-create-theme') {
9
+ $primary: configure-palette.daff-configure-palette(palette.$daff-blue, 60);
10
+ $secondary: configure-palette.daff-configure-palette(palette.$daff-purple, 60);
11
+ $tertiary: configure-palette.daff-configure-palette(palette.$daff-turquoise, 60);
12
+ $neutral: configure-palette.daff-configure-palette(palette.$daff-neutral, 50);
13
+ $informational: configure-palette.daff-configure-palette(palette.$daff-blue, 40);
14
+ $warn: configure-palette.daff-configure-palette(palette.$daff-bronze, 40);
15
+ $critical: configure-palette.daff-configure-palette(palette.$daff-red, 40);
16
+ $success: configure-palette.daff-configure-palette(palette.$daff-green, 40);
17
+ $text-color-inverse: get-color.daff-color(palette.$daff-neutral, 10);
18
+ $text-color-default: get-color.daff-color(palette.$daff-neutral, 100);
19
+
20
+ $default-daff-light-theme: (
21
+ 'mode': 'light',
22
+ 'base': palette.$white,
23
+ 'base-contrast': palette.$black,
24
+ 'white': palette.$white,
25
+ 'black': palette.$black,
26
+ 'neutral': configure-palette.daff-configure-palette(palette.$daff-neutral, 60),
27
+ );
28
+ $daff-dark-theme: (
29
+ 'mode': 'dark',
30
+ 'base': get-color.daff-color(palette.$daff-neutral, 100),
31
+ 'base-contrast': palette.$white,
32
+ 'white': palette.$white,
33
+ 'black': palette.$black,
34
+ 'neutral': configure-palette.daff-configure-palette(palette.$daff-neutral, 50),
35
+ );
36
+
37
+ @include it('creates a light theme with only required parameters') {
38
+ $config: (
39
+ 'primary': $primary,
40
+ 'secondary': $secondary,
41
+ 'tertiary': $tertiary
42
+ );
43
+ $theme: daff-create-theme($config);
44
+
45
+ @include assert-equal(map.get($theme, 'primary'), $primary);
46
+ @include assert-equal(map.get($theme, 'secondary'), $secondary);
47
+ @include assert-equal(map.get($theme, 'tertiary'), $tertiary);
48
+ @include assert-true(map.has-key($theme, 'core'));
49
+
50
+ $core: map.get($theme, 'core');
51
+ @include assert-equal($core, $default-daff-light-theme);
52
+ }
53
+
54
+ @include it('creates a dark theme when mode is specified') {
55
+ $config: (
56
+ 'mode': 'dark',
57
+ 'primary': $primary,
58
+ 'secondary': $secondary,
59
+ 'tertiary': $tertiary
60
+ );
61
+ $theme: daff-create-theme($config);
62
+ @include assert-equal(map.get($theme, 'primary'), $primary);
63
+ @include assert-equal(map.get($theme, 'secondary'), $secondary);
64
+ @include assert-equal(map.get($theme, 'tertiary'), $tertiary);
65
+ @include assert-true(map.has-key($theme, 'core'));
66
+
67
+ $core: map.get($theme, 'core');
68
+ @include assert-equal($core, $daff-dark-theme);
69
+ }
70
+
71
+ @include it('creates a theme with all optional parameters') {
72
+ $config: (
73
+ 'mode': 'light',
74
+ 'primary': $primary,
75
+ 'secondary': $secondary,
76
+ 'tertiary': $tertiary,
77
+ 'neutral': $neutral,
78
+ 'informational': $informational,
79
+ 'warn': $warn,
80
+ 'critical': $critical,
81
+ 'success': $success,
82
+ 'text-color-inverse': $text-color-inverse,
83
+ 'text-color-default': $text-color-default
84
+ );
85
+ $theme: daff-create-theme($config);
86
+
87
+ @include assert-equal(map.get($theme, 'primary'), $primary);
88
+ @include assert-equal(map.get($theme, 'secondary'), $secondary);
89
+ @include assert-equal(map.get($theme, 'tertiary'), $tertiary);
90
+ @include assert-equal(map.get($theme, 'informational'), $informational);
91
+ @include assert-equal(map.get($theme, 'warn'), $warn);
92
+ @include assert-equal(map.get($theme, 'critical'), $critical);
93
+ @include assert-equal(map.get($theme, 'success'), $success);
94
+ @include assert-equal(map.get($theme, 'text-color-default'), $text-color-default);
95
+ @include assert-equal(map.get($theme, 'text-color-inverse'), $text-color-inverse);
96
+ @include assert-equal(map.get($theme, 'neutral'), $neutral);
97
+
98
+ @include assert-true(map.has-key($theme, 'core'));
99
+ $core: map.get($theme, 'core');
100
+ $expected-core: map.merge($default-daff-light-theme, (
101
+ 'neutral': $neutral,
102
+ ));
103
+ @include assert-equal($core, $expected-core);
104
+ }
105
+
106
+ @include it('provides default status colors when not specified') {
107
+ $config: (
108
+ 'mode': 'light',
109
+ 'primary': $primary,
110
+ 'secondary': $secondary,
111
+ 'tertiary': $tertiary
112
+ );
113
+ $theme: daff-create-theme($config);
114
+
115
+ @include assert-equal(
116
+ map.get($theme, 'informational'), configure-palette.daff-configure-palette(palette.$daff-neutral, 60)
117
+ );
118
+ @include assert-equal(map.get($theme, 'warn'), configure-palette.daff-configure-palette(palette.$daff-bronze, 60));
119
+ @include assert-equal(map.get($theme, 'critical'), configure-palette.daff-configure-palette(palette.$daff-red, 60));
120
+ @include assert-equal(map.get($theme, 'success'), configure-palette.daff-configure-palette(palette.$daff-green, 60));
121
+ }
122
+ }
@@ -0,0 +1 @@
1
+ @forward 'create-theme' show daff-create-theme;
@@ -0,0 +1,36 @@
1
+ @use 'sass:map';
2
+ @use 'sass:list';
3
+ @use '../get-base-color' as *;
4
+
5
+ /// Returns a light and dark color.
6
+ ///
7
+ /// If you are not using Daffodil's default theme, a theme **must** be
8
+ /// created with `daff-create-theme` before this function can be used.
9
+ /// See the [customize your own theme](daff.io/docs/design/theming/customize-your-own-theme)
10
+ /// guide for more information.
11
+ ///
12
+ /// @group Theming
13
+ ///
14
+ /// @param {Map} $theme — A theme map created with the `daff-create-theme` function.
15
+ ///
16
+ /// @return {List} — Returns a list of colors
17
+ ///
18
+ /// @example scss
19
+ /// @use '@daffodil/design/scss/theme' as daff-theme;
20
+ ///
21
+ /// @mixin custom-content-theme($theme) {
22
+ /// $availableColors: daff-theme.daff-get-font-colors($theme);
23
+ /// }
24
+ ///
25
+ @function daff-get-font-colors($theme) {
26
+ @if (map.get($theme, 'text-color-default')) {
27
+ @return (
28
+ map.get($theme, 'text-color-default'),
29
+ map.get($theme, 'text-color-inverse')
30
+ );
31
+ }
32
+ @return (
33
+ daff-get-base-color($theme, 'white'),
34
+ daff-get-base-color($theme, 'black')
35
+ );
36
+ }