@ulu/frontend 0.4.0 → 0.4.2

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.
@@ -8,6 +8,39 @@
8
8
  @use "../utils";
9
9
  @use "../cssvar";
10
10
 
11
+ /// Module Settings
12
+ /// @type Map
13
+ /// @prop {Dimension} sticky-top-offset [0px]
14
+ /// @prop {Dimension} sticky-bottom-offset [0px]
15
+
16
+ $config: (
17
+ "sticky-top-offset": 0px,
18
+ "sticky-bottom-offset": 0px
19
+ ) !default;
20
+
21
+ /// Change modules $config
22
+ /// @param {Map} $changes Map of changes
23
+ @mixin set($changes) {
24
+ $config: map.merge($config, $changes) !global;
25
+ }
26
+
27
+ /// Get a config option
28
+ /// @param {String} $name Name of property
29
+ @function get($name) {
30
+ @return utils.require-map-get($config, $name, "base root [config]");
31
+ }
32
+
33
+ /// Global root variables (CSS Custom Properties)
34
+ /// @type Map
35
+ $cssvars: () !default;
36
+
37
+ /// Set global root variables
38
+ /// @param {Map} $changes Map of changes
39
+ /// @param {String} $merge-mode Merge mode see utils.map-merge() [null|"deep"|"overwrite"]
40
+ @mixin set-cssvars($changes, $merge-mode: null) {
41
+ $cssvars: utils.map-merge($cssvars, $changes, $merge-mode) !global;
42
+ }
43
+
11
44
  /// Output custom properties in :root for base stylesheet
12
45
  /// @example scss
13
46
  /// @include ulu.base-root-styles();
@@ -18,13 +51,14 @@
18
51
  :root {
19
52
  @include custom-properties();
20
53
  @include cssvar.declare-breakpoint();
54
+ @include cssvar.declare-all($cssvars);
21
55
  }
22
56
  }
23
57
 
24
58
  /// Output custom properties for ulu
25
59
 
26
60
  @mixin custom-properties() {
27
- --ulu-sticky-top-offset: 0px; // Should be adjusted by user
28
- --ulu-sticky-bottom-offset: 0px; // Should be adjusted by user
61
+ --ulu-sticky-top-offset: #{ get("sticky-top-offset") }; // Should be adjusted by user
62
+ --ulu-sticky-bottom-offset: #{ get("sticky-bottom-offset") }; // Should be adjusted by user
29
63
  --ulu-scrollbar-width: 0px; // Needs to be set by JS
30
64
  }
@@ -0,0 +1,143 @@
1
+ ////
2
+ /// @group themes
3
+ /// Output base themes stylesheets
4
+ ////
5
+
6
+ @use "sass:list";
7
+ @use "sass:string";
8
+ @use "sass:map";
9
+ @use "../utils";
10
+ @use "../themes";
11
+ @use "../cssvar";
12
+ @use "../selector";
13
+
14
+ /// Module Settings
15
+ /// @type Map
16
+ /// @prop {Boolean} output-inverse [true] Whether to output the `.theme-inverse` utility and corresponding inverse variables
17
+ /// @prop {Color} fake-dark-color [white] The fallback text color applied to elements using the `.theme-dark-fake` utility
18
+ /// @prop {String} fake-dark-filter [invert(1) hue-rotate(180deg) saturate(0.7)] The filter applied to elements using the `.theme-dark-fake` utility
19
+ $config: (
20
+ "output-inverse": true,
21
+ "fake-dark-color": white,
22
+ "fake-dark-filter": invert(1) hue-rotate(180deg) saturate(0.7)
23
+ ) !default;
24
+
25
+ /// Change modules $config
26
+ /// @param {Map} $changes Map of changes
27
+ @mixin set($changes) {
28
+ $config: map.merge($config, $changes) !global;
29
+ }
30
+
31
+ /// Get a config option
32
+ /// @param {String} $name Name of property
33
+ @function get($name) {
34
+ @return utils.require-map-get($config, $name, "base themes [config]");
35
+ }
36
+
37
+ /// Outputs base theme variables and classes
38
+ /// @example scss
39
+ /// @include ulu.base-themes-styles();
40
+ @mixin styles {
41
+ @include utils.file-header('base', 'themes');
42
+
43
+ @if (list.length(themes.$tokens) > 0) {
44
+ $keys: themes.get-keys();
45
+ $default: themes.get("default");
46
+ $prefix: selector.class("theme");
47
+ $dark-selectors: ();
48
+ $inverses: themes.get("inverses");
49
+ $inverse-prefix: selector.class("theme-inverse");
50
+ $output-inverse: get("output-inverse");
51
+
52
+ // 1. Build Base Themes
53
+ @each $key in $keys {
54
+ $selectors: ();
55
+ $selectors: list.append($selectors, "#{ $prefix }-#{ $key }", comma);
56
+
57
+ @if ($key == $default) {
58
+ $selectors: list.append($selectors, ":root", comma);
59
+ }
60
+
61
+ #{ $selectors } {
62
+ // Standard color-scheme and CSS vars
63
+ $color-scheme: themes.get-color-scheme($key);
64
+ @if ($color-scheme) {
65
+ color-scheme: #{ $color-scheme };
66
+ }
67
+ @include themes.declare($key);
68
+
69
+ // Optional Inverse Variables (Variable Swap Approach)
70
+ // Can use @scope in the future but for now we suffix -"inverse"
71
+ @if ($output-inverse) {
72
+ $inverse-key: map.get($inverses, $key);
73
+ @if ($inverse-key) {
74
+ $inv-scheme: themes.get-color-scheme($inverse-key);
75
+ @if ($inv-scheme) {
76
+ --ulu-inverse-color-scheme: #{ $inv-scheme };
77
+ }
78
+
79
+ @each $prop, $theme-map in themes.$tokens {
80
+ @if (utils.is-map($theme-map)) {
81
+ $inv-value: map.get($theme-map, $inverse-key);
82
+ @if ($inv-value) {
83
+ // Only output the inverse variable, not its fallback!
84
+ @include cssvar.declare("inverse-#{$prop}", $inv-value);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+
91
+ // Contextual trigger for the fake dark utility
92
+ @if ($color-scheme == "dark") {
93
+ --ulu-theme-fake-filter: #{ get("fake-dark-filter") };
94
+ --ulu-theme-fake-color: #{ get("fake-dark-color") };
95
+ } @else {
96
+ --ulu-theme-fake-filter: none;
97
+ --ulu-theme-fake-color: inherit;
98
+ }
99
+ }
100
+
101
+ // Collect dark themes for the fake utility
102
+ @if (themes.get-color-scheme($key) == "dark") {
103
+ $dark-selectors: list.append($dark-selectors, $selectors, comma);
104
+ // Ensure fake dark applies to inverted light themes
105
+ @each $current-theme, $inverse-target in $inverses {
106
+ @if ($inverse-target == $key) {
107
+ $dark-selectors: list.append($dark-selectors, "#{ $prefix }-#{ $current-theme } #{ $inverse-prefix }", comma);
108
+ @if ($current-theme == $default) {
109
+ $dark-selectors: list.append($dark-selectors, ":root #{ $inverse-prefix }", comma);
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+
116
+ // 2. The Inverse Utility Class
117
+ @if ($output-inverse and list.length(map.keys($inverses)) > 0) {
118
+ #{ $inverse-prefix } {
119
+ color-scheme: var(--ulu-inverse-color-scheme, inherit);
120
+ @each $prop, $theme-map in themes.$tokens {
121
+ @if (utils.is-map($theme-map)) {
122
+ $inv-name: cssvar.name("inverse-" + $prop);
123
+ // Swap them: --site-color-bg: var(--site-inverse-color-bg)
124
+ @include cssvar.declare($prop, var(#{ $inv-name }));
125
+ }
126
+ }
127
+ }
128
+ }
129
+
130
+ // 3. The Fake Dark Utility Class
131
+ /// Can be used on elements that need dark mode but that have colors that can't be updated (canvas charts for example)
132
+ /// It inverts the items color, and then inverts/spins the element colors so they match the hue before inversion
133
+ /// It also decreases the contrast slightly
134
+ @if (list.length($dark-selectors) > 0) {
135
+ #{ $dark-selectors } {
136
+ #{ $prefix }-dark-fake {
137
+ filter: var(--ulu-theme-fake-filter, none);
138
+ color: var(--ulu-theme-fake-color, inherit);
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
@@ -19,11 +19,15 @@
19
19
  /// @prop {Dimension} border-width [1px] Flipcard border width
20
20
  /// @prop {Color} border-color ["rule-light"] Flipcard border color
21
21
  /// @prop {Dimension} border-radius [6px] Border radius for flipcard.
22
- /// @prop {Color} border-color-hover ["rule-dark"] border color when hovered.
22
+ /// @prop {Color} border-color-hover ["rule"] border color when hovered.
23
23
  /// @prop {Dimension} border-width-focus [3px] Border width that shows when focused.
24
24
  /// @prop {Color} border-color-focus ["focus"] border color when focused
25
25
  /// @prop {Time} anim-duration [430ms] Animation duration.
26
26
  /// @prop {Time} anim-delay [200ms] Animation delay.
27
+ /// @prop {String} anim-front-close ["FlipcardFrontClose"] Animation name for front close.
28
+ /// @prop {String} anim-front-open ["FlipcardFrontOpen"] Animation name for front open.
29
+ /// @prop {String} anim-back-open ["FlipcardBackOpen"] Animation name for back open.
30
+ /// @prop {CssValue} anim-timing-function [ease-out] Animation timing function.
27
31
  /// @prop {Dimension} padding [1.5rem] Padding for the flipcard.
28
32
  /// @prop {Color} title-color ["type"] Color of the front page text.
29
33
  /// @prop {Color} title-color-hover ["link-hover"] Color of the front page text when hovered or focused.
@@ -71,13 +71,13 @@ $config: (
71
71
  "animation-initial-duration" : 500ms,
72
72
  "animation-initial-timing" : ease-in,
73
73
  "animation-indeterminate-duration" : 2.5s
74
- ) !default;
74
+ ) !default;
75
75
 
76
- /// @type Map
77
- /// This is the map of styles (variations in progress bar types)
78
- /// - Each style becomes the modifier and accepts ("bar-color", "bar-height", "track-color")
79
- /// - Use this to match whatever progress system(s) your creating
80
- $styles: (
76
+ /// @type Map
77
+ /// This is the map of styles (variations in progress bar types)
78
+ /// - Each style becomes the modifier and accepts ("bar-color", "bar-height", "track-color")
79
+ /// - Use this to match whatever progress system(s) your creating
80
+ $styles: (
81
81
  "success" : (
82
82
  "bar-color" : "success",
83
83
  "icon-color" : "success"
@@ -97,7 +97,7 @@ $config: (
97
97
  "bar-height" : 4px,
98
98
  "track-color" : transparent,
99
99
  )
100
- ) !default;
100
+ ) !default;
101
101
 
102
102
  /// Change modules $config
103
103
  /// @param {Map} $changes Map of changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "A framework-agnostic frontend toolkit providing a modular, tree-shakable library of accessible components and utilities. Designed for seamless integration, it features a highly configurable SCSS system for any environment and vanilla JavaScript modules optimized for traditional websites and content management systems.",
5
5
  "type": "module",
6
6
  "files": [