@mikebrucker/brucks 0.1.0 → 0.1.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.
- package/README.md +21 -29
- package/dist/blucks/components/loader.css +169 -0
- package/dist/{ui → blucks}/components/loader.d.ts +4 -3
- package/dist/blucks/components/loader.js +70 -0
- package/dist/blucks/components/loader.js.map +1 -0
- package/dist/blucks/components/scrollToTopFab.css +9 -0
- package/dist/blucks/components/scrollToTopFab.d.ts +1 -0
- package/dist/blucks/components/scrollToTopFab.js +2 -1
- package/dist/blucks/components/scrollToTopFab.js.map +1 -1
- package/dist/blucks/index.d.ts +1 -0
- package/dist/blucks/index.js +2 -1
- package/dist/style/theme.css +0 -190
- package/dist/ui/index.d.ts +1 -2
- package/dist/ui/index.js +1 -2
- package/dist/ui/lib/defaultLabels.d.ts +25 -2
- package/dist/ui/lib/defaultLabels.js +19 -2
- package/dist/ui/lib/defaultLabels.js.map +1 -1
- package/dist/ui/lib/labels.d.ts +5 -3
- package/dist/ui/lib/labels.js +20 -18
- package/dist/ui/lib/labels.js.map +1 -1
- package/package.json +3 -2
- package/dist/ui/components/loader.js +0 -27
- package/dist/ui/components/loader.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ It has three entry points, one per folder in `src/`:
|
|
|
10
10
|
| --- | --- | --- |
|
|
11
11
|
| `@mikebrucker/brucks/style` (+ `@mikebrucker/brucks/style/theme.css`) | the Tailwind theme, `cn`, `Side`, the class recipes, the style settings | nothing |
|
|
12
12
|
| `@mikebrucker/brucks/ui` (+ `@mikebrucker/brucks/ui/<file>`) | the components, `BrucksProvider`, the back stack | style |
|
|
13
|
-
| `@mikebrucker/brucks/blucks` | `AppLayout`, `Header`, `Footer`, the settings kit, `HomeCard`, `ScrollToTopFab`, `useDisclosure`, `useScrollAncestor`, `isKeyOf` | ui, style |
|
|
13
|
+
| `@mikebrucker/brucks/blucks` | `AppLayout`, `Header`, `Footer`, the settings kit, `HomeCard`, `Loader`, `ScrollToTopFab`, `useDisclosure`, `useScrollAncestor`, `isKeyOf` | ui, style |
|
|
14
14
|
|
|
15
15
|
There is no plain `brucks` import, so everything has exactly one import path.
|
|
16
16
|
`npm run lint` keeps the layers apart: style imports neither ui nor blucks, and ui
|
|
@@ -101,8 +101,8 @@ The theme provides:
|
|
|
101
101
|
`html.high-contrast`, `html[data-accent]`)
|
|
102
102
|
- the `dark` and `hc` variants
|
|
103
103
|
- the stacking layers (see below)
|
|
104
|
-
- the drawer
|
|
105
|
-
- the `safe-area-y` utility
|
|
104
|
+
- the drawer and collapsible keyframes
|
|
105
|
+
- the `safe-area-y` utility
|
|
106
106
|
- a base rule giving every element `border-border` and `outline-ring`
|
|
107
107
|
- a reduced-motion rule: with reduced motion on, every animation and transition
|
|
108
108
|
finishes at once
|
|
@@ -144,35 +144,23 @@ to `@mikebrucker/brucks/ui/x`. `cn` comes from `@mikebrucker/brucks/style`.
|
|
|
144
144
|
|
|
145
145
|
### Labels
|
|
146
146
|
|
|
147
|
-
The components
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
and `menu` names `Drawer`:
|
|
147
|
+
The components' screen reader labels come in English and German.
|
|
148
|
+
`BrucksProvider` from `@mikebrucker/brucks/ui` sets the language (`"en"` or
|
|
149
|
+
`"de"`) for everything inside it, English if left out. In a Next app, render it
|
|
150
|
+
in the `[lang]` layout, so `loading.tsx` gets it too:
|
|
152
151
|
|
|
153
152
|
```tsx
|
|
154
|
-
<BrucksProvider
|
|
155
|
-
labels={{
|
|
156
|
-
close: t(($) => $.ariaLabels.close),
|
|
157
|
-
dialog: t(($) => $.ariaLabels.dialog),
|
|
158
|
-
menu: t(($) => $.ariaLabels.menu),
|
|
159
|
-
dragToReorder: t(($) => $.ariaLabels.drag_to_reorder),
|
|
160
|
-
reorderAnnouncement: (values) => t(($) => $.ariaLabels.reorder_announcement, values),
|
|
161
|
-
notification: t(($) => $.ariaLabels.notification),
|
|
162
|
-
notifications: t(($) => $.ariaLabels.notifications), // keep "{hotkey}" in the text
|
|
163
|
-
dragInstructions: t(($) => $.ariaLabels.drag_instructions),
|
|
164
|
-
scrollToTop: t(($) => $.ariaLabels.scroll_to_top),
|
|
165
|
-
skipToContent: t(($) => $.ariaLabels.skip_to_content),
|
|
166
|
-
}}
|
|
167
|
-
>
|
|
168
|
-
{children}
|
|
169
|
-
</BrucksProvider>
|
|
153
|
+
<BrucksProvider language={lang}>{children}</BrucksProvider>
|
|
170
154
|
```
|
|
171
155
|
|
|
172
|
-
`
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
156
|
+
`labels` replaces single ones (the keys of `BrucksLabels`), for the app's own
|
|
157
|
+
wording or a language brucks doesn't speak; the rest come from `language`. A
|
|
158
|
+
nested provider starts from its own `language`, not from the provider around it.
|
|
159
|
+
The one provider also names `@mikebrucker/brucks/blucks`'s `ScrollToTopFab`
|
|
160
|
+
(`scrollToTop`), `AppLayout`'s skip link (`skipToContent`) and `Loader`'s status
|
|
161
|
+
(`loading`), and `menu` names `Drawer`. `Drawer` and `Modal` take a `title` for
|
|
162
|
+
their screen reader name, in place of the "menu" and "dialog" labels, and
|
|
163
|
+
`Loader` a `label` in place of "loading".
|
|
176
164
|
|
|
177
165
|
### Android back button
|
|
178
166
|
|
|
@@ -211,7 +199,9 @@ wiring.
|
|
|
211
199
|
### Blocks (`@mikebrucker/brucks/blucks`)
|
|
212
200
|
|
|
213
201
|
The blocks of an app, optional: ui and style never need them. Together with the
|
|
214
|
-
style settings they make a full settings page.
|
|
202
|
+
style settings they make a full settings page. Their own CSS comes with them:
|
|
203
|
+
`Loader` and `ScrollToTopFab` import the `.css` file next to them, which the app's
|
|
204
|
+
bundler loads along with the component, so the theme carries none of it.
|
|
215
205
|
|
|
216
206
|
- `AppLayout` frames every page: a skip link, the `header`, `main` as the one
|
|
217
207
|
scroller, with the page in a centered column, an optional `sidebar` beside it
|
|
@@ -264,6 +254,8 @@ style settings they make a full settings page.
|
|
|
264
254
|
```
|
|
265
255
|
|
|
266
256
|
Without `asChild` it is a button that runs `onClick`.
|
|
257
|
+
- `Loader` draws bouncing bars in the text color; `fullScreen` centers them over
|
|
258
|
+
the page.
|
|
267
259
|
- `ScrollToTopFab` scrolls its nearest scrolling ancestor to the top. It fades in
|
|
268
260
|
after `screensBeforeVisible` screen heights; `position="inline"` keeps it in
|
|
269
261
|
the flow, always shown. Its name is the `scrollToTop` label. Pressed from the
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/* The bars hold a [2 3 5 6 7 6 4] spectrum contour and pulse together on a 4-beat envelope. */
|
|
2
|
+
.loader {
|
|
3
|
+
display: inline-block;
|
|
4
|
+
position: relative;
|
|
5
|
+
width: 100px;
|
|
6
|
+
height: 50px;
|
|
7
|
+
background-repeat: no-repeat;
|
|
8
|
+
background-image:
|
|
9
|
+
linear-gradient(currentColor 50px, transparent 0),
|
|
10
|
+
linear-gradient(currentColor 50px, transparent 0),
|
|
11
|
+
linear-gradient(currentColor 50px, transparent 0),
|
|
12
|
+
linear-gradient(currentColor 50px, transparent 0),
|
|
13
|
+
linear-gradient(currentColor 50px, transparent 0),
|
|
14
|
+
linear-gradient(currentColor 50px, transparent 0),
|
|
15
|
+
linear-gradient(currentColor 50px, transparent 0);
|
|
16
|
+
background-position:
|
|
17
|
+
0px center,
|
|
18
|
+
15px center,
|
|
19
|
+
30px center,
|
|
20
|
+
45px center,
|
|
21
|
+
60px center,
|
|
22
|
+
75px center,
|
|
23
|
+
90px center;
|
|
24
|
+
animation: musicBounce 1.8s ease-in-out infinite;
|
|
25
|
+
}
|
|
26
|
+
@keyframes musicBounce {
|
|
27
|
+
0% {
|
|
28
|
+
background-size:
|
|
29
|
+
10px 12px,
|
|
30
|
+
10px 18px,
|
|
31
|
+
10px 20px,
|
|
32
|
+
10px 35px,
|
|
33
|
+
10px 33px,
|
|
34
|
+
10px 25px,
|
|
35
|
+
10px 24px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
8.3333% {
|
|
39
|
+
background-size:
|
|
40
|
+
10px 17px,
|
|
41
|
+
10px 19px,
|
|
42
|
+
10px 30px,
|
|
43
|
+
10px 41px,
|
|
44
|
+
10px 35px,
|
|
45
|
+
10px 36px,
|
|
46
|
+
10px 27px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
16.6667% {
|
|
50
|
+
background-size:
|
|
51
|
+
10px 17px,
|
|
52
|
+
10px 17px,
|
|
53
|
+
10px 33px,
|
|
54
|
+
10px 32px,
|
|
55
|
+
10px 37px,
|
|
56
|
+
10px 37px,
|
|
57
|
+
10px 21px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
25% {
|
|
61
|
+
background-size:
|
|
62
|
+
10px 12px,
|
|
63
|
+
10px 14px,
|
|
64
|
+
10px 25px,
|
|
65
|
+
10px 25px,
|
|
66
|
+
10px 42px,
|
|
67
|
+
10px 34px,
|
|
68
|
+
10px 17px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
33.3333% {
|
|
72
|
+
background-size:
|
|
73
|
+
10px 13px,
|
|
74
|
+
10px 21px,
|
|
75
|
+
10px 26px,
|
|
76
|
+
10px 31px,
|
|
77
|
+
10px 39px,
|
|
78
|
+
10px 36px,
|
|
79
|
+
10px 24px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
41.6667% {
|
|
83
|
+
background-size:
|
|
84
|
+
10px 13px,
|
|
85
|
+
10px 22px,
|
|
86
|
+
10px 27px,
|
|
87
|
+
10px 32px,
|
|
88
|
+
10px 29px,
|
|
89
|
+
10px 27px,
|
|
90
|
+
10px 26px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
50% {
|
|
94
|
+
background-size:
|
|
95
|
+
10px 12px,
|
|
96
|
+
10px 18px,
|
|
97
|
+
10px 29px,
|
|
98
|
+
10px 35px,
|
|
99
|
+
10px 38px,
|
|
100
|
+
10px 25px,
|
|
101
|
+
10px 24px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
58.3333% {
|
|
105
|
+
background-size:
|
|
106
|
+
10px 17px,
|
|
107
|
+
10px 19px,
|
|
108
|
+
10px 32px,
|
|
109
|
+
10px 41px,
|
|
110
|
+
10px 48px,
|
|
111
|
+
10px 36px,
|
|
112
|
+
10px 27px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
66.6667% {
|
|
116
|
+
background-size:
|
|
117
|
+
10px 17px,
|
|
118
|
+
10px 17px,
|
|
119
|
+
10px 24px,
|
|
120
|
+
10px 32px,
|
|
121
|
+
10px 33px,
|
|
122
|
+
10px 37px,
|
|
123
|
+
10px 21px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
75% {
|
|
127
|
+
background-size:
|
|
128
|
+
10px 12px,
|
|
129
|
+
10px 14px,
|
|
130
|
+
10px 24px,
|
|
131
|
+
10px 25px,
|
|
132
|
+
10px 29px,
|
|
133
|
+
10px 34px,
|
|
134
|
+
10px 17px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
83.3333% {
|
|
138
|
+
background-size:
|
|
139
|
+
10px 13px,
|
|
140
|
+
10px 21px,
|
|
141
|
+
10px 35px,
|
|
142
|
+
10px 31px,
|
|
143
|
+
10px 44px,
|
|
144
|
+
10px 36px,
|
|
145
|
+
10px 24px;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
91.6667% {
|
|
149
|
+
background-size:
|
|
150
|
+
10px 13px,
|
|
151
|
+
10px 22px,
|
|
152
|
+
10px 27px,
|
|
153
|
+
10px 32px,
|
|
154
|
+
10px 41px,
|
|
155
|
+
10px 27px,
|
|
156
|
+
10px 26px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
100% {
|
|
160
|
+
background-size:
|
|
161
|
+
10px 12px,
|
|
162
|
+
10px 18px,
|
|
163
|
+
10px 20px,
|
|
164
|
+
10px 35px,
|
|
165
|
+
10px 33px,
|
|
166
|
+
10px 25px,
|
|
167
|
+
10px 24px;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./loader.css";
|
|
1
2
|
type LoaderProps = {
|
|
2
3
|
isOpen: boolean;
|
|
3
4
|
/** Tailwind text color utilities, e.g. "text-cyan-400" */
|
|
@@ -6,10 +7,10 @@ type LoaderProps = {
|
|
|
6
7
|
fullScreen?: boolean;
|
|
7
8
|
/** With fullScreen, skip the dimmed backdrop so the page shows through */
|
|
8
9
|
transparentBg?: boolean;
|
|
9
|
-
/** What screen readers announce
|
|
10
|
+
/** What screen readers announce; the `loading` label if left out */
|
|
10
11
|
label?: string;
|
|
11
12
|
/** Makes the wrapper a keyboard-accessible button you can click */
|
|
12
13
|
onClick?: () => void;
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
export {};
|
|
15
|
+
declare function Loader({ isOpen, className, fullScreen, transparentBg, label, onClick }: LoaderProps): import("react").JSX.Element | null;
|
|
16
|
+
export { Loader };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../style/utils.js";
|
|
3
|
+
import { useBrucksLabels } from "../../ui/lib/labels.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import "./loader.css";
|
|
7
|
+
// src/blucks/components/loader.tsx
|
|
8
|
+
function Loader(t0) {
|
|
9
|
+
const $ = c(14);
|
|
10
|
+
const { isOpen, className, fullScreen, transparentBg, label, onClick } = t0;
|
|
11
|
+
const labels = useBrucksLabels();
|
|
12
|
+
if (!isOpen) return null;
|
|
13
|
+
const backdropClassName = !transparentBg ? "bg-black/50" : null;
|
|
14
|
+
let t1;
|
|
15
|
+
if ($[0] !== backdropClassName || $[1] !== fullScreen) {
|
|
16
|
+
t1 = fullScreen ? cn("fixed inset-0 z-loader flex items-center justify-center", backdropClassName) : void 0;
|
|
17
|
+
$[0] = backdropClassName;
|
|
18
|
+
$[1] = fullScreen;
|
|
19
|
+
$[2] = t1;
|
|
20
|
+
} else t1 = $[2];
|
|
21
|
+
const wrapperClassName = t1;
|
|
22
|
+
const t2 = `loader ${className ?? ""}`;
|
|
23
|
+
let t3;
|
|
24
|
+
if ($[3] !== t2) {
|
|
25
|
+
t3 = t2.trim();
|
|
26
|
+
$[3] = t2;
|
|
27
|
+
$[4] = t3;
|
|
28
|
+
} else t3 = $[4];
|
|
29
|
+
let t4;
|
|
30
|
+
if ($[5] !== t3) {
|
|
31
|
+
t4 = /* @__PURE__ */ jsx("span", { className: t3 });
|
|
32
|
+
$[5] = t3;
|
|
33
|
+
$[6] = t4;
|
|
34
|
+
} else t4 = $[6];
|
|
35
|
+
const bars = t4;
|
|
36
|
+
const t5 = label ?? labels.loading;
|
|
37
|
+
let t6;
|
|
38
|
+
if ($[7] !== t5) {
|
|
39
|
+
t6 = /* @__PURE__ */ jsx("span", {
|
|
40
|
+
role: "status",
|
|
41
|
+
"aria-live": "polite",
|
|
42
|
+
className: "sr-only",
|
|
43
|
+
children: t5
|
|
44
|
+
});
|
|
45
|
+
$[7] = t5;
|
|
46
|
+
$[8] = t6;
|
|
47
|
+
} else t6 = $[8];
|
|
48
|
+
const status = t6;
|
|
49
|
+
let t7;
|
|
50
|
+
if ($[9] !== bars || $[10] !== onClick || $[11] !== status || $[12] !== wrapperClassName) {
|
|
51
|
+
t7 = onClick ? /* @__PURE__ */ jsxs("button", {
|
|
52
|
+
type: "button",
|
|
53
|
+
onClick,
|
|
54
|
+
className: wrapperClassName,
|
|
55
|
+
children: [bars, status]
|
|
56
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
57
|
+
className: wrapperClassName,
|
|
58
|
+
children: [bars, status]
|
|
59
|
+
});
|
|
60
|
+
$[9] = bars;
|
|
61
|
+
$[10] = onClick;
|
|
62
|
+
$[11] = status;
|
|
63
|
+
$[12] = wrapperClassName;
|
|
64
|
+
$[13] = t7;
|
|
65
|
+
} else t7 = $[13];
|
|
66
|
+
return t7;
|
|
67
|
+
}
|
|
68
|
+
export { Loader };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","names":["c","_c","cn","useBrucksLabels","LoaderProps","isOpen","className","fullScreen","transparentBg","label","onClick","Loader","t0","$","labels","backdropClassName","t1","undefined","wrapperClassName","t2","t3","trim","t4","bars","t5","loading","t6","status","t7","_c"],"sources":["../../../src/blucks/components/loader.tsx"],"sourcesContent":["\"use client\";\n\nimport \"~/blucks/components/loader.css\";\nimport { cn } from \"~/style/utils\";\nimport { useBrucksLabels } from \"~/ui/lib/labels\";\n\ntype LoaderProps = {\n isOpen: boolean;\n /** Tailwind text color utilities, e.g. \"text-cyan-400\" */\n className?: string;\n /** Center the loader over a full-page overlay */\n fullScreen?: boolean;\n /** With fullScreen, skip the dimmed backdrop so the page shows through */\n transparentBg?: boolean;\n /** What screen readers announce; the `loading` label if left out */\n label?: string;\n /** Makes the wrapper a keyboard-accessible button you can click */\n onClick?: () => void;\n};\n\nfunction Loader({ isOpen, className, fullScreen, transparentBg, label, onClick }: LoaderProps) {\n const labels = useBrucksLabels();\n if (!isOpen) return null;\n\n const backdropClassName = !transparentBg ? \"bg-black/50\" : null;\n const wrapperClassName = fullScreen\n ? cn(\"fixed inset-0 z-loader flex items-center justify-center\", backdropClassName)\n : undefined;\n\n const bars = <span className={`loader ${className ?? \"\"}`.trim()} />;\n\n const status = (\n <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {label ?? labels.loading}\n </span>\n );\n\n return onClick ? (\n <button type=\"button\" onClick={onClick} className={wrapperClassName}>\n {bars}\n {status}\n </button>\n ) : (\n <div className={wrapperClassName}>\n {bars}\n {status}\n </div>\n );\n}\n\nexport { Loader };\n"],"mappings":";;;;;;;AAoBA,SAAAW,OAAAC,IAAA;CAAA,MAAAC,IAAAZ,EAAA,EAAA;CAAgB,MAAA,EAAAI,QAAAC,WAAAC,YAAAC,eAAAC,OAAAC,YAAA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AAA,CACGK,MACAI,MACG;;EACPd,EAAA,KAAAU;EAAAV,EAAA,MAAAH;EAAAG,EAAA,MAAAc;EAAAd,EAAA,MAAAK;EAAAL,EAAA,MAAAe;CAAA,OAAAA,KAAAf,EAAA;CAAA,OAVMe;AAUN"}
|
|
@@ -8,6 +8,7 @@ import { c } from "react/compiler-runtime";
|
|
|
8
8
|
import { useEffect, useRef, useState } from "react";
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
10
|
import { FlyingHumanIcon } from "@hugeicons/core-free-icons";
|
|
11
|
+
import "./scrollToTopFab.css";
|
|
11
12
|
// src/blucks/components/scrollToTopFab.tsx
|
|
12
13
|
/** Frames the scroller may sit still before the climb counts as stalled. */
|
|
13
14
|
var STALLED_FRAMES = 3;
|
|
@@ -141,7 +142,7 @@ function ScrollToTopFab(t0) {
|
|
|
141
142
|
$[11] = t13;
|
|
142
143
|
} else t13 = $[11];
|
|
143
144
|
const t14 = labels.scrollToTop;
|
|
144
|
-
const t15 = animate && "animate-
|
|
145
|
+
const t15 = animate && "animate-[flap_1s_ease-in-out_infinite]";
|
|
145
146
|
const t16 = icon === FlyingHumanIcon && "-rotate-25";
|
|
146
147
|
let t17;
|
|
147
148
|
if ($[12] !== t15 || $[13] !== t16) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollToTopFab.js","names":["c","_c","FlyingHumanIcon","ComponentProps","useEffect","useRef","useState","useScrollAncestor","cn","Fab","AppIcon","useBrucksLabels","STALLED_FRAMES","HANDOVER_EVENTS","const","ScrollToTopFabProps","screensBeforeVisible","position","className","theme","icon","animate","ScrollToTopFab","t0","$","t1","t2","t3","t4","t5","undefined","labels","fadesOnScroll","fabRef","scrollAncestor","visible","setVisible","t6","t7","onScroll","scrollTop","clientHeight","scrollTarget","document","documentElement","addEventListener","passive","removeEventListener","endClimb","t8","t9","Symbol","for","current","t10","fab","activeElement","focus","preventScroll","blur","window","matchMedia","matches","scrollTo","top","behavior","runway","frame","requestAnimationFrame","tick","previousTop","stalledFrames","stop","event","cancelAnimationFrame","event_0","scrollToTop","t11","t12","t13","t14","t15","t16","t17","t18","t19","_c"],"sources":["../../../src/blucks/components/scrollToTopFab.tsx"],"sourcesContent":["\"use client\";\n\nimport { FlyingHumanIcon } from \"@hugeicons/core-free-icons\";\nimport { type ComponentProps, useEffect, useRef, useState } from \"react\";\nimport { useScrollAncestor } from \"~/blucks/hooks/useScrollAncestor\";\nimport { cn } from \"~/style/utils\";\nimport { Fab } from \"~/ui/components/fab\";\nimport { AppIcon } from \"~/ui/components/icon\";\nimport { useBrucksLabels } from \"~/ui/lib/labels\";\n\n/** Frames the scroller may sit still before the climb counts as stalled. */\nconst STALLED_FRAMES = 3;\n\n/** Reader input that means the scroller is theirs again. */\nconst HANDOVER_EVENTS = [\"wheel\", \"touchstart\", \"pointerdown\", \"keydown\"] as const;\n\ntype ScrollToTopFabProps = {\n /** How many screen heights must be scrolled before the button appears. */\n screensBeforeVisible?: number;\n /** `inline` drops the fixed positioning and keeps the button in normal flow. */\n position?: \"bottom-right\" | \"bottom-left\" | \"inline\";\n className?: string;\n /** Draws the icon in the theme accent. */\n theme?: boolean;\n icon?: ComponentProps<typeof AppIcon>[\"icon\"];\n /** Rocks the icon with the flap animation. */\n animate?: boolean;\n};\n\nfunction ScrollToTopFab({\n screensBeforeVisible = 2.5,\n position = \"bottom-right\",\n className,\n theme = false,\n icon = FlyingHumanIcon,\n animate = true,\n}: ScrollToTopFabProps) {\n const labels = useBrucksLabels();\n\n // An in-flow button would leave a hole while hidden, so it never fades out.\n const fadesOnScroll = position !== \"inline\";\n\n const fabRef = useRef<HTMLButtonElement>(null);\n const scrollAncestor = useScrollAncestor(fabRef);\n const [visible, setVisible] = useState(false);\n\n useEffect(() => {\n if (!scrollAncestor || !fadesOnScroll) return;\n\n const onScroll = () => {\n setVisible(scrollAncestor.scrollTop > scrollAncestor.clientHeight * screensBeforeVisible);\n };\n\n // The page's own scrolling fires its scroll events at the document, not at <html>.\n const scrollTarget: EventTarget =\n scrollAncestor === document.documentElement ? document : scrollAncestor;\n\n onScroll();\n scrollTarget.addEventListener(\"scroll\", onScroll, { passive: true });\n\n return () => scrollTarget.removeEventListener(\"scroll\", onScroll);\n }, [scrollAncestor, screensBeforeVisible, fadesOnScroll]);\n\n /** Tears down an in-flight climb: the frame loop and its handover listeners. */\n const endClimb = useRef<(() => void) | null>(null);\n useEffect(() => () => endClimb.current?.(), []);\n\n const scrollToTop = () => {\n if (!scrollAncestor) return;\n endClimb.current?.();\n\n // Focus goes up with the reader, instead of staying on a button left at the bottom (and hidden there).\n const fab = fabRef.current;\n if (fab && document.activeElement === fab) {\n scrollAncestor.focus({ preventScroll: true });\n if (document.activeElement === fab) fab.blur();\n }\n\n if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n scrollAncestor.scrollTo({ top: 0, behavior: \"auto\" });\n return;\n }\n\n /*\n * The browser paces a smooth scroll by its distance, and a virtualized list\n * puts hundreds of thousands of pixels between the bottom and the top, so\n * animating the whole trip crawls. Cut to within a screen of the top - none\n * of what is skipped is on screen long enough to read - and animate only\n * that last leg.\n */\n const runway = scrollAncestor.clientHeight;\n if (scrollAncestor.scrollTop > runway) {\n scrollAncestor.scrollTo({ top: runway, behavior: \"auto\" });\n }\n\n scrollAncestor.scrollTo({ top: 0, behavior: \"smooth\" });\n\n /*\n * A virtualized list remeasures rows as they scroll into view and re-anchors\n * the scroll offset to keep them from jumping, which cancels the native\n * animation partway up. Re-aim whenever the climb stalls short of the top,\n * and hand the scroller back the moment the reader touches it.\n */\n let frame = requestAnimationFrame(tick);\n let previousTop = scrollAncestor.scrollTop;\n let stalledFrames = 0;\n\n function tick() {\n if (!scrollAncestor) return;\n const { scrollTop } = scrollAncestor;\n\n if (scrollTop === 0) {\n endClimb.current?.();\n return;\n }\n\n stalledFrames = scrollTop === previousTop ? stalledFrames + 1 : 0;\n previousTop = scrollTop;\n\n if (stalledFrames >= STALLED_FRAMES) {\n stalledFrames = 0;\n scrollAncestor.scrollTo({ top: 0, behavior: \"smooth\" });\n }\n\n frame = requestAnimationFrame(tick);\n }\n\n const stop = () => endClimb.current?.();\n for (const event of HANDOVER_EVENTS) {\n scrollAncestor.addEventListener(event, stop, { passive: true });\n }\n\n endClimb.current = () => {\n cancelAnimationFrame(frame);\n for (const event of HANDOVER_EVENTS) {\n scrollAncestor.removeEventListener(event, stop);\n }\n endClimb.current = null;\n };\n };\n\n return (\n <Fab\n ref={fabRef}\n type=\"button\"\n position={position}\n visible={fadesOnScroll ? visible : true}\n className={cn(className, theme ? \"text-theme-600\" : null)}\n aria-label={labels.scrollToTop}\n onClick={scrollToTop}\n >\n <AppIcon\n icon={icon}\n className={cn(animate && \"animate-flap\", icon === FlyingHumanIcon && \"-rotate-25\")}\n />\n </Fab>\n );\n}\n\nexport { ScrollToTopFab };\n"],"mappings":";;;;;;;;;;;;AAWA,IAAMY,iBAAiB;;AAGvB,IAAMC,kBAAkB;CAAC;CAAS;CAAc;CAAe;AAAS;AAexE,SAAAS,eAAAC,IAAA;CAAA,MAAAC,IAAAvB,EAAA,EAAA;CAAwB,MAAA,EAAAe,sBAAAS,IAAAR,UAAAS,IAAAR,WAAAC,OAAAQ,IAAAP,MAAAQ,IAAAP,SAAAQ,OAAAN;CACtB,MAAAP,uBAAAS,OAAAK,KAAAA,IAAA,MAAAL;CACA,MAAAR,WAAAS,OAAAI,KAAAA,IAAA,iBAAAJ;CAEA,MAAAP,QAAAQ,OAAAG,KAAAA,IAAA,QAAAH;CACA,MAAAP,OAAAQ,OAAAE,KAAAA,IAAA5B,kBAAA0B;CACA,MAAAP,UAAAQ,OAAAC,KAAAA,IAAA,OAAAD;CAEA,MAAAE,SAAepB,gBAAgB;CAG/B,MAAAqB,gBAAsBf,aAAa;CAEnC,MAAAgB,SAAe5B,OAA0B,IAAI;CAC7C,MAAA6B,iBAAuB3B,kBAAkB0B,MAAM;CAC/C,MAAA,CAAAE,SAAAC,cAA8B9B,SAAS,KAAK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D,EAAA;CAAA,OAbN6D;AAaM"}
|
|
1
|
+
{"version":3,"file":"scrollToTopFab.js","names":["c","_c","FlyingHumanIcon","ComponentProps","useEffect","useRef","useState","useScrollAncestor","cn","Fab","AppIcon","useBrucksLabels","STALLED_FRAMES","HANDOVER_EVENTS","const","ScrollToTopFabProps","screensBeforeVisible","position","className","theme","icon","animate","ScrollToTopFab","t0","$","t1","t2","t3","t4","t5","undefined","labels","fadesOnScroll","fabRef","scrollAncestor","visible","setVisible","t6","t7","onScroll","scrollTop","clientHeight","scrollTarget","document","documentElement","addEventListener","passive","removeEventListener","endClimb","t8","t9","Symbol","for","current","t10","fab","activeElement","focus","preventScroll","blur","window","matchMedia","matches","scrollTo","top","behavior","runway","frame","requestAnimationFrame","tick","previousTop","stalledFrames","stop","event","cancelAnimationFrame","event_0","scrollToTop","t11","t12","t13","t14","t15","t16","t17","t18","t19","_c"],"sources":["../../../src/blucks/components/scrollToTopFab.tsx"],"sourcesContent":["\"use client\";\n\nimport { FlyingHumanIcon } from \"@hugeicons/core-free-icons\";\nimport { type ComponentProps, useEffect, useRef, useState } from \"react\";\nimport \"~/blucks/components/scrollToTopFab.css\";\nimport { useScrollAncestor } from \"~/blucks/hooks/useScrollAncestor\";\nimport { cn } from \"~/style/utils\";\nimport { Fab } from \"~/ui/components/fab\";\nimport { AppIcon } from \"~/ui/components/icon\";\nimport { useBrucksLabels } from \"~/ui/lib/labels\";\n\n/** Frames the scroller may sit still before the climb counts as stalled. */\nconst STALLED_FRAMES = 3;\n\n/** Reader input that means the scroller is theirs again. */\nconst HANDOVER_EVENTS = [\"wheel\", \"touchstart\", \"pointerdown\", \"keydown\"] as const;\n\ntype ScrollToTopFabProps = {\n /** How many screen heights must be scrolled before the button appears. */\n screensBeforeVisible?: number;\n /** `inline` drops the fixed positioning and keeps the button in normal flow. */\n position?: \"bottom-right\" | \"bottom-left\" | \"inline\";\n className?: string;\n /** Draws the icon in the theme accent. */\n theme?: boolean;\n icon?: ComponentProps<typeof AppIcon>[\"icon\"];\n /** Rocks the icon with the flap animation. */\n animate?: boolean;\n};\n\nfunction ScrollToTopFab({\n screensBeforeVisible = 2.5,\n position = \"bottom-right\",\n className,\n theme = false,\n icon = FlyingHumanIcon,\n animate = true,\n}: ScrollToTopFabProps) {\n const labels = useBrucksLabels();\n\n // An in-flow button would leave a hole while hidden, so it never fades out.\n const fadesOnScroll = position !== \"inline\";\n\n const fabRef = useRef<HTMLButtonElement>(null);\n const scrollAncestor = useScrollAncestor(fabRef);\n const [visible, setVisible] = useState(false);\n\n useEffect(() => {\n if (!scrollAncestor || !fadesOnScroll) return;\n\n const onScroll = () => {\n setVisible(scrollAncestor.scrollTop > scrollAncestor.clientHeight * screensBeforeVisible);\n };\n\n // The page's own scrolling fires its scroll events at the document, not at <html>.\n const scrollTarget: EventTarget =\n scrollAncestor === document.documentElement ? document : scrollAncestor;\n\n onScroll();\n scrollTarget.addEventListener(\"scroll\", onScroll, { passive: true });\n\n return () => scrollTarget.removeEventListener(\"scroll\", onScroll);\n }, [scrollAncestor, screensBeforeVisible, fadesOnScroll]);\n\n /** Tears down an in-flight climb: the frame loop and its handover listeners. */\n const endClimb = useRef<(() => void) | null>(null);\n useEffect(() => () => endClimb.current?.(), []);\n\n const scrollToTop = () => {\n if (!scrollAncestor) return;\n endClimb.current?.();\n\n // Focus goes up with the reader, instead of staying on a button left at the bottom (and hidden there).\n const fab = fabRef.current;\n if (fab && document.activeElement === fab) {\n scrollAncestor.focus({ preventScroll: true });\n if (document.activeElement === fab) fab.blur();\n }\n\n if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n scrollAncestor.scrollTo({ top: 0, behavior: \"auto\" });\n return;\n }\n\n /*\n * The browser paces a smooth scroll by its distance, and a virtualized list\n * puts hundreds of thousands of pixels between the bottom and the top, so\n * animating the whole trip crawls. Cut to within a screen of the top - none\n * of what is skipped is on screen long enough to read - and animate only\n * that last leg.\n */\n const runway = scrollAncestor.clientHeight;\n if (scrollAncestor.scrollTop > runway) {\n scrollAncestor.scrollTo({ top: runway, behavior: \"auto\" });\n }\n\n scrollAncestor.scrollTo({ top: 0, behavior: \"smooth\" });\n\n /*\n * A virtualized list remeasures rows as they scroll into view and re-anchors\n * the scroll offset to keep them from jumping, which cancels the native\n * animation partway up. Re-aim whenever the climb stalls short of the top,\n * and hand the scroller back the moment the reader touches it.\n */\n let frame = requestAnimationFrame(tick);\n let previousTop = scrollAncestor.scrollTop;\n let stalledFrames = 0;\n\n function tick() {\n if (!scrollAncestor) return;\n const { scrollTop } = scrollAncestor;\n\n if (scrollTop === 0) {\n endClimb.current?.();\n return;\n }\n\n stalledFrames = scrollTop === previousTop ? stalledFrames + 1 : 0;\n previousTop = scrollTop;\n\n if (stalledFrames >= STALLED_FRAMES) {\n stalledFrames = 0;\n scrollAncestor.scrollTo({ top: 0, behavior: \"smooth\" });\n }\n\n frame = requestAnimationFrame(tick);\n }\n\n const stop = () => endClimb.current?.();\n for (const event of HANDOVER_EVENTS) {\n scrollAncestor.addEventListener(event, stop, { passive: true });\n }\n\n endClimb.current = () => {\n cancelAnimationFrame(frame);\n for (const event of HANDOVER_EVENTS) {\n scrollAncestor.removeEventListener(event, stop);\n }\n endClimb.current = null;\n };\n };\n\n return (\n <Fab\n ref={fabRef}\n type=\"button\"\n position={position}\n visible={fadesOnScroll ? visible : true}\n className={cn(className, theme ? \"text-theme-600\" : null)}\n aria-label={labels.scrollToTop}\n onClick={scrollToTop}\n >\n <AppIcon\n icon={icon}\n className={cn(\n animate && \"animate-[flap_1s_ease-in-out_infinite]\",\n icon === FlyingHumanIcon && \"-rotate-25\",\n )}\n />\n </Fab>\n );\n}\n\nexport { ScrollToTopFab };\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAMY,iBAAiB;;AAGvB,IAAMC,kBAAkB;CAAC;CAAS;CAAc;CAAe;AAAS;AAexE,SAAAS,eAAAC,IAAA;CAAA,MAAAC,IAAAvB,EAAA,EAAA;CAAwB,MAAA,EAAAe,sBAAAS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AAAA,MAAA5D,EAAA;CAAA,IAAA6D;CAAA,IAAA7D,EAAA,QAAAO,OAAA6C,eAAApD,EAAA,QAAAP,YAAAO,EAAA,QAAAoD,eAAApD,EAAA,QAAAqD,OAAArD,EAAA,QAAAuD,OAAAvD,EAAA,QAAA4D,KAAA;EAfJC,MAAA,oBAAC,KAAD;GACOpD,KAAAA;GACA,MAAA;GACKhB;GACD,SAAA4D;GACE,WAAAE;GACC,cAAAC;GACHJ,SAAAA;GAETQ,UAAAA;EATE,CAAA;EAgBE5D,EAAA,MAAAO,OAAA6C;EAAApD,EAAA,MAAAP;EAAAO,EAAA,MAAAoD;EAAApD,EAAA,MAAAqD;EAAArD,EAAA,MAAAuD;EAAAvD,EAAA,MAAA4D;EAAA5D,EAAA,MAAA6D;CAAA,OAAAA,MAAA7D,EAAA;CAAA,OAhBN6D;AAgBM"}
|
package/dist/blucks/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { HomeCard, type HomeCardProps } from "./components/homeCard";
|
|
2
|
+
export { Loader } from "./components/loader";
|
|
2
3
|
export { ScrollToTopFab } from "./components/scrollToTopFab";
|
|
3
4
|
export { SettingsPickerModal } from "./components/settingsPickerModal";
|
|
4
5
|
export { SettingsRow } from "./components/settingsRow";
|
package/dist/blucks/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HomeCard } from "./components/homeCard.js";
|
|
2
|
+
import { Loader } from "./components/loader.js";
|
|
2
3
|
import { useScrollAncestor } from "./hooks/useScrollAncestor.js";
|
|
3
4
|
import { ScrollToTopFab } from "./components/scrollToTopFab.js";
|
|
4
5
|
import { SettingsPickerModal } from "./components/settingsPickerModal.js";
|
|
@@ -10,4 +11,4 @@ import { AppLayout } from "./layout/appLayout.js";
|
|
|
10
11
|
import { Footer } from "./layout/footer.js";
|
|
11
12
|
import { Header } from "./layout/header.js";
|
|
12
13
|
import { isKeyOf } from "./lib/utils.js";
|
|
13
|
-
export { AppLayout, Footer, Header, HomeCard, ScrollToTopFab, SettingsPickerModal, SettingsRow, SettingsSection, SettingsSwatchButton, isKeyOf, useDisclosure, useScrollAncestor };
|
|
14
|
+
export { AppLayout, Footer, Header, HomeCard, Loader, ScrollToTopFab, SettingsPickerModal, SettingsRow, SettingsSection, SettingsSwatchButton, isKeyOf, useDisclosure, useScrollAncestor };
|
package/dist/style/theme.css
CHANGED
|
@@ -1142,8 +1142,6 @@ html[data-accent="sixer"] {
|
|
|
1142
1142
|
ships keyframes under those names that always collapse to 0. */
|
|
1143
1143
|
--animate-collapsible-expand: collapsible-expand 0.3s ease-in-out;
|
|
1144
1144
|
--animate-collapsible-collapse: collapsible-collapse 0.3s ease-in-out;
|
|
1145
|
-
/* ScrollToTopFab's flying human */
|
|
1146
|
-
--animate-flap: flap 1s ease-in-out infinite;
|
|
1147
1145
|
}
|
|
1148
1146
|
|
|
1149
1147
|
/* Stacking layers, lowest first. Not `inline`, so the `z-*` utilities read real
|
|
@@ -1231,15 +1229,6 @@ html[data-accent="sixer"] {
|
|
|
1231
1229
|
height: var(--collapsible-collapsed-height, 0px);
|
|
1232
1230
|
}
|
|
1233
1231
|
}
|
|
1234
|
-
@keyframes flap {
|
|
1235
|
-
0%,
|
|
1236
|
-
100% {
|
|
1237
|
-
rotate: -25deg;
|
|
1238
|
-
}
|
|
1239
|
-
50% {
|
|
1240
|
-
rotate: -15deg;
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
1232
|
|
|
1244
1233
|
@layer base {
|
|
1245
1234
|
* {
|
|
@@ -1268,182 +1257,3 @@ html[data-accent="sixer"] {
|
|
|
1268
1257
|
padding-top: env(safe-area-inset-top);
|
|
1269
1258
|
padding-bottom: env(safe-area-inset-bottom);
|
|
1270
1259
|
}
|
|
1271
|
-
|
|
1272
|
-
/* Loader */
|
|
1273
|
-
.loader {
|
|
1274
|
-
display: inline-block;
|
|
1275
|
-
position: relative;
|
|
1276
|
-
width: 100px;
|
|
1277
|
-
height: 50px;
|
|
1278
|
-
background-repeat: no-repeat;
|
|
1279
|
-
background-image:
|
|
1280
|
-
linear-gradient(currentColor 50px, transparent 0),
|
|
1281
|
-
linear-gradient(currentColor 50px, transparent 0),
|
|
1282
|
-
linear-gradient(currentColor 50px, transparent 0),
|
|
1283
|
-
linear-gradient(currentColor 50px, transparent 0),
|
|
1284
|
-
linear-gradient(currentColor 50px, transparent 0),
|
|
1285
|
-
linear-gradient(currentColor 50px, transparent 0),
|
|
1286
|
-
linear-gradient(currentColor 50px, transparent 0);
|
|
1287
|
-
background-position:
|
|
1288
|
-
0px center,
|
|
1289
|
-
15px center,
|
|
1290
|
-
30px center,
|
|
1291
|
-
45px center,
|
|
1292
|
-
60px center,
|
|
1293
|
-
75px center,
|
|
1294
|
-
90px center;
|
|
1295
|
-
animation: musicBounce 1.8s ease-in-out infinite;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
/*
|
|
1299
|
-
Real music keeps a spectral SHAPE rather than scattering randomly: energy humps
|
|
1300
|
-
in the low-mids/presence and tapers at the edges. The bars hold that [2 3 5 6 7 6 4]
|
|
1301
|
-
contour the whole time and the whole curve pulses to a 4-beat envelope, with only a
|
|
1302
|
-
subtle per-bar wiggle so it breathes instead of moving in rigid lockstep. So the edge
|
|
1303
|
-
bars stay short, the middle bars stay tall, and they all rise and fall together on
|
|
1304
|
-
the beat. Whole-cycle frequencies keep 100% lined up with 0% for a seamless loop.
|
|
1305
|
-
*/
|
|
1306
|
-
@keyframes musicBounce {
|
|
1307
|
-
0% {
|
|
1308
|
-
background-size:
|
|
1309
|
-
10px 12px,
|
|
1310
|
-
10px 18px,
|
|
1311
|
-
10px 20px,
|
|
1312
|
-
10px 35px,
|
|
1313
|
-
10px 33px,
|
|
1314
|
-
10px 25px,
|
|
1315
|
-
10px 24px;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
8.3333% {
|
|
1319
|
-
background-size:
|
|
1320
|
-
10px 17px,
|
|
1321
|
-
10px 19px,
|
|
1322
|
-
10px 30px,
|
|
1323
|
-
10px 41px,
|
|
1324
|
-
10px 35px,
|
|
1325
|
-
10px 36px,
|
|
1326
|
-
10px 27px;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
16.6667% {
|
|
1330
|
-
background-size:
|
|
1331
|
-
10px 17px,
|
|
1332
|
-
10px 17px,
|
|
1333
|
-
10px 33px,
|
|
1334
|
-
10px 32px,
|
|
1335
|
-
10px 37px,
|
|
1336
|
-
10px 37px,
|
|
1337
|
-
10px 21px;
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
25% {
|
|
1341
|
-
background-size:
|
|
1342
|
-
10px 12px,
|
|
1343
|
-
10px 14px,
|
|
1344
|
-
10px 25px,
|
|
1345
|
-
10px 25px,
|
|
1346
|
-
10px 42px,
|
|
1347
|
-
10px 34px,
|
|
1348
|
-
10px 17px;
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
33.3333% {
|
|
1352
|
-
background-size:
|
|
1353
|
-
10px 13px,
|
|
1354
|
-
10px 21px,
|
|
1355
|
-
10px 26px,
|
|
1356
|
-
10px 31px,
|
|
1357
|
-
10px 39px,
|
|
1358
|
-
10px 36px,
|
|
1359
|
-
10px 24px;
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
41.6667% {
|
|
1363
|
-
background-size:
|
|
1364
|
-
10px 13px,
|
|
1365
|
-
10px 22px,
|
|
1366
|
-
10px 27px,
|
|
1367
|
-
10px 32px,
|
|
1368
|
-
10px 29px,
|
|
1369
|
-
10px 27px,
|
|
1370
|
-
10px 26px;
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
50% {
|
|
1374
|
-
background-size:
|
|
1375
|
-
10px 12px,
|
|
1376
|
-
10px 18px,
|
|
1377
|
-
10px 29px,
|
|
1378
|
-
10px 35px,
|
|
1379
|
-
10px 38px,
|
|
1380
|
-
10px 25px,
|
|
1381
|
-
10px 24px;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
58.3333% {
|
|
1385
|
-
background-size:
|
|
1386
|
-
10px 17px,
|
|
1387
|
-
10px 19px,
|
|
1388
|
-
10px 32px,
|
|
1389
|
-
10px 41px,
|
|
1390
|
-
10px 48px,
|
|
1391
|
-
10px 36px,
|
|
1392
|
-
10px 27px;
|
|
1393
|
-
}
|
|
1394
|
-
|
|
1395
|
-
66.6667% {
|
|
1396
|
-
background-size:
|
|
1397
|
-
10px 17px,
|
|
1398
|
-
10px 17px,
|
|
1399
|
-
10px 24px,
|
|
1400
|
-
10px 32px,
|
|
1401
|
-
10px 33px,
|
|
1402
|
-
10px 37px,
|
|
1403
|
-
10px 21px;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
75% {
|
|
1407
|
-
background-size:
|
|
1408
|
-
10px 12px,
|
|
1409
|
-
10px 14px,
|
|
1410
|
-
10px 24px,
|
|
1411
|
-
10px 25px,
|
|
1412
|
-
10px 29px,
|
|
1413
|
-
10px 34px,
|
|
1414
|
-
10px 17px;
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
83.3333% {
|
|
1418
|
-
background-size:
|
|
1419
|
-
10px 13px,
|
|
1420
|
-
10px 21px,
|
|
1421
|
-
10px 35px,
|
|
1422
|
-
10px 31px,
|
|
1423
|
-
10px 44px,
|
|
1424
|
-
10px 36px,
|
|
1425
|
-
10px 24px;
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
91.6667% {
|
|
1429
|
-
background-size:
|
|
1430
|
-
10px 13px,
|
|
1431
|
-
10px 22px,
|
|
1432
|
-
10px 27px,
|
|
1433
|
-
10px 32px,
|
|
1434
|
-
10px 41px,
|
|
1435
|
-
10px 27px,
|
|
1436
|
-
10px 26px;
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
100% {
|
|
1440
|
-
background-size:
|
|
1441
|
-
10px 12px,
|
|
1442
|
-
10px 18px,
|
|
1443
|
-
10px 20px,
|
|
1444
|
-
10px 35px,
|
|
1445
|
-
10px 33px,
|
|
1446
|
-
10px 25px,
|
|
1447
|
-
10px 24px;
|
|
1448
|
-
}
|
|
1449
|
-
}
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export { Fab, fabVariants } from "./components/fab";
|
|
|
9
9
|
export { Form, FormControl, FormField, FormLabel, FormMessage } from "./components/form";
|
|
10
10
|
export { AppIcon } from "./components/icon";
|
|
11
11
|
export { Input, inputVariants } from "./components/input";
|
|
12
|
-
export { default as Loader } from "./components/loader";
|
|
13
12
|
export { Modal, useModalCloseIcon } from "./components/modal";
|
|
14
13
|
export { Note } from "./components/note";
|
|
15
14
|
export { Popover, PopoverClose } from "./components/popover";
|
|
@@ -29,5 +28,5 @@ export { Toggle, toggleVariants } from "./components/toggle";
|
|
|
29
28
|
export { ToggleGroup, ToggleGroupItem } from "./components/toggle-group";
|
|
30
29
|
export { Tooltip } from "./components/tooltip";
|
|
31
30
|
export { closeTopmost, useCloseOnBack } from "./hooks/useCloseOnBack";
|
|
32
|
-
export { type BrucksLabels, defaultLabels } from "./lib/defaultLabels";
|
|
31
|
+
export { type BrucksLabels, type BrucksLanguage, defaultLabels } from "./lib/defaultLabels";
|
|
33
32
|
export { BrucksProvider, useBrucksLabels } from "./lib/labels";
|
package/dist/ui/index.js
CHANGED
|
@@ -12,7 +12,6 @@ import { Drawer } from "./components/drawer.js";
|
|
|
12
12
|
import { Fab, fabVariants } from "./components/fab.js";
|
|
13
13
|
import { Form, FormControl, FormField, FormLabel, FormMessage } from "./components/form.js";
|
|
14
14
|
import { Input, inputVariants } from "./components/input.js";
|
|
15
|
-
import Loader from "./components/loader.js";
|
|
16
15
|
import { Modal, useModalCloseIcon } from "./components/modal.js";
|
|
17
16
|
import { Note } from "./components/note.js";
|
|
18
17
|
import { Popover, PopoverClose } from "./components/popover.js";
|
|
@@ -31,4 +30,4 @@ import { Toast } from "./components/toast.js";
|
|
|
31
30
|
import { Toggle, toggleVariants } from "./components/toggle.js";
|
|
32
31
|
import { ToggleGroup, ToggleGroupItem } from "./components/toggle-group.js";
|
|
33
32
|
import { Tooltip } from "./components/tooltip.js";
|
|
34
|
-
export { Accordion, AccordionGroup, AlertDialog, AppIcon, BrucksProvider, Button, Checkbox, Chip, Collapsible, Drawer, Fab, Form, FormControl, FormField, FormLabel, FormMessage, Input,
|
|
33
|
+
export { Accordion, AccordionGroup, AlertDialog, AppIcon, BrucksProvider, Button, Checkbox, Chip, Collapsible, Drawer, Fab, Form, FormControl, FormField, FormLabel, FormMessage, Input, Modal, Note, Popover, PopoverClose, Progress, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, Separator, Slider, SortableList, SortableListRow, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, buttonVariants, closeTopmost, defaultLabels, fabVariants, inputVariants, textareaVariants, toggleVariants, useBrucksLabels, useCloseOnBack, useModalCloseIcon };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The words the components speak for themselves - screen reader names and
|
|
3
|
-
* announcements.
|
|
4
|
-
*
|
|
3
|
+
* announcements. brucks ships them in English and German: `BrucksProvider` picks
|
|
4
|
+
* the language, and its `labels` replace single ones.
|
|
5
5
|
*
|
|
6
6
|
* Kept out of the "use client" provider module, so a Server Component reading the
|
|
7
7
|
* defaults gets the object rather than a client reference.
|
|
@@ -27,5 +27,28 @@ export type BrucksLabels = {
|
|
|
27
27
|
scrollToTop: string;
|
|
28
28
|
/** AppLayout's skip link to `main`. */
|
|
29
29
|
skipToContent: string;
|
|
30
|
+
/** Loader's status, unless it gets a `label`. */
|
|
31
|
+
loading: string;
|
|
30
32
|
};
|
|
31
33
|
export declare const defaultLabels: BrucksLabels;
|
|
34
|
+
export declare const translations: {
|
|
35
|
+
en: BrucksLabels;
|
|
36
|
+
de: {
|
|
37
|
+
close: string;
|
|
38
|
+
dialog: string;
|
|
39
|
+
menu: string;
|
|
40
|
+
dragToReorder: string;
|
|
41
|
+
reorderAnnouncement: ({ item, position, total }: {
|
|
42
|
+
item: string;
|
|
43
|
+
position: number;
|
|
44
|
+
total: number;
|
|
45
|
+
}) => string;
|
|
46
|
+
notification: string;
|
|
47
|
+
notifications: string;
|
|
48
|
+
dragInstructions: string;
|
|
49
|
+
scrollToTop: string;
|
|
50
|
+
skipToContent: string;
|
|
51
|
+
loading: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export type BrucksLanguage = keyof typeof translations;
|
|
@@ -9,8 +9,25 @@ var defaultLabels = {
|
|
|
9
9
|
notifications: "Notifications ({hotkey})",
|
|
10
10
|
dragInstructions: "To pick up an item, press Space or Enter. Move it with the arrow keys, press Space or Enter again to drop it, or Escape to cancel.",
|
|
11
11
|
scrollToTop: "Scroll back to top",
|
|
12
|
-
skipToContent: "Skip to content"
|
|
12
|
+
skipToContent: "Skip to content",
|
|
13
|
+
loading: "Loading"
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
var translations = {
|
|
16
|
+
en: defaultLabels,
|
|
17
|
+
de: {
|
|
18
|
+
close: "Schließen",
|
|
19
|
+
dialog: "Dialog",
|
|
20
|
+
menu: "Menü",
|
|
21
|
+
dragToReorder: "Zum Umsortieren ziehen",
|
|
22
|
+
reorderAnnouncement: ({ item, position, total }) => `${item} auf Position ${position} von ${total} verschoben`,
|
|
23
|
+
notification: "Benachrichtigung",
|
|
24
|
+
notifications: "Benachrichtigungen ({hotkey})",
|
|
25
|
+
dragInstructions: "Drück die Leertaste oder Enter, um ein Element anzuheben. Beweg es mit den Pfeiltasten und drück die Leertaste oder Enter erneut, um es abzulegen, oder Escape, um abzubrechen.",
|
|
26
|
+
scrollToTop: "Zurück nach oben scrollen",
|
|
27
|
+
skipToContent: "Zum Inhalt springen",
|
|
28
|
+
loading: "Wird geladen"
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export { defaultLabels, translations };
|
|
15
32
|
|
|
16
33
|
//# sourceMappingURL=defaultLabels.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultLabels.js","names":[],"sources":["../../../src/ui/lib/defaultLabels.ts"],"sourcesContent":["/**\n * The words the components speak for themselves - screen reader names and\n * announcements.
|
|
1
|
+
{"version":3,"file":"defaultLabels.js","names":[],"sources":["../../../src/ui/lib/defaultLabels.ts"],"sourcesContent":["/**\n * The words the components speak for themselves - screen reader names and\n * announcements. brucks ships them in English and German: `BrucksProvider` picks\n * the language, and its `labels` replace single ones.\n *\n * Kept out of the \"use client\" provider module, so a Server Component reading the\n * defaults gets the object rather than a client reference.\n */\nexport type BrucksLabels = {\n close: string;\n dialog: string;\n /** Names the Drawer, and Header's action button. */\n menu: string;\n dragToReorder: string;\n reorderAnnouncement: (values: { item: string; position: number; total: number }) => string;\n /** Spoken before a toast's text. */\n notification: string;\n /** Names the toast region; Radix replaces `{hotkey}` with the key that focuses it. */\n notifications: string;\n /** How to sort with the keyboard, read when a drag handle is focused. */\n dragInstructions: string;\n /** Names ScrollToTopFab. */\n scrollToTop: string;\n /** AppLayout's skip link to `main`. */\n skipToContent: string;\n /** Loader's status, unless it gets a `label`. */\n loading: string;\n};\n\nexport const defaultLabels: BrucksLabels = {\n close: \"Close\",\n dialog: \"Dialog\",\n menu: \"Menu\",\n dragToReorder: \"Drag to reorder\",\n reorderAnnouncement: ({ item, position, total }) =>\n `${item} moved to position ${position} of ${total}`,\n notification: \"Notification\",\n notifications: \"Notifications ({hotkey})\",\n dragInstructions:\n \"To pick up an item, press Space or Enter. Move it with the arrow keys, press Space or Enter again to drop it, or Escape to cancel.\",\n scrollToTop: \"Scroll back to top\",\n skipToContent: \"Skip to content\",\n loading: \"Loading\",\n};\n\nexport const translations = {\n en: defaultLabels,\n de: {\n close: \"Schließen\",\n dialog: \"Dialog\",\n menu: \"Menü\",\n dragToReorder: \"Zum Umsortieren ziehen\",\n reorderAnnouncement: ({ item, position, total }) =>\n `${item} auf Position ${position} von ${total} verschoben`,\n notification: \"Benachrichtigung\",\n notifications: \"Benachrichtigungen ({hotkey})\",\n dragInstructions:\n \"Drück die Leertaste oder Enter, um ein Element anzuheben. Beweg es mit den Pfeiltasten und drück die Leertaste oder Enter erneut, um es abzulegen, oder Escape, um abzubrechen.\",\n scrollToTop: \"Zurück nach oben scrollen\",\n skipToContent: \"Zum Inhalt springen\",\n loading: \"Wird geladen\",\n },\n} satisfies Record<string, BrucksLabels>;\n\nexport type BrucksLanguage = keyof typeof translations;\n"],"mappings":";AA6BA,IAAa,gBAA8B;CACzC,OAAO;CACP,QAAQ;CACR,MAAM;CACN,eAAe;CACf,sBAAsB,EAAE,MAAM,UAAU,YACtC,GAAG,KAAK,qBAAqB,SAAS,MAAM;CAC9C,cAAc;CACd,eAAe;CACf,kBACE;CACF,aAAa;CACb,eAAe;CACf,SAAS;AACX;AAEA,IAAa,eAAe;CAC1B,IAAI;CACJ,IAAI;EACF,OAAO;EACP,QAAQ;EACR,MAAM;EACN,eAAe;EACf,sBAAsB,EAAE,MAAM,UAAU,YACtC,GAAG,KAAK,gBAAgB,SAAS,OAAO,MAAM;EAChD,cAAc;EACd,eAAe;EACf,kBACE;EACF,aAAa;EACb,eAAe;EACf,SAAS;CACX;AACF"}
|
package/dist/ui/lib/labels.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import { type BrucksLabels } from "./defaultLabels";
|
|
2
|
+
import { type BrucksLabels, type BrucksLanguage } from "./defaultLabels";
|
|
3
3
|
type BrucksProviderProps = {
|
|
4
|
-
/**
|
|
4
|
+
/** The language of brucks's own labels; English if left out. */
|
|
5
|
+
language?: BrucksLanguage;
|
|
6
|
+
/** Any label left out comes from `language`. */
|
|
5
7
|
labels?: Partial<BrucksLabels>;
|
|
6
8
|
children: ReactNode;
|
|
7
9
|
};
|
|
8
|
-
export declare function BrucksProvider({ labels, children }: BrucksProviderProps): import("react").JSX.Element;
|
|
10
|
+
export declare function BrucksProvider({ language, labels, children }: BrucksProviderProps): import("react").JSX.Element;
|
|
9
11
|
export declare function useBrucksLabels(): BrucksLabels;
|
|
10
12
|
export {};
|
package/dist/ui/lib/labels.js
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { defaultLabels } from "./defaultLabels.js";
|
|
2
|
+
import { defaultLabels, translations } from "./defaultLabels.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { createContext, useContext } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
// src/ui/lib/labels.tsx
|
|
7
7
|
var LabelsContext = createContext(defaultLabels);
|
|
8
8
|
function BrucksProvider(t0) {
|
|
9
|
-
const $ = c(
|
|
10
|
-
const { labels, children } = t0;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const $ = c(6);
|
|
10
|
+
const { language: t1, labels, children } = t0;
|
|
11
|
+
const t2 = translations[t1 === void 0 ? "en" : t1];
|
|
12
|
+
let t3;
|
|
13
|
+
if ($[0] !== labels || $[1] !== t2) {
|
|
14
|
+
t3 = {
|
|
15
|
+
...t2,
|
|
15
16
|
...labels
|
|
16
17
|
};
|
|
17
18
|
$[0] = labels;
|
|
18
|
-
$[1] =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
$[1] = t2;
|
|
20
|
+
$[2] = t3;
|
|
21
|
+
} else t3 = $[2];
|
|
22
|
+
let t4;
|
|
23
|
+
if ($[3] !== children || $[4] !== t3) {
|
|
24
|
+
t4 = /* @__PURE__ */ jsx(LabelsContext.Provider, {
|
|
25
|
+
value: t3,
|
|
24
26
|
children
|
|
25
27
|
});
|
|
26
|
-
$[
|
|
27
|
-
$[
|
|
28
|
-
$[
|
|
29
|
-
} else
|
|
30
|
-
return
|
|
28
|
+
$[3] = children;
|
|
29
|
+
$[4] = t3;
|
|
30
|
+
$[5] = t4;
|
|
31
|
+
} else t4 = $[5];
|
|
32
|
+
return t4;
|
|
31
33
|
}
|
|
32
34
|
function useBrucksLabels() {
|
|
33
35
|
return useContext(LabelsContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.js","names":["c","_c","createContext","ReactNode","useContext","BrucksLabels","defaultLabels","LabelsContext","BrucksProviderProps","labels","Partial","children","BrucksProvider","t0","$","t1","t2","useBrucksLabels","_c"],"sources":["../../../src/ui/lib/labels.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type ReactNode, useContext } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"labels.js","names":["c","_c","createContext","ReactNode","useContext","BrucksLabels","BrucksLanguage","defaultLabels","translations","LabelsContext","BrucksProviderProps","language","labels","Partial","children","BrucksProvider","t0","$","t1","undefined","t2","t3","t4","useBrucksLabels","_c"],"sources":["../../../src/ui/lib/labels.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type ReactNode, useContext } from \"react\";\nimport {\n type BrucksLabels,\n type BrucksLanguage,\n defaultLabels,\n translations,\n} from \"~/ui/lib/defaultLabels\";\n\nconst LabelsContext = createContext<BrucksLabels>(defaultLabels);\n\ntype BrucksProviderProps = {\n /** The language of brucks's own labels; English if left out. */\n language?: BrucksLanguage;\n /** Any label left out comes from `language`. */\n labels?: Partial<BrucksLabels>;\n children: ReactNode;\n};\n\nexport function BrucksProvider({ language = \"en\", labels, children }: BrucksProviderProps) {\n return (\n <LabelsContext.Provider value={{ ...translations[language], ...labels }}>\n {children}\n </LabelsContext.Provider>\n );\n}\n\nexport function useBrucksLabels() {\n return useContext(LabelsContext);\n}\n"],"mappings":";;;;;;AAUA,IAAMS,gBAAgBP,cAA4BK,aAAa;AAU/D,SAAOQ,eAAAC,IAAA;CAAA,MAAAC,IAAAhB,EAAA,CAAA;CAAwB,MAAA,EAAAU,UAAAO,IAAAN,QAAAE,aAAAE;CAES,MAAAI,KAAAZ,aAFPU,OAAAC,KAAAA,IAAA,OAAAD;CAE6B,IAAAG;CAAA,IAAAJ,EAAA,OAAAL,UAAAK,EAAA,OAAAG,IAAA;EAA3BC,KAAA;GAAA,GAAKD;GAAsB,GAAKR;EAAO;EAACK,EAAA,KAAAL;EAAAK,EAAA,KAAAG;EAAAH,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAH,YAAAG,EAAA,OAAAI,IAAA;EAAvEC,KAAA,oBAAA,cAAA,UAAA;GAA+B,OAAAD;GAC5BP;EACH,CAAA;EAAyBG,EAAA,KAAAH;EAAAG,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFzBK;AAEyB;AAI7B,SAAOC,kBAAA;CAAA,OACEnB,WAAWK,aAAa;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikebrucker/brucks",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "builds `brucks`'s Brucks with blucks and brui bromponents;",
|
|
5
|
+
"homepage": "https://github.com/mikebrucker/brucks",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"sideEffects": [
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { cn } from "../../style/utils.js";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
// src/ui/components/loader.tsx
|
|
4
|
-
function Loader({ isOpen, className, fullScreen, transparentBg, label, onClick }) {
|
|
5
|
-
if (!isOpen) return null;
|
|
6
|
-
const wrapperClassName = fullScreen ? cn("fixed inset-0 z-loader flex items-center justify-center", !transparentBg ? "bg-black/50" : null) : void 0;
|
|
7
|
-
const bars = /* @__PURE__ */ jsx("span", { className: `loader ${className ?? ""}`.trim() });
|
|
8
|
-
const status = /* @__PURE__ */ jsx("span", {
|
|
9
|
-
role: "status",
|
|
10
|
-
"aria-live": "polite",
|
|
11
|
-
className: "sr-only",
|
|
12
|
-
lang: label === void 0 ? "en" : void 0,
|
|
13
|
-
children: label ?? "Loading"
|
|
14
|
-
});
|
|
15
|
-
return onClick ? /* @__PURE__ */ jsxs("button", {
|
|
16
|
-
type: "button",
|
|
17
|
-
onClick,
|
|
18
|
-
className: wrapperClassName,
|
|
19
|
-
children: [bars, status]
|
|
20
|
-
}) : /* @__PURE__ */ jsxs("div", {
|
|
21
|
-
className: wrapperClassName,
|
|
22
|
-
children: [bars, status]
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
export { Loader as default };
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","names":[],"sources":["../../../src/ui/components/loader.tsx"],"sourcesContent":["import { cn } from \"~/style/utils\";\n\ntype LoaderProps = {\n isOpen: boolean;\n /** Tailwind text color utilities, e.g. \"text-cyan-400\" */\n className?: string;\n /** Center the loader over a full-page overlay */\n fullScreen?: boolean;\n /** With fullScreen, skip the dimmed backdrop so the page shows through */\n transparentBg?: boolean;\n /** What screen readers announce, in the page's language; English \"Loading\" if left out */\n label?: string;\n /** Makes the wrapper a keyboard-accessible button you can click */\n onClick?: () => void;\n};\n\nexport default function Loader({\n isOpen,\n className,\n fullScreen,\n transparentBg,\n label,\n onClick,\n}: LoaderProps) {\n if (!isOpen) return null;\n\n const backdropClassName = !transparentBg ? \"bg-black/50\" : null;\n const wrapperClassName = fullScreen\n ? cn(\"fixed inset-0 z-loader flex items-center justify-center\", backdropClassName)\n : undefined;\n\n const bars = <span className={`loader ${className ?? \"\"}`.trim()} />;\n\n // The fallback is English on any page, so it says so for the screen reader's voice.\n const status = (\n <span\n role=\"status\"\n aria-live=\"polite\"\n className=\"sr-only\"\n lang={label === undefined ? \"en\" : undefined}\n >\n {label ?? \"Loading\"}\n </span>\n );\n\n return onClick ? (\n <button type=\"button\" onClick={onClick} className={wrapperClassName}>\n {bars}\n {status}\n </button>\n ) : (\n <div className={wrapperClassName}>\n {bars}\n {status}\n </div>\n );\n}\n"],"mappings":";;;AAgBA,SAAwB,OAAO,EAC7B,QACA,WACA,YACA,eACA,OACA,WACc;CACd,IAAI,CAAC,QAAQ,OAAO;CAGpB,MAAM,mBAAmB,aACrB,GAAG,2DAFmB,CAAC,gBAAgB,gBAAgB,IAEwB,IAC/E,KAAA;CAEJ,MAAM,OAAO,oBAAC,QAAD,EAAM,WAAW,UAAU,aAAa,KAAK,KAAK,EAAI,CAAA;CAGnE,MAAM,SACJ,oBAAC,QAAD;EACE,MAAK;EACL,aAAU;EACV,WAAU;EACV,MAAM,UAAU,KAAA,IAAY,OAAO,KAAA;EAElC,UAAA,SAAS;CACN,CAAA;CAGR,OAAO,UACL,qBAAC,UAAD;EAAQ,MAAK;EAAkB;EAAS,WAAW;EAAnD,UAAA,CACG,MACA,MACK;CAER,CAAA,IAAA,qBAAC,OAAD;EAAK,WAAW;EAAhB,UAAA,CACG,MACA,MACE;;AAET"}
|