@brightspot/ui 6.8.0 → 6.8.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/CHANGELOG.md +661 -0
- package/README.md +18 -2
- package/dist/storybook/CHANGELOG.md +661 -0
- package/dist/storybook/README.md +195 -0
- package/dist/storybook/assets/{ActionBar.stories-CJBn-mku.js → ActionBar.stories-TlhuCumU.js} +31 -28
- package/dist/storybook/assets/ActionItem-CjtyGLd5.js +16 -0
- package/dist/storybook/assets/{ActionItem.stories-DXzC9C1u.js → ActionItem.stories-BVlNQvfP.js} +2 -2
- package/dist/storybook/assets/AiSparkle.stories-DMzc8JUe.js +73 -0
- package/dist/storybook/assets/Avatar-C6Li1sPI.js +4 -0
- package/dist/storybook/assets/Avatar.stories-COj6XrPn.js +213 -0
- package/dist/storybook/assets/AvatarGroup-DgxRTZBe.js +1 -0
- package/dist/storybook/assets/AvatarGroup.stories-Dh3e7iN2.js +225 -0
- package/dist/storybook/assets/Badge-bWrvpEgX.js +1 -0
- package/dist/storybook/assets/{Badge.stories-DEpoJpUZ.js → Badge.stories-KXpmEXpt.js} +4 -4
- package/dist/storybook/assets/Banner-FSFX1AIb.css +1 -0
- package/dist/storybook/assets/{Banner.stories--jeU6fKq.js → Banner.stories-Cnhm3dXK.js} +14 -14
- package/dist/storybook/assets/Button-DE0s-gat.js +10 -0
- package/dist/storybook/assets/Button.stories-Cwg1YZEb.js +54 -0
- package/dist/storybook/assets/ButtonGroup-CoLI5nGO.js +1 -0
- package/dist/storybook/assets/{ButtonGroup.stories-CerE_0AC.js → ButtonGroup.stories-VhnKPP1n.js} +7 -7
- package/dist/storybook/assets/Card-DyntwdY-.css +1 -0
- package/dist/storybook/assets/{Card.stories-5SxHtU3Y.js → Card.stories-BgpL90zB.js} +60 -29
- package/dist/storybook/assets/{Celebrate.stories-COS789GX.js → Celebrate.stories-D3NJgYcX.js} +5 -5
- package/dist/storybook/assets/Checkbox-BC1T_KxW.js +30 -0
- package/dist/storybook/assets/{Checkbox.stories-DuQu38Gv.js → Checkbox.stories-AFQNz7dQ.js} +10 -10
- package/dist/storybook/assets/CircularProgress-eqVb2jUD.js +42 -0
- package/dist/storybook/assets/{CircularProgress.stories-Lf2Ws46Y.js → CircularProgress.stories-B6t8VhmJ.js} +2 -2
- package/dist/storybook/assets/ClipboardMixin-DcxrOy5B.js +1 -0
- package/dist/storybook/assets/{ClipboardMixin.stories-BT5KfLZ_.js → ClipboardMixin.stories-BqtQMjmS.js} +6 -6
- package/dist/storybook/assets/{Color-6BZIO3FS-BNBxjqrS.js → Color-6BZIO3FS-CDluohEc.js} +1 -1
- package/dist/storybook/assets/{Colors.stories-Ck6bXbd0.js → Colors.stories-CqTniDIa.js} +1 -1
- package/dist/storybook/assets/{CombinedEffects.stories-DLELdAMr.js → CombinedEffects.stories-FwW0chy5.js} +2 -2
- package/dist/storybook/assets/{ComponentStatesMixin-B6uJL_2c.js → ComponentStatesMixin-hUqOL2aW.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin.stories-fiyrALkY.js → ComponentStatesMixin.stories-CwGoq685.js} +1 -1
- package/dist/storybook/assets/{CopyToClipboard.stories-2OfBH19_.js → CopyToClipboard.stories-DUGjgtQx.js} +18 -10
- package/dist/storybook/assets/{Debounce.stories-C9qo3lIN.js → Debounce.stories-CrWfXhKS.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-LL677BLK-CBVYZYjR.js → DocsRenderer-LL677BLK-9e51z9Xc.js} +3 -3
- package/dist/storybook/assets/{Dropdown.stories-15ZDMkRz.js → Dropdown.stories-BsBxV0wp.js} +2 -2
- package/dist/storybook/assets/DropdownMenu-B-LvOIGj.js +42 -0
- package/dist/storybook/assets/EmptyState-h0A4Qpiu.css +1 -0
- package/dist/storybook/assets/{EmptyState.stories-Bjb8hzYj.js → EmptyState.stories-CJ1w8Tp2.js} +33 -21
- package/dist/storybook/assets/EscaAvatar.stories-BoLLSj9q.js +140 -0
- package/dist/storybook/assets/{Events.stories-BV0vMF2I.js → Events.stories-C3sTBwPJ.js} +2 -2
- package/dist/storybook/assets/{Heading.stories-CEUJqUbQ.js → Heading.stories-jmXDRBmM.js} +1 -1
- package/dist/storybook/assets/{HueRipple.stories-CwvtcOM_.js → HueRipple.stories-BPx5aSYd.js} +2 -2
- package/dist/storybook/assets/Icon-CWyJRQf7.js +34409 -0
- package/dist/storybook/assets/{Icon.stories-AB_v-61c.js → Icon.stories-iYBxmv2x.js} +10 -10
- package/dist/storybook/assets/IconButton-Di5Rgs7F.js +12 -0
- package/dist/storybook/assets/{IconButton.stories-BHuHsM3k.js → IconButton.stories-DENLoxVk.js} +2 -2
- package/dist/storybook/assets/LinearProgress-D9ngIVlv.js +25 -0
- package/dist/storybook/assets/{LinearProgress.stories-BNN5SXe3.js → LinearProgress.stories-u90B_VJR.js} +2 -2
- package/dist/storybook/assets/Message-CM3eexdu.css +1 -0
- package/dist/storybook/assets/Message-nFAa55c_.js +28 -0
- package/dist/storybook/assets/{Message.stories-DdLhMXnb.js → Message.stories-B4rpz5rI.js} +2 -2
- package/dist/storybook/assets/OnFindMixin-oL1bvTFj.js +1 -0
- package/dist/storybook/assets/{OnFindMixin.stories-B-5TeBOF.js → OnFindMixin.stories-CdeS5sFA.js} +9 -9
- package/dist/storybook/assets/Pagination-CSWcjuDU.js +88 -0
- package/dist/storybook/assets/{Pagination.stories-C9zsOdb2.js → Pagination.stories-Da2WzJkv.js} +33 -33
- package/dist/storybook/assets/{Popover.stories-BiqIwebU.js → Popover.stories-CVljlVHc.js} +16 -16
- package/dist/storybook/assets/ProgressMixin-CeSrn0_P.js +1 -0
- package/dist/storybook/assets/Radio-rvfGhZwK.js +25 -0
- package/dist/storybook/assets/{Radio.stories-BmrEdPkm.js → Radio.stories-B0wHdJuc.js} +6 -6
- package/dist/storybook/assets/{RadioGroup.stories-ChARVXs3.js → RadioGroup.stories-D8krOSlP.js} +22 -22
- package/dist/storybook/assets/{ReadyMixin-BbuzH3uO.js → ReadyMixin-CvX_eidU.js} +1 -1
- package/dist/storybook/assets/RovingTabindexMixin-9z8lwaM9.js +1 -0
- package/dist/storybook/assets/{RovingTabindexMixin.stories-xm4b394_.js → RovingTabindexMixin.stories-Y8vBWjJp.js} +5 -5
- package/dist/storybook/assets/{Rtc.stories-DdcMaELA.js → Rtc.stories-D3Y-z8y_.js} +1 -1
- package/dist/storybook/assets/{ScrollShadow.stories-CI67Ougx.js → ScrollShadow.stories-1KD0lWHX.js} +1 -1
- package/dist/storybook/assets/{Switch.stories-DOqrRkxc.js → Switch.stories-Bsqvm_HE.js} +60 -27
- package/dist/storybook/assets/{Tab.stories-DN8o4cf_.js → Tab.stories-CzcTisNs.js} +7 -7
- package/dist/storybook/assets/Tabs-DdpYNZSW.js +17 -0
- package/dist/storybook/assets/{Tabs.stories-BEowfCcl.js → Tabs.stories-UOS3V0J4.js} +6 -6
- package/dist/storybook/assets/{Throttle.stories-BZ_nsuw1.js → Throttle.stories-C8jgzh6e.js} +1 -1
- package/dist/storybook/assets/Tooltip.stories-B5BoI0cH.js +143 -0
- package/dist/storybook/assets/TooltipMixin-CVKslCDt.js +1 -0
- package/dist/storybook/assets/{Upload.stories-sAEiabwq.js → Upload.stories-BsQDCDqo.js} +102 -52
- package/dist/storybook/assets/UploadItem-CYQqNwUF.js +54 -0
- package/dist/storybook/assets/{UploadItem.stories-C19JMfmB.js → UploadItem.stories-_le7XBTV.js} +4 -4
- package/dist/storybook/assets/{Welcome.stories-C30jg0r1.js → Welcome.stories-rramKkhd.js} +38 -8
- package/dist/storybook/assets/Widget-elBzGg8w.css +1 -0
- package/dist/storybook/assets/Widget.stories-DtbAaklk.js +279 -0
- package/dist/storybook/assets/{WithTooltip-65CFNBJE-PFRy5maL.js → WithTooltip-65CFNBJE-DK6GcBuR.js} +1 -1
- package/dist/storybook/assets/ai-sparkle-BZMJJAxY.js +1 -0
- package/dist/storybook/assets/aria-D5THOgos.js +1 -0
- package/dist/storybook/assets/{blocks-DLjjvsFT.js → blocks-DHnzPh43.js} +5 -5
- package/dist/storybook/assets/esca-glow-BwdhBvIX.js +2 -0
- package/dist/storybook/assets/esca-idle-B-fumiIb.js +1 -0
- package/dist/storybook/assets/esca-search-rwNfo19I.js +1 -0
- package/dist/storybook/assets/esca-task-complete-BAJP2dY2.js +1 -0
- package/dist/storybook/assets/esca-wave-Bjs4CUR7.js +1 -0
- package/dist/storybook/assets/{formatter-EIJCOSYU-D39uscG_.js → formatter-EIJCOSYU-qig-qWlG.js} +1 -1
- package/dist/storybook/assets/i18n-BQ-Uj-0B.js +1 -0
- package/dist/storybook/assets/if-defined-DerKRcyC.js +1 -0
- package/dist/storybook/assets/{iframe-B9buZjP7.js → iframe-DlBK9Drk.js} +24 -24
- package/dist/storybook/assets/{index-BdEHup-4.js → index-CItQyB37.js} +1 -1
- package/dist/storybook/assets/lottie_svg-C3v6xdng.js +2 -0
- package/dist/storybook/assets/{onFind-CGzSFqNN.js → onFind-Ci35eu2y.js} +1 -1
- package/dist/storybook/assets/{onFind.stories-Dq71qO14.js → onFind.stories-BmbwWWo1.js} +1 -1
- package/dist/storybook/assets/{onRemove.stories-B1GqLH_U.js → onRemove.stories-DFWCIgE4.js} +1 -1
- package/dist/storybook/assets/{onVisible.stories-BNKxOfLw.js → onVisible.stories-B-onpgE-.js} +1 -1
- package/dist/storybook/assets/property-Bmq4RTSP.js +1 -0
- package/dist/storybook/assets/ref-BhKk4SDh.js +1 -0
- package/dist/storybook/assets/state-DVIUS0Gf.js +1 -0
- package/dist/storybook/assets/{style-map-qCiIYcp5.js → style-map-DE4G47KD.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-ED5Y7EFY-CUM-CaRF.js → syntaxhighlighter-ED5Y7EFY-Dfgnal1d.js} +1 -1
- package/dist/storybook/custom-elements.json +11835 -0
- package/dist/storybook/docs/components/ActionBar.md +55 -0
- package/dist/storybook/docs/components/ActionItem.md +50 -0
- package/dist/storybook/docs/components/AiSparkle.md +33 -0
- package/dist/storybook/docs/components/Avatar.md +45 -0
- package/dist/storybook/docs/components/AvatarGroup.md +34 -0
- package/dist/storybook/docs/components/Badge.md +47 -0
- package/dist/storybook/docs/components/Banner.md +35 -0
- package/dist/storybook/docs/components/ButtonGroup.md +65 -0
- package/dist/storybook/docs/components/Card.md +67 -0
- package/dist/storybook/docs/components/Checkbox.md +49 -0
- package/dist/storybook/docs/components/CircularProgress.md +40 -0
- package/dist/storybook/docs/components/CopyToClipboard.md +51 -0
- package/dist/storybook/docs/components/Dropdown.md +74 -0
- package/dist/storybook/docs/components/DropdownItem.md +45 -0
- package/dist/storybook/docs/components/DropdownMenu.md +41 -0
- package/dist/storybook/docs/components/EmptyState.md +62 -0
- package/dist/storybook/docs/components/EscaAvatar.md +40 -0
- package/dist/storybook/docs/components/Icon.md +40 -0
- package/dist/storybook/docs/components/IconButton.md +36 -0
- package/dist/storybook/docs/components/LinearProgress.md +37 -0
- package/dist/storybook/docs/components/Message.md +50 -0
- package/dist/storybook/docs/components/Pagination.md +70 -0
- package/dist/storybook/docs/components/Popover.md +59 -0
- package/dist/storybook/docs/components/README.md +48 -0
- package/dist/storybook/docs/components/Radio.md +55 -0
- package/dist/storybook/docs/components/RadioGroup.md +34 -0
- package/dist/storybook/docs/components/Switch.md +48 -0
- package/dist/storybook/docs/components/Tab.md +40 -0
- package/dist/storybook/docs/components/Tabs.md +49 -0
- package/dist/storybook/docs/components/Upload.md +63 -0
- package/dist/storybook/docs/components/UploadItem.md +30 -0
- package/dist/storybook/docs/components/Widget.md +88 -0
- package/dist/storybook/docs/dari-elements.md +55 -0
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/index.html +29 -2
- package/dist/storybook/llms-full.txt +1721 -0
- package/dist/storybook/llms.txt +65 -0
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/robots.txt +7 -0
- package/dist/storybook/sb-addons/storybook-3/manager-bundle.js +1 -1
- package/dist/storybook/sitemap.xml +90 -0
- package/docs/components/ActionBar.md +41 -64
- package/docs/components/ActionItem.md +50 -96
- package/docs/components/AiSparkle.md +23 -60
- package/docs/components/Avatar.md +45 -88
- package/docs/components/AvatarGroup.md +24 -44
- package/docs/components/Badge.md +34 -62
- package/docs/components/Banner.md +25 -39
- package/docs/components/ButtonGroup.md +65 -99
- package/docs/components/Card.md +67 -83
- package/docs/components/Checkbox.md +49 -91
- package/docs/components/CircularProgress.md +40 -84
- package/docs/components/CopyToClipboard.md +35 -40
- package/docs/components/Dropdown.md +74 -120
- package/docs/components/DropdownItem.md +45 -81
- package/docs/components/DropdownMenu.md +30 -70
- package/docs/components/EmptyState.md +45 -62
- package/docs/components/EscaAvatar.md +30 -61
- package/docs/components/Icon.md +29 -62
- package/docs/components/IconButton.md +36 -83
- package/docs/components/LinearProgress.md +28 -70
- package/docs/components/Message.md +38 -63
- package/docs/components/Pagination.md +70 -100
- package/docs/components/Popover.md +46 -79
- package/docs/components/README.md +34 -40
- package/docs/components/Radio.md +55 -105
- package/docs/components/RadioGroup.md +26 -55
- package/docs/components/Switch.md +48 -84
- package/docs/components/Tab.md +30 -70
- package/docs/components/Tabs.md +49 -86
- package/docs/components/Upload.md +63 -112
- package/docs/components/UploadItem.md +22 -53
- package/docs/components/Widget.md +66 -67
- package/llms.txt +63 -0
- package/package.json +9 -6
- package/dist/storybook/assets/AiSparkle.stories-BfjT5jrJ.js +0 -72
- package/dist/storybook/assets/Avatar.stories-D8lnIZaY.js +0 -213
- package/dist/storybook/assets/AvatarGroup.stories-Cz9oVah0.js +0 -225
- package/dist/storybook/assets/Button-2ucj5lUP.js +0 -10
- package/dist/storybook/assets/Button.stories-ndl1RJd7.js +0 -54
- package/dist/storybook/assets/EscaAvatar.stories-Rc2MSzCX.js +0 -139
- package/dist/storybook/assets/LucideDynamicLoader-BuoNL33C.js +0 -1
- package/dist/storybook/assets/Tooltip.stories-3bar43ZN.js +0 -143
- package/dist/storybook/assets/Widget.stories-9-1XpZNl.js +0 -233
- package/dist/storybook/assets/if-defined-BwWBCoAU.js +0 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Brightspot UI
|
|
2
|
+
|
|
3
|
+
`@brightspot/ui` is a library of ready-made interface pieces — buttons, widgets, icons — plus a full set of colors and styles (light, dark, and high-contrast) for the screens inside the Brightspot CMS.
|
|
4
|
+
|
|
5
|
+
The CMS's own interface is built from this UI library, and we're gradually moving the rest of it over. It is also published so individual Brightspot projects can use it.
|
|
6
|
+
|
|
7
|
+
## What do you want to do?
|
|
8
|
+
|
|
9
|
+
- [Fix or change the CMS UI](#fix-or-change-the-cms-ui)
|
|
10
|
+
- [Use the UI library in a project](#use-the-ui-library-in-a-project)
|
|
11
|
+
- [Improve the UI library itself](#improve-the-ui-library-itself)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Fix or change the CMS UI
|
|
16
|
+
|
|
17
|
+
The CMS interface lives in `src/legacy/tool-ui/`. Edit files there and preview them in a running CMS one of two ways.
|
|
18
|
+
|
|
19
|
+
**You'll need:** Node 22 (`nvm use 22`), Yarn 1, a local `brightspot` checkout, and `yarn install` then `yarn build` run once here. The CMS bundle imports some library components from the build output, so rerun `yarn build` after changing them.
|
|
20
|
+
|
|
21
|
+
> **Editor tip:** In VSCode, the recommended extensions autocomplete the `btu-*` classes as you type. See the [VSCode setup notes](src/legacy/tool-ui/README.md#visual-studio-code).
|
|
22
|
+
|
|
23
|
+
### Fast way — live preview (for everyday edits)
|
|
24
|
+
|
|
25
|
+
1. Start the CMS backend (in your `brightspot/` folder):
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
docker compose up -d
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
2. Start the live preview (here):
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
cd src/legacy/tool-ui
|
|
35
|
+
yarn server:local
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
3. Open the dev server — note the **`:8080`**, not plain `localhost`:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
https://localhost:8080/cms/
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Click through the certificate warning (local cert — normal).
|
|
45
|
+
|
|
46
|
+
Now edit anything in `src/legacy/tool-ui/src/` and the browser updates on its own — no rebuilding.
|
|
47
|
+
|
|
48
|
+
_Seeing `502` errors? The CMS backend isn't reachable — check the docker step._
|
|
49
|
+
|
|
50
|
+
_Seeing `The 'btu-…' class does not exist` after a pull? Run `yarn install` here. New utilities can arrive with new dependency versions — icon names come from `lucide-static` — and a pull updates the code without updating what's installed. Running it at the repo root installs the `src/legacy/tool-ui/` workspace too, so one command covers both._
|
|
51
|
+
|
|
52
|
+
### Full way — build the real package (for a final check only)
|
|
53
|
+
|
|
54
|
+
Slower, but produces the actual file the CMS ships. Needs two temporary edits in `brightspot` — **don't commit them**.
|
|
55
|
+
|
|
56
|
+
1. Build the package (here):
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
./gradlew publishToMavenLocal
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. Point `brightspot` at your build:
|
|
63
|
+
- `site/build.gradle` — add `mavenLocal()` under `repositories`
|
|
64
|
+
- `platform/brightspot-dependencies/build.gradle` — change the cms-tool-ui line to:
|
|
65
|
+
|
|
66
|
+
```groovy
|
|
67
|
+
api 'com.brightspot.ui:cms-tool-ui:9999-SNAPSHOT'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
3. Rebuild and run (in `brightspot/`):
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
./gradlew docker
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
4. Check it at https://localhost/cms/, then undo the two edits when done.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Use the UI library in a project
|
|
81
|
+
|
|
82
|
+
> Starting a new frontend package? [`@brightspot/ui-builder`](https://www.npmjs.com/package/@brightspot/ui-builder) scaffolds the build (Vite) and wires up this preset for you. The steps below are for adding the library to a build you already have.
|
|
83
|
+
|
|
84
|
+
**You'll need:** a frontend using TailwindCSS v3.
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
yarn add -D @brightspot/ui
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If you don't already have one, create a Tailwind config file at the root of your frontend — `tailwind.config.mjs`:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
// tailwind.config.mjs
|
|
94
|
+
export default {
|
|
95
|
+
content: ['./src/**/*.{js,ts,html,java}'], // wherever your markup lives, including Java that builds class lists
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Then add `@brightspot/ui` as a [preset](https://v3.tailwindcss.com/docs/presets). One line pulls in everything — all colors, styles, and components:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
// tailwind.config.mjs
|
|
103
|
+
import preset from '@brightspot/ui'
|
|
104
|
+
|
|
105
|
+
export default {
|
|
106
|
+
presets: [preset],
|
|
107
|
+
content: ['./src/**/*.{js,ts,html,java}'],
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Leave `plugins` empty — the preset already registers every component's plugin, so listing them again double-registers.
|
|
112
|
+
|
|
113
|
+
To use a component, import it (it self-registers its `btu-*` element), then use the tag. Import from the `components/` subpath with the `.js` extension — not the deep `dist/` path:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import '@brightspot/ui/components/badge/Badge.js'
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<btu-badge>Draft</btu-badge>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
On a CMS page, the CMS defines only a few of these elements itself. Import every other element your plugin uses, including ones your Java renders through the generated `com.brightspot.ui.dari` classes. [Using these in a plugin](docs/components/README.md#using-these-in-a-plugin) lists which ones the CMS defines.
|
|
124
|
+
|
|
125
|
+
Browse every component, with live examples, at [ui.brightspot.com](https://ui.brightspot.com). The site shows only the newest release. To browse the version you have installed (6.8.1 or later), serve the copy that ships in the package and open http://localhost:6006:
|
|
126
|
+
|
|
127
|
+
```sh
|
|
128
|
+
npx http-server node_modules/@brightspot/ui/dist/storybook -p 6006
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Opening its `index.html` straight from disk doesn't work, because browsers block its scripts on `file://`.
|
|
132
|
+
|
|
133
|
+
### Point your AI coding agent at the docs
|
|
134
|
+
|
|
135
|
+
The package ships docs written for coding agents, matched to the installed version: `llms.txt` at the package root, one page per component in `docs/components/`, and the Custom Elements Manifest. Agents don't find them on their own, so add this to your project's `AGENTS.md` or `CLAUDE.md`:
|
|
136
|
+
|
|
137
|
+
```md
|
|
138
|
+
## @brightspot/ui
|
|
139
|
+
|
|
140
|
+
This project uses `@brightspot/ui` web components (`btu-*` tags). Before writing or changing code that uses them,
|
|
141
|
+
read `node_modules/@brightspot/ui/llms.txt` and the component pages it links to. They match the installed version,
|
|
142
|
+
so prefer them over what you remember about this library.
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Without a local install, give the agent `https://ui.brightspot.com/llms.txt`, which describes the newest release.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Improve the UI library itself
|
|
150
|
+
|
|
151
|
+
Adding or fixing a component, style, or color.
|
|
152
|
+
|
|
153
|
+
**You'll need:** Node 22 (`nvm use 22`), Yarn 1.
|
|
154
|
+
|
|
155
|
+
**Where things live:**
|
|
156
|
+
|
|
157
|
+
- `src/` — the UI library (components, styles, colors); this is what gets published.
|
|
158
|
+
- `src/legacy/tool-ui/` — the CMS interface (see the first section).
|
|
159
|
+
- `tool-ui/` — packaging only.
|
|
160
|
+
|
|
161
|
+
Build and preview components in the catalog — no CMS needed:
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
yarn storybook
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Before committing:
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
yarn build # compile everything
|
|
171
|
+
yarn check:conventions # check the rules
|
|
172
|
+
yarn format # tidy formatting
|
|
173
|
+
yarn test:storybook # run tests
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**House rules** — when you touch one of these areas, read its guide in `.ai/` first:
|
|
177
|
+
|
|
178
|
+
| Area | Guide |
|
|
179
|
+
| ----------------------------------------------- | -------------------------------------- |
|
|
180
|
+
| Naming (sizes, icons, events, CSS vars) | `.ai/LESSONS-NAMING.md` |
|
|
181
|
+
| JSDoc and types | `.ai/LESSONS-JSDOC.md` |
|
|
182
|
+
| Reusing the button primitive | `.ai/LESSONS-BUTTON-REUSE.md` |
|
|
183
|
+
| Keeping plugin styles isolated | `.ai/LESSONS-PLUGIN-ISOLATION.md` |
|
|
184
|
+
| Safelisting classes written at runtime | `.ai/LESSONS-SAFELIST.md` |
|
|
185
|
+
| Preset vs Storybook config; adding a new plugin | `.ai/LESSONS-TAILWIND-CONFIGS.md` |
|
|
186
|
+
| CSS custom properties + Tailwind gotchas | `.ai/LESSONS-CSS-PROPS.md` |
|
|
187
|
+
| Writing Storybook stories | `.ai/LESSONS-STORYBOOK.md` |
|
|
188
|
+
| Anchor positioning / popovers | `.ai/LESSONS-ANCHOR-POSITIONING.md` |
|
|
189
|
+
| Reduced motion | `.ai/LESSONS-REDUCED-MOTION.md` |
|
|
190
|
+
| Roving tabindex | `.ai/LESSONS-ROVING-TABINDEX.md` |
|
|
191
|
+
| Composing components | `.ai/LESSONS-COMPONENT-COMPOSITION.md` |
|
|
192
|
+
|
|
193
|
+
See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for documentation standards.
|
|
194
|
+
|
|
195
|
+
**Releases** are automatic: merge to `main`, and a version is tagged and published for you.
|
package/dist/storybook/assets/{ActionBar.stories-CJBn-mku.js → ActionBar.stories-TlhuCumU.js}
RENAMED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as C,x as l,g as z}from"./iframe-DlBK9Drk.js";import{o as k}from"./style-map-DE4G47KD.js";import{n as b}from"./property-Bmq4RTSP.js";import{E as I,R as A}from"./ReadyMixin-CvX_eidU.js";import{R as P}from"./RovingTabindexMixin-9z8lwaM9.js";import"./DropdownMenu-B-LvOIGj.js";import"./ActionItem-CjtyGLd5.js";import"./preload-helper-PPVm8Dsz.js";import"./aria-D5THOgos.js";import"./TooltipMixin-CVKslCDt.js";import"./Icon-CWyJRQf7.js";import"./Badge-bWrvpEgX.js";import"./if-defined-DerKRcyC.js";import"./CircularProgress-eqVb2jUD.js";import"./ProgressMixin-CeSrn0_P.js";var T=Object.defineProperty,d=(n,t,e,a)=>{for(var i=void 0,o=n.length-1,r;o>=0;o--)(r=n[o])&&(i=r(t,e,i)||i);return i&&T(t,e,i),i};const u={tertiary:0,secondary:1,primary:2,destructive:0};class m extends P(I(A(C))){constructor(){super(...arguments),this.position="bottom",this.sticky=!1,this.alignment="default",this.shadow=!1,this.label="",this.compact=!1,this.initialClasses=[],this._initialClassesCaptured=!1,this._items=[],this._startZone=null,this._endZone=null,this._moreDropdown=null,this._ro=null,this._rafId=null,this._expandedWidths=new Map,this._compactedWidths=new Map,this._hasOverflow=!1,this._compactedItems=new Set,this._boundKeydown=this._handleKeydown.bind(this)}createRenderRoot(){return this}_getRovingTargets(){const t=[];if(this._startZone){for(const e of this._startZone.querySelectorAll("btu-action-item"))if(e.style.display!=="none"){const a=e.querySelector("button");a&&t.push(a)}}if(this._moreDropdown&&this._moreDropdown.style.display!=="none"){const e=this._moreDropdown.querySelector("button");e&&t.push(e)}for(const e of this._getEndZoneItems())if(e.style.display!=="none"){const a=e.querySelector("button");a&&t.push(a)}return t}connectedCallback(){this._initialClassesCaptured||(this.className&&(this.initialClasses=this.className.split(" ").filter(t=>t.trim())),this._initialClassesCaptured=!0),this._items=Array.from(this.querySelectorAll("btu-action-item")),this._items.forEach(t=>t.remove()),this.setAttribute("role","toolbar"),this.setAttribute("aria-orientation","horizontal"),super.connectedCallback(),this.addEventListener("keydown",this._boundKeydown)}willUpdate(){const t=[...this.initialClasses,"btu-action-bar"];this.className=t.filter(Boolean).join(" "),this.label?this.setAttribute("aria-label",this.label):this.removeAttribute("aria-label")}firstUpdated(){if(this._startZone=this.querySelector(".btu-action-bar-start"),this._endZone=this.querySelector(".btu-action-bar-end"),!(!this._startZone||!this._endZone)){for(const t of this._items)(this._getItemZone(t)==="start"?this._startZone:this._endZone).appendChild(t);this._sortEndZoneItems(),this._createOverflowDropdown(this._endZone),this._cacheWidths(this._expandedWidths,!1),this._cacheWidths(this._compactedWidths,!0),this._setupOverflowDetection(),this._updateTabindex(0),this.emit("btu-action-bar-ready")}}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this._boundKeydown),this._ro&&(this._ro.disconnect(),this._ro=null),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null)}_getItemZone(t){return t.zone==="start"||t.zone==="end"?t.zone:t.variant==="destructive"?"start":"end"}_getVisibleItems(){const t=[];return this._startZone&&t.push(...Array.from(this._startZone.querySelectorAll("btu-action-item"))),this._endZone&&t.push(...Array.from(this._endZone.querySelectorAll(":scope > btu-action-item"))),t.filter(e=>e.style.display!=="none")}_getEndZoneItems(){return this._endZone?Array.from(this._endZone.querySelectorAll(":scope > btu-action-item")):[]}_sortEndZoneItems(){if(!this._endZone)return;const t=this._getEndZoneItems(),e=this.alignment==="start";t.sort((a,i)=>{const o=u[a.variant]??0,r=u[i.variant]??0;return e?r-o:o-r});for(const a of t)this._endZone.appendChild(a)}_cacheWidths(t,e){t.clear();for(const a of this._getEndZoneItems()){const o=e&&a.compactable&&a.symbol&&!a.iconOnly?a.querySelector("button"):null;o&&o.classList.add("btu-button-text-hidden"),t.set(a,a.getBoundingClientRect().width),o&&o.classList.remove("btu-button-text-hidden")}}_calcTotalWidth(t){const e=parseFloat(getComputedStyle(this._endZone).gap)||12;let a=0;for(const i of t){if(i.style.display==="none")continue;const r=(this._compactedItems.has(i)?this._compactedWidths:this._expandedWidths).get(i)||i.getBoundingClientRect().width;a>0&&(a+=e),a+=r}return a}_setupOverflowDetection(){this._ro=new ResizeObserver(()=>this._scheduleRecalc()),this._ro.observe(this)}_scheduleRecalc(){this._rafId||(this._rafId=requestAnimationFrame(()=>{this._rafId=null,this._recalculateOverflow()}))}_recalculateOverflow(){if(!this._endZone)return;const t=this._getEndZoneItems(),e=this._endZone.clientWidth,a=40,i=parseFloat(getComputedStyle(this._endZone).gap)||12;if(t.forEach(s=>s.style.display=""),this._compactedItems.clear(),this._calcTotalWidth(t)<=e){this._hasOverflow=!1,this._updateOverflowDropdown([]),this._updateTabindex(Math.min(this._rovingIndex,this._getVisibleItems().length-1));return}const o=[...t].sort((s,S)=>(u[s.variant]??0)-(u[S.variant]??0));if(this.compact){for(const s of o)if(!(!s.compactable||!s.symbol||s.iconOnly)&&(this._compactedItems.add(s),this._calcTotalWidth(t)<=e)){this._hasOverflow=!1,this._updateOverflowDropdown([]),this._updateTabindex(Math.min(this._rovingIndex,this._getVisibleItems().length-1));return}}const r=[];for(const s of o){const S=t.filter(D=>!r.includes(D));if(this._calcTotalWidth(S)+a+i<=e)break;r.push(s),s.style.display="none"}this._hasOverflow=r.length>0,this._updateOverflowDropdown(r),this._updateTabindex(Math.min(this._rovingIndex,Math.max(0,this._getVisibleItems().length-1)))}_createOverflowDropdown(t){this._moreDropdown=document.createElement("btu-dropdown"),this._moreDropdown.setAttribute("symbol","ellipsis"),this._moreDropdown.setAttribute("icon-only",""),this._moreDropdown.setAttribute("variant","tertiary"),this._moreDropdown.setAttribute("size","sm"),this._moreDropdown.setAttribute("no-chevron",""),this._moreDropdown.setAttribute("aria-label","More actions"),this._moreDropdown.style.display="none";const e=document.createElement("btu-dropdown-menu");this._moreDropdown.appendChild(e),t.prepend(this._moreDropdown),this._moreDropdown.addEventListener("btu-dropdown-item-select",this._handleOverflowSelect.bind(this))}_updateOverflowDropdown(t){if(!this._moreDropdown)return;const e=this._moreDropdown.querySelector("btu-dropdown-menu");if(!e)return;if(t.length===0){this._moreDropdown.style.display="none",e.innerHTML="";return}this._moreDropdown.style.display="",e.innerHTML="";const a=[...t].reverse();for(const i of a){const o=document.createElement("btu-dropdown-item");o.setAttribute("label",i.label),o.dataset.itemIndex=String(this._items.indexOf(i)),i.symbol&&o.setAttribute("symbol",i.symbol),i.disabled&&o.setAttribute("disabled",""),e.appendChild(o)}}_handleOverflowSelect(t){const e=t.target,a=parseInt(e.dataset.itemIndex||"-1",10),i=this._items[a];i&&!i.disabled&&!i.loading&&i.emit("btu-action-item-click",{label:i.label})}_updateTabindex(t){this._rovingFocus(t,!1);const a=this._getRovingTargets()[this._rovingIndex];this._getVisibleItems().forEach(o=>{const r=o.querySelector("button");o._configure({tabindex:r===a?0:-1,collapsed:this._compactedItems.has(o)})})}updated(t){(t.has("compact")||t.has("alignment"))&&this._scheduleRecalc()}_handleKeydown(t){const e=getComputedStyle(this).direction==="rtl",a=e?"ArrowLeft":"ArrowRight",i=e?"ArrowRight":"ArrowLeft";switch(t.key){case a:t.preventDefault(),this._rovingNext();break;case i:t.preventDefault(),this._rovingPrev();break;case"Home":t.preventDefault(),this._rovingFirst();break;case"End":t.preventDefault(),this._rovingLast();break}}render(){return l`
|
|
2
|
+
<div class="btu-action-bar-start"></div>
|
|
3
|
+
<div class="btu-action-bar-end"></div>
|
|
4
|
+
`}}d([b({type:String,reflect:!0})],m.prototype,"position");d([b({type:Boolean,reflect:!0})],m.prototype,"sticky");d([b({type:String,reflect:!0,attribute:"item-alignment"})],m.prototype,"alignment");d([b({type:Boolean,reflect:!0})],m.prototype,"shadow");d([b({type:String})],m.prototype,"label");d([b({type:Boolean,reflect:!0})],m.prototype,"compact");customElements.get("btu-action-bar")||customElements.define("btu-action-bar",m);const{events:Z,args:O,argTypes:c}=z("btu-action-bar"),J={title:"Components/Action Bar",component:"btu-action-bar",tags:["autodocs"],parameters:{docs:{subtitle:"A persistent container for primary, secondary, tertiary, and destructive actions",description:{component:`
|
|
2
5
|
ActionBar provides a horizontal bar for grouping action buttons, typically anchored to the bottom of a view.
|
|
3
6
|
|
|
4
7
|
<h3>Two-Zone Layout:</h3>
|
|
@@ -17,15 +20,15 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
17
20
|
<li><strong>Tab</strong> — Exit toolbar</li>
|
|
18
21
|
<li><strong>Initial focus</strong> — Lands on the first item in visual order per WAI-ARIA toolbar conventions, not the primary action. Arrow keys reach any item quickly.</li>
|
|
19
22
|
</ul>
|
|
20
|
-
`}},actions:{handles:
|
|
23
|
+
`}},actions:{handles:Z},controls:{expanded:!0}},args:{...O,label:"Content actions",position:"bottom","item-alignment":"default",shadow:!1,sticky:!1,compact:!1},argTypes:{...c,"--action-bar-gap":{table:{disable:!0}},"--action-bar-padding":{table:{disable:!0}},"--action-bar-background":{table:{disable:!0}},"--action-bar-border-color":{table:{disable:!0}},"--action-bar-z-index":{table:{disable:!0}},label:{...c.label,control:{type:"text"},description:"Accessible label for the toolbar region"},position:{...c.position,control:{type:"select"},options:["top","bottom"],description:"Bar position (top or bottom). Use with `sticky` for sticky behavior."},sticky:{...c.sticky,control:{type:"boolean"},description:"CSS sticky positioning (combines with position for direction)"},"item-alignment":{...c["item-alignment"],control:{type:"select"},options:["default","start","center","end"],description:"Content alignment (non-default disables two-zone layout)"},shadow:{...c.shadow,control:{type:"boolean"},description:"Adds a box-shadow"},compact:{...c.compact,control:{type:"boolean"},description:"Progressive label compacting before overflow (items need `compactable`)"},customGap:{name:"--action-bar-gap",control:{type:"text"},description:"Gap between items (default: 0.75rem)",table:{category:"css properties"}},customPadding:{name:"--action-bar-padding",control:{type:"text"},description:"Bar padding (default: 1.5rem)",table:{category:"css properties"}},customBackground:{name:"--action-bar-background",control:{type:"color"},description:"Background color",table:{category:"css properties"}},customBorderColor:{name:"--action-bar-border-color",control:{type:"color"},description:"Border color",table:{category:"css properties"}}},render:n=>{const t={};return n.customGap&&(t["--action-bar-gap"]=n.customGap),n.customPadding&&(t["--action-bar-padding"]=n.customPadding),n.customBackground&&(t["--action-bar-background"]=n.customBackground),n.customBorderColor&&(t["--action-bar-border-color"]=n.customBorderColor),l`
|
|
21
24
|
<btu-action-bar
|
|
22
|
-
label="${
|
|
23
|
-
position="${
|
|
24
|
-
?sticky="${
|
|
25
|
-
item-alignment="${
|
|
26
|
-
?shadow="${
|
|
27
|
-
?compact="${
|
|
28
|
-
style=${
|
|
25
|
+
label="${n.label}"
|
|
26
|
+
position="${n.position}"
|
|
27
|
+
?sticky="${n.sticky}"
|
|
28
|
+
item-alignment="${n["item-alignment"]}"
|
|
29
|
+
?shadow="${n.shadow}"
|
|
30
|
+
?compact="${n.compact}"
|
|
31
|
+
style=${k(t)}
|
|
29
32
|
>
|
|
30
33
|
<btu-action-item
|
|
31
34
|
zone="start"
|
|
@@ -36,7 +39,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
36
39
|
<btu-action-item zone="end" variant="secondary" label="Cancel"></btu-action-item>
|
|
37
40
|
<btu-action-item zone="end" variant="primary" label="Save Changes"></btu-action-item>
|
|
38
41
|
</btu-action-bar>
|
|
39
|
-
`}},
|
|
42
|
+
`}},p={args:{}},h={render:()=>l`
|
|
40
43
|
<div class="flex flex-col gap-4">
|
|
41
44
|
<div>
|
|
42
45
|
<p class="mb-2 text-sm font-medium text-gray-500">
|
|
@@ -70,7 +73,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
70
73
|
</btu-action-bar>
|
|
71
74
|
</div>
|
|
72
75
|
</div>
|
|
73
|
-
`,parameters:{docs:{description:{story:"Items are automatically sorted by variant priority regardless of authored DOM order. In default/end/center alignment, primary is rightmost. In start alignment, primary is leftmost. Items with the same variant maintain their author order."}}}},
|
|
76
|
+
`,parameters:{docs:{description:{story:"Items are automatically sorted by variant priority regardless of authored DOM order. In default/end/center alignment, primary is rightmost. In start alignment, primary is leftmost. Items with the same variant maintain their author order."}}}},y={render:()=>l`
|
|
74
77
|
<div class="flex flex-col gap-4">
|
|
75
78
|
<div>
|
|
76
79
|
<p class="mb-2 text-sm font-medium text-gray-500">item-alignment="default" (two-zone layout)</p>
|
|
@@ -101,7 +104,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
101
104
|
</btu-action-bar>
|
|
102
105
|
</div>
|
|
103
106
|
</div>
|
|
104
|
-
`,parameters:{docs:{description:{story:'The `item-alignment` attribute controls content positioning. The default "two-zone" layout separates start and end items; other alignments place all items together. Items are auto-sorted by variant priority.'}}}},
|
|
107
|
+
`,parameters:{docs:{description:{story:'The `item-alignment` attribute controls content positioning. The default "two-zone" layout separates start and end items; other alignments place all items together. Items are auto-sorted by variant priority.'}}}},v={render:()=>l`
|
|
105
108
|
<div class="flex flex-wrap gap-4">
|
|
106
109
|
<div class="flex h-[300px] w-[300px] flex-col rounded-lg border border-gray-200">
|
|
107
110
|
<div class="flex-1 p-4 text-sm text-gray-500">position="bottom" (default)</div>
|
|
@@ -132,12 +135,12 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
132
135
|
</div>
|
|
133
136
|
</div>
|
|
134
137
|
</div>
|
|
135
|
-
`,parameters:{docs:{description:{story:"Position variants: `bottom` (default, margin-top: auto), `top` (margin-bottom: auto). The `sticky` attribute enables CSS sticky positioning — combine with `position` for direction."}}}},
|
|
138
|
+
`,parameters:{docs:{description:{story:"Position variants: `bottom` (default, margin-top: auto), `top` (margin-bottom: auto). The `sticky` attribute enables CSS sticky positioning — combine with `position` for direction."}}}},f={render:()=>l`
|
|
136
139
|
<btu-action-bar label="Shadow bar" shadow>
|
|
137
140
|
<btu-action-item zone="end" variant="secondary" label="Cancel"></btu-action-item>
|
|
138
141
|
<btu-action-item zone="end" variant="primary" label="Save Changes"></btu-action-item>
|
|
139
142
|
</btu-action-bar>
|
|
140
|
-
`,parameters:{docs:{description:{story:"The `shadow` attribute adds a box-shadow to the bar for visual elevation."}}}},
|
|
143
|
+
`,parameters:{docs:{description:{story:"The `shadow` attribute adds a box-shadow to the bar for visual elevation."}}}},g={render:()=>l`
|
|
141
144
|
<div
|
|
142
145
|
style="width: 400px; max-width: 100%; resize: horizontal; overflow: hidden; border: 1px solid oklch(var(--btu-theme-gray-200)); border-radius: 0.5rem;"
|
|
143
146
|
>
|
|
@@ -148,7 +151,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
148
151
|
<btu-action-item zone="end" variant="primary" label="Publish" symbol="send"></btu-action-item>
|
|
149
152
|
</btu-action-bar>
|
|
150
153
|
</div>
|
|
151
|
-
`,parameters:{docs:{description:{story:`When items don't fit, the least important overflow first into a "More" dropdown. Resize to see: tertiary "Preview" overflows before secondary "Save Draft", which overflows before primary "Publish".`}}}},
|
|
154
|
+
`,parameters:{docs:{description:{story:`When items don't fit, the least important overflow first into a "More" dropdown. Resize to see: tertiary "Preview" overflows before secondary "Save Draft", which overflows before primary "Publish".`}}}},w={render:()=>l`
|
|
152
155
|
<div
|
|
153
156
|
style="width: 600px; max-width: 100%; resize: horizontal; overflow: hidden; border: 1px solid oklch(var(--btu-theme-gray-200)); border-radius: 0.5rem;"
|
|
154
157
|
>
|
|
@@ -159,7 +162,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
159
162
|
<btu-action-item variant="primary" label="Publish" symbol="send" compactable></btu-action-item>
|
|
160
163
|
</btu-action-bar>
|
|
161
164
|
</div>
|
|
162
|
-
`,parameters:{docs:{description:{story:'With `compact` on the bar and `compactable` on items, labels progressively compact to icon-only mode (least important first) before overflowing. Resize the container to see:\n1. Tertiary "Preview" compacts first\n2. Then secondary "Save Draft" compacts\n3. Then primary "Publish" compacts\n4. Finally items overflow into "More" dropdown'}}}},
|
|
165
|
+
`,parameters:{docs:{description:{story:'With `compact` on the bar and `compactable` on items, labels progressively compact to icon-only mode (least important first) before overflowing. Resize the container to see:\n1. Tertiary "Preview" compacts first\n2. Then secondary "Save Draft" compacts\n3. Then primary "Publish" compacts\n4. Finally items overflow into "More" dropdown'}}}},x={render:()=>l`
|
|
163
166
|
<div
|
|
164
167
|
style="width: 500px; max-width: 100%; resize: horizontal; overflow: hidden; border: 1px solid oklch(var(--btu-theme-gray-200)); border-radius: 0.5rem;"
|
|
165
168
|
>
|
|
@@ -170,18 +173,18 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
170
173
|
<btu-action-item variant="primary" label="Publish" symbol="send"></btu-action-item>
|
|
171
174
|
</btu-action-bar>
|
|
172
175
|
</div>
|
|
173
|
-
`,parameters:{docs:{description:{story:'Items without `compactable` (or without an icon) skip the compact phase and go directly to overflow. Here, "Help" (no icon) and "Publish" (not marked compactable) never compact — only "Preview" and "Save Draft" can.'}}}},
|
|
176
|
+
`,parameters:{docs:{description:{story:'Items without `compactable` (or without an icon) skip the compact phase and go directly to overflow. Here, "Help" (no icon) and "Publish" (not marked compactable) never compact — only "Preview" and "Save Draft" can.'}}}},_={render:()=>l`
|
|
174
177
|
<btu-action-bar
|
|
175
178
|
label="Custom styled"
|
|
176
179
|
shadow
|
|
177
|
-
style=${
|
|
180
|
+
style=${k({"--action-bar-gap":"2rem","--action-bar-padding":"1.5rem 3rem","--action-bar-background":"oklch(0.25 0.05 260)","--action-bar-border-color":"oklch(0.55 0.15 280)"})}
|
|
178
181
|
>
|
|
179
182
|
<btu-action-item zone="end" variant="secondary" label="Cancel"></btu-action-item>
|
|
180
183
|
<btu-action-item zone="end" variant="primary" label="Save Changes"></btu-action-item>
|
|
181
184
|
</btu-action-bar>
|
|
182
|
-
`,parameters:{docs:{description:{story:"CSS custom properties allow full visual customization of the bar. Use the controls panel to experiment with `--action-bar-*` properties."}}}};
|
|
185
|
+
`,parameters:{docs:{description:{story:"CSS custom properties allow full visual customization of the bar. Use the controls panel to experiment with `--action-bar-*` properties."}}}};p.parameters={...p.parameters,docs:{...p.parameters?.docs,source:{originalSource:`{
|
|
183
186
|
args: {}
|
|
184
|
-
}`,...
|
|
187
|
+
}`,...p.parameters?.docs?.source}}};h.parameters={...h.parameters,docs:{...h.parameters?.docs,source:{originalSource:`{
|
|
185
188
|
render: () => html\`
|
|
186
189
|
<div class="flex flex-col gap-4">
|
|
187
190
|
<div>
|
|
@@ -224,7 +227,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
224
227
|
}
|
|
225
228
|
}
|
|
226
229
|
}
|
|
227
|
-
}`,...
|
|
230
|
+
}`,...h.parameters?.docs?.source}}};y.parameters={...y.parameters,docs:{...y.parameters?.docs,source:{originalSource:`{
|
|
228
231
|
render: () => html\`
|
|
229
232
|
<div class="flex flex-col gap-4">
|
|
230
233
|
<div>
|
|
@@ -264,7 +267,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
264
267
|
}
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
|
-
}`,...
|
|
270
|
+
}`,...y.parameters?.docs?.source}}};v.parameters={...v.parameters,docs:{...v.parameters?.docs,source:{originalSource:`{
|
|
268
271
|
render: () => html\`
|
|
269
272
|
<div class="flex flex-wrap gap-4">
|
|
270
273
|
<div class="flex h-[300px] w-[300px] flex-col rounded-lg border border-gray-200">
|
|
@@ -304,7 +307,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
304
307
|
}
|
|
305
308
|
}
|
|
306
309
|
}
|
|
307
|
-
}`,...
|
|
310
|
+
}`,...v.parameters?.docs?.source}}};f.parameters={...f.parameters,docs:{...f.parameters?.docs,source:{originalSource:`{
|
|
308
311
|
render: () => html\`
|
|
309
312
|
<btu-action-bar label="Shadow bar" shadow>
|
|
310
313
|
<btu-action-item zone="end" variant="secondary" label="Cancel"></btu-action-item>
|
|
@@ -318,7 +321,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
318
321
|
}
|
|
319
322
|
}
|
|
320
323
|
}
|
|
321
|
-
}`,...
|
|
324
|
+
}`,...f.parameters?.docs?.source}}};g.parameters={...g.parameters,docs:{...g.parameters?.docs,source:{originalSource:`{
|
|
322
325
|
render: () => html\`
|
|
323
326
|
<div
|
|
324
327
|
style="width: 400px; max-width: 100%; resize: horizontal; overflow: hidden; border: 1px solid oklch(var(--btu-theme-gray-200)); border-radius: 0.5rem;"
|
|
@@ -338,7 +341,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
338
341
|
}
|
|
339
342
|
}
|
|
340
343
|
}
|
|
341
|
-
}`,...
|
|
344
|
+
}`,...g.parameters?.docs?.source}}};w.parameters={...w.parameters,docs:{...w.parameters?.docs,source:{originalSource:`{
|
|
342
345
|
render: () => html\`
|
|
343
346
|
<div
|
|
344
347
|
style="width: 600px; max-width: 100%; resize: horizontal; overflow: hidden; border: 1px solid oklch(var(--btu-theme-gray-200)); border-radius: 0.5rem;"
|
|
@@ -362,7 +365,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
362
365
|
}
|
|
363
366
|
}
|
|
364
367
|
}
|
|
365
|
-
}`,...
|
|
368
|
+
}`,...w.parameters?.docs?.source}}};x.parameters={...x.parameters,docs:{...x.parameters?.docs,source:{originalSource:`{
|
|
366
369
|
render: () => html\`
|
|
367
370
|
<div
|
|
368
371
|
style="width: 500px; max-width: 100%; resize: horizontal; overflow: hidden; border: 1px solid oklch(var(--btu-theme-gray-200)); border-radius: 0.5rem;"
|
|
@@ -382,7 +385,7 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
382
385
|
}
|
|
383
386
|
}
|
|
384
387
|
}
|
|
385
|
-
}`,...
|
|
388
|
+
}`,...x.parameters?.docs?.source}}};_.parameters={..._.parameters,docs:{..._.parameters?.docs,source:{originalSource:`{
|
|
386
389
|
render: () => html\`
|
|
387
390
|
<btu-action-bar
|
|
388
391
|
label="Custom styled"
|
|
@@ -405,4 +408,4 @@ ActionBar provides a horizontal bar for grouping action buttons, typically ancho
|
|
|
405
408
|
}
|
|
406
409
|
}
|
|
407
410
|
}
|
|
408
|
-
}`,...
|
|
411
|
+
}`,..._.parameters?.docs?.source}}};const Y=["Default","AutoSort","Alignments","Positions","Shadow","Overflow","ProgressiveCompact","MixedCompactable","CustomStyling"];export{y as Alignments,h as AutoSort,_ as CustomStyling,p as Default,x as MixedCompactable,g as Overflow,v as Positions,w as ProgressiveCompact,f as Shadow,Y as __namedExportsOrder,J as default};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{i as p,E as u,x as b}from"./iframe-DlBK9Drk.js";import{n as r}from"./property-Bmq4RTSP.js";import{o as d}from"./if-defined-DerKRcyC.js";import{o as y}from"./style-map-DE4G47KD.js";import{E as m,R as f}from"./ReadyMixin-CvX_eidU.js";import{T as g}from"./TooltipMixin-CVKslCDt.js";import"./CircularProgress-eqVb2jUD.js";import"./Icon-CWyJRQf7.js";var _=Object.defineProperty,n=(l,t,e,s)=>{for(var o=void 0,a=l.length-1,c;a>=0;a--)(c=l[a])&&(o=c(t,e,o)||o);return o&&_(t,e,o),o};const h={primary:["btu-button","btu-button-primary","btu-button-sm"],secondary:["btu-button","btu-button-gray","btu-button-sm"],tertiary:["btu-button","btu-button-gray","btu-button-sm","btu-button-fill-none"],destructive:["btu-button","btu-button-error","btu-button-sm","btu-button-fill-none"]};class i extends g(m(f(p))){constructor(){super(...arguments),this.label="",this.variant="secondary",this.symbol="",this.iconOnly=!1,this.disabled=!1,this.loading=!1,this.zone="",this.compactable=!1,this._tabindex=0,this._collapsed=!1}createRenderRoot(){return this}_configure(t){this._tabindex=t.tabindex,this._collapsed=t.collapsed,this._collapsed&&this.symbol?(this.tooltip=this.label,this.tooltipPosition="top"):this.iconOnly||(this.tooltip=""),queueMicrotask(()=>this.requestUpdate())}updated(t){super.updated(t),this._relayTooltipAttrs()}_relayTooltipAttrs(){const t=this.querySelector("button");if(!t)return;const e=this.style.getPropertyValue("anchor-name");e&&(this.style.removeProperty("anchor-name"),t.style.setProperty("anchor-name",e));const s=this.querySelector("[data-tooltip-internal]");s?(this.removeAttribute("aria-describedby"),t.setAttribute("aria-describedby",s.id)):t.removeAttribute("aria-describedby")}firstUpdated(){!this.label&&!this.symbol&&console.warn("[btu-action-item] No label or icon provided.",this),this.compactable&&!this.symbol&&console.warn("[btu-action-item] `compactable` has no effect without an icon.",this),this.iconOnly&&this.symbol&&queueMicrotask(()=>{this.tooltip=this.label,this.tooltipPosition="top"})}_handleClick(){this.disabled||this.loading||this.emit("btu-action-item-click",{label:this.label})}_getSpinnerColor(){return this.variant==="primary"||this.variant==="destructive"?"white":"gray"}_buildButtonClasses(){const e=[...h[this.variant]??h.secondary];return(this.iconOnly||this._collapsed)&&e.push("btu-button-text-hidden"),e.join(" ")}_getButtonStyles(){const t={},e=this.style.getPropertyValue("--button-color").trim();e&&(t["--button-color"]=e);const s=this.style.getPropertyValue("--button-text-color").trim();s&&(t["--button-text-color"]=s);const o=this.style.getPropertyValue("--button-border-radius").trim();return o&&(t["--button-border-radius"]=o),t}render(){const t=this.iconOnly||this._collapsed,e=t&&this.label||void 0,s=this.symbol&&!this.loading,o=this.loading;return b`
|
|
2
|
+
<button
|
|
3
|
+
type="button"
|
|
4
|
+
class="${this._buildButtonClasses()}"
|
|
5
|
+
style=${y(this._getButtonStyles())}
|
|
6
|
+
aria-label=${d(e)}
|
|
7
|
+
aria-disabled="${this.disabled?"true":"false"}"
|
|
8
|
+
aria-busy="${this.loading?"true":"false"}"
|
|
9
|
+
tabindex="${this._tabindex}"
|
|
10
|
+
@click="${this._handleClick}"
|
|
11
|
+
>
|
|
12
|
+
${o?b`<btu-circular-progress size="sm" color="${this._getSpinnerColor()}"></btu-circular-progress>`:u}
|
|
13
|
+
${s?b`<btu-icon symbol="${this.symbol}" size="sm"></btu-icon>`:u}
|
|
14
|
+
${t?u:this.label}
|
|
15
|
+
</button>
|
|
16
|
+
`}}n([r({type:String})],i.prototype,"label");n([r({type:String})],i.prototype,"variant");n([r({type:String})],i.prototype,"symbol");n([r({type:Boolean,attribute:"icon-only"})],i.prototype,"iconOnly");n([r({type:Boolean,reflect:!0})],i.prototype,"disabled");n([r({type:Boolean,reflect:!0})],i.prototype,"loading");n([r({type:String,reflect:!0})],i.prototype,"zone");n([r({type:Boolean,reflect:!0})],i.prototype,"compactable");customElements.get("btu-action-item")||customElements.define("btu-action-item",i);
|
package/dist/storybook/assets/{ActionItem.stories-DXzC9C1u.js → ActionItem.stories-BVlNQvfP.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as d,x as a}from"./iframe-
|
|
1
|
+
import{g as d,x as a}from"./iframe-DlBK9Drk.js";import{o as b}from"./style-map-DE4G47KD.js";import"./ActionItem-CjtyGLd5.js";import"./preload-helper-PPVm8Dsz.js";import"./property-Bmq4RTSP.js";import"./if-defined-DerKRcyC.js";import"./ReadyMixin-CvX_eidU.js";import"./TooltipMixin-CVKslCDt.js";import"./CircularProgress-eqVb2jUD.js";import"./ProgressMixin-CeSrn0_P.js";import"./aria-D5THOgos.js";import"./Icon-CWyJRQf7.js";const{events:m,args:u,argTypes:e}=d("btu-action-item"),$={title:"Components/Action Bar/Action Item",component:"btu-action-item",tags:["autodocs"],parameters:{docs:{subtitle:"A button element for use within an ActionBar",description:{component:`
|
|
2
2
|
ActionItem renders a styled button using existing \`btu-button-*\` classes. It supports four visual variants — primary, secondary, tertiary, and destructive — along with optional icons, icon-only mode, loading state, and disabled state.
|
|
3
3
|
|
|
4
4
|
<h3>Standalone vs. Inside ActionBar:</h3>
|
|
@@ -200,4 +200,4 @@ ActionItem renders a styled button using existing \`btu-button-*\` classes. It s
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
}`,...c.parameters?.docs?.source}}};const
|
|
203
|
+
}`,...c.parameters?.docs?.source}}};const L=["Default","Variants","WithIcons","IconOnly","States","CustomStyling"];export{c as CustomStyling,o as Default,s as IconOnly,l as States,n as Variants,r as WithIcons,L as __namedExportsOrder,$ as default};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./lottie_svg-C3v6xdng.js","./iframe-DlBK9Drk.js","./preload-helper-PPVm8Dsz.js","./iframe-BzrT7trF.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as b,x as r,g as _}from"./iframe-DlBK9Drk.js";import{o as v}from"./style-map-DE4G47KD.js";import{_ as u}from"./preload-helper-PPVm8Dsz.js";import{n as f}from"./property-Bmq4RTSP.js";import{e as z,n as x}from"./ref-BhKk4SDh.js";import{E as k,R as w}from"./ReadyMixin-CvX_eidU.js";var S=Object.defineProperty,y=(t,e,i,p)=>{for(var s=void 0,a=t.length-1,h;a>=0;a--)(h=t[a])&&(s=h(e,i,s)||s);return s&&S(e,i,s),s};const O=()=>u(()=>import("./ai-sparkle-BZMJJAxY.js"),[],import.meta.url).then(t=>t.default);let $;const A=()=>$??=u(()=>import("./lottie_svg-C3v6xdng.js").then(t=>t.l),__vite__mapDeps([0,1,2,3]),import.meta.url),m={xs:"1.25rem",sm:"2rem",md:"2.5rem",lg:"3rem",xl:"3.5rem"};class d extends k(w(b)){constructor(){super(...arguments),this.playing=!1,this.size="md",this._containerRef=z(),this._animation=null,this._loaded=!1,this._loadToken=0,this._reduceMotion=!1,this._visible=!0,this._onMotionChange=e=>{this._reduceMotion=e.matches,this._sync()}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.hasAttribute("aria-hidden")||this.setAttribute("aria-hidden","true"),this.style.display||(this.style.display="inline-block"),this._applySize(),this._motionQuery=window.matchMedia?.("(prefers-reduced-motion: reduce)"),this._reduceMotion=this._motionQuery?.matches??!1,this._motionQuery?.addEventListener("change",this._onMotionChange)}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver?.disconnect(),this._resizeObserver=void 0,this._intersectionObserver?.disconnect(),this._intersectionObserver=void 0,this._motionQuery?.removeEventListener("change",this._onMotionChange),this._loadToken++,this._animation?.destroy(),this._animation=null}firstUpdated(e){super.firstUpdated(e),this._resizeObserver=new ResizeObserver(()=>this._animation?.resize()),this._resizeObserver.observe(this),this._intersectionObserver=new IntersectionObserver(([i])=>{this._visible=i.isIntersecting,this._visible&&this._animation?.resize(),this._sync()}),this._intersectionObserver.observe(this),this._build(),this.emit("btu-ai-sparkle-ready")}updated(e){super.updated(e),e.has("playing")&&this._sync(),e.has("size")&&this._applySize()}render(){return r`<div ${x(this._containerRef)} style="width: 100%; height: 100%"></div>`}_applySize(){const e=m[this.size]??m.md;this.style.width=`var(--ai-sparkle-size, ${e})`,this.style.height=`var(--ai-sparkle-size, ${e})`}async _build(){const e=++this._loadToken,[{default:i},p]=await Promise.all([A(),O()]),s=this._containerRef.value;if(e!==this._loadToken||!s||this._animation)return;const a=i.loadAnimation({container:s,renderer:"svg",loop:!0,autoplay:!1,animationData:structuredClone(p)});a.addEventListener("DOMLoaded",()=>{this._loaded=!0,a.resize(),this._sync()}),this._animation=a}_sync(){const e=this._animation;if(!(!e||!this._loaded)){if(!this.playing||this._reduceMotion){const i=Math.max(0,e.getDuration(!0)-1);e.goToAndStop(i,!0);return}this._visible?e.play():e.pause()}}}y([f({reflect:!0,converter:{fromAttribute:t=>t!==null&&t!=="false",toAttribute:t=>t?"":null}})],d.prototype,"playing");y([f({type:String,reflect:!0})],d.prototype,"size");customElements.get("btu-ai-sparkle")||customElements.define("btu-ai-sparkle",d);const{events:E,args:T,argTypes:c}=_("btu-ai-sparkle"),g=["xs","sm","md","lg","xl"],L={title:"Components/AI/Sparkle",component:"btu-ai-sparkle",tags:["autodocs"],parameters:{docs:{subtitle:"The animated AI-branding sparkle",description:{component:`
|
|
3
|
+
<h3>When to use:</h3>
|
|
4
|
+
<ul>
|
|
5
|
+
<li>On the control that opens an AI surface (e.g. the button that opens the Esca assistant), to draw the eye to it</li>
|
|
6
|
+
</ul>
|
|
7
|
+
|
|
8
|
+
<p>Drive it with the <code>playing</code> boolean: <code>true</code> loops the clip while the AI surface is closed; set it <code>false</code> once the surface is open so it holds a static frame and stops competing for attention. Reduced-motion users always get the frozen frame.</p>
|
|
9
|
+
|
|
10
|
+
<h3>Accessibility:</h3>
|
|
11
|
+
<ul>
|
|
12
|
+
<li>Decorative by default (<code>aria-hidden="true"</code>, set only when absent) — the control it sits in owns the accessible name.</li>
|
|
13
|
+
</ul>
|
|
14
|
+
`}},actions:{handles:E},controls:{expanded:!0}},args:{...T,playing:!0,size:"md"},argTypes:{...c,"--ai-sparkle-size":{table:{disable:!0}},playing:{...c.playing,control:{type:"boolean"},description:"Whether the sparkle animates. `false` (default) holds the last (fully-formed) frame.",table:{category:"Attributes",defaultValue:{summary:"false"}}},size:{...c.size,control:{type:"select"},options:g,description:"Sparkle size scale (mirrors btu-avatar). Overridden by `--ai-sparkle-size`.",table:{category:"Attributes",defaultValue:{summary:"md"}}},customSize:{name:"--ai-sparkle-size",control:{type:"text"},description:'Width/height override (e.g. "20px"). Beats the `size` attribute; default box is 2.5rem (md).',table:{category:"css properties"}}},render:t=>{const e={};return t.customSize&&(e["--ai-sparkle-size"]=t.customSize),r`<btu-ai-sparkle
|
|
15
|
+
?playing=${t.playing}
|
|
16
|
+
size="${t.size}"
|
|
17
|
+
style=${v(e)}
|
|
18
|
+
></btu-ai-sparkle>`}},n={args:{},parameters:{docs:{description:{story:"Toggle `playing` to switch between the looping animation and the static frame, and resize with `size`."}}}},o={render:()=>r`<div class="flex flex-row items-start gap-8">
|
|
19
|
+
${[!0,!1].map(t=>r`
|
|
20
|
+
<div class="flex flex-col items-center gap-2">
|
|
21
|
+
<btu-ai-sparkle ?playing=${t} size="xl"></btu-ai-sparkle>
|
|
22
|
+
<span class="text-xs font-medium text-gray-700">${t?"playing":"static"}</span>
|
|
23
|
+
</div>
|
|
24
|
+
`)}
|
|
25
|
+
</div>`,parameters:{docs:{description:{story:'The looping state (left) next to the frozen frame (right) that `playing="false"` holds.'}}}},l={render:()=>r`<div class="flex flex-row items-center gap-6">
|
|
26
|
+
${g.map(t=>r`
|
|
27
|
+
<div class="flex flex-col items-center gap-2">
|
|
28
|
+
<btu-ai-sparkle size="${t}"></btu-ai-sparkle>
|
|
29
|
+
<span class="text-xs text-gray-600">${t}</span>
|
|
30
|
+
</div>
|
|
31
|
+
`)}
|
|
32
|
+
</div>`,parameters:{docs:{description:{story:"The `size` scale (`xs`–`xl`), mirroring `<btu-avatar>`. For an arbitrary size, override with the `--ai-sparkle-size` custom property."}}}};n.parameters={...n.parameters,docs:{...n.parameters?.docs,source:{originalSource:`{
|
|
33
|
+
args: {},
|
|
34
|
+
parameters: {
|
|
35
|
+
docs: {
|
|
36
|
+
description: {
|
|
37
|
+
story: 'Toggle \`playing\` to switch between the looping animation and the static frame, and resize with \`size\`.'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}`,...n.parameters?.docs?.source}}};o.parameters={...o.parameters,docs:{...o.parameters?.docs,source:{originalSource:`{
|
|
42
|
+
render: () => html\`<div class="flex flex-row items-start gap-8">
|
|
43
|
+
\${([true, false] as const).map(playing => html\`
|
|
44
|
+
<div class="flex flex-col items-center gap-2">
|
|
45
|
+
<btu-ai-sparkle ?playing=\${playing} size="xl"></btu-ai-sparkle>
|
|
46
|
+
<span class="text-xs font-medium text-gray-700">\${playing ? 'playing' : 'static'}</span>
|
|
47
|
+
</div>
|
|
48
|
+
\`)}
|
|
49
|
+
</div>\`,
|
|
50
|
+
parameters: {
|
|
51
|
+
docs: {
|
|
52
|
+
description: {
|
|
53
|
+
story: 'The looping state (left) next to the frozen frame (right) that \`playing="false"\` holds.'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}`,...o.parameters?.docs?.source}}};l.parameters={...l.parameters,docs:{...l.parameters?.docs,source:{originalSource:`{
|
|
58
|
+
render: () => html\`<div class="flex flex-row items-center gap-6">
|
|
59
|
+
\${sizeOptions.map(size => html\`
|
|
60
|
+
<div class="flex flex-col items-center gap-2">
|
|
61
|
+
<btu-ai-sparkle size="\${size}"></btu-ai-sparkle>
|
|
62
|
+
<span class="text-xs text-gray-600">\${size}</span>
|
|
63
|
+
</div>
|
|
64
|
+
\`)}
|
|
65
|
+
</div>\`,
|
|
66
|
+
parameters: {
|
|
67
|
+
docs: {
|
|
68
|
+
description: {
|
|
69
|
+
story: 'The \`size\` scale (\`xs\`–\`xl\`), mirroring \`<btu-avatar>\`. For an arbitrary size, override with the \`--ai-sparkle-size\` custom property.'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}`,...l.parameters?.docs?.source}}};const V=["Default","PlayingVsStatic","Sizes"];export{n as Default,o as PlayingVsStatic,l as Sizes,V as __namedExportsOrder,L as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{i as c,x as h}from"./iframe-DlBK9Drk.js";import{n as r}from"./property-Bmq4RTSP.js";import{r as n}from"./state-DVIUS0Gf.js";import{E as f,R as p}from"./ReadyMixin-CvX_eidU.js";import{T as u}from"./TooltipMixin-CVKslCDt.js";var g=Object.defineProperty,s=(o,t,i,d)=>{for(var a=void 0,l=o.length-1,m;l>=0;l--)(m=o[l])&&(a=m(t,i,a)||a);return a&&g(t,i,a),a};class e extends u(f(p(c))){constructor(){super(...arguments),this.src="",this.alt="",this.fallback="",this.size="md",this.initialClasses=[],this._initialClassesCaptured=!1,this.imageLoaded=!1,this.imageError=!1}connectedCallback(){super.connectedCallback(),this._initialClassesCaptured||(this.className&&(this.initialClasses=this.className.split(" ").filter(t=>t.trim())),this._initialClassesCaptured=!0)}createRenderRoot(){return this}willUpdate(){const t=[...this.initialClasses,"btu-avatar",`btu-avatar-${this.size}`,this.imageLoaded?"btu-avatar-image-loaded":""];this.className=t.filter(Boolean).join(" ")}firstUpdated(){if(this.emit("btu-avatar-ready"),this.src){const t=this.querySelector("img");t&&(t.addEventListener("load",()=>{this.imageLoaded=!0,this.imageError=!1,this.emit("btu-avatar-image-loaded",{src:this.src})}),t.addEventListener("error",i=>{this.imageLoaded=!1,this.imageError=!0,this.emit("btu-avatar-image-error",{src:this.src,error:i})}))}}updated(t){if(super.updated(t),t.has("src")&&(this.imageError=!1,this.imageLoaded=!1,this.src)){const i=this.querySelector("img");i&&(i.addEventListener("load",()=>{this.imageLoaded=!0,this.imageError=!1,this.emit("btu-avatar-image-loaded",{src:this.src})}),i.addEventListener("error",d=>{this.imageLoaded=!1,this.imageError=!0,this.emit("btu-avatar-image-error",{src:this.src,error:d})}))}}render(){return h`
|
|
2
|
+
<div class="btu-avatar-fallback">${this.fallback}</div>
|
|
3
|
+
${this.src&&!this.imageError?h`<img src="${this.src}" alt="${this.alt}" />`:""}
|
|
4
|
+
`}}s([r({type:String})],e.prototype,"src");s([r({type:String})],e.prototype,"alt");s([r({type:String})],e.prototype,"fallback");s([r({type:String})],e.prototype,"size");s([n()],e.prototype,"imageLoaded");s([n()],e.prototype,"imageError");customElements.get("btu-avatar")||customElements.define("btu-avatar",e);
|