@appss/ui 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +41 -0
- package/README.md +262 -2
- package/dist/appearances/profiles.d.ts +4 -0
- package/dist/appearances/profiles.d.ts.map +1 -0
- package/dist/appearances/profiles.js +5 -0
- package/dist/appearances/profiles.js.map +1 -0
- package/dist/appearances/reddit/profile.d.ts +187 -0
- package/dist/appearances/reddit/profile.d.ts.map +1 -0
- package/dist/appearances/reddit/profile.js +107 -0
- package/dist/appearances/reddit/profile.js.map +1 -0
- package/dist/appearances/reddit/reddit.module.css.js +240 -0
- package/dist/appearances/reddit/reddit.module.css.js.map +1 -0
- package/dist/appearances/telegram/profile.d.ts +197 -0
- package/dist/appearances/telegram/profile.d.ts.map +1 -0
- package/dist/appearances/telegram/profile.js +114 -0
- package/dist/appearances/telegram/profile.js.map +1 -0
- package/dist/appearances/telegram/telegram.module.css.js +270 -0
- package/dist/appearances/telegram/telegram.module.css.js.map +1 -0
- package/dist/components/Accordion/Accordion.d.ts +4 -0
- package/dist/components/Accordion/Accordion.d.ts.map +1 -0
- package/dist/components/Accordion/Accordion.js +91 -0
- package/dist/components/Accordion/Accordion.js.map +1 -0
- package/dist/components/Accordion/Accordion.module.css.js +30 -0
- package/dist/components/Accordion/Accordion.module.css.js.map +1 -0
- package/dist/components/Accordion/Accordion.types.d.ts +34 -0
- package/dist/components/Accordion/Accordion.types.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.d.ts +4 -0
- package/dist/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.js +50 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/Avatar.module.css.js +18 -0
- package/dist/components/Avatar/Avatar.module.css.js.map +1 -0
- package/dist/components/Avatar/Avatar.types.d.ts +24 -0
- package/dist/components/Avatar/Avatar.types.d.ts.map +1 -0
- package/dist/components/Banner/Banner.d.ts +3 -0
- package/dist/components/Banner/Banner.d.ts.map +1 -0
- package/dist/components/Banner/Banner.js +39 -0
- package/dist/components/Banner/Banner.js.map +1 -0
- package/dist/components/Banner/Banner.module.css.js +24 -0
- package/dist/components/Banner/Banner.module.css.js.map +1 -0
- package/dist/components/Banner/Banner.types.d.ts +25 -0
- package/dist/components/Banner/Banner.types.d.ts.map +1 -0
- package/dist/components/BottomNav/BottomNav.d.ts +3 -0
- package/dist/components/BottomNav/BottomNav.d.ts.map +1 -0
- package/dist/components/BottomNav/BottomNav.js +68 -0
- package/dist/components/BottomNav/BottomNav.js.map +1 -0
- package/dist/components/BottomNav/BottomNav.module.css.js +24 -0
- package/dist/components/BottomNav/BottomNav.module.css.js.map +1 -0
- package/dist/components/BottomNav/BottomNav.types.d.ts +35 -0
- package/dist/components/BottomNav/BottomNav.types.d.ts.map +1 -0
- package/dist/components/Button/Button.d.ts +3 -0
- package/dist/components/Button/Button.d.ts.map +1 -0
- package/dist/components/Button/Button.js +52 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/Button.module.css.js +24 -0
- package/dist/components/Button/Button.module.css.js.map +1 -0
- package/dist/components/Button/Button.types.d.ts +23 -0
- package/dist/components/Button/Button.types.d.ts.map +1 -0
- package/dist/components/Card/Card.d.ts +3 -0
- package/dist/components/Card/Card.d.ts.map +1 -0
- package/dist/components/Card/Card.js +50 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/Card.module.css.js +21 -0
- package/dist/components/Card/Card.module.css.js.map +1 -0
- package/dist/components/Card/Card.types.d.ts +23 -0
- package/dist/components/Card/Card.types.d.ts.map +1 -0
- package/dist/components/ChatListItem/ChatListItem.d.ts +7 -0
- package/dist/components/ChatListItem/ChatListItem.d.ts.map +1 -0
- package/dist/components/ChatListItem/ChatListItem.js +75 -0
- package/dist/components/ChatListItem/ChatListItem.js.map +1 -0
- package/dist/components/ChatListItem/ChatListItem.module.css.js +51 -0
- package/dist/components/ChatListItem/ChatListItem.module.css.js.map +1 -0
- package/dist/components/ChatListItem/ChatListItem.types.d.ts +38 -0
- package/dist/components/ChatListItem/ChatListItem.types.d.ts.map +1 -0
- package/dist/components/ChatListItem/MessageStatusIcon.d.ts +7 -0
- package/dist/components/ChatListItem/MessageStatusIcon.d.ts.map +1 -0
- package/dist/components/ChatListItem/MessageStatusIcon.js +18 -0
- package/dist/components/ChatListItem/MessageStatusIcon.js.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts +4 -0
- package/dist/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/components/Dialog/Dialog.js +63 -0
- package/dist/components/Dialog/Dialog.js.map +1 -0
- package/dist/components/Dialog/Dialog.module.css.js +21 -0
- package/dist/components/Dialog/Dialog.module.css.js.map +1 -0
- package/dist/components/Dialog/Dialog.types.d.ts +26 -0
- package/dist/components/Dialog/Dialog.types.d.ts.map +1 -0
- package/dist/components/Divider/Divider.d.ts +3 -0
- package/dist/components/Divider/Divider.d.ts.map +1 -0
- package/dist/components/Divider/Divider.js +27 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Divider/Divider.module.css.js +9 -0
- package/dist/components/Divider/Divider.module.css.js.map +1 -0
- package/dist/components/Divider/Divider.types.d.ts +17 -0
- package/dist/components/Divider/Divider.types.d.ts.map +1 -0
- package/dist/components/IconButton/IconButton.d.ts +3 -0
- package/dist/components/IconButton/IconButton.d.ts.map +1 -0
- package/dist/components/IconButton/IconButton.js +49 -0
- package/dist/components/IconButton/IconButton.js.map +1 -0
- package/dist/components/IconButton/IconButton.module.css.js +15 -0
- package/dist/components/IconButton/IconButton.module.css.js.map +1 -0
- package/dist/components/IconButton/IconButton.types.d.ts +25 -0
- package/dist/components/IconButton/IconButton.types.d.ts.map +1 -0
- package/dist/components/Likes/Likes.d.ts +4 -0
- package/dist/components/Likes/Likes.d.ts.map +1 -0
- package/dist/components/Likes/Likes.js +85 -0
- package/dist/components/Likes/Likes.js.map +1 -0
- package/dist/components/Likes/Likes.module.css.js +18 -0
- package/dist/components/Likes/Likes.module.css.js.map +1 -0
- package/dist/components/Likes/Likes.types.d.ts +27 -0
- package/dist/components/Likes/Likes.types.d.ts.map +1 -0
- package/dist/components/Link/Link.d.ts +3 -0
- package/dist/components/Link/Link.d.ts.map +1 -0
- package/dist/components/Link/Link.js +47 -0
- package/dist/components/Link/Link.js.map +1 -0
- package/dist/components/Link/Link.module.css.js +15 -0
- package/dist/components/Link/Link.module.css.js.map +1 -0
- package/dist/components/Link/Link.types.d.ts +22 -0
- package/dist/components/Link/Link.types.d.ts.map +1 -0
- package/dist/components/Menu/Menu.d.ts +4 -0
- package/dist/components/Menu/Menu.d.ts.map +1 -0
- package/dist/components/Menu/Menu.js +134 -0
- package/dist/components/Menu/Menu.js.map +1 -0
- package/dist/components/Menu/Menu.module.css.js +27 -0
- package/dist/components/Menu/Menu.module.css.js.map +1 -0
- package/dist/components/Menu/Menu.types.d.ts +32 -0
- package/dist/components/Menu/Menu.types.d.ts.map +1 -0
- package/dist/components/MessageBubble/MessageBubble.d.ts +3 -0
- package/dist/components/MessageBubble/MessageBubble.d.ts.map +1 -0
- package/dist/components/MessageBubble/MessageBubble.js +85 -0
- package/dist/components/MessageBubble/MessageBubble.js.map +1 -0
- package/dist/components/MessageBubble/MessageBubble.module.css.js +54 -0
- package/dist/components/MessageBubble/MessageBubble.module.css.js.map +1 -0
- package/dist/components/MessageBubble/MessageBubble.types.d.ts +54 -0
- package/dist/components/MessageBubble/MessageBubble.types.d.ts.map +1 -0
- package/dist/components/MessageComposer/MessageComposer.d.ts +3 -0
- package/dist/components/MessageComposer/MessageComposer.d.ts.map +1 -0
- package/dist/components/MessageComposer/MessageComposer.js +55 -0
- package/dist/components/MessageComposer/MessageComposer.js.map +1 -0
- package/dist/components/MessageComposer/MessageComposer.module.css.js +24 -0
- package/dist/components/MessageComposer/MessageComposer.module.css.js.map +1 -0
- package/dist/components/MessageComposer/MessageComposer.types.d.ts +27 -0
- package/dist/components/MessageComposer/MessageComposer.types.d.ts.map +1 -0
- package/dist/components/MessageDivider/MessageDivider.d.ts +3 -0
- package/dist/components/MessageDivider/MessageDivider.d.ts.map +1 -0
- package/dist/components/MessageDivider/MessageDivider.js +28 -0
- package/dist/components/MessageDivider/MessageDivider.js.map +1 -0
- package/dist/components/MessageDivider/MessageDivider.module.css.js +12 -0
- package/dist/components/MessageDivider/MessageDivider.module.css.js.map +1 -0
- package/dist/components/MessageDivider/MessageDivider.types.d.ts +19 -0
- package/dist/components/MessageDivider/MessageDivider.types.d.ts.map +1 -0
- package/dist/components/NavBar/NavBar.d.ts +3 -0
- package/dist/components/NavBar/NavBar.d.ts.map +1 -0
- package/dist/components/NavBar/NavBar.js +42 -0
- package/dist/components/NavBar/NavBar.js.map +1 -0
- package/dist/components/NavBar/NavBar.module.css.js +24 -0
- package/dist/components/NavBar/NavBar.module.css.js.map +1 -0
- package/dist/components/NavBar/NavBar.types.d.ts +26 -0
- package/dist/components/NavBar/NavBar.types.d.ts.map +1 -0
- package/dist/components/NavList/NavList.d.ts +3 -0
- package/dist/components/NavList/NavList.d.ts.map +1 -0
- package/dist/components/NavList/NavList.js +53 -0
- package/dist/components/NavList/NavList.js.map +1 -0
- package/dist/components/NavList/NavList.module.css.js +24 -0
- package/dist/components/NavList/NavList.module.css.js.map +1 -0
- package/dist/components/NavList/NavList.types.d.ts +31 -0
- package/dist/components/NavList/NavList.types.d.ts.map +1 -0
- package/dist/components/SearchField/SearchField.d.ts +3 -0
- package/dist/components/SearchField/SearchField.d.ts.map +1 -0
- package/dist/components/SearchField/SearchField.js +38 -0
- package/dist/components/SearchField/SearchField.js.map +1 -0
- package/dist/components/SearchField/SearchField.module.css.js +18 -0
- package/dist/components/SearchField/SearchField.module.css.js.map +1 -0
- package/dist/components/SearchField/SearchField.types.d.ts +23 -0
- package/dist/components/SearchField/SearchField.types.d.ts.map +1 -0
- package/dist/components/Section/Section.d.ts +4 -0
- package/dist/components/Section/Section.d.ts.map +1 -0
- package/dist/components/Section/Section.js +101 -0
- package/dist/components/Section/Section.js.map +1 -0
- package/dist/components/Section/Section.module.css.js +36 -0
- package/dist/components/Section/Section.module.css.js.map +1 -0
- package/dist/components/Section/Section.types.d.ts +36 -0
- package/dist/components/Section/Section.types.d.ts.map +1 -0
- package/dist/components/Stat/Stat.d.ts +4 -0
- package/dist/components/Stat/Stat.d.ts.map +1 -0
- package/dist/components/Stat/Stat.js +31 -0
- package/dist/components/Stat/Stat.js.map +1 -0
- package/dist/components/Stat/Stat.module.css.js +15 -0
- package/dist/components/Stat/Stat.module.css.js.map +1 -0
- package/dist/components/Stat/Stat.types.d.ts +18 -0
- package/dist/components/Stat/Stat.types.d.ts.map +1 -0
- package/dist/components/Switch/Switch.d.ts +4 -0
- package/dist/components/Switch/Switch.d.ts.map +1 -0
- package/dist/components/Switch/Switch.js +45 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Switch/Switch.module.css.js +21 -0
- package/dist/components/Switch/Switch.module.css.js.map +1 -0
- package/dist/components/Switch/Switch.types.d.ts +19 -0
- package/dist/components/Switch/Switch.types.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +4 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.js +92 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tabs/Tabs.module.css.js +24 -0
- package/dist/components/Tabs/Tabs.module.css.js.map +1 -0
- package/dist/components/Tabs/Tabs.types.d.ts +31 -0
- package/dist/components/Tabs/Tabs.types.d.ts.map +1 -0
- package/dist/components/Tag/Tag.d.ts +3 -0
- package/dist/components/Tag/Tag.d.ts.map +1 -0
- package/dist/components/Tag/Tag.js +33 -0
- package/dist/components/Tag/Tag.js.map +1 -0
- package/dist/components/Tag/Tag.module.css.js +12 -0
- package/dist/components/Tag/Tag.module.css.js.map +1 -0
- package/dist/components/Tag/Tag.types.d.ts +20 -0
- package/dist/components/Tag/Tag.types.d.ts.map +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +4 -0
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/Tooltip/Tooltip.js +63 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.module.css.js +12 -0
- package/dist/components/Tooltip/Tooltip.module.css.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts +24 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts.map +1 -0
- package/dist/core/AppssProvider.d.ts +21 -0
- package/dist/core/AppssProvider.d.ts.map +1 -0
- package/dist/core/AppssProvider.js +42 -0
- package/dist/core/AppssProvider.js.map +1 -0
- package/dist/core/appearance.d.ts +28 -0
- package/dist/core/appearance.d.ts.map +1 -0
- package/dist/core/appearance.js +40 -0
- package/dist/core/appearance.js.map +1 -0
- package/dist/core/host.d.ts +28 -0
- package/dist/core/host.d.ts.map +1 -0
- package/dist/core/host.js +42 -0
- package/dist/core/host.js.map +1 -0
- package/dist/hosts/adapters.d.ts +5 -0
- package/dist/hosts/adapters.d.ts.map +1 -0
- package/dist/hosts/adapters.js +21 -0
- package/dist/hosts/adapters.js.map +1 -0
- package/dist/icons/icons.d.ts +164 -0
- package/dist/icons/icons.d.ts.map +1 -0
- package/dist/icons/icons.js +220 -0
- package/dist/icons/icons.js.map +1 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/icons/index.js +43 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations.d.ts +9 -0
- package/dist/integrations.d.ts.map +1 -0
- package/dist/integrations.js +27 -0
- package/dist/integrations.js.map +1 -0
- package/dist/modules/hideOnScroll.d.ts +7 -0
- package/dist/modules/hideOnScroll.d.ts.map +1 -0
- package/dist/modules/hideOnScroll.js +39 -0
- package/dist/modules/hideOnScroll.js.map +1 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +5 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/recipes/buttons.d.ts +30 -0
- package/dist/recipes/buttons.d.ts.map +1 -0
- package/dist/recipes/buttons.js +28 -0
- package/dist/recipes/buttons.js.map +1 -0
- package/dist/recipes/index.d.ts +4 -0
- package/dist/recipes/index.d.ts.map +1 -0
- package/dist/recipes/index.js +23 -0
- package/dist/recipes/index.js.map +1 -0
- package/dist/recipes/navigation.d.ts +36 -0
- package/dist/recipes/navigation.d.ts.map +1 -0
- package/dist/recipes/navigation.js +28 -0
- package/dist/recipes/navigation.js.map +1 -0
- package/dist/recipes/recipes.module.css.js +27 -0
- package/dist/recipes/recipes.module.css.js.map +1 -0
- package/dist/recipes/whatsapp.d.ts +155 -0
- package/dist/recipes/whatsapp.d.ts.map +1 -0
- package/dist/recipes/whatsapp.js +155 -0
- package/dist/recipes/whatsapp.js.map +1 -0
- package/dist/recipes/whatsapp.module.css.js +135 -0
- package/dist/recipes/whatsapp.module.css.js.map +1 -0
- package/dist/styles.css +4157 -0
- package/docs/components/Accordion.md +76 -0
- package/docs/components/Avatar.md +64 -0
- package/docs/components/Banner.md +70 -0
- package/docs/components/BottomNav.md +86 -0
- package/docs/components/Button.md +93 -0
- package/docs/components/Card.md +75 -0
- package/docs/components/Cell.md +89 -0
- package/docs/components/ChatListItem.md +102 -0
- package/docs/components/Dialog.md +93 -0
- package/docs/components/Divider.md +66 -0
- package/docs/components/IconButton.md +86 -0
- package/docs/components/Likes.md +74 -0
- package/docs/components/Link.md +79 -0
- package/docs/components/Menu.md +105 -0
- package/docs/components/MessageBubble.md +91 -0
- package/docs/components/MessageComposer.md +93 -0
- package/docs/components/MessageDivider.md +66 -0
- package/docs/components/NavBar.md +85 -0
- package/docs/components/NavList.md +85 -0
- package/docs/components/SearchField.md +81 -0
- package/docs/components/Section.md +81 -0
- package/docs/components/Stat.md +66 -0
- package/docs/components/Switch.md +74 -0
- package/docs/components/Tabs.md +85 -0
- package/docs/components/Tag.md +63 -0
- package/docs/components/Tooltip.md +62 -0
- package/docs/exports.json +90 -0
- package/docs/foundations.md +99 -0
- package/docs/gaps.json +12 -0
- package/docs/icons.md +20 -0
- package/docs/index.md +57 -0
- package/docs/recipes.md +43 -0
- package/docs/replaces.json +12 -0
- package/package.json +81 -4
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Dialog
|
|
2
|
+
|
|
3
|
+
A modal window on the native `<dialog>` element: the browser traps focus and restores it on close. `placement="bottom"` makes a bottom sheet.
|
|
4
|
+
|
|
5
|
+
Import `Dialog` from `@appss/ui`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Confirming destructive actions: delete, cancel booking, leave group.
|
|
10
|
+
- Short choices and short forms; a simple bottom sheet (`placement="bottom"`).
|
|
11
|
+
- Required choices: `dismissible={false}` disables Escape and backdrop close.
|
|
12
|
+
- Not for inline notices: use `Banner` or text.
|
|
13
|
+
- Not for a list of actions on a trigger: use `Menu`.
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Notes |
|
|
18
|
+
| ------------- | ---------------------- | ---------- | ------------------------------------------------------------------------------- |
|
|
19
|
+
| `open` | `boolean` | required | Controlled. |
|
|
20
|
+
| `onClose` | `() => void` | required | Called on Escape and backdrop click; set `open` to false here. |
|
|
21
|
+
| `title` | `ReactNode` | required | |
|
|
22
|
+
| `children` | `ReactNode` | | Body text or a short form. |
|
|
23
|
+
| `actions` | `ReactNode` | | Buttons. The first focusable element gets focus; mark another with `autoFocus`. |
|
|
24
|
+
| `placement` | `"center" \| "bottom"` | `"center"` | `bottom` = sheet across the bottom edge. |
|
|
25
|
+
| `dismissible` | `boolean` | `true` | |
|
|
26
|
+
|
|
27
|
+
Also `appearance`, `recipe`, `adaptation`, `className`, `style` and native `<dialog>` attributes except `title`.
|
|
28
|
+
|
|
29
|
+
## Slots
|
|
30
|
+
|
|
31
|
+
`root`, `panel`, `title`, `body`, `actions`.
|
|
32
|
+
|
|
33
|
+
## Sizes by platform
|
|
34
|
+
|
|
35
|
+
| Platform | Look |
|
|
36
|
+
| -------- | ---------------------------------------------------- |
|
|
37
|
+
| Web | width up to 480, radius 20, padding 24, title 20/700 |
|
|
38
|
+
| Telegram | radius 14, section background, theme colours |
|
|
39
|
+
| Reddit | radius 16, 20/24 title |
|
|
40
|
+
|
|
41
|
+
## Recipes
|
|
42
|
+
|
|
43
|
+
None.
|
|
44
|
+
|
|
45
|
+
## Correct
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { useState } from "react";
|
|
49
|
+
|
|
50
|
+
export function CancelBooking() {
|
|
51
|
+
const [open, setOpen] = useState(false);
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<Button variant="outline" tone="destructive" onClick={() => setOpen(true)}>
|
|
55
|
+
Cancel booking
|
|
56
|
+
</Button>
|
|
57
|
+
<Dialog
|
|
58
|
+
open={open}
|
|
59
|
+
onClose={() => setOpen(false)}
|
|
60
|
+
title="Cancel this booking?"
|
|
61
|
+
actions={
|
|
62
|
+
<>
|
|
63
|
+
<Button variant="plain" autoFocus onClick={() => setOpen(false)}>
|
|
64
|
+
Keep booking
|
|
65
|
+
</Button>
|
|
66
|
+
<Button tone="destructive" onClick={() => setOpen(false)}>
|
|
67
|
+
Cancel booking
|
|
68
|
+
</Button>
|
|
69
|
+
</>
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
The slot on Tuesday at 10:00 will be released. Cancellation is free.
|
|
73
|
+
</Dialog>
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Wrong
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
// Hand-made overlay: no focus trap, no Escape, hard-coded backdrop and surface.
|
|
83
|
+
{
|
|
84
|
+
open && (
|
|
85
|
+
<div style={{ position: "fixed", inset: 0, background: "rgba(0,0,0,.5)" }}>
|
|
86
|
+
<div style={{ background: "#fff", borderRadius: 12 }}>Cancel this booking?</div>
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Invented props: Dialog uses open, onClose and title.
|
|
92
|
+
<Dialog isOpen={open} onOpenChange={setOpen} header="Cancel?" />;
|
|
93
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Divider
|
|
2
|
+
|
|
3
|
+
A 1 px rule (`<hr>`), horizontal or vertical, in the platform's separator colour.
|
|
4
|
+
|
|
5
|
+
Import `Divider` from `@appss/ui`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Between content blocks inside a Card or a page.
|
|
10
|
+
- Between toolbar groups: `orientation="vertical"` inside a flex row.
|
|
11
|
+
- Not between Cells: `Section` draws row separators itself.
|
|
12
|
+
- Not between messages: use `MessageDivider`.
|
|
13
|
+
|
|
14
|
+
## Props
|
|
15
|
+
|
|
16
|
+
| Prop | Type | Default | Notes |
|
|
17
|
+
| ------------- | ---------------------------- | -------------- | ----- |
|
|
18
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | |
|
|
19
|
+
|
|
20
|
+
Also `appearance`, `recipe`, `adaptation`, `className`, `style` and native `<hr>` attributes.
|
|
21
|
+
|
|
22
|
+
## Slots
|
|
23
|
+
|
|
24
|
+
`root`.
|
|
25
|
+
|
|
26
|
+
## Sizes by platform
|
|
27
|
+
|
|
28
|
+
1 px everywhere; the colour follows the platform separator.
|
|
29
|
+
|
|
30
|
+
## Recipes
|
|
31
|
+
|
|
32
|
+
None.
|
|
33
|
+
|
|
34
|
+
## Correct
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
export function ReceiptTotals() {
|
|
38
|
+
return (
|
|
39
|
+
<Card title="Summary">
|
|
40
|
+
<div style={{ display: "flex", justifyContent: "space-between" }}>
|
|
41
|
+
<span>Subtotal</span>
|
|
42
|
+
<span>$42.00</span>
|
|
43
|
+
</div>
|
|
44
|
+
<Divider style={{ margin: "12px 0" }} />
|
|
45
|
+
<div style={{ display: "flex", justifyContent: "space-between", fontWeight: 700 }}>
|
|
46
|
+
<span>Total</span>
|
|
47
|
+
<span>$45.50</span>
|
|
48
|
+
</div>
|
|
49
|
+
</Card>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Wrong
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
// A div painted as a line with a hard-coded grey: invisible in dark themes.
|
|
58
|
+
<div style={{ height: 1, background: "#e5e5e5" }} />
|
|
59
|
+
|
|
60
|
+
// Dividers between Cells: Section already separates its rows.
|
|
61
|
+
<Section>
|
|
62
|
+
<Cell title="Profile" />
|
|
63
|
+
<Divider />
|
|
64
|
+
<Cell title="Payments" />
|
|
65
|
+
</Section>
|
|
66
|
+
```
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# IconButton
|
|
2
|
+
|
|
3
|
+
Round button that shows only an icon. `label` is required: it is the accessible name, because there is no visible text.
|
|
4
|
+
|
|
5
|
+
Import `IconButton` from `@appss/ui`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Header and toolbar actions: back, close, more, search, add.
|
|
10
|
+
- Send, attach, microphone in a composer.
|
|
11
|
+
- A toggle such as favourite or mute: pass `pressed`.
|
|
12
|
+
- A counter or a dot on the corner: `badge`.
|
|
13
|
+
- Not when the action needs visible text: use `Button`.
|
|
14
|
+
- Not for three or more secondary actions: put them in a `Menu`.
|
|
15
|
+
|
|
16
|
+
## Props
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Notes |
|
|
19
|
+
| ---------- | ------------------------------------------- | --------- | --------------------------------------------------- |
|
|
20
|
+
| `label` | `string` | required | Accessible name, e.g. "Back", "Add to favourites". |
|
|
21
|
+
| `icon` | `ReactNode` | required | An icon from `@appss/ui/icons`. |
|
|
22
|
+
| `variant` | `"plain" \| "soft" \| "outline" \| "solid"` | `"plain"` | `plain` has no background. |
|
|
23
|
+
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | Circle 32 / 40 / 48. |
|
|
24
|
+
| `badge` | `number \| boolean` | | Counter (shows 99+ above 99); `true` renders a dot. |
|
|
25
|
+
| `pressed` | `boolean` | | Toggle state, exposed as `aria-pressed`. |
|
|
26
|
+
| `onClick` | `(event) => void` | | Native. |
|
|
27
|
+
| `disabled` | `boolean` | | Native. |
|
|
28
|
+
|
|
29
|
+
Also `appearance`, `recipe`, `adaptation`, `className`, `style` and native `<button>` attributes except `children` and `aria-label` (use `label`).
|
|
30
|
+
|
|
31
|
+
## Slots
|
|
32
|
+
|
|
33
|
+
`root`, `icon`, `badge`.
|
|
34
|
+
|
|
35
|
+
## Sizes by platform
|
|
36
|
+
|
|
37
|
+
| Platform | Size | Look |
|
|
38
|
+
| -------- | ------------------- | -------------------------------------------------------------------- |
|
|
39
|
+
| Web | 32 / 40 / 48 circle | `soft` tinted, `solid` filled with the accent |
|
|
40
|
+
| Telegram | 32 / 40 / 48 circle | `soft` is a glass circle; inside a NavBar every button becomes glass |
|
|
41
|
+
| Reddit | circle 40 | `solid` orange, orange-red counter |
|
|
42
|
+
|
|
43
|
+
## Recipes
|
|
44
|
+
|
|
45
|
+
`whatsappIconButton`: circle 48; `soft` white with a soft shadow, `solid` green, `plain` no background.
|
|
46
|
+
|
|
47
|
+
## Correct
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { useState } from "react";
|
|
51
|
+
import { BackIcon, NotificationIcon, StarIcon } from "@appss/ui/icons";
|
|
52
|
+
|
|
53
|
+
export function DetailsHeader() {
|
|
54
|
+
const [saved, setSaved] = useState(false);
|
|
55
|
+
return (
|
|
56
|
+
<NavBar
|
|
57
|
+
title="Studio session"
|
|
58
|
+
leading={<IconButton label="Back" icon={<BackIcon />} onClick={() => history.back()} />}
|
|
59
|
+
trailing={
|
|
60
|
+
<>
|
|
61
|
+
<IconButton
|
|
62
|
+
label={saved ? "Remove from favourites" : "Add to favourites"}
|
|
63
|
+
icon={<StarIcon />}
|
|
64
|
+
pressed={saved}
|
|
65
|
+
onClick={() => setSaved(!saved)}
|
|
66
|
+
/>
|
|
67
|
+
<IconButton label="Notifications" icon={<NotificationIcon />} badge={3} />
|
|
68
|
+
</>
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Wrong
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
// No label: screen readers announce just "button". TypeScript rejects it too.
|
|
79
|
+
<IconButton icon={<CloseIcon />} onClick={close} />
|
|
80
|
+
|
|
81
|
+
// Raw button with an emoji instead of an icon and a hard-coded colour.
|
|
82
|
+
<button style={{ color: "#007aff" }} onClick={close}>✕</button>
|
|
83
|
+
|
|
84
|
+
// aria-label and children are not props; use label and icon.
|
|
85
|
+
<IconButton aria-label="Close"><CloseIcon /></IconButton>
|
|
86
|
+
```
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Likes
|
|
2
|
+
|
|
3
|
+
An up/down vote control with a score. `score` excludes the user's own vote; the control adds it.
|
|
4
|
+
|
|
5
|
+
Import `Likes` from `@appss/ui`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Rating posts, answers, ideas, recipes in a community or feed.
|
|
10
|
+
- Not for a single favourite or bookmark toggle: use `IconButton` with `pressed`.
|
|
11
|
+
- Not for read-only counters: use `Stat` or text.
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
| Prop | Type | Default | Notes |
|
|
16
|
+
| -------------- | --------------------------- | -------- | ----------------------------------------------- |
|
|
17
|
+
| `score` | `number` | required | Score without the user's vote. |
|
|
18
|
+
| `vote` | `"up" \| "down" \| null` | required | The user's vote. |
|
|
19
|
+
| `onVoteChange` | `(vote) => void` | | Clicking the active arrow again sends `null`. |
|
|
20
|
+
| `upLabel` | `string` | | Pass "Upvote"; the built-in default is Russian. |
|
|
21
|
+
| `downLabel` | `string` | | Pass "Downvote". |
|
|
22
|
+
| `label` | `string` | | Group name, e.g. "Post rating". |
|
|
23
|
+
| `formatScore` | `(score: number) => string` | compact | Default shows 1.2K style numbers. |
|
|
24
|
+
| `size` | `"sm" \| "md"` | `"md"` | 32 / 36 (Reddit `md` 40). |
|
|
25
|
+
|
|
26
|
+
Also `appearance`, `recipe`, `adaptation`, `className`, `style` and native `<div>` attributes except `children`.
|
|
27
|
+
|
|
28
|
+
## Slots
|
|
29
|
+
|
|
30
|
+
`root`, `up`, `down`, `score`.
|
|
31
|
+
|
|
32
|
+
## Sizes by platform
|
|
33
|
+
|
|
34
|
+
| Platform | Height sm / md | Look |
|
|
35
|
+
| -------- | -------------- | ---------------------------------------- |
|
|
36
|
+
| Web | 32 / 36 | pill |
|
|
37
|
+
| Telegram | 32 | theme colours |
|
|
38
|
+
| Reddit | 32 / 40 | up is filled orange, down is blue-violet |
|
|
39
|
+
|
|
40
|
+
## Recipes
|
|
41
|
+
|
|
42
|
+
None.
|
|
43
|
+
|
|
44
|
+
## Correct
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import { useState } from "react";
|
|
48
|
+
|
|
49
|
+
export function PostRating() {
|
|
50
|
+
const [vote, setVote] = useState<"up" | "down" | null>(null);
|
|
51
|
+
return (
|
|
52
|
+
<Likes
|
|
53
|
+
score={128}
|
|
54
|
+
vote={vote}
|
|
55
|
+
onVoteChange={setVote}
|
|
56
|
+
upLabel="Upvote"
|
|
57
|
+
downLabel="Downvote"
|
|
58
|
+
label="Post rating"
|
|
59
|
+
size="sm"
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Wrong
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
// Hand-made arrows with hard-coded colours and a score that forgets the user's vote.
|
|
69
|
+
<button style={{ color: voted ? "#ff4500" : "#888" }} onClick={() => setVoted(!voted)}>▲</button>
|
|
70
|
+
<span>{score}</span>
|
|
71
|
+
|
|
72
|
+
// Invented props.
|
|
73
|
+
<Likes count={128} liked onLike={like} />
|
|
74
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Link
|
|
2
|
+
|
|
3
|
+
Inline text link rendered as `<a>`. Follows the platform's link colour.
|
|
4
|
+
|
|
5
|
+
Import `Link` from `@appss/ui`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Links inside running text: terms, help articles, "Learn more".
|
|
10
|
+
- A "See all" action in a Card header (`Card` `action`).
|
|
11
|
+
- External links: pass `external` to open a new tab with a safe `rel`.
|
|
12
|
+
- Not for list rows that open a screen: use `Cell` with `href`.
|
|
13
|
+
- Not for the main action of a screen: use `Button`.
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Notes |
|
|
18
|
+
| ---------- | ---------------------- | ---------- | ------------------------------------------------------ |
|
|
19
|
+
| `href` | `string` | required | |
|
|
20
|
+
| `children` | `ReactNode` | | Link text. |
|
|
21
|
+
| `variant` | `"accent" \| "subtle"` | `"accent"` | `subtle` uses the text colour. |
|
|
22
|
+
| `external` | `boolean` | `false` | Opens in a new tab with `rel="noopener noreferrer"`. |
|
|
23
|
+
| `leading` | `ReactNode` | | Icon before the text. |
|
|
24
|
+
| `trailing` | `ReactNode` | | Icon after the text. |
|
|
25
|
+
| `onClick` | `(event) => void` | | Native; call `event.preventDefault()` for SPA routing. |
|
|
26
|
+
|
|
27
|
+
Also `appearance`, `recipe`, `adaptation`, `className`, `style` and native `<a>` attributes.
|
|
28
|
+
|
|
29
|
+
## Slots
|
|
30
|
+
|
|
31
|
+
`root`, `leading`, `trailing`.
|
|
32
|
+
|
|
33
|
+
## Sizes by platform
|
|
34
|
+
|
|
35
|
+
Inherits the surrounding font size everywhere. Telegram: theme link colour, no underline. Reddit: blue, underline on hover. Web: accent colour.
|
|
36
|
+
|
|
37
|
+
## Recipes
|
|
38
|
+
|
|
39
|
+
None.
|
|
40
|
+
|
|
41
|
+
## Correct
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { ChevronRightIcon } from "@appss/ui/icons";
|
|
45
|
+
|
|
46
|
+
export function UpcomingCard() {
|
|
47
|
+
return (
|
|
48
|
+
<Card
|
|
49
|
+
title="Upcoming"
|
|
50
|
+
action={
|
|
51
|
+
<Link href="/bookings" variant="subtle" trailing={<ChevronRightIcon size={16} />}>
|
|
52
|
+
See all
|
|
53
|
+
</Link>
|
|
54
|
+
}
|
|
55
|
+
>
|
|
56
|
+
<p style={{ margin: 0 }}>
|
|
57
|
+
Free cancellation up to 24 hours before the visit.{" "}
|
|
58
|
+
<Link href="https://example.com/terms" external>
|
|
59
|
+
Booking terms
|
|
60
|
+
</Link>
|
|
61
|
+
</p>
|
|
62
|
+
</Card>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Wrong
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
// Raw anchor with a hard-coded link colour: wrong in Telegram dark themes.
|
|
71
|
+
<a href="/terms" style={{ color: "#2481cc", textDecoration: "underline" }}>Terms</a>
|
|
72
|
+
|
|
73
|
+
// target="_blank" without a safe rel; use external.
|
|
74
|
+
<Link href="https://example.com" target="_blank">Docs</Link>
|
|
75
|
+
|
|
76
|
+
// A list of links styled as rows: use Section and Cell with href.
|
|
77
|
+
<Link href="/profile">Profile</Link>
|
|
78
|
+
<Link href="/payments">Payments</Link>
|
|
79
|
+
```
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Menu
|
|
2
|
+
|
|
3
|
+
Dropdown menu: a trigger button plus a list of actions, with full keyboard support (arrows, Home, End, Escape).
|
|
4
|
+
|
|
5
|
+
Import `Menu` from `@appss/ui`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Three or more secondary actions behind a More button in a NavBar or on a card.
|
|
10
|
+
- Row actions: Edit, Duplicate, Share, Delete (`tone: "destructive"` and `separatorBefore` for the last).
|
|
11
|
+
- Not for filters or view switches: use `Tabs`.
|
|
12
|
+
- Not for one or two actions: show `IconButton`s directly.
|
|
13
|
+
- Not for choosing a form value: write a select (gap).
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Notes |
|
|
18
|
+
| -------------- | ---------------------------------------------------------------------------------------- | --------- | ------------------------------------------------------- |
|
|
19
|
+
| `trigger` | `ReactNode` | required | Visible trigger content: an icon or text. |
|
|
20
|
+
| `triggerLabel` | `string` | | Required when the trigger is icon-only, e.g. "More". |
|
|
21
|
+
| `items` | `{ id, label, icon?, tone?: "default" \| "destructive", disabled?, separatorBefore? }[]` | required | `label` is a string. |
|
|
22
|
+
| `onSelect` | `(id: string) => void` | | Called with the chosen item id; the menu closes itself. |
|
|
23
|
+
| `align` | `"start" \| "end"` | `"start"` | Use `"end"` for a trigger on the right edge. |
|
|
24
|
+
|
|
25
|
+
Also `appearance`, `recipe`, `adaptation`, `className`, `style` and native `<div>` attributes except `children` and `onSelect`.
|
|
26
|
+
|
|
27
|
+
## Slots
|
|
28
|
+
|
|
29
|
+
`root`, `trigger`, `popover`, `item`, `icon`, `label`, `separator`.
|
|
30
|
+
|
|
31
|
+
## Sizes by platform
|
|
32
|
+
|
|
33
|
+
| Platform | Row height | Look |
|
|
34
|
+
| -------- | ---------- | --------------------------- |
|
|
35
|
+
| Web | 40 | min width 200 |
|
|
36
|
+
| Telegram | 44 | radius 13, glass background |
|
|
37
|
+
| Reddit | 48 | radius 8, shadow |
|
|
38
|
+
|
|
39
|
+
## Recipes
|
|
40
|
+
|
|
41
|
+
None.
|
|
42
|
+
|
|
43
|
+
## Correct
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { useState } from "react";
|
|
47
|
+
import { EditIcon, MoreIcon, PinIcon } from "@appss/ui/icons";
|
|
48
|
+
|
|
49
|
+
export function HabitActions() {
|
|
50
|
+
const [confirming, setConfirming] = useState(false);
|
|
51
|
+
return (
|
|
52
|
+
<>
|
|
53
|
+
<Menu
|
|
54
|
+
trigger={<MoreIcon />}
|
|
55
|
+
triggerLabel="Habit actions"
|
|
56
|
+
align="end"
|
|
57
|
+
items={[
|
|
58
|
+
{ id: "edit", label: "Edit habit", icon: <EditIcon /> },
|
|
59
|
+
{ id: "pin", label: "Pin to top", icon: <PinIcon /> },
|
|
60
|
+
{ id: "delete", label: "Delete habit", tone: "destructive", separatorBefore: true },
|
|
61
|
+
]}
|
|
62
|
+
onSelect={(id) => {
|
|
63
|
+
if (id === "delete") setConfirming(true);
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
<Dialog
|
|
67
|
+
open={confirming}
|
|
68
|
+
onClose={() => setConfirming(false)}
|
|
69
|
+
title="Delete this habit?"
|
|
70
|
+
actions={
|
|
71
|
+
<>
|
|
72
|
+
<Button variant="plain" onClick={() => setConfirming(false)}>
|
|
73
|
+
Keep
|
|
74
|
+
</Button>
|
|
75
|
+
<Button tone="destructive" onClick={() => setConfirming(false)}>
|
|
76
|
+
Delete
|
|
77
|
+
</Button>
|
|
78
|
+
</>
|
|
79
|
+
}
|
|
80
|
+
>
|
|
81
|
+
Its history and streak will be removed.
|
|
82
|
+
</Dialog>
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Wrong
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
// Hand-made dropdown: no focus management, no Escape, no outside click.
|
|
92
|
+
{
|
|
93
|
+
open && (
|
|
94
|
+
<div style={{ position: "absolute", background: "#fff", boxShadow: "0 4px 12px #0003" }}>
|
|
95
|
+
<div onClick={edit}>Edit</div>
|
|
96
|
+
<div onClick={remove} style={{ color: "red" }}>
|
|
97
|
+
Delete
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Invented API: items take ids and onSelect, not onClick per item; icon trigger needs triggerLabel.
|
|
104
|
+
<Menu trigger={<MoreIcon />} items={[{ label: "Edit", onClick: edit }]} />;
|
|
105
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# MessageBubble
|
|
2
|
+
|
|
3
|
+
One chat message: incoming (`direction="in"`) or outgoing (`"out"`), with time, delivery status, author in groups, a quoted reply, reactions and quick-reply buttons. Time sits at the end of the last line when there is room.
|
|
4
|
+
|
|
5
|
+
Import `MessageBubble` from `@appss/ui`.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- Chat threads and AI assistant conversations.
|
|
10
|
+
- Quick-reply buttons under a bot or assistant message: `actions` and `onAction`.
|
|
11
|
+
- Group chats: `author`, `authorColor`, `authorBadge`, `avatar` on the last message of a run and `avatarSpace` on the others.
|
|
12
|
+
- Not for comments in a feed: use `Card`.
|
|
13
|
+
- Not for notifications or announcements: use `Banner`.
|
|
14
|
+
|
|
15
|
+
## Props
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Notes |
|
|
18
|
+
| ------------- | ---------------------------------------------- | -------- | --------------------------------------------------------------- |
|
|
19
|
+
| `direction` | `"in" \| "out"` | required | `out` = sent by the user, aligned to the end. |
|
|
20
|
+
| `children` | `ReactNode` | | Message text. |
|
|
21
|
+
| `time` | `string` | | Formatted, e.g. "09:41". |
|
|
22
|
+
| `status` | `"sending" \| "sent" \| "delivered" \| "read"` | | Outgoing only. |
|
|
23
|
+
| `author` | `ReactNode` | | Sender name in groups. |
|
|
24
|
+
| `authorColor` | `string` | | Sender name colour; use a token. |
|
|
25
|
+
| `authorBadge` | `ReactNode` | | Role next to the author, e.g. "admin". |
|
|
26
|
+
| `reply` | `{ author, text, color? }` | | Quoted message. |
|
|
27
|
+
| `title` | `ReactNode` | | Bold first line. |
|
|
28
|
+
| `reactions` | `ReactNode` | | Reaction chips under the text, e.g. `Tag`s. |
|
|
29
|
+
| `actions` | `{ id, label, icon? }[]` | | Quick-reply buttons under the bubble. |
|
|
30
|
+
| `onAction` | `(id: string) => void` | | |
|
|
31
|
+
| `avatar` | `ReactNode` | | Sender avatar beside incoming group messages. |
|
|
32
|
+
| `avatarSpace` | `boolean` | | Keeps the avatar column empty so a run stays aligned. |
|
|
33
|
+
| `tail` | `boolean` | | Telegram: on the last message of a run; WhatsApp: on the first. |
|
|
34
|
+
|
|
35
|
+
Also `appearance`, `recipe`, `adaptation`, `className`, `style` and native `<div>` attributes except `title`.
|
|
36
|
+
|
|
37
|
+
## Slots
|
|
38
|
+
|
|
39
|
+
`root`, `avatar`, `bubble`, `author`, `authorName`, `authorBadge`, `reply`, `replyAuthor`, `replyText`, `title`, `content`, `reactions`, `meta`, `time`, `status`, `actions`, `action`.
|
|
40
|
+
|
|
41
|
+
## Sizes by platform
|
|
42
|
+
|
|
43
|
+
| Platform | Look |
|
|
44
|
+
| -------- | ------------------------------------------------------- |
|
|
45
|
+
| Web | radius 16, text 15, width up to 80% (max 520) |
|
|
46
|
+
| Telegram | radius 18, text 17, outgoing tinted, tail at the bottom |
|
|
47
|
+
| Reddit | dense, 14 px |
|
|
48
|
+
|
|
49
|
+
## Recipes
|
|
50
|
+
|
|
51
|
+
`whatsappMessageBubble`: radius 18, text 17, white incoming, light green outgoing, green quick-reply buttons.
|
|
52
|
+
|
|
53
|
+
## Correct
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
export function AssistantReply({ onPick }: { onPick: (id: string) => void }) {
|
|
57
|
+
return (
|
|
58
|
+
<div style={{ display: "grid", gap: 4, padding: "8px 12px" }}>
|
|
59
|
+
<MessageBubble direction="out" time="09:40" status="read" tail>
|
|
60
|
+
Plan a 20 minute workout for today
|
|
61
|
+
</MessageBubble>
|
|
62
|
+
<MessageBubble
|
|
63
|
+
direction="in"
|
|
64
|
+
time="09:41"
|
|
65
|
+
title="20 minute full body"
|
|
66
|
+
tail
|
|
67
|
+
actions={[
|
|
68
|
+
{ id: "start", label: "Start workout" },
|
|
69
|
+
{ id: "easier", label: "Make it easier" },
|
|
70
|
+
]}
|
|
71
|
+
onAction={onPick}
|
|
72
|
+
>
|
|
73
|
+
Warm up for 4 minutes, then 3 rounds of squats, push-ups and plank, 45 seconds each with 15
|
|
74
|
+
seconds of rest.
|
|
75
|
+
</MessageBubble>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Wrong
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// Hand-made bubbles with hard-coded platform colours.
|
|
85
|
+
<div style={{ alignSelf: mine ? "flex-end" : "flex-start", background: mine ? "#effdde" : "#fff" }}>
|
|
86
|
+
{text}
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
// Invented props: direction, not isOwn; text goes in children.
|
|
90
|
+
<MessageBubble isOwn text={text} timestamp={date} />
|
|
91
|
+
```
|