@ulu/frontend 0.2.0-beta.8 → 0.2.1

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 (53) hide show
  1. package/README.dev.md +36 -13
  2. package/README.md +3 -1
  3. package/dist/es/core/events.js +36 -25
  4. package/dist/es/core/settings.js +33 -22
  5. package/dist/es/index.js +92 -88
  6. package/dist/es/ui/dialog.js +57 -46
  7. package/dist/es/ui/index.d.ts +2 -0
  8. package/dist/es/ui/modal-builder.js +39 -28
  9. package/dist/es/ui/overflow-scroller.js +30 -24
  10. package/dist/es/ui/programmatic-modal.js +55 -0
  11. package/dist/es/ui/proxy-click.js +37 -26
  12. package/dist/es/ui/resizer.js +57 -49
  13. package/dist/es/ui/slider.d.ts.map +1 -1
  14. package/dist/es/ui/slider.js +90 -67
  15. package/dist/es/ui/tab-manager.d.ts +145 -0
  16. package/dist/es/ui/tab-manager.d.ts.map +1 -0
  17. package/dist/es/ui/tab-manager.js +155 -0
  18. package/dist/es/ui/tabs.d.ts +5 -5
  19. package/dist/es/ui/tabs.d.ts.map +1 -1
  20. package/dist/es/ui/tabs.js +34 -51
  21. package/dist/es/ui/theme-toggle.js +80 -69
  22. package/dist/es/ui/tooltip.js +53 -44
  23. package/dist/es/utils/floating-ui.js +35 -24
  24. package/dist/umd/frontend.css +1 -0
  25. package/dist/umd/ulu-frontend.umd.js +40 -47
  26. package/lib/js/exports.md +1 -0
  27. package/lib/js/ui/index.js +8 -0
  28. package/lib/js/ui/slider.js +3 -3
  29. package/lib/js/ui/tab-manager.js +324 -0
  30. package/lib/js/ui/tabs.js +33 -92
  31. package/lib/scss/_breakpoint.scss +3 -3
  32. package/lib/scss/_button.scss +3 -3
  33. package/lib/scss/_color.scss +3 -2
  34. package/lib/scss/_element.scss +10 -4
  35. package/lib/scss/_layout.scss +11 -4
  36. package/lib/scss/_selector.scss +2 -1
  37. package/lib/scss/_typography.scss +9 -10
  38. package/lib/scss/_utils.scss +52 -19
  39. package/lib/scss/base/_elements.scss +1 -1
  40. package/lib/scss/components/_basic-hero.scss +1 -1
  41. package/lib/scss/components/_button-verbose.scss +2 -2
  42. package/lib/scss/components/_callout.scss +3 -4
  43. package/lib/scss/components/_css-icon.scss +2 -2
  44. package/lib/scss/components/_data-grid.scss +5 -5
  45. package/lib/scss/components/_flipcard.scss +3 -2
  46. package/lib/scss/components/_index.scss +6 -0
  47. package/lib/scss/components/_panel.scss +1 -1
  48. package/lib/scss/components/_popover.scss +9 -6
  49. package/lib/scss/components/_tabs.scss +20 -5
  50. package/lib/scss/components/_tagged.scss +59 -0
  51. package/package.json +25 -35
  52. package/dist/umd/style.css +0 -1
  53. package/lib/js/ui/dialog.todo +0 -3
@@ -5,6 +5,7 @@
5
5
  @use "sass:map";
6
6
  @use "sass:list";
7
7
  @use "sass:meta";
8
+
8
9
  @use "utils";
9
10
  @use "breakpoint";
10
11
  @use "color";
@@ -128,14 +129,20 @@ $containers: (
128
129
  @mixin match-container-margin($property, $name: "container", $include-padding: true) {
129
130
  $container: get-container($name);
130
131
  $breakpoints: map.get($container, "breakpoints");
131
- $padding: if($include-padding, get-container-padding($name, true), 0);
132
+ $padding: 0;
133
+ @if ($include-padding) {
134
+ $padding: get-container-padding($name, true);
135
+ }
132
136
  $max: map.get($container, "max-width");
133
137
  #{ $property }: max(((100vw - $max) / 2) + $padding, $padding);
134
138
  @if $breakpoints {
135
139
  @each $breakpoint, $props in $breakpoints {
136
140
  $direction: map.get($props, "direction");
137
141
  @include breakpoint.from($breakpoint, $direction) {
138
- $pad: if($include-padding, get-container-padding($name, true, $breakpoint), 0);
142
+ $pad: 0;
143
+ @if ($include-padding) {
144
+ $pad: get-container-padding($name, true, $breakpoint);
145
+ }
139
146
  #{ $property }: max(((100vw - $max) / 2) + $pad, $pad);
140
147
  }
141
148
  }
@@ -154,7 +161,7 @@ $containers: (
154
161
  @if (not $is-list) {
155
162
  @return $padding;
156
163
  } @else {
157
- @return list.nth($padding, if($sides, 2, 1));
164
+ @return list.nth($padding, utils.when($sides, 2, 1));
158
165
  }
159
166
  }
160
167
 
@@ -168,7 +175,7 @@ $containers: (
168
175
  $responsive: map.get($container, "responsive");
169
176
  $x: get-container-padding-x($name, $specific-breakpoint);
170
177
  $y: get-container-padding-y($name, $specific-breakpoint);
171
- $resp-amount: if(meta.type-of($responsive) == number, $responsive, utils.get("responsive-change"));
178
+ $resp-amount: utils.when(meta.type-of($responsive) == number, $responsive, utils.get("responsive-change"));
172
179
 
173
180
  @if $responsive {
174
181
  @if $sides {
@@ -5,6 +5,7 @@
5
5
 
6
6
  @use "sass:string";
7
7
  @use "sass:map";
8
+
8
9
  @use "utils";
9
10
 
10
11
  /// Module Settings
@@ -67,7 +68,7 @@ $-class-wildcards: ();
67
68
  // Check if it's a wildcard
68
69
  $wildcard: -get-class-wildcard($class);
69
70
  $override: map.get($-class-overrides, $class);
70
- $updated: if($override, $override, if($wildcard, $wildcard, $class));
71
+ $updated: utils.fallback($override, $wildcard, $class);
71
72
  $name: "#{ get("prefix") }#{ $updated }";
72
73
  @if $name-only {
73
74
  @return $name;
@@ -115,9 +115,8 @@ $config: (
115
115
  /// @param {Number} $base Conversion base (defaults to font-size)
116
116
  /// @return {Number} Rem value
117
117
 
118
- @function em($value, $base: null) {
118
+ @function em($value, $base: get("font-size")) {
119
119
  @if (math.unit($value) == "px") {
120
- $base: if($base, $base, get("font-size"));
121
120
  @return math.div($base, $value) * 1em;
122
121
  } @else {
123
122
  @return $value;
@@ -128,7 +127,7 @@ $config: (
128
127
  /// @param {Boolean} $force Force words to break (will have unusual breaks)
129
128
 
130
129
  @mixin word-break($force: false) {
131
- word-break: if($force, break-all, normal);
130
+ word-break: utils.when($force, break-all, normal);
132
131
  word-break: break-word;
133
132
  hyphens: auto;
134
133
  }
@@ -144,16 +143,16 @@ $config: (
144
143
  @function new-size($font-size, $line-height: true, $is-headline: false) {
145
144
  @return (
146
145
  "font-size": $font-size,
147
- "font-weight" : if($is-headline, get("font-weight-bold"), null),
146
+ "font-weight" : utils.when($is-headline, get("font-weight-bold"), null),
148
147
  "line-height": $line-height,
149
- "margin-bottom" : if($is-headline, get("margin-bottom"), null),
150
- "margin-top" : if($is-headline, get("margin-top"), null),
148
+ "margin-bottom" : utils.when($is-headline, get("margin-bottom"), null),
149
+ "margin-top" : utils.when($is-headline, get("margin-top"), null),
151
150
  "responsive" : true,
152
- "helper-class" : if($is-headline, false, true),
151
+ "helper-class" : utils.when($is-headline, false, true),
153
152
  "helper-class-prefixed" : true,
154
- "base-class" : if($is-headline, true, false),
153
+ "base-class" : utils.when($is-headline, true, false),
155
154
  "base-class-prefixed" : false,
156
- "color" : if($is-headline, color.get("headline"), null)
155
+ "color" : utils.when($is-headline, color.get("headline"), null)
157
156
  );
158
157
  }
159
158
 
@@ -353,7 +352,7 @@ $sizes: get-default-sizes() !default;
353
352
  line-height: get-size-converted-value($size, "line-height");
354
353
  margin-top: get-size-converted-value($size, "margin-top");
355
354
  margin-bottom: get-size-converted-value($size, "margin-bottom");
356
- color: if($color, color.get($color), null);
355
+ color: utils.when($color, color.get($color), null);
357
356
  }
358
357
 
359
358
  // If they have breakpoints, process them
@@ -106,12 +106,12 @@ $config: (
106
106
  /// "h2" : true,
107
107
  /// "h3" : false
108
108
  /// );
109
- /// @if(ulu.utils-included("h2", $include-styles)) {
109
+ /// @if (ulu.utils-included("h2", $include-styles)) {
110
110
  /// h2 {
111
111
  /// font-size: 24px;
112
112
  /// }
113
113
  /// }
114
- /// @if(ulu.utils-included("h3", $include-styles)) {
114
+ /// @if (ulu.utils-included("h3", $include-styles)) {
115
115
  /// h3 {
116
116
  /// font-size: 18px;
117
117
  /// }
@@ -136,6 +136,26 @@ $config: (
136
136
  }
137
137
  }
138
138
 
139
+ /// Selects a value based on a condition (Ternary Function)
140
+ /// - To replace SASS if() which is deprecated see
141
+ /// - Eagerly evaluates arguments (use native @if or if(sass()... if you need lazy evaluation).
142
+ /// @param {*} $condition The condition/value to test for truthiness
143
+ /// @param {*} $true Value if true
144
+ /// @param {*} $false Value if false
145
+ /// @link https://sass-lang.com/documentation/breaking-changes/if-function/
146
+ /// @example scss {compile} Example usage
147
+ /// .test {
148
+ /// color: ulu.utils-when(true, red, blue)
149
+ /// }
150
+ /// @return {*} Either true or false value based on conditions truthiness
151
+
152
+ @function when($condition, $value-true, $value-false) {
153
+ @if $condition {
154
+ @return $value-true;
155
+ }
156
+ @return $value-false;
157
+ }
158
+
139
159
  /// Provide a default when value type is not correct
140
160
  /// @param {String} $type type of value it should be
141
161
  /// @param {String} $value the value to provide if it is that type
@@ -177,13 +197,19 @@ $config: (
177
197
  @function number-info($number, $errors: false) {
178
198
 
179
199
  @if (meta.type-of($number) == 'number') {
180
- $is-unitless: math.is-unitless($number);
181
- @return (
182
- "unit": if($is-unitless, null, math.unit($number)),
183
- "value": if($is-unitless, $number, strip-unit($number)),
184
- "invalid" : false
185
- );
186
-
200
+ @if (math.is-unitless($number)) {
201
+ @return (
202
+ "unit": null,
203
+ "value": $number,
204
+ "invalid" : false
205
+ );
206
+ } @else {
207
+ @return (
208
+ "unit": math.unit($number),
209
+ "value": strip-unit($number),
210
+ "invalid" : false
211
+ );
212
+ }
187
213
  } @else {
188
214
  @if ($errors) {
189
215
  @error "Expected Number, got #{ meta.type-of($number) } for #{ $number }";
@@ -442,7 +468,7 @@ $config: (
442
468
  /// @param {*} $value The value to check
443
469
  /// @param {*} $default The value to return when true
444
470
  @function default($value, $default) {
445
- @return if($value == true, $default, $value);
471
+ @return when($value == true, $default, $value);
446
472
  }
447
473
 
448
474
  /// Replaces all or one occurrence of a string within a string
@@ -456,7 +482,7 @@ $config: (
456
482
  $index: string.index($string, $find);
457
483
 
458
484
  @if ($index) {
459
- $start: if($index == 1, "", string.slice($string, 1, string.length($find) - 1));
485
+ $start: when($index == 1, "", string.slice($string, 1, string.length($find) - 1));
460
486
  $end: string.slice($string, $index + string.length($find));
461
487
  $new: $start + $replace;
462
488
  @if ($all) {
@@ -542,10 +568,17 @@ $config: (
542
568
  /// @throw If the list length > 4 (incorrect syntax for shorthand)
543
569
 
544
570
  @function get-spacing($value) {
545
- $is-list: meta.type-of($value) == "list";
546
- $length: if($is-list, list.length($value), 1);
547
- $single: $length == 1;
548
- $top: if($is-list, list.nth($value, 1), $value); // Top is always the same
571
+ @if (meta.type-of($value) != "list") {
572
+ @return (
573
+ "top" : $value,
574
+ "right" : $value,
575
+ "bottom" : $value,
576
+ "left" : $value,
577
+ );
578
+ }
579
+
580
+ $length: list.length($value);
581
+ $top: list.nth($value, 1); // Top is always the same
549
582
 
550
583
  @if ($length > 4) {
551
584
  @error "Spacing has more than 4 arguments (not correct shorthand)";
@@ -553,9 +586,9 @@ $config: (
553
586
 
554
587
  @return (
555
588
  "top" : $top,
556
- "right" : if($single, $top, list.nth($value, 2)),
557
- "bottom" : if($single, $top, list.nth($value, if($length >= 3, 3, 1))),
558
- "left" : if($single, $top, list.nth($value, if($length == 4, 4, 2)))
589
+ "right" : list.nth($value, 1),
590
+ "bottom" : list.nth($value, when($length >= 3, 3, 1)),
591
+ "left" : list.nth($value, when($length == 4, 4, 2))
559
592
  );
560
593
  }
561
594
 
@@ -831,7 +864,7 @@ $config: (
831
864
  /// @return {Map} The $value if it was a map, else empty map
832
865
 
833
866
  @function ensure-map($value) {
834
- @return if(is-map($value), $value, ());
867
+ @return when(is-map($value), $value, ());
835
868
  }
836
869
 
837
870
  /// Returns true if edge passed is an end (top/bottom)
@@ -88,7 +88,7 @@ $config: (
88
88
  }
89
89
  p {
90
90
  $margin-top: typography.get("margin-top");
91
- margin-top: if($margin-top, $margin-top, 0);
91
+ margin-top: utils.when($margin-top, $margin-top, 0);
92
92
  margin-bottom: typography.get("margin-bottom");
93
93
  }
94
94
  sub, sup {
@@ -81,7 +81,7 @@ $config: (
81
81
  padding-bottom: get("padding-bottom");
82
82
  }
83
83
  #{ $prefix }__content-main {
84
- $min-width: if(get("main-min-width"), get("main-min-width"), get("main-max-width"));
84
+ $min-width: utils.fallback(get("main-min-width"), get("main-max-width"));
85
85
  // Using max/min-width so that we don't need to add selectors to change flex-basis
86
86
  // when centered. Using flex-basis: 0 to allow flexbox to decide the items width
87
87
  // allows it to expand/shrink within. min(100%... Never larger than parent
@@ -136,8 +136,8 @@ $config: (
136
136
  $cap-side: get("cap-side");
137
137
  $cap-defaults: (
138
138
  "offset" : utils.if-type("number", get("border-width"), 0),
139
- "border-radius" : if(get("cap-match-radius"), get("border-radius"), 0),
140
- "padding-adjust" : if(utils.is-side($cap-side), $padding-x, $padding-y)
139
+ "border-radius" : utils.when(get("cap-match-radius"), get("border-radius"), 0),
140
+ "padding-adjust" : utils.when(utils.is-side($cap-side), $padding-x, $padding-y)
141
141
  );
142
142
 
143
143
  #{ $prefix } {
@@ -6,7 +6,6 @@
6
6
  @use "sass:map";
7
7
  @use "sass:meta";
8
8
 
9
-
10
9
  @use "../utils";
11
10
  @use "../selector";
12
11
  @use "../element";
@@ -132,7 +131,7 @@ $styles: (
132
131
  @if (not get("caps-disabled")) {
133
132
  $cap-defaults: (
134
133
  "offset" : get("border-width"),
135
- "border-radius" : if(get("cap-match-radius"), get("border-radius"), null),
134
+ "border-radius" : utils.when(get("cap-match-radius"), get("border-radius"), null),
136
135
  // "padding-adjust" : map.get($padding-info, $cap-side)
137
136
  );
138
137
  @include element.cap(
@@ -187,14 +186,14 @@ $styles: (
187
186
  @if ($cap and $caps-enabled) {
188
187
  $match-radius: utils.if-type("bool", $cap-match-radius, get("cap-match-radius"));
189
188
  // Padding adjust always has to be set (since size could change or padding)
190
- $padding-info: utils.get-spacing(if($padding, $padding, get("padding")));
189
+ $padding-info: utils.get-spacing(utils.fallback($padding, get("padding")));
191
190
  $cap-radius: utils.if-type("number", $border-radius, get("border-radius"));
192
191
  $cap-options: utils.ensure-map(map.get($style, "cap-options"));
193
192
  $cap-defaults: (
194
193
  "size" : map.get(get("cap-options"), "size"),
195
194
  "padding-adjust" : map.get($padding-info, $cap-side),
196
195
  "offset" : $border-width,
197
- "border-radius" : if($match-radius, $cap-radius, null)
196
+ "border-radius" : utils.when($match-radius, $cap-radius, null)
198
197
  );
199
198
 
200
199
  @include element.cap-appearance(
@@ -17,8 +17,8 @@
17
17
 
18
18
  @use "sass:map";
19
19
  @use "sass:math";
20
- @use "../color";
21
20
 
21
+ @use "../color";
22
22
  @use "../utils";
23
23
 
24
24
  /// Module Settings
@@ -322,7 +322,7 @@ $config: (
322
322
 
323
323
  @include for-each-stroke() using ($alt-width, $alt-border-radius) {
324
324
  // $drag-gap-multiplier: map.get($props, "drag-gap-multiplier");
325
- // $drag-gap-multiplier: if($drag-gap-multiplier, $drag-gap-multiplier, 0);
325
+ // $drag-gap-multiplier: utils.when($drag-gap-multiplier, $drag-gap-multiplier, 0);
326
326
  &[class*="css-icon--drag"] {
327
327
  &::before {
328
328
  margin-top: -(($alt-width + $alt-width) * get("drag-gap-multiplier"));
@@ -6,13 +6,13 @@
6
6
  @use "sass:map";
7
7
  @use "sass:math";
8
8
 
9
+ @use "../utils";
9
10
  @use "../breakpoint";
10
11
  @use "../color";
11
12
  @use "../element";
12
13
  @use "../layout";
13
14
  @use "../selector";
14
15
  @use "../typography";
15
- @use "../utils";
16
16
 
17
17
  /// Module Settings
18
18
  /// @type Map
@@ -96,7 +96,7 @@ $config: (
96
96
  @if (not $name) {
97
97
  @return get("gutter");
98
98
  } @else {
99
- $map: if($custom-map, $custom-map, get("extra-breakpoints"));
99
+ $map: utils.fallback($custom-map, get("extra-breakpoints"));
100
100
  $settings: utils.require-map-get($map, $name, "grid [get-gutter]");
101
101
  @return map.get($settings, "gutter");
102
102
  }
@@ -138,7 +138,7 @@ $config: (
138
138
  @mixin create(
139
139
  $columns: get("columns"),
140
140
  $breakpoint: get-default-breakpoint(),
141
- $extra-breakpoints: if(breakpoint.exists("large"), get("extra-breakpoints"), false),
141
+ $extra-breakpoints: utils.when(breakpoint.exists("large"), get("extra-breakpoints"), false),
142
142
  $gutter: get("gutter"),
143
143
  $include-rules: false,
144
144
  $rule-size: get("rule-size"),
@@ -513,7 +513,7 @@ $config: (
513
513
  @include -create-extra-breakpoint(
514
514
  $name: $name,
515
515
  $breakpoint: map.get($options, "breakpoint"),
516
- $gutter: if($g, $g, $gutter),
516
+ $gutter: utils.fallback($g, $gutter),
517
517
  $columns: $columns,
518
518
  $attribute: $attribute,
519
519
  $attribute-item: $attribute-item,
@@ -760,7 +760,7 @@ $config: (
760
760
  $select-rule-row,
761
761
  $between: false
762
762
  ) {
763
- $key: if($between, 'between', $position);
763
+ $key: utils.when($between, 'between', $position);
764
764
 
765
765
  &#{'[#{ $attribute }*="rules-row: #{ $key }"]'} {
766
766
  > #{ $select-item } {
@@ -5,8 +5,9 @@
5
5
  /// Flipcard (content revealed on backside of card after click)
6
6
 
7
7
  @use "sass:map";
8
- @use "../color";
8
+
9
9
  @use "../utils";
10
+ @use "../color";
10
11
  @use "../selector";
11
12
 
12
13
  /// Module Settings
@@ -196,7 +197,7 @@ $config: (
196
197
  }
197
198
  #{ $prefix }__front-content {
198
199
  color: color.get(get("title-color-image"));
199
- @if(get("bottom-shadow")) {
200
+ @if (get("bottom-shadow")) {
200
201
  // bottom position includes padding so that the shadow
201
202
  &::after {
202
203
  content: '';
@@ -54,6 +54,7 @@
54
54
  @forward "hero" as hero-*;
55
55
  @forward "tabs" as tabs-*;
56
56
  @forward "tag" as tag-*;
57
+ @forward "tagged" as tagged-*;
57
58
  @forward "tile-grid" as tile-grid-*;
58
59
  @forward "tile-button" as tile-button-*;
59
60
  @forward "tile-grid-overlay" as tile-grid-overlay-*;
@@ -116,6 +117,7 @@
116
117
  @use "hero";
117
118
  @use "tabs";
118
119
  @use "tag";
120
+ @use "tagged";
119
121
  @use "tile-grid";
120
122
  @use "tile-button";
121
123
  @use "tile-grid-overlay";
@@ -178,6 +180,7 @@ $all-includes: (
178
180
  "hero",
179
181
  "tabs",
180
182
  "tag",
183
+ "tagged",
181
184
  "tile-grid",
182
185
  "tile-button",
183
186
  "tile-grid-overlay",
@@ -254,6 +257,9 @@ $current-includes: $all-includes;
254
257
  @if (list.index($includes, "tag")) {
255
258
  @include tag.styles;
256
259
  }
260
+ @if (list.index($includes, "tagged")) {
261
+ @include tagged.styles;
262
+ }
257
263
  @if (list.index($includes, "callout")) {
258
264
  @include callout.styles;
259
265
  }
@@ -229,7 +229,7 @@ $styles: (
229
229
  font-family: map.get($props, "font-family");
230
230
  color: color.get(map.get($props, "color"));
231
231
  box-shadow: map.get($props, "box-shadow");
232
- flex-grow: if(map.get($props, "grow") == false, 0, 1); // Default is grow
232
+ flex-grow: utils.when(map.get($props, "grow") == false, 0, 1); // Default is grow
233
233
  border-top: element.get-optional-rule-style(map.get($props, "border-top"));
234
234
  border-bottom: element.get-optional-rule-style(map.get($props, "border-bottom"));
235
235
 
@@ -8,9 +8,9 @@
8
8
  @use "sass:map";
9
9
  @use "sass:meta";
10
10
 
11
+ @use "../utils";
11
12
  @use "../selector";
12
13
  @use "../typography";
13
- @use "../utils";
14
14
  @use "../color";
15
15
  @use "../layout";
16
16
  @use "../element";
@@ -298,11 +298,14 @@ $config: (
298
298
  $hypotenuse: utils.hypotenuse($unitless, $unitless);
299
299
  $hypotenuse-half: math.div($hypotenuse, 2);
300
300
  $manual-extent: get("arrow-box-shadow-extent");
301
- $shadow-extent: if(
302
- $manual-extent,
303
- $manual-extent,
304
- if(utils.is-list($box-shadow), utils.box-shadow-extent($box-shadow), 5px)
305
- );
301
+ $shadow-extent: 5px;
302
+
303
+ @if ($manual-extent) {
304
+ $shadow-extent: $manual-extent;
305
+ } @else if (utils.is-list($box-shadow)) {
306
+ $shadow-extent: utils.box-shadow-extent($box-shadow);
307
+ }
308
+
306
309
  $overlap: utils.strip-unit($shadow-extent);
307
310
  $mask-height: utils.add-unit($hypotenuse-half + $overlap, $unit);
308
311
  $mask-width: utils.add-unit($hypotenuse + $overlap, $unit);
@@ -6,13 +6,13 @@
6
6
  @use "sass:map";
7
7
  @use "sass:meta";
8
8
 
9
+ @use "../utils";
9
10
  @use "../color";
10
11
  @use "../selector";
11
12
  @use "../breakpoint";
12
13
  @use "../layout";
13
14
  @use "../typography";
14
15
  @use "../element";
15
- @use "../utils";
16
16
 
17
17
  // Used for function fallback
18
18
  $-fallbacks: (
@@ -43,7 +43,10 @@ $-fallbacks: (
43
43
  /// @prop {Color} indicator-transition-duration [200ms] The transition duration for indicator
44
44
  /// @prop {Color} indicator-scale-start [0] The starting scale for the indicator (set to 1 to disable expanding on click)
45
45
  /// @prop {Color} tab-color [link] The type color for the tabs. This uses color.scss, so the value of this options should be a variable from color.scss.
46
- /// @prop {Color} tab-color-hover [link-hover] The type color for the tabs when hovered or focused. This uses color.scss, so the value of this options should be a variable from color.scss.
46
+ /// @prop {Color} tab-color-hover [link-hover] The type color for the tabs when hovered. This uses color.scss, so the value of this options should be a variable from color.scss.
47
+ /// @prop {Color|null} tab-color-focus [null] The type color for a tab when it has keyboard focus.
48
+ /// @prop {Color} tab-background-color-focus [#eeeeee] The background color for a tab when it has keyboard focus.
49
+ /// @prop {Boolean} tab-hide-native-focus [true] Hides the default browser outline on focused tabs.
47
50
  /// @prop {Color} tab-color-selected [selected] The tab type color when selected. This uses color.scss, so the value of this options should be a variable from color.scss.
48
51
  /// @prop {Color} tab-background-color-selected [null] The tab background color when selected
49
52
  /// @prop {CssValue} tab-font-weight [true] The font weight for the tab, defaults to typography "font-weight-semibold"
@@ -69,6 +72,9 @@ $config: (
69
72
  "indicator-scale-start" : 0,
70
73
  "tab-color" : "type-tertiary",
71
74
  "tab-color-hover" : "selected",
75
+ "tab-color-focus": null,
76
+ "tab-background-color-focus": "selected-background",
77
+ "tab-hide-native-focus": true,
72
78
  "tab-color-selected" : "selected",
73
79
  "tab-background-color-selected" : null,
74
80
  "tab-font-weight" : true,
@@ -159,12 +165,21 @@ $config: (
159
165
  // Add focus so as user clicks item it starts the active state styling
160
166
  &:focus,
161
167
  &[aria-selected="true"] {
162
- outline: none; // We are providing focus styling
168
+ @if get("tab-hide-native-focus") {
169
+ outline: none;
170
+ }
163
171
  &::after {
164
172
  opacity: 1;
165
173
  transform: scaleX(1);
166
174
  }
167
175
  }
176
+ // Add new focus-specific colors
177
+ // Using :focus-visible so it only applies to keyboard focus
178
+ &:focus-visible,
179
+ &[aria-selected="true"]:focus-visible {
180
+ color: color.get(get("tab-color-focus"));
181
+ background-color: color.get(get("tab-background-color-focus"));
182
+ }
168
183
  &[aria-selected="true"] {
169
184
  color: color.get(get("tab-color-selected"));
170
185
  background-color: color.get(get("tab-background-color-selected"));
@@ -209,8 +224,8 @@ $config: (
209
224
  white-space: normal;
210
225
  text-align: left;
211
226
  &::after {
212
- left: if(get("vertical-indicator-left"), 0, auto);
213
- right: if(not get("vertical-indicator-left"), 0, auto);;
227
+ left: utils.when(get("vertical-indicator-left"), 0, auto);
228
+ right: utils.when(not get("vertical-indicator-left"), 0, auto);
214
229
  bottom: 0;
215
230
  top: 0;
216
231
  width: get("indicator-size");
@@ -0,0 +1,59 @@
1
+ ////
2
+ /// @group tagged
3
+ /// Provides styles to tags that should appear as superscripts of their related content. Custom properties --ulu-tagged-y, --ulu-tagged-x, and --ulu-tagged-transform can be adjusted if needed (inline style, in a specific styling for something, etc)
4
+ ////
5
+
6
+ @use "sass:map";
7
+
8
+ @use "../selector";
9
+ @use "../utils";
10
+
11
+ /// Module Settings
12
+ /// @type Map
13
+ /// @prop {Dimension} position-x [-0.75em] Horizontal absolute position of the tag.
14
+ /// @prop {Dimension} position-y [-0.75em] Vertical absolute position of the tag.
15
+ /// @prop {CssValue} icon-opacity [null] Adds a transform styling to the tag.
16
+
17
+ $config: (
18
+ "position-x": 0,
19
+ "position-y": 0,
20
+ "transform": translate(50%, -50%)
21
+ ) !default;
22
+
23
+ /// Change modules $config
24
+ /// @param {Map} $changes Map of changes
25
+ /// @example scss
26
+ /// @include ulu.component-tagged-set(( "property" : value ));
27
+
28
+ @mixin set($changes) {
29
+ $config: map.merge($config, $changes) !global;
30
+ }
31
+
32
+ /// Get a config option
33
+ /// @param {Map} $name Name of property
34
+ /// @example scss
35
+ /// @include ulu.component-tagged-get("property");
36
+
37
+ @function get($name) {
38
+ @return utils.require-map-get($config, $name, "tagged [config]");
39
+ }
40
+
41
+ /// Output component styles
42
+ /// @example scss
43
+ /// @include ulu.component-tagged-styles();
44
+
45
+ @mixin styles {
46
+
47
+ $prefix: selector.class("tagged");
48
+
49
+ #{ $prefix } {
50
+ position: relative;
51
+ }
52
+ #{ $prefix }__tag {
53
+ position: absolute;
54
+ top: var(--ulu-tagged-y, get("position-y"));
55
+ right: var(--ulu-tagged-x, get("position-x"));
56
+ transform: var(--ulu-tagged-transform, get("transform"));
57
+ margin: 0; // So it doesn't interfere if present
58
+ }
59
+ }