@allxsmith/bestax-bulma 5.40.0 → 5.42.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 (40) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Carousel.js +282 -103
  4. package/dist/esm/components/Carousel.js.map +1 -1
  5. package/dist/esm/components/Menu.js +77 -2
  6. package/dist/esm/components/Menu.js.map +1 -1
  7. package/dist/esm/components/Modal.js +3 -3
  8. package/dist/esm/components/Modal.js.map +1 -1
  9. package/dist/esm/components/Popover.js +2 -2
  10. package/dist/esm/components/Popover.js.map +1 -1
  11. package/dist/esm/components/Sidebar.js +2 -2
  12. package/dist/esm/components/Sidebar.js.map +1 -1
  13. package/dist/esm/elements/Image.js +4 -12
  14. package/dist/esm/elements/Image.js.map +1 -1
  15. package/dist/esm/helpers/useFocusTrap.js +60 -41
  16. package/dist/esm/helpers/useFocusTrap.js.map +1 -1
  17. package/dist/extras.css +1 -1
  18. package/dist/extras.css.map +1 -1
  19. package/dist/index.cjs +442 -181
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.esm.js +1 -1
  22. package/dist/types/components/Carousel.d.ts +96 -8
  23. package/dist/types/components/Menu.d.ts +49 -0
  24. package/dist/types/elements/Image.d.ts +6 -1
  25. package/dist/types/helpers/useFocusTrap.d.ts +16 -8
  26. package/dist/types-cjs/components/Carousel.d.ts +96 -8
  27. package/dist/types-cjs/components/Menu.d.ts +49 -0
  28. package/dist/types-cjs/elements/Image.d.ts +6 -1
  29. package/dist/types-cjs/helpers/useFocusTrap.d.ts +16 -8
  30. package/dist/versions/bestax-no-dark-mode.css +1 -1
  31. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  32. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  33. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  34. package/dist/versions/bestax-no-helpers.css +1 -1
  35. package/dist/versions/bestax-no-helpers.css.map +1 -1
  36. package/dist/versions/bestax-prefixed.css +1 -1
  37. package/dist/versions/bestax-prefixed.css.map +1 -1
  38. package/package.json +6 -6
  39. package/src/scss/components/_carousel.scss +77 -24
  40. package/src/scss/components/_menu.scss +130 -3
@@ -1,6 +1,12 @@
1
1
  // Carousel component styles
2
2
  @use "bulma/sass/utilities/initial-variables" as iv;
3
3
  @use "bulma/sass/utilities/css-variables" as cv;
4
+ @use "bulma/sass/utilities/mixins" as mx;
5
+
6
+ // The space between two items in view, left out at the track's edges. A
7
+ // length, so `0px` rather than `0`: the track's offset adds it to a
8
+ // percentage inside `calc()`, where a bare `0` is not a length.
9
+ $carousel-item-gap: 0px !default;
4
10
 
5
11
  // Carousel-specific SCSS sizing variables
6
12
  $carousel-arrow-size: 48px !default;
@@ -126,10 +132,70 @@ $carousel-indicator-line-radius: cv.getVar("radius-small") !default;
126
132
  "carousel-overlay-indicator-background-active": #{$carousel-overlay-indicator-background-active},
127
133
  "carousel-transition-duration": #{$carousel-transition-duration},
128
134
  "carousel-fade-duration": #{$carousel-fade-duration},
135
+ "carousel-item-gap": #{$carousel-item-gap},
136
+ // How many items are in view. `Carousel` writes each `itemsToShow*`
137
+ // prop it is given as the variable of the same name on its own
138
+ // element; the rest fall back the way the props do, each viewport to
139
+ // the next narrower one and all of them to `itemsToShow`. Declared
140
+ // here, on every carousel, so one nested in another's items starts
141
+ // from its own props rather than inheriting the outer one's.
142
+ "carousel-items-to-show": 1,
143
+ "carousel-items-to-show-mobile": #{cv.getVar("carousel-items-to-show")},
144
+ "carousel-items-to-show-tablet": #{cv.getVar("carousel-items-to-show")},
145
+ "carousel-items-to-show-desktop": #{cv.getVar("carousel-items-to-show-tablet")},
146
+ "carousel-items-to-show-widescreen": #{cv.getVar("carousel-items-to-show-desktop")},
147
+ "carousel-items-to-show-fullhd": #{cv.getVar("carousel-items-to-show-widescreen")},
148
+ // The count for the viewport the page is in, which the item widths and
149
+ // the track's offset both read. Bulma's breakpoint mixins below pick
150
+ // the tablet count and wider; every width they don't reach is mobile,
151
+ // as it is to the script. A `mobile` block of its own would leave out
152
+ // the fractional widths between Bulma's `mobile` query (up to 768px)
153
+ // and its `tablet` one (from 769px), where the two would disagree.
154
+ "carousel-items-in-view": #{cv.getVar("carousel-items-to-show-mobile")},
129
155
  )
130
156
  );
131
157
  }
132
158
 
159
+ @include mx.tablet {
160
+ .#{iv.$class-prefix}carousel {
161
+ @include cv.register-vars(
162
+ (
163
+ "carousel-items-in-view": #{cv.getVar("carousel-items-to-show-tablet")},
164
+ )
165
+ );
166
+ }
167
+ }
168
+
169
+ @include mx.desktop {
170
+ .#{iv.$class-prefix}carousel {
171
+ @include cv.register-vars(
172
+ (
173
+ "carousel-items-in-view": #{cv.getVar("carousel-items-to-show-desktop")},
174
+ )
175
+ );
176
+ }
177
+ }
178
+
179
+ @include mx.widescreen {
180
+ .#{iv.$class-prefix}carousel {
181
+ @include cv.register-vars(
182
+ (
183
+ "carousel-items-in-view": #{cv.getVar("carousel-items-to-show-widescreen")},
184
+ )
185
+ );
186
+ }
187
+ }
188
+
189
+ @include mx.fullhd {
190
+ .#{iv.$class-prefix}carousel {
191
+ @include cv.register-vars(
192
+ (
193
+ "carousel-items-in-view": #{cv.getVar("carousel-items-to-show-fullhd")},
194
+ )
195
+ );
196
+ }
197
+ }
198
+
133
199
  .#{iv.$class-prefix}carousel {
134
200
  position: relative;
135
201
  overflow: hidden;
@@ -147,15 +213,22 @@ $carousel-indicator-line-radius: cv.getVar("radius-small") !default;
147
213
  // Slides container
148
214
  .#{iv.$class-prefix}carousel-slides {
149
215
  display: flex;
216
+ gap: cv.getVar("carousel-item-gap");
150
217
  width: 100%;
151
218
  will-change: transform;
152
219
  }
153
220
 
154
- // Individual slide
221
+ // Individual slide: an equal share of the track, less the gaps between
222
+ // the items in view
155
223
  .#{iv.$class-prefix}carousel-item {
156
- flex: 0 0 100%;
157
- width: 100%;
158
- min-width: 100%;
224
+ $carousel-item-width: calc(
225
+ (100% - (#{cv.getVar("carousel-items-in-view")} - 1) * #{cv.getVar("carousel-item-gap")}) /
226
+ #{cv.getVar("carousel-items-in-view")}
227
+ );
228
+
229
+ flex: 0 0 $carousel-item-width;
230
+ width: $carousel-item-width;
231
+ min-width: $carousel-item-width;
159
232
 
160
233
  // Allow images to fill the slide
161
234
  img {
@@ -505,26 +578,6 @@ $carousel-indicator-line-radius: cv.getVar("radius-small") !default;
505
578
  }
506
579
  }
507
580
 
508
- // Carousel list variant (multiple visible items)
509
- .#{iv.$class-prefix}carousel-list {
510
- .#{iv.$class-prefix}carousel-container {
511
- overflow: visible;
512
- }
513
-
514
- .#{iv.$class-prefix}carousel-slides {
515
- display: flex;
516
- gap: 1rem;
517
- }
518
-
519
- .#{iv.$class-prefix}carousel-item {
520
- flex: 0 0 auto;
521
- width: auto;
522
- position: relative;
523
- opacity: 1;
524
- visibility: visible;
525
- }
526
- }
527
-
528
581
  // Responsive adjustments
529
582
  @media screen and (max-width: 768px) {
530
583
  .#{iv.$class-prefix}carousel {
@@ -1,4 +1,128 @@
1
1
  // Bestax Extras - Menu Styles
2
+ // Two additions to Bulma's menu: `Menu.Section`, a section that opens and
3
+ // closes, and a mark for the active item in forced colors.
4
+
5
+ @use "bulma/sass/utilities/initial-variables" as iv;
6
+ @use "bulma/sass/utilities/css-variables" as cv;
7
+ @use "../mixins" as *;
8
+
9
+ // Menu.Section's own. Its heading reads the menu label's variables, so a
10
+ // theme that restyles the labels restyles it too, and these cover what a
11
+ // label doesn't have: the room between its words and its chevron, and the
12
+ // chevron.
13
+ $menu-section-gap: 0.375em !default;
14
+ $menu-section-chevron-size: 1em !default;
15
+ $menu-section-chevron-color: currentColor !default;
16
+ $menu-section-chevron-duration: cv.getVar("duration") !default;
17
+
18
+ .#{iv.$class-prefix}menu {
19
+ @include cv.register-vars(
20
+ (
21
+ "menu-section-gap": #{$menu-section-gap},
22
+ "menu-section-chevron-size": #{$menu-section-chevron-size},
23
+ "menu-section-chevron-color": #{$menu-section-chevron-color},
24
+ "menu-section-chevron-duration": #{$menu-section-chevron-duration},
25
+ )
26
+ );
27
+ }
28
+
29
+ // The space Bulma puts around a label, which turns on where the label sits
30
+ // among the menu's children: above it unless it comes first, and below it
31
+ // unless it comes last. A heading takes the same two from where its section
32
+ // sits, plus the space between an open heading and its own list. Without
33
+ // the one below, a menu list right after a closed section would sit flush
34
+ // under its heading, as if it were the section's. Two sections in a row are
35
+ // still one space apart, since the margins collapse. They're on the heading,
36
+ // so the label's `em` measures them in the label's own small size, as
37
+ // Bulma's do. The heading doesn't carry `.menu-label` itself, because its
38
+ // own place inside its section never changes.
39
+ .#{iv.$class-prefix}menu-section:not(:first-child) > .#{iv.$class-prefix}menu-section-toggle {
40
+ margin-top: cv.getVar("menu-label-spacing");
41
+ }
42
+
43
+ .#{iv.$class-prefix}menu-section:not(:last-child) > .#{iv.$class-prefix}menu-section-toggle,
44
+ .#{iv.$class-prefix}menu-section-toggle[aria-expanded="true"] {
45
+ margin-bottom: cv.getVar("menu-label-spacing");
46
+ }
47
+
48
+ // The heading is a button drawn like Bulma's `.menu-label`: small, spaced
49
+ // and uppercase, in the label's weak text color.
50
+ .#{iv.$class-prefix}menu-section-toggle {
51
+ align-items: center;
52
+ appearance: none;
53
+ background: none;
54
+ border: none;
55
+ color: cv.getVar("menu-label-color");
56
+ cursor: pointer;
57
+ display: flex;
58
+ font-family: inherit;
59
+ font-size: cv.getVar("menu-label-font-size");
60
+ font-weight: inherit;
61
+ gap: cv.getVar("menu-section-gap");
62
+ letter-spacing: cv.getVar("menu-label-letter-spacing");
63
+ line-height: inherit;
64
+ margin: 0;
65
+ padding: 0;
66
+ text-align: start;
67
+ text-transform: uppercase;
68
+ width: 100%;
69
+
70
+ &:focus {
71
+ outline: none;
72
+ }
73
+
74
+ &:focus-visible {
75
+ @include extras-focus-outline;
76
+ }
77
+ }
78
+
79
+ .#{iv.$class-prefix}menu-section-label {
80
+ flex: 1 1 auto;
81
+ min-width: 0;
82
+ }
83
+
84
+ // TreeView's chevron, drawn the same way: two sides of a square, turned, in
85
+ // a box of its own, the way Bulma's `%arrow` draws the `.select` arrow. It
86
+ // sits at the end of the heading, points to the end of the line while
87
+ // closed and down while open, and both follow a right-to-left page. It's a
88
+ // border in the heading's text color, so it stays in forced colors.
89
+ .#{iv.$class-prefix}menu-section-chevron {
90
+ align-items: center;
91
+ display: inline-flex;
92
+ flex: none;
93
+ height: cv.getVar("menu-section-chevron-size");
94
+ justify-content: center;
95
+ width: cv.getVar("menu-section-chevron-size");
96
+
97
+ &::after {
98
+ // The square's bottom and left sides before it's turned, so physical
99
+ // sides, like the turn.
100
+ border-color: cv.getVar("menu-section-chevron-color");
101
+ border-style: solid;
102
+ border-width: 0 0 0.125em 0.125em;
103
+ content: "";
104
+ height: 0.5em;
105
+ transform: translateX(-15%) rotate(-135deg);
106
+ transition-duration: cv.getVar("menu-section-chevron-duration");
107
+ transition-property: transform;
108
+ width: 0.5em;
109
+ }
110
+ }
111
+
112
+ .#{iv.$class-prefix}menu-section-toggle[aria-expanded="false"]:dir(rtl) > .#{iv.$class-prefix}menu-section-chevron::after {
113
+ transform: translateX(15%) rotate(45deg);
114
+ }
115
+
116
+ .#{iv.$class-prefix}menu-section-toggle[aria-expanded="true"] > .#{iv.$class-prefix}menu-section-chevron::after {
117
+ transform: translateY(-15%) rotate(-45deg);
118
+ }
119
+
120
+ @media (prefers-reduced-motion: reduce) {
121
+ .#{iv.$class-prefix}menu-section-chevron::after {
122
+ transition: none;
123
+ }
124
+ }
125
+
2
126
  // Bulma draws a menu's active item with a fill and a text color and nothing
3
127
  // else, and forced colors (Windows' contrast themes) replaces both, so the
4
128
  // active item looks like every other item there. This marks it with a bar in
@@ -14,9 +138,6 @@
14
138
  //
15
139
  // It reads the classes Bulma highlights, on the elements Bulma styles as
16
140
  // items, so a hand-written `.is-active` link gets it too.
17
-
18
- @use "bulma/sass/utilities/initial-variables" as iv;
19
-
20
141
  @media (forced-colors: active) {
21
142
  .#{iv.$class-prefix}menu-list {
22
143
  a,
@@ -34,4 +155,10 @@
34
155
  }
35
156
  }
36
157
  }
158
+
159
+ // A section heading's focus ring in the system's text color, as
160
+ // TreeView's is.
161
+ .#{iv.$class-prefix}menu-section-toggle:focus-visible {
162
+ outline-color: CanvasText;
163
+ }
37
164
  }