@ulu/frontend 0.0.22 → 0.1.0-beta.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 (212) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/deprecated/js/drupal-programmatic-modal.js +91 -0
  3. package/{js/ui/modals.js → deprecated/js/micromodal-modals.js} +41 -67
  4. package/dist/ulu-frontend.min.css +1 -1
  5. package/dist/ulu-frontend.min.js +70 -1
  6. package/index.js +6 -1
  7. package/js/events/index.js +58 -7
  8. package/js/index.js +3 -7
  9. package/js/{helpers/css-breakpoint.js → ui/breakpoints.js} +9 -11
  10. package/js/ui/collapsible.js +195 -0
  11. package/js/ui/dialog.js +157 -0
  12. package/js/ui/dialog.todo +37 -0
  13. package/js/ui/flipcard.js +55 -11
  14. package/js/ui/grid.js +2 -47
  15. package/js/ui/index.js +21 -0
  16. package/js/ui/modal-builder.js +197 -0
  17. package/js/ui/overflow-scroller-pager.js +1 -1
  18. package/js/ui/overflow-scroller.js +8 -5
  19. package/js/ui/page.js +14 -0
  20. package/js/ui/popover.js +135 -0
  21. package/js/ui/print-details.js +44 -0
  22. package/js/ui/print.js +67 -0
  23. package/js/ui/programmatic-modal.js +79 -81
  24. package/js/ui/proxy-click.js +80 -0
  25. package/js/ui/resizer.js +3 -3
  26. package/js/ui/scroll-slider.js +56 -0
  27. package/js/ui/scrollpoint.js +300 -0
  28. package/js/ui/slider.js +72 -10
  29. package/js/ui/tabs.js +85 -58
  30. package/js/ui/theme-toggle.js +129 -0
  31. package/js/ui/tooltip.js +268 -67
  32. package/js/utils/{logger.js → class-logger.js} +6 -5
  33. package/js/utils/dom.js +122 -0
  34. package/js/utils/file-save.js +67 -0
  35. package/js/utils/floating-ui.js +83 -0
  36. package/js/utils/id.js +22 -0
  37. package/js/utils/index.js +7 -0
  38. package/js/{helpers → utils}/pause-youtube-video.js +1 -1
  39. package/package.json +32 -11
  40. package/resources/drupal/twig-macros/accordion.twig +99 -0
  41. package/resources/drupal/twig-macros/dropdown.twig +44 -0
  42. package/resources/drupal/twig-macros/flipcard.twig +69 -0
  43. package/resources/drupal/twig-macros/image.twig +30 -0
  44. package/resources/drupal/twig-macros/layout.twig +338 -0
  45. package/resources/drupal/twig-macros/slider.twig +214 -0
  46. package/resources/drupal/twig-macros/tabs.twig +84 -0
  47. package/scss/README.md +13 -1
  48. package/scss/_breakpoint.scss +69 -26
  49. package/scss/_button.scss +148 -57
  50. package/scss/_color.scss +46 -28
  51. package/scss/_cssvar.scss +103 -12
  52. package/scss/_element.scss +84 -67
  53. package/scss/_index.scss +0 -3
  54. package/scss/_layout.scss +71 -37
  55. package/scss/_path.scss +2 -2
  56. package/scss/_selector.scss +20 -11
  57. package/scss/_typography.scss +115 -82
  58. package/scss/_units.scss +14 -13
  59. package/scss/_utils.scss +280 -18
  60. package/scss/base/_color.scss +2 -1
  61. package/scss/base/_elements.scss +61 -35
  62. package/scss/base/_index.scss +60 -23
  63. package/scss/base/_keyframes.scss +115 -16
  64. package/scss/base/_layout.scss +10 -6
  65. package/scss/base/_normalize.scss +6 -122
  66. package/scss/base/_print.scss +49 -0
  67. package/scss/base/_root.scss +28 -0
  68. package/scss/base/_typography.scss +4 -1
  69. package/scss/components/_accordion.scss +217 -0
  70. package/scss/components/_adaptive-spacing.scss +148 -0
  71. package/scss/components/_badge.scss +17 -14
  72. package/scss/components/_button-verbose.scss +138 -0
  73. package/scss/components/_button.scss +9 -4
  74. package/scss/components/_callout.scss +175 -0
  75. package/scss/components/_captioned-figure.scss +173 -0
  76. package/scss/components/_card-grid.scss +75 -0
  77. package/scss/components/_card.scss +420 -0
  78. package/scss/components/_css-icon.scss +433 -0
  79. package/scss/{_grid.scss → components/_data-grid.scss} +100 -68
  80. package/scss/components/_data-table.scss +180 -0
  81. package/scss/components/_fill-context.scss +20 -22
  82. package/scss/components/_flipcard-grid.scss +66 -0
  83. package/scss/components/_flipcard.scss +304 -0
  84. package/scss/components/_form-theme.scss +633 -0
  85. package/scss/components/_hero.scss +183 -0
  86. package/scss/components/_horizontal-rule.scss +51 -0
  87. package/scss/components/_image-grid.scss +71 -0
  88. package/scss/components/_index.scss +276 -38
  89. package/scss/components/_links.scss +1 -1
  90. package/scss/components/_list-lines.scss +14 -3
  91. package/scss/components/_list-ordered.scss +3 -1
  92. package/scss/components/_list-unordered.scss +3 -1
  93. package/scss/components/_menu-stack.scss +245 -0
  94. package/scss/components/_modal.scss +495 -0
  95. package/scss/components/_nav-strip.scss +148 -0
  96. package/scss/components/_overlay-section.scss +122 -0
  97. package/scss/components/_pager.scss +168 -0
  98. package/scss/components/_placeholder-block.scss +121 -0
  99. package/scss/components/_popover.scss +263 -0
  100. package/scss/components/_pull-quote.scss +111 -0
  101. package/scss/components/_ratio-box.scss +64 -0
  102. package/scss/components/_rule.scss +12 -9
  103. package/scss/components/_scroll-slider.scss +204 -0
  104. package/scss/components/_skip-link.scss +92 -0
  105. package/scss/components/_slider.scss +241 -0
  106. package/scss/components/_spoke-spinner.scss +193 -0
  107. package/scss/components/_tabs.scss +179 -0
  108. package/scss/components/_tag.scss +142 -0
  109. package/scss/components/_tile-button.scss +131 -0
  110. package/scss/components/_tile-grid-overlay.scss +132 -0
  111. package/scss/components/_tile-grid.scss +172 -0
  112. package/scss/components/_vignette.scss +65 -0
  113. package/scss/components/_wysiwyg.scss +94 -0
  114. package/scss/helpers/_color.scss +1 -0
  115. package/scss/helpers/_display.scss +2 -1
  116. package/scss/helpers/_index.scss +45 -22
  117. package/scss/helpers/_print.scss +20 -43
  118. package/scss/helpers/_typography.scss +3 -0
  119. package/scss/helpers/_units.scss +10 -13
  120. package/scss/helpers/_utilities.scss +5 -1
  121. package/scss/stylesheets/base-styles.scss +7 -0
  122. package/scss/stylesheets/component-styles.scss +7 -0
  123. package/scss/stylesheets/helper-styles.scss +7 -0
  124. package/types/events/index.d.ts +1 -1
  125. package/types/events/index.d.ts.map +1 -1
  126. package/types/index.d.ts +2 -2
  127. package/types/{helpers/css-breakpoint.d.ts → ui/breakpoints.d.ts} +3 -3
  128. package/types/ui/breakpoints.d.ts.map +1 -0
  129. package/types/ui/collapsible.d.ts +67 -0
  130. package/types/ui/collapsible.d.ts.map +1 -0
  131. package/types/ui/dialog.d.ts +42 -0
  132. package/types/ui/dialog.d.ts.map +1 -0
  133. package/types/ui/flipcard.d.ts +8 -1
  134. package/types/ui/flipcard.d.ts.map +1 -1
  135. package/types/ui/grid.d.ts +0 -11
  136. package/types/ui/grid.d.ts.map +1 -1
  137. package/types/ui/index.d.ts +23 -0
  138. package/types/ui/index.d.ts.map +1 -0
  139. package/types/ui/modal-builder.d.ts +54 -0
  140. package/types/ui/modal-builder.d.ts.map +1 -0
  141. package/types/ui/overflow-scroller-pager.d.ts +1 -1
  142. package/types/ui/overflow-scroller-pager.d.ts.map +1 -1
  143. package/types/ui/overflow-scroller.d.ts +3 -1
  144. package/types/ui/overflow-scroller.d.ts.map +1 -1
  145. package/types/ui/page.d.ts +5 -0
  146. package/types/ui/page.d.ts.map +1 -0
  147. package/types/ui/popover.d.ts +40 -0
  148. package/types/ui/popover.d.ts.map +1 -0
  149. package/types/ui/print-details.d.ts +10 -0
  150. package/types/ui/print-details.d.ts.map +1 -0
  151. package/types/ui/print.d.ts +10 -0
  152. package/types/ui/print.d.ts.map +1 -0
  153. package/types/ui/programmatic-modal.d.ts +19 -1
  154. package/types/ui/programmatic-modal.d.ts.map +1 -1
  155. package/types/ui/proxy-click.d.ts +18 -0
  156. package/types/ui/proxy-click.d.ts.map +1 -0
  157. package/types/ui/resizer.d.ts +1 -1
  158. package/types/ui/resizer.d.ts.map +1 -1
  159. package/types/ui/scroll-slider.d.ts +13 -0
  160. package/types/ui/scroll-slider.d.ts.map +1 -0
  161. package/types/ui/scrollpoint.d.ts +133 -0
  162. package/types/ui/scrollpoint.d.ts.map +1 -0
  163. package/types/ui/slider.d.ts +14 -2
  164. package/types/ui/slider.d.ts.map +1 -1
  165. package/types/ui/tabs.d.ts +22 -0
  166. package/types/ui/tabs.d.ts.map +1 -1
  167. package/types/ui/theme-toggle.d.ts +14 -0
  168. package/types/ui/theme-toggle.d.ts.map +1 -0
  169. package/types/ui/tooltip.d.ts +92 -10
  170. package/types/ui/tooltip.d.ts.map +1 -1
  171. package/types/utils/{logger.d.ts → class-logger.d.ts} +1 -1
  172. package/types/utils/class-logger.d.ts.map +1 -0
  173. package/types/utils/dom.d.ts +48 -0
  174. package/types/utils/dom.d.ts.map +1 -0
  175. package/types/utils/file-save.d.ts +64 -0
  176. package/types/utils/file-save.d.ts.map +1 -0
  177. package/types/utils/floating-ui.d.ts +19 -0
  178. package/types/utils/floating-ui.d.ts.map +1 -0
  179. package/types/utils/id.d.ts +10 -0
  180. package/types/utils/id.d.ts.map +1 -0
  181. package/types/utils/index.d.ts +9 -0
  182. package/types/utils/index.d.ts.map +1 -0
  183. package/types/utils/pause-youtube-video.d.ts.map +1 -0
  184. package/js/helpers/file-save.js +0 -52
  185. package/js/helpers/scrollbar-width-property.js +0 -14
  186. package/project.todo +0 -22
  187. package/scss/_calculate.scss +0 -64
  188. package/scss/_utility.scss +0 -12
  189. package/types/helpers/css-breakpoint.d.ts.map +0 -1
  190. package/types/helpers/file-save.d.ts +0 -17
  191. package/types/helpers/file-save.d.ts.map +0 -1
  192. package/types/helpers/node-data-manager.d.ts +0 -45
  193. package/types/helpers/node-data-manager.d.ts.map +0 -1
  194. package/types/helpers/pause-youtube-video.d.ts.map +0 -1
  195. package/types/helpers/scrollbar-width-property.d.ts +0 -11
  196. package/types/helpers/scrollbar-width-property.d.ts.map +0 -1
  197. package/types/ui/modals.d.ts +0 -27
  198. package/types/ui/modals.d.ts.map +0 -1
  199. package/types/utils/logger.d.ts.map +0 -1
  200. package/vite.config.js +0 -36
  201. /package/{js/deprecated → deprecated/js}/doc-ready.js +0 -0
  202. /package/{js/deprecated → deprecated/js}/jquery-prototypes.js +0 -0
  203. /package/{js/deprecated → deprecated/js}/mini-collapsible-popper-positioning.js +0 -0
  204. /package/{js/deprecated → deprecated/js}/mini-collapsible.js +0 -0
  205. /package/{js/helpers → deprecated/js}/node-data-manager.js +0 -0
  206. /package/{js/deprecated → deprecated/js}/script-loader.js +0 -0
  207. /package/{js/deprecated → deprecated/js}/waypoints/README.md +0 -0
  208. /package/{js/deprecated → deprecated/js}/waypoints/anchor-menu.js +0 -0
  209. /package/{js/deprecated → deprecated/js}/waypoints/element-waypoint.js +0 -0
  210. /package/{js/deprecated → deprecated/js}/waypoints/examples/page-link-menu.md +0 -0
  211. /package/{js/deprecated → deprecated/js}/waypoints/state-in-attribute.js +0 -0
  212. /package/types/{helpers → utils}/pause-youtube-video.d.ts +0 -0
package/scss/_button.scss CHANGED
@@ -14,45 +14,84 @@
14
14
  @use "utils";
15
15
 
16
16
  // Used for function fallback
17
- $-element-get: meta.get-function("get", false, "element");
18
17
  $-fallbacks: (
19
- "box-shadow" : $-element-get
18
+ "box-shadow": meta.get-function("get", false, "element")
20
19
  );
21
20
 
22
21
  /// Module Settings
23
22
  /// @type Map
23
+ /// @prop {String} active-selector ["&.is-active"] The selector that determines if a button is active
24
+ /// @prop {CssValue} box-shadow [true] Specify box shadow for default button. Default true will fallback to element "box-shadow"
25
+ /// @prop {Number} line-height [1.1] Line height for button
26
+ /// @prop {Dimension} letter-spacing [0.02em]
27
+ /// @prop {Dimension} margin [(0.45em 0.5em 0.45em 0)] Margin for buttons, usually left margin is omitted so buttons can flow inline and make space between them and the next element inline
28
+ /// @prop {Dimension} min-width [9rem] The smallest width for all buttons
29
+ /// @prop {Dimension} padding [(0.75em 1.5em)] Button inner padding value, pass space separated list
30
+ /// @prop {CssValue} white-space [nowrap] Adjust button line wrapping, by default line's are not wrapped
31
+ /// @prop {String} border-color ["control-border"] The border color for the button, usually if there is no border we set this to match the background color so if a button with no borders is adjacent a style that has borders the heights will match.
32
+ /// @prop {String} border-color-hover ["control-border-hover"] Color of border when button is hovered
33
+ /// @prop {String} border-color-active ["control-border-active"] Color of border when a button has active class
34
+ /// @prop {Dimension} border-radius [2rem] Border Radius for button
35
+ /// @prop {Dimension} border-width [1px] Width of button border
36
+ /// @prop {String} background-color ["control-background"] Background color of button
37
+ /// @prop {String} background-color-hover ["control-background-hover"] Background color of button when hovered
38
+ /// @prop {String} background-color-active ["control-background-active"] Background color of button when active
39
+ /// @prop {String} color ["control"] Text color of button
40
+ /// @prop {String} color-hover ["control-hover"] Text color of button when hovered
41
+ /// @prop {String} color-active ["control-active"] Text color of button when active
42
+ /// @prop {CssValue} font-family [inherit] Font family for button
43
+ /// @prop {CssValue} font-weight [bold] Font weight for button
44
+ /// @prop {String} font-size ["base"] Font size for button, can be omitted if it should inherit, sizes can also work with utility type size classes
45
+ /// @prop {Dimension} icon-size [2.5rem] The size of a button when used with an icon
46
+ /// @prop {Dimension} icon-font-size [1.38rem] The font size for the icon when a button is an icon button
47
+ /// @prop {Dimension} icon-border-radius [50%] The border radius of a icon button (defaults to 50% circle)
48
+ /// @prop {CssValue} text-shadow [none] Text shadow for button
49
+ /// @prop {CssValue} text-transform [none] Text transform for button
50
+ /// @prop {CssValue} text-decoration [none] Text decoration of button
51
+ /// @prop {Boolean} transition-enabled [true] Whether or not to enable transitions on button properties like background-color, color, border color as they change state
52
+ /// @prop {Time} transition-duration [200ms] The duration of the button's transition if enabled
53
+ /// @prop {List} transition-properties [(border-color, background-color, color, box-shadow)] The properties to transition if `transition-enabled`
24
54
 
25
55
  $config: (
26
- "padding": (0.75em 1.5em),
27
- "background-color": color.tint(black, 30%),
28
- "background-color-hover": black,
29
- "font-family": inherit,
30
- "white-space" : nowrap,
31
- "font-weight": bold,
56
+ "active-selector": "&.is-active",
57
+ "box-shadow": true,
32
58
  "line-height": 1.1,
33
59
  "letter-spacing": 0.02em,
34
- "text-transform": none,
35
- "text-shadow": none,
36
- "font-size": "base",
37
- "color": white,
38
- "color-hover": white,
39
- "color-active": white,
40
- "box-shadow": true,
41
- "border-radius": 2rem,
42
- "border-width": 0,
43
- "border-color": transparent,
44
- "border-color-hover": transparent,
45
60
  "margin": (0.45em 0.5em 0.45em 0),
46
61
  "min-width": 9rem,
62
+ "padding": (0.75em 1.5em),
63
+ "white-space": nowrap,
64
+ "border-color": "control-border",
65
+ "border-color-active": "control-border-active",
66
+ "border-color-hover": "control-border-hover",
67
+ "border-radius": 2rem,
68
+ "border-width": 1px,
69
+ "background-color": "control-background",
70
+ "background-color-hover": "control-background-hover",
71
+ "background-color-active": "control-background-active",
72
+ "color": "control",
73
+ "color-hover": "control-hover",
74
+ "color-active": "control-active",
75
+ "font-family": inherit,
76
+ "font-weight": bold,
77
+ "font-size": "base",
47
78
  "icon-size": 2.5rem,
48
79
  "icon-font-size": 1.38rem,
49
80
  "icon-border-radius": 50%,
50
- "text-decoration" : none
81
+ "text-shadow": none,
82
+ "text-transform": none,
83
+ "text-decoration": none,
84
+ "transition-enabled": true,
85
+ "transition-duration": 200ms,
86
+ "transition-properties": (border-color, background-color, color, box-shadow),
51
87
  ) !default;
52
-
88
+
53
89
  /// Button sizes
90
+ /// - A map that holds to the sizes for buttons in the theme
91
+ /// - Use set-sizes() to adjust the sizes for the theme
92
+ /// - Don't edit sizes variable directly
54
93
  /// @type Map
55
-
94
+
56
95
  $sizes: (
57
96
  "small" : (
58
97
  "padding": (0.35em 1.5em),
@@ -68,6 +107,8 @@ $sizes: (
68
107
  ) !default;
69
108
 
70
109
  /// Button styles
110
+ /// - A map of styles for each button in the theme. Us set-styles() to overwrite or merge into these styles
111
+ /// - Don't edit styles variable directly
71
112
  /// @type Map
72
113
 
73
114
  $styles: (
@@ -85,7 +126,7 @@ $styles: (
85
126
  "outline" : (
86
127
  "background-color" : transparent,
87
128
  "color" : "type",
88
- "border-color" : "rule",
129
+ "border-color" : "rule-light",
89
130
  "box-shadow" : none,
90
131
  "hover" : (
91
132
  "background-color" : "white",
@@ -95,8 +136,8 @@ $styles: (
95
136
 
96
137
  /// Change modules $config
97
138
  /// @param {Map} $changes Map of changes
98
- /// @example scss - General example, replace module-name with module's name
99
- /// @include module-name.set(( "property" : value ));
139
+ /// @example scss - General example
140
+ /// @include ulu.button-set(( "property" : value ));
100
141
 
101
142
  @mixin set($changes) {
102
143
  $config: map.merge($config, $changes) !global;
@@ -104,15 +145,16 @@ $styles: (
104
145
 
105
146
  /// Get a config option
106
147
  /// @param {Map} $name Name of property
107
- /// @example scss - General example, replace module-name with module's name
108
- /// @include module-name.get("property");
148
+ /// @example scss - General example
149
+ /// @include ulu.button-get("property");
109
150
 
110
151
  @function get($name) {
111
152
  $value: utils.require-map-get($config, $name, "button [config]");
112
153
  @return utils.function-fallback($name, $value, $-fallbacks);
113
154
  }
114
155
 
115
- /// Set button styles
156
+ /// Set button styles
157
+ /// - See $styles for example of structure of map
116
158
  /// @param {Map} $changes Map of changes
117
159
  /// @param {String} $merge-mode Merge mode see utils.map-merge() [null|"deep"|"overwrite"]
118
160
 
@@ -121,6 +163,7 @@ $styles: (
121
163
  }
122
164
 
123
165
  /// Set Button Sizes
166
+ /// - See $sizes for example of structure of map
124
167
  /// @param {Map} $changes Map of changes
125
168
  /// @param {String} $merge-mode Merge mode see utils.map-merge() [null|"deep"|"overwrite"]
126
169
 
@@ -128,7 +171,7 @@ $styles: (
128
171
  $sizes: utils.map-merge($sizes, $changes, $merge-mode) !global;
129
172
  }
130
173
 
131
- /// Print styles to reset browser button style
174
+ /// Reset CSS for button (to change browser defaults for button styling)
132
175
 
133
176
  @mixin reset() {
134
177
  text-transform: none;
@@ -143,7 +186,7 @@ $styles: (
143
186
  cursor: pointer;
144
187
  }
145
188
 
146
- /// Print default button styles
189
+ /// Output the default button styles
147
190
  /// @param {Boolean} $with-reset [false] Include button.reset()
148
191
 
149
192
  @mixin default($with-reset: false) {
@@ -175,12 +218,17 @@ $styles: (
175
218
  white-space: get("white-space");
176
219
  max-width: 100%; // Questionable, not sure if it's needed
177
220
  flex-shrink: 0;
178
- // Should override link visted coloring
221
+ // Should override link visited coloring
222
+
223
+ @if get("transition-enabled") {
224
+ transition-duration: get("transition-duration");
225
+ transition-property: get("transition-properties");
226
+ }
179
227
  &,
180
228
  &:visited {
181
229
  color: color.get(get("color"));
182
- border: get("border-width") solid get("border-color");
183
- background-color: get("background-color");
230
+ border: get("border-width") solid color.get(get("border-color"));
231
+ background-color: color.get(get("background-color"));
184
232
  text-decoration: get("text-decoration");
185
233
  }
186
234
  &:last-child {
@@ -188,14 +236,35 @@ $styles: (
188
236
  }
189
237
  &:hover,
190
238
  &:focus {
191
- color: get("color-hover");
192
- background-color: get("background-color-hover");
193
- border-color: get("border-color-hover");
239
+ color: color.get(get("color-hover"));
240
+ background-color: color.get(get("background-color-hover"));
241
+ border-color: color.get(get("border-color-hover"));
194
242
  text-decoration: get("text-decoration");
195
243
  }
244
+ @include when-active() {
245
+ color: color.get(get("color-active"));
246
+ background-color: color.get(get("background-color-active"));
247
+ border-color: color.get(get("border-color-active"));
248
+ }
196
249
  }
197
250
 
198
- /// Print button size styles for a specifc size
251
+ /// Mixin to wrap in active selectors
252
+ /// - Use to match the button's active selector
253
+ /// @example scss
254
+ /// // Site specific styling for active button
255
+ /// .button {
256
+ /// @include when-active() {
257
+ /// background: linear-gradient(0.25turn, #3f87a6, #ebf8e1, #f69d3c);
258
+ /// }
259
+ /// }
260
+
261
+ @mixin when-active() {
262
+ #{ get("active-selector") } {
263
+ @content;
264
+ }
265
+ }
266
+
267
+ /// Print button size styles for a specific size
199
268
  /// @param {String} $name Name of size from $sizes
200
269
  /// @see $sizes
201
270
  /// @see set-sizes
@@ -218,16 +287,24 @@ $styles: (
218
287
  /// @see set-styles
219
288
  /// @return {*} The property you were trying to get
220
289
 
221
- @function get-style-value($name, $prop, $for-hover: false) {
222
- $is-color-prop: string.index($prop, "color");
290
+ @function get-style-value($name, $prop, $state: null) {
223
291
  $style: utils.require-map-get($styles, $name, 'button [color value]');
224
- $hover: map.get($style, "hover");
225
- $hover: if($hover, $hover, ());
226
- $from: if($for-hover, $hover, $style);
292
+ $state-style: ();
293
+ // If a specific state [hover, active] grab that map
294
+ @if ($state) {
295
+ $state-style: map.get($style, $state);
296
+ $state-style: if($state-style, $state-style, ());
297
+ }
298
+ // From is the map to grab styles from
299
+ $from: if($state, $state-style, $style);
227
300
  $value: map.get($from, $prop);
228
- $value: if($value, $value, map.get($style, $prop)); // Fallback to parent (if hover)
229
301
 
230
- @if (meta.type-of($value) == "string" and $is-color-prop and $value != "inherit" and $value != "transparent") {
302
+ // Fallback to parent (if hover)
303
+ @if ($state == "hover") {
304
+ $value: if($value, $value, map.get($style, $prop));
305
+ }
306
+
307
+ @if (meta.type-of($value) == "string" and string.index($prop, "color")) {
231
308
  @return color.get($value);
232
309
  } @else {
233
310
  @return $value;
@@ -242,13 +319,16 @@ $styles: (
242
319
  /// @see set-styles
243
320
 
244
321
  @mixin style-styles($name) {
245
- background-color: get-style-value($name, "background-color", false);
246
- color: get-style-value($name, "color", false);
247
- border-color: get-style-value($name, "border-color", false);
248
- border-width: get-style-value($name, "border-width", false);
249
- box-shadow: get-style-value($name, "box-shadow", false);
250
- text-decoration: get-style-value($name, "text-decoration", false);
251
- font-weight: get-style-value($name, "font-weight", false);
322
+ background-color: get-style-value($name, "background-color");
323
+ color: get-style-value($name, "color");
324
+ border-color: get-style-value($name, "border-color");
325
+ border-width: get-style-value($name, "border-width");
326
+ box-shadow: get-style-value($name, "box-shadow");
327
+ text-decoration: get-style-value($name, "text-decoration");
328
+ font-weight: get-style-value($name, "font-weight");
329
+ @if get-style-value($name, "transition-duration") {
330
+ transition-duration: get-style-value($name, "transition-duration");
331
+ }
252
332
  }
253
333
 
254
334
  /// Print a button style's base styles (hover styles only)
@@ -259,18 +339,26 @@ $styles: (
259
339
  /// @see set-styles
260
340
 
261
341
  @mixin style-styles-hover($name) {
262
- background-color: get-style-value($name, "background-color", true);
263
- color: get-style-value($name, "color", true);
264
- border-color: get-style-value($name, "border-color", true);
265
- box-shadow: get-style-value($name, "box-shadow", true);
266
- text-decoration: get-style-value($name, "text-decoration", true);
342
+ background-color: get-style-value($name, "background-color", "hover");
343
+ color: get-style-value($name, "color", "hover");
344
+ border-color: get-style-value($name, "border-color", "hover");
345
+ box-shadow: get-style-value($name, "box-shadow", "hover");
346
+ text-decoration: get-style-value($name, "text-decoration", "hover");
347
+ }
348
+
349
+ @mixin style-styles-active($name) {
350
+ @include when-active() {
351
+ background-color: get-style-value($name, "background-color", "active");
352
+ color: get-style-value($name, "color", "active");
353
+ border-color: get-style-value($name, "border-color", "active");
354
+ }
267
355
  }
268
356
 
269
357
  /// Print a button style
270
358
  /// - Includes base/visited styling, and hover/focus state styles
271
359
  /// - To print only one of those states, use style-styles or style-styles-hover
272
360
  /// - By default this mixin prints the buttons base styles along with :visited state.
273
- /// This is to avoid link visted states effecting the button styles (if used in editor areas
361
+ /// This is to avoid link visited states effecting the button styles (if used in editor areas
274
362
  /// or other areas that apply automatic links styling for example. (param below to override behavior)
275
363
  /// @param {String} $name Name of style from $styles
276
364
  /// @param {String} $no-visited [false] Do not include :visited selector for button base styles
@@ -290,4 +378,7 @@ $styles: (
290
378
  &:focus {
291
379
  @include style-styles-hover($name);
292
380
  }
381
+ @include when-active() {
382
+ @include style-styles-active($name);
383
+ }
293
384
  }
package/scss/_color.scss CHANGED
@@ -5,32 +5,47 @@
5
5
  @use "sass:map";
6
6
  @use "sass:meta";
7
7
  @use "sass:string";
8
+ @use "sass:color";
9
+
8
10
  @use "utils";
9
11
  @use "selector";
10
12
 
11
13
  /// The color palette map, can be extended or modified with set() and accessed with get()
12
- /// Note do not use names that start with "--" as those are reserved for custom-properties (pass through) also "inherit" is reserved.
14
+ /// - Note do not use names that start with "var(" which are reserved for custom properties. Also do not use "inherit" or "transparent" as those are reserved.
15
+ /// - The default palette color names are used throughout the system
13
16
  /// @type map
14
17
 
15
18
  $palette: (
16
- "black": black,
17
- "white": white,
18
- "type": black,
19
- "background": white,
20
- "focus": blue,
21
- "error": red,
22
- "warning": orange,
23
- "accent": orange,
24
- "selected" : green,
25
- "box-shadow": rgba(0, 0, 0, 0.349),
26
- "box-shadow:hover" : rgba(0, 0, 0, 0.5),
27
- "rule": gray,
28
- "rule-light": lightgray,
29
- "link": blue,
30
- "link:hover": darkblue,
31
- "link:active": darkblue,
32
- "link:visited": purple,
33
- "bullet": inherit
19
+ "black" : black,
20
+ "white" : white,
21
+ "type" : black,
22
+ "type-secondary" : rgb(82, 82, 82),
23
+ "type-tertiary" : rgb(157, 157, 157),
24
+ "headline" : inherit,
25
+ "background" : white,
26
+ "focus" : blue,
27
+ "error" : red,
28
+ "warning" : orange,
29
+ "accent" : orange,
30
+ "selected" : green,
31
+ "box-shadow" : rgba(0, 0, 0, 0.349),
32
+ "box-shadow-hover" : rgba(0, 0, 0, 0.5),
33
+ "rule" : gray,
34
+ "rule-light" : lightgray,
35
+ "link" : blue,
36
+ "link-hover" : darkblue,
37
+ "link-active" : darkblue,
38
+ "link-visited" : purple,
39
+ "bullet" : inherit,
40
+ "control" : white,
41
+ "control-hover" : white,
42
+ "control-active" : white,
43
+ "control-border" : purple,
44
+ "control-border-hover" : blue,
45
+ "control-border-active" : orange,
46
+ "control-background" : purple,
47
+ "control-background-hover": blue,
48
+ "control-background-active": orange,
34
49
  ) !default;
35
50
 
36
51
  /// Pairs of background-color and color definitions
@@ -53,6 +68,7 @@ $contexts: (
53
68
  );
54
69
 
55
70
  /// Palette entries that are output as classes when using all-color-class-styles
71
+ /// - Use set-color-classes mixin to alter this map
56
72
  $color-classes: (
57
73
  "black" : true,
58
74
  "white" : true,
@@ -62,7 +78,7 @@ $color-classes: (
62
78
  /// Used to override or extend the color palette
63
79
  /// @param {Map} $changes A map to merge into the color palette
64
80
  /// @example scss Setting the error and type color
65
- /// @include color.set((
81
+ /// @include ulu.color-set((
66
82
  /// "type" : #444,
67
83
  /// "error" : orange,
68
84
  /// ));
@@ -73,13 +89,13 @@ $color-classes: (
73
89
 
74
90
  /// Get a color from the palette by name
75
91
  /// @param {String} $name Name of color to get
76
- /// @return {Color} Note if non-string value is passed it is sent back through, along with custom properties and keyword inherit
92
+ /// @return {Color} Note if non-string value is passed it is sent back through, along with custom properties ("var(..." and keywords inherit and transparent. This is by design so that you can always pass a user's colors through this (without having to check if it's a color value or a string [color palette])
77
93
 
78
94
  @function get($name) {
79
95
  // Allow non lookup if the value is already a color (helps with code flow)
80
96
  @if (meta.type-of($name) == "string") {
81
- // Allow custom-properties and keyword inherit to pass through
82
- @if ($name == "inherit" or string.index($name, "var(") == 1) {
97
+ // Allow custom-properties and keyword inherit/transparent to pass through
98
+ @if ($name == "inherit" or $name == "transparent" or string.index($name, "var(") == 1) {
83
99
  @return $name;
84
100
  // Else look up the color from the palette
85
101
  } @else {
@@ -91,13 +107,15 @@ $color-classes: (
91
107
  @return $name;
92
108
  }
93
109
 
94
- /// Set ouput classes for all-color-class-styles
110
+ /// Set output classes for all-color-class-styles
95
111
  /// @param {Map} $changes Map of changes (you can disable defaults this way)
96
112
 
97
113
  @mixin set-color-classes($changes) {
98
114
  $color-classes: map.merge($color-classes, $changes) !global;
99
115
  }
100
116
 
117
+ /// Check if a color is set in the palette
118
+
101
119
  @function exists($name) {
102
120
  $color: map.get($palette, $name);
103
121
  @return if($color != null, true, false);
@@ -108,7 +126,7 @@ $color-classes: (
108
126
  /// @param {Map} $deep Use deep merge
109
127
  /// @param {Map} $overwrite Overwrite the completly (cannot be used with deep)
110
128
  /// @example scss Overwriting contexts
111
- /// @include color.set-contexts((
129
+ /// @include ulu.color-set-contexts((
112
130
  /// "dark" : (
113
131
  /// "background-color" : red,
114
132
  /// "color" : white,
@@ -135,7 +153,7 @@ $color-classes: (
135
153
  @function get-context-value($name, $prop) {
136
154
  $context: get-context($name);
137
155
  $value: map.get($context, $prop);
138
- // Get from pallete by name
156
+ // Get from palette by name
139
157
  @if (meta.type-of($value) == "string") {
140
158
  $value: get($value);
141
159
  }
@@ -161,7 +179,7 @@ $color-classes: (
161
179
  /// @link https://css-tricks.com/snippets/sass/tint-shade-functions/ Modified from source (CSS Tricks, Kitty Giraudel)
162
180
 
163
181
  @function tint($color, $percentage) {
164
- @return mix(get("white"), get($color), $percentage);
182
+ @return color.mix(get("white"), get($color), $percentage);
165
183
  }
166
184
 
167
185
  /// Darken a color with the default black by a percentage
@@ -172,7 +190,7 @@ $color-classes: (
172
190
  /// @link https://css-tricks.com/snippets/sass/tint-shade-functions/ Modified from source (CSS Tricks, Kitty Giraudel)
173
191
 
174
192
  @function shade($color, $percentage) {
175
- @return mix(get("black"), get($color), $percentage);
193
+ @return color.mix(get("black"), get($color), $percentage);
176
194
  }
177
195
 
178
196
  /// Prints all context styles
package/scss/_cssvar.scss CHANGED
@@ -6,12 +6,14 @@
6
6
  @use "sass:meta";
7
7
  @use "sass:map";
8
8
  @use "sass:string";
9
+ @use "sass:list";
10
+
9
11
  @use "utils";
10
12
  @use "breakpoint";
11
13
 
12
14
  /// Module Settings
13
15
  /// @type Map
14
- /// @prop {String} prefix [""] Default prefix, will be added to all custom properties when using mixin or functions, unless overriden, set to empty quotes to disable
16
+ /// @prop {String} prefix [""] Default prefix, will be added to all custom properties when using mixin or functions, unless overridden, set to empty quotes to disable
15
17
 
16
18
  $config: (
17
19
  "prefix" : ""
@@ -19,7 +21,7 @@ $config: (
19
21
 
20
22
  /// Change modules $config
21
23
  /// @example scss Setting the prefix to 'ulu'
22
- /// @include cssvar.set(( "prefix" : "ulu" ));
24
+ /// @include ulu.cssvar-set(( "prefix" : "ulu" ));
23
25
  /// @param {Map} $changes Map of changes
24
26
 
25
27
  @mixin set($changes) {
@@ -28,7 +30,7 @@ $config: (
28
30
 
29
31
  /// Get a config option
30
32
  /// @example scss Getting the config value for prefix
31
- /// $prefix: cssvar.get("prefix");
33
+ /// $prefix: ulu.cssvar-get("prefix");
32
34
  /// @param {String} $name Name of property
33
35
  /// @return {*} Map property value
34
36
 
@@ -38,7 +40,7 @@ $config: (
38
40
 
39
41
  /// Get a custom property name (with optional prefix)
40
42
  /// @example scss Getting a custom property name
41
- /// #{ cssvar.name("base-color") } { ... }
43
+ /// #{ ulu.cssvar-name("base-color") } { ... }
42
44
  /// @param {String} $name Name of custom property
43
45
  /// @param {String} $prefix [$config.prefix] Override default prefix
44
46
  /// @return {String} The formatted property name (unquoted string)
@@ -51,23 +53,28 @@ $config: (
51
53
  }
52
54
  }
53
55
 
54
- /// Function to use a custom property within a declartion value
56
+ /// Function to use a custom property within a declaration value
55
57
  /// @example scss Print an custom property as a value
56
58
  /// .test {
57
- /// color: cssvar.use("base-color");
59
+ /// color: ulu.cssvar-use("base-color");
58
60
  /// }
59
61
  /// @param {String} $name Name of custom property
62
+ /// @param {String} $default-value [null] Provide a default value for var()
60
63
  /// @param {String} $prefix [$config.prefix] Override default prefix
61
- /// @return {String} Formatted custom propety for use in property value (ie. var(...))
64
+ /// @return {String} Formatted custom property for use in property value (ie. var(...))
62
65
 
63
- @function use($name, $prefix: get("prefix")) {
64
- @return var(name($name, $prefix));
66
+ @function use($name, $default-value: null, $prefix: get("prefix")) {
67
+ @if ($default-value) {
68
+ @return var(name($name, $prefix), $default-value);
69
+ } @else {
70
+ @return var(name($name, $prefix));
71
+ }
65
72
  }
66
73
 
67
74
  /// Outputs a single custom property declaration
68
75
  /// @example scss Declare a custom property
69
76
  /// :root {
70
- /// @include cssvar.declare("base-color", red);
77
+ /// @include ulu.cssvar-declare("base-color", red);
71
78
  /// }
72
79
  /// @param {String} $name Name of property
73
80
  /// @param {*} $value The properties value to declare
@@ -80,7 +87,7 @@ $config: (
80
87
  /// Outputs a map as custom properties
81
88
  /// @example scss Declare each property in a map as a custom property
82
89
  /// :root {
83
- /// @include cssvar.declare($colors);
90
+ /// @include ulu.cssvar-declare($colors);
84
91
  /// }
85
92
  /// @param {Map} $props Properties to declare
86
93
  /// @param {String} $prefix [$config.prefix] Override default prefix
@@ -94,7 +101,7 @@ $config: (
94
101
  /// Declare a custom property for current breakpoint
95
102
  /// @example scss Declare each property in a map as a custom property
96
103
  /// :root {
97
- /// @include cssvar.declare-breakpoint();
104
+ /// @include ulu.cssvar-declare-breakpoint();
98
105
  /// }
99
106
  /// @param {Map} $breakpoints [breakpoint.get-sizes()] Breakpoints to declare
100
107
  /// @param {String} $name ["breakpoint"] Name to use for custom property
@@ -113,4 +120,88 @@ $config: (
113
120
  @include declare($name, $size, $prefix);
114
121
  }
115
122
  }
123
+ }
124
+
125
+ /// Declare a custom property for each breakpoint size
126
+ /// @example scss Declare each property in a map as a custom property
127
+ /// :root {
128
+ /// @include ulu.cssvar-declare-breakpoint-sizes();
129
+ /// }
130
+ /// @param {Map} $breakpoints [breakpoint.get-sizes()] Breakpoints to declare
131
+ /// @param {String} $name ["breakpoint-size-"] Name to use for custom property (prefixes size name)
132
+ /// @param {String} $prefix [$config.prefix] Override default prefix
133
+
134
+ @mixin declare-breakpoint-sizes(
135
+ $breakpoints: breakpoint.get-sizes(),
136
+ $name: "breakpoint",
137
+ $prefix: get("prefix"),
138
+ ) {
139
+ @each $size, $value in $breakpoints {
140
+ $min: breakpoint.get-size-value($size);
141
+ $max: breakpoint.get-size-value($size, true);
142
+ @include declare("#{ $name }-#{ $size }-min", $min, $prefix);
143
+ @include declare("#{ $name }-#{ $size }-max", $max, $prefix);
144
+ }
145
+ }
146
+
147
+ /// Outputs css vars for a specific type from a theme map
148
+ /// @param {Map} $theme The map containing the values. Example (
149
+ /// @param {String} $key The key used to retrieve values from the map.
150
+ /// @param {String} $prefix The optional prefix for CSS variables.
151
+ /// @example scss - Example of theme map and usage
152
+ /// // Defining a map to hold my color theme values
153
+ /// $color-themes: (
154
+ /// "color-button" : (
155
+ /// "light" : blue,
156
+ /// "dark" : red
157
+ /// ), ...
158
+ /// );
159
+ ///
160
+ /// // Declaring default theme
161
+ /// :root {
162
+ /// @include ulu.cssvar-declare-theme-values($color-themes, "light");
163
+ /// }
164
+ ///
165
+ /// // Creating class to use on body/other elements to switch to dark theme
166
+ /// .theme-dark {
167
+ /// @include ulu.cssvar-declare-theme-values($color-themes, "dark");
168
+ /// }
169
+
170
+ @mixin declare-theme-values($theme, $key, $prefix: get("prefix")) {
171
+ @each $name, $definition in $theme {
172
+ $value: map.get($definition, $key);
173
+ @if ($value) {
174
+ @include declare($name, $value, $prefix);
175
+ }
176
+ }
177
+ }
178
+
179
+ /// Joins a list of cssvar names
180
+ /// - Use to "+", "-" and then use in calc
181
+ /// @param {List} $names list of names (string), like if using use
182
+ /// @param {String} $separator Separator to use when joining custom property var statements
183
+ /// @return {String} For example if separator was "+" would result in "var(--some-prop) + var(--another-prop)"
184
+
185
+ @function join($names, $separator) {
186
+ $values: ();
187
+ @each $name in $names {
188
+ $values: append($values, use($name));
189
+ }
190
+ @return utils.list-join($values, $separator);
191
+ }
192
+
193
+ /// For any names passed will join them with "+" and wrap in calc
194
+ /// @param {String} $name Name string (pass multiple comma separated)
195
+ /// @return {String} A string like "calc(var(--some-prop) + var(--another-prop))"
196
+
197
+ @function add($names...) {
198
+ @return calc(join($names, "+"));
199
+ }
200
+
201
+ /// For any names passed will join them with "-" and wrap in calc
202
+ /// @param {String} $name Name string (pass multiple comma separated)
203
+ /// @return {String} A string like "calc(var(--some-prop) - var(--another-prop))"
204
+
205
+ @function subtract($names...) {
206
+ @return calc(join($names, "-"));
116
207
  }