@sableui/react 0.14.0 → 0.15.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/CHANGELOG.md +58 -0
- package/DESIGN.md +3 -1
- package/dist/blocks/index.d.ts +12 -1
- package/dist/blocks/index.js +4 -0
- package/dist/blocks/message-reactions-block.js +87 -0
- package/dist/blocks/message-reactions-block.meta.js +23 -0
- package/dist/components/bubble/bubble.js +105 -5
- package/dist/components/bubble/bubble.meta.js +42 -6
- package/dist/components/bubble/bubble.variants.js +1 -1
- package/dist/components/bubble/index.js +2 -0
- package/dist/components/feedback/feedback.js +8 -1
- package/dist/components/feedback/feedback.meta.js +6 -0
- package/dist/components/like-button/index.js +7 -0
- package/dist/components/like-button/like-button.js +89 -0
- package/dist/components/like-button/like-button.meta.js +132 -0
- package/dist/components/reaction-picker/index.js +13 -0
- package/dist/components/reaction-picker/reaction-picker.js +104 -0
- package/dist/components/reaction-picker/reaction-picker.meta.js +156 -0
- package/dist/components/toast/toast.js +25 -13
- package/dist/components/toast/toast.meta.js +7 -1
- package/dist/file-hashes.json +26 -17
- package/dist/foundations/motion.js +21 -1
- package/dist/icon-sets/reicon.js +11 -1
- package/dist/index.d.ts +295 -62
- package/dist/index.js +3 -1
- package/dist/lib/taxonomy.js +2 -0
- package/dist/motion/Burst.js +79 -0
- package/dist/motion/index.js +2 -0
- package/dist/styles.css +141 -0
- package/llms/blocks/message-reactions-block.md +116 -0
- package/llms/components/bubble.md +17 -7
- package/llms/components/feedback.md +1 -0
- package/llms/components/like-button.md +91 -0
- package/llms/components/reaction-picker.md +115 -0
- package/llms/components/toast.md +2 -1
- package/llms/foundations/motion.md +18 -2
- package/llms/reference/utilities.md +4 -1
- package/llms-full.txt +374 -12
- package/llms.txt +9 -6
- package/package.json +1 -1
- package/registry.json +573 -12
- package/targets/ios.json +18 -0
package/llms/components/toast.md
CHANGED
|
@@ -53,7 +53,7 @@ Use Toast for transient feedback caused by a user action: saved, failed, copied,
|
|
|
53
53
|
| closeIcon | ReactNode | <Icon name="xmark" /> | Override the dismiss-button glyph. The default already follows the injected icon set. |
|
|
54
54
|
| useToast / useToastManager | () => { toasts, add, close, update, promise } | — | Manager hook for use inside components. add({ title, description, timeout?, type?, priority?, actionProps? }) returns the new toast id and applies the same persistence default as toast.* — an error, loading, or actionProps toast stays until dismissed unless you pass a timeout. close(id), update(id, opts), and promise(p, opts) round out the API. |
|
|
55
55
|
| toast | (message, options?) => string & { success, error, warning, info, message, loading, promise, dismiss, update, add, custom } | — | Imperative singleton callable OUTSIDE React (event handlers, utilities, non-React code) — the Sonner-shaped surface that makes migrating a lib/toast wrapper a near drop-in. Requires a mounted <ToastProvider> (it binds the shared manager). Each call returns the toast id; toast.dismiss(id?) closes one or all; toast.promise(p, { loading, success, error }) and toast.update(id, opts) handle async + in-place updates. |
|
|
56
|
-
| type (toast option) | "success" \| "error" \| "warning" \| "info" \| "loading" | — | Set by the toast.* helpers. Drives a
|
|
56
|
+
| type (toast option) | "success" \| "error" \| "warning" \| "info" \| "loading" | — | Set by the toast.* helpers. Drives a leading status glyph from the shared tone list, the same one Note and InlineStatus use (success→success, error→destructive, warning→warning, info→info), which blooms in as the toast lands; loading shows a spinner, and the glyph blooms in its place when the toast settles. Both loading and error persist until updated or dismissed unless the call supplies a timeout. |
|
|
57
57
|
|
|
58
58
|
## Tokens used
|
|
59
59
|
|
|
@@ -63,6 +63,7 @@ Use Toast for transient feedback caused by a user action: saved, failed, copied,
|
|
|
63
63
|
|
|
64
64
|
- **arrival** · ToastRoot · `motion-slide-left` — A toast interrupts without being asked, so where it came from is the reader's first question. Sliding in from the viewport edge answers it and marks the toast as belonging to the edge rather than to whatever it happens to cover.
|
|
65
65
|
- **response** · ToastAction · `motion-interactive` — Toasts are on a timer, so the action has to look actionable at a glance — there is no time to hunt for the hit target.
|
|
66
|
+
- **response** · Status glyph · `motion-bloom` — The glyph is what says how it went, so it lands as its own beat: it blooms in 120ms after the card, and blooms again in the spinner's place when a loading toast settles. A 16px glyph needs that amplitude to read as an answer; the card itself only slides.
|
|
66
67
|
- **transition** · ToastRoot · `motion-slide-left` — Leaving the same way it entered keeps the stack legible when several dismiss at once; toasts that fade in place leave the remaining ones jumping to fill gaps with no visible cause.
|
|
67
68
|
- **transition** · ToastRoot (stacked) · _custom (outside the recipe layer)_ — A stacked toast arrives from the anchored edge in front of the others, which step back and shrink to make room; hovering fans the deck out into the list. Moving every card, rather than snapping them, shows that the new one went on top and the old ones are still there.
|
|
68
69
|
- **activity** · ToastRoot · _no motion_ — A toast reports a result that has already happened. Anything still in flight belongs in the surface that started it, where the reader is still looking.
|
|
@@ -33,6 +33,8 @@ Reach for one named class before writing a transition.
|
|
|
33
33
|
| `motion-appear` | fast fade + base scale | A small control mounting in place: a clear button, a send arrow, a badge. @starting-style, no JS. |
|
|
34
34
|
| `motion-arrive` | base · decelerate · staggered · expressive | Items a user action brings into a list: a folder's children on expand, a row just added. Never on every render. |
|
|
35
35
|
| `motion-size` | base · emphasized · expressive | An element easing between intrinsic sizes when its label changes: a two-step confirm, Copy → Copied. |
|
|
36
|
+
| `motion-bloom` | slower · 0 → 1.2 → 1 · expressive | A small glyph landing in its on state: a liked heart, a picked rating, a toast's status icon. Remount it (key) to replay; never on the resting state. |
|
|
37
|
+
| `<Burst>` | slower ring + thrown dots · expressive | The follow-through behind a bloom, in the theme's palette families. Only on a choice a person made: a like, a star, a finished task. |
|
|
36
38
|
| `motion-draw` | slower · decelerate | SVG line art drawing on when a <Reveal> scrolls in. The path needs pathLength="1"; stagger siblings with --motion-draw-delay. |
|
|
37
39
|
| `motion-spin · pulse · shimmer · dot-bounce · ping` | loops | Activity. Scale-aware, so reduced motion freezes them. |
|
|
38
40
|
|
|
@@ -53,7 +55,7 @@ Essential motion answers the user; expressive motion narrates continuity. Expres
|
|
|
53
55
|
| Name | Value | Use |
|
|
54
56
|
|---|---|---|
|
|
55
57
|
| `essential` | always, unless off | Colour and focus feedback, press, overlay arrival, disclosure height, loaders, chart hover. |
|
|
56
|
-
| `expressive` | full only | Glides, rolling numbers (NumberTicker), drawn ticks, shakes, staggers, chart arrival and morph, scroll reveals, spring overshoot. |
|
|
58
|
+
| `expressive` | full only | Glides, rolling numbers (NumberTicker), drawn ticks, blooms and bursts, shakes, staggers, chart arrival and morph, scroll reveals, spring overshoot. |
|
|
57
59
|
| `full` | default | Both levels play. The crafted default. |
|
|
58
60
|
| `subtle` | data-motion="subtle" | Essential only; nothing overshoots. For dense tools, embedded widgets, readers who want calm without stillness. |
|
|
59
61
|
| `off` | data-motion="off" · reduce-motion | Nothing moves; every state still changes. |
|
|
@@ -82,7 +84,10 @@ Every interactive component answers all four, by filling the slot or declining i
|
|
|
82
84
|
8. **One thing travels; two things do not blink. When a selection, a value or a mark changes in place, move the one element that represents it.** A fill switching off here and on there is two events the eye has to connect. A glide, a roll or a draw is one, and it is most of what makes an interface feel made rather than assembled.
|
|
83
85
|
9. **Flourishes are expressive: multiply their durations by --motion-expressive and gate JS ones on useMotion().expressive.** `subtle` promises the answers without the choreography. A glide on a plain token keeps playing after someone asked for calm.
|
|
84
86
|
10. **A state change finishes its story: refused shakes and says why, success confirms in place, armed asks again.** Motion that starts a change and leaves the outcome to a snap reads as unfinished. ConfirmButton, OtpField's invalid shake and the copy-to-check swap are the reference cases.
|
|
85
|
-
11. **
|
|
87
|
+
11. **Amplitude scales with smallness. A 16px glyph that turns on grows from nothing past its size; a surface travels from 0.96 and a press settles to 0.97.** The same 4% that is right for a dialog is invisible on an icon, which is why a state change on a small control used to read as a colour swap with no life in it. A dialog that overshot 20% would lurch. Size, not importance, sets how far a thing moves.
|
|
88
|
+
12. **Stage a moment: the main object lands first, the follow-through after it.** A ring that opens, a glyph that blooms 90ms later, dots thrown 60ms after that read as one event with a cause and an effect. Everything starting on the same frame reads as a flash. LikeButton and the toast's status glyph are the reference cases.
|
|
89
|
+
13. **Celebrate only what a person chose, and only at full motion.** A burst is a reply. On a like it is delight; on a system event, on load, or on every row of a list it is a notification wearing confetti. Under subtle the fill alone answers.
|
|
90
|
+
14. **Component motion props and MotionScope only turn motion down.** `full` on a component means inherit. Nothing below the provider can switch motion back on for a reader who asked for it off.
|
|
86
91
|
|
|
87
92
|
## Never
|
|
88
93
|
|
|
@@ -127,6 +132,17 @@ The underline used to vanish under one tab and appear under the next. Now it sli
|
|
|
127
132
|
|
|
128
133
|
The digits that changed roll; the ones that did not stay still, so the eye goes straight to the difference.
|
|
129
134
|
|
|
135
|
+
### A glyph that lands
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
// before
|
|
139
|
+
<Icon name="heart" variant={liked ? "solid" : "regular"} />
|
|
140
|
+
// after
|
|
141
|
+
<LikeButton count={likes} defaultPressed={liked} />
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The heart used to swap fill in one frame. Now it blooms past its size and settles while a ring and dots burst from it, and the count rolls: the same state, told as an event.
|
|
145
|
+
|
|
130
146
|
### Faster exits
|
|
131
147
|
|
|
132
148
|
```tsx
|
|
@@ -130,7 +130,7 @@ The `@utility` and `@custom-variant` layer in `styles.css`: what each one is, wh
|
|
|
130
130
|
- **Instead of** An animated fade or a hand-written `mask-image` gradient. Use `StreamingText` first; this is for a stream rendered without it.
|
|
131
131
|
- `<span className="stream-tail">{latestChunk}</span>`
|
|
132
132
|
|
|
133
|
-
### motion (
|
|
133
|
+
### motion (31)
|
|
134
134
|
|
|
135
135
|
- **`motion-interactive`** — The transition for interactive chrome: colour, background, border, shadow, opacity, fill, stroke, scale and translate at the fast duration and standard easing. Also removes the mobile tap delay and the platform's grey tap flash. *Use for:* On anything clickable that changes on hover, focus, press or selection: a custom row, a tile, a link, an app-owned button. It is the `response` slot, and the only transition declarer such an element needs.
|
|
136
136
|
- **Instead of** Tailwind's colour-only or all-property transition utilities with a hand-picked duration. Those ignore --motion-scale, skip the transform properties `motion-press` needs, and leave the 300ms tap delay on touch screens. sable-lint's `static-interactive` fires on a hover style with no recipe.
|
|
@@ -178,6 +178,9 @@ The `@utility` and `@custom-variant` layer in `styles.css`: what each one is, wh
|
|
|
178
178
|
- **`motion-arrive`** — Items a user action brings into a list settle into place one after another: a short fade down from 0.25rem. Stagger with `--motion-arrive-delay` (raw ms; the recipe scales it). Expressive. *Use for:* Only on items that are NEW because of something the user did: a folder's children on expand, a row just added, results that load in. Tree's expand already uses it.
|
|
179
179
|
- **Instead of** A staggered entrance on every render of a list, which turns a list into a loading delay, or an inline keyframe animation with literal durations.
|
|
180
180
|
- `<li className="motion-arrive" style={{ "--motion-arrive-delay": "36ms" } as CSSProperties}>{row.name}</li>`
|
|
181
|
+
- **`motion-bloom`** — A small glyph landing in its "on" state grows from nothing past its size (1.2) and settles. The amplitude a 16px glyph needs to read as an event; surfaces never bloom. A keyframe that plays on mount, so remount the glyph (a changing `key`) to replay it. `--motion-bloom-delay` holds it at nothing first (raw ms; the recipe scales it). Expressive. *Use for:* A glyph that a person's choice turns on: a liked heart, a starred item, a status icon arriving in a toast. LikeButton and Toast already use it. Pair with <Burst> for the follow-through on a celebratory toggle.
|
|
182
|
+
- **Instead of** A bigger motion-press or motion-pop on the whole control (a button or card that overshoots 20% lurches), or a hand-written scale keyframe with literal durations. Never on the resting state: a page that loads with a post already liked must not bloom every heart.
|
|
183
|
+
- `<span key={likes} className={liked ? "motion-bloom" : undefined}><Icon name="heart" variant={liked ? "solid" : "regular"} /></span>`
|
|
181
184
|
- **`motion-size`** — Eases an element between sizes: between a keyword and a length (0 ↔ auto) through `interpolate-size: allow-keywords`, and between measured pixel sizes when paired with `useAutoSize()`, so a button whose label changes stretches to the new width instead of jumping. A superset of motion-interactive's transition list, so it can sit on a Button. The size is expressive. *Use for:* A control whose content changes length in place: a two-step confirm button, a Copy → Copied label, a chip that gains a count. ConfirmButton already uses it.
|
|
182
185
|
- **Instead of** A hand-written width transition, or a fixed width that clips the longer label. A content-sized box computes `width: auto` before and after its label changes, so on its own the recipe has nothing to ease — that is what `useAutoSize()` is for.
|
|
183
186
|
- `const size = useAutoSize<HTMLButtonElement, HTMLSpanElement>()
|
package/llms-full.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sable (@sableui/react)
|
|
2
2
|
|
|
3
|
-
> An owned, themeable React component system. Default theme: **Sable** (dark-by-default, content-first, fluid product UI). Behavior from Base UI; styling via Tailwind v4 + semantic CSS-variable tokens; Reicon icons via a pluggable adapter.
|
|
3
|
+
> An owned, themeable React component system. Default theme: **Sable** (dark-by-default, content-first, fluid product UI). Behavior from Base UI; styling via Tailwind v4 + semantic CSS-variable tokens; Reicon icons via a pluggable adapter. 121 components, 13 layout primitives, and a **patterns** tier of canonical page shells. The full, per-component contract is the generated `registry.json`.
|
|
4
4
|
|
|
5
5
|
## Start here — brief, composition, evidence
|
|
6
6
|
|
|
@@ -3882,6 +3882,8 @@ Reach for one named class before writing a transition.
|
|
|
3882
3882
|
| `motion-appear` | fast fade + base scale | A small control mounting in place: a clear button, a send arrow, a badge. @starting-style, no JS. |
|
|
3883
3883
|
| `motion-arrive` | base · decelerate · staggered · expressive | Items a user action brings into a list: a folder's children on expand, a row just added. Never on every render. |
|
|
3884
3884
|
| `motion-size` | base · emphasized · expressive | An element easing between intrinsic sizes when its label changes: a two-step confirm, Copy → Copied. |
|
|
3885
|
+
| `motion-bloom` | slower · 0 → 1.2 → 1 · expressive | A small glyph landing in its on state: a liked heart, a picked rating, a toast's status icon. Remount it (key) to replay; never on the resting state. |
|
|
3886
|
+
| `<Burst>` | slower ring + thrown dots · expressive | The follow-through behind a bloom, in the theme's palette families. Only on a choice a person made: a like, a star, a finished task. |
|
|
3885
3887
|
| `motion-draw` | slower · decelerate | SVG line art drawing on when a <Reveal> scrolls in. The path needs pathLength="1"; stagger siblings with --motion-draw-delay. |
|
|
3886
3888
|
| `motion-spin · pulse · shimmer · dot-bounce · ping` | loops | Activity. Scale-aware, so reduced motion freezes them. |
|
|
3887
3889
|
|
|
@@ -3902,7 +3904,7 @@ Essential motion answers the user; expressive motion narrates continuity. Expres
|
|
|
3902
3904
|
| Name | Value | Use |
|
|
3903
3905
|
|---|---|---|
|
|
3904
3906
|
| `essential` | always, unless off | Colour and focus feedback, press, overlay arrival, disclosure height, loaders, chart hover. |
|
|
3905
|
-
| `expressive` | full only | Glides, rolling numbers (NumberTicker), drawn ticks, shakes, staggers, chart arrival and morph, scroll reveals, spring overshoot. |
|
|
3907
|
+
| `expressive` | full only | Glides, rolling numbers (NumberTicker), drawn ticks, blooms and bursts, shakes, staggers, chart arrival and morph, scroll reveals, spring overshoot. |
|
|
3906
3908
|
| `full` | default | Both levels play. The crafted default. |
|
|
3907
3909
|
| `subtle` | data-motion="subtle" | Essential only; nothing overshoots. For dense tools, embedded widgets, readers who want calm without stillness. |
|
|
3908
3910
|
| `off` | data-motion="off" · reduce-motion | Nothing moves; every state still changes. |
|
|
@@ -3931,7 +3933,10 @@ Every interactive component answers all four, by filling the slot or declining i
|
|
|
3931
3933
|
8. **One thing travels; two things do not blink. When a selection, a value or a mark changes in place, move the one element that represents it.** A fill switching off here and on there is two events the eye has to connect. A glide, a roll or a draw is one, and it is most of what makes an interface feel made rather than assembled.
|
|
3932
3934
|
9. **Flourishes are expressive: multiply their durations by --motion-expressive and gate JS ones on useMotion().expressive.** `subtle` promises the answers without the choreography. A glide on a plain token keeps playing after someone asked for calm.
|
|
3933
3935
|
10. **A state change finishes its story: refused shakes and says why, success confirms in place, armed asks again.** Motion that starts a change and leaves the outcome to a snap reads as unfinished. ConfirmButton, OtpField's invalid shake and the copy-to-check swap are the reference cases.
|
|
3934
|
-
11. **
|
|
3936
|
+
11. **Amplitude scales with smallness. A 16px glyph that turns on grows from nothing past its size; a surface travels from 0.96 and a press settles to 0.97.** The same 4% that is right for a dialog is invisible on an icon, which is why a state change on a small control used to read as a colour swap with no life in it. A dialog that overshot 20% would lurch. Size, not importance, sets how far a thing moves.
|
|
3937
|
+
12. **Stage a moment: the main object lands first, the follow-through after it.** A ring that opens, a glyph that blooms 90ms later, dots thrown 60ms after that read as one event with a cause and an effect. Everything starting on the same frame reads as a flash. LikeButton and the toast's status glyph are the reference cases.
|
|
3938
|
+
13. **Celebrate only what a person chose, and only at full motion.** A burst is a reply. On a like it is delight; on a system event, on load, or on every row of a list it is a notification wearing confetti. Under subtle the fill alone answers.
|
|
3939
|
+
14. **Component motion props and MotionScope only turn motion down.** `full` on a component means inherit. Nothing below the provider can switch motion back on for a reader who asked for it off.
|
|
3935
3940
|
|
|
3936
3941
|
## Never
|
|
3937
3942
|
|
|
@@ -3976,6 +3981,17 @@ The underline used to vanish under one tab and appear under the next. Now it sli
|
|
|
3976
3981
|
|
|
3977
3982
|
The digits that changed roll; the ones that did not stay still, so the eye goes straight to the difference.
|
|
3978
3983
|
|
|
3984
|
+
### A glyph that lands
|
|
3985
|
+
|
|
3986
|
+
```tsx
|
|
3987
|
+
// before
|
|
3988
|
+
<Icon name="heart" variant={liked ? "solid" : "regular"} />
|
|
3989
|
+
// after
|
|
3990
|
+
<LikeButton count={likes} defaultPressed={liked} />
|
|
3991
|
+
```
|
|
3992
|
+
|
|
3993
|
+
The heart used to swap fill in one frame. Now it blooms past its size and settles while a ring and dots burst from it, and the count rolls: the same state, told as an event.
|
|
3994
|
+
|
|
3979
3995
|
### Faster exits
|
|
3980
3996
|
|
|
3981
3997
|
```tsx
|
|
@@ -8289,6 +8305,125 @@ export function MediaPlayerBlock({ className, framed = true, onPlayingChange, on
|
|
|
8289
8305
|
|
|
8290
8306
|
---
|
|
8291
8307
|
|
|
8308
|
+
# MessageReactionsBlock
|
|
8309
|
+
|
|
8310
|
+
A short thread you can react to: right-click or long-press a bubble for a menu with a row of quick reactions above Reply and Copy, or use the add-reaction pill under a message. A new reaction blooms in and sprays copies of its emoji.
|
|
8311
|
+
|
|
8312
|
+
**Intent:** Reach for this when a conversation excerpt should be reactable — a team thread, a comment card, a support transcript. A read-only excerpt is ChatThreadBlock; a working chat with a composer and history is the ChatPanel page shell.
|
|
8313
|
+
|
|
8314
|
+
**Block:** Social & messaging · card · designed for 18rem–24rem wide (fills its container up to the max)
|
|
8315
|
+
|
|
8316
|
+
## Notes
|
|
8317
|
+
|
|
8318
|
+
- Two ways in, on purpose: the right-click / long-press menu is fast once you know it is there, and the add-reaction pill is how a first-time reader finds reactions at all.
|
|
8319
|
+
- The quick row in the menu is MenuReactions (checkbox menu items) and the one in the pill's popover is ReactionPicker (a toolbar), so each is reachable by the keyboard model of the surface it sits in.
|
|
8320
|
+
- Only the reader's own reaction celebrates. Counts from other people roll quietly, and the reactions a page loads with never play.
|
|
8321
|
+
- The add-reaction pill appears only on messages that already have reactions; a message with none is reacted to from its menu, which keeps quiet rows quiet.
|
|
8322
|
+
|
|
8323
|
+
## Accessibility
|
|
8324
|
+
|
|
8325
|
+
- Each bubble is focusable, and its menu opens on right click, long press, Shift+F10 or the Menu key; its reactions are checkbox items reporting whether the reader has used each one.
|
|
8326
|
+
- Each reaction pill is a toggle named by its meaning and count ("Party, 3") with `aria-pressed`; the emoji and the burst are hidden from assistive tech.
|
|
8327
|
+
- Under reduced motion the reaction appears and the count changes at once; nothing else is lost.
|
|
8328
|
+
|
|
8329
|
+
## Source
|
|
8330
|
+
|
|
8331
|
+
```tsx
|
|
8332
|
+
import { Bubble, BubbleReaction, BubbleReactionAdd, BubbleReactions, Card, CardContent, CardFooter, cn, ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger, DEFAULT_REACTIONS, MenuReactions, Message } from "@sableui/react"
|
|
8333
|
+
|
|
8334
|
+
const messages: { id: string; text: string; mine: boolean; reactions: Record<string, number> }[] = [
|
|
8335
|
+
{ id: "m1", text: "The new onboarding flow is live on staging 🚀", mine: false, reactions: { "🎉": 2, "👀": 1 } },
|
|
8336
|
+
{ id: "m2", text: "Clicked through it twice. The progress bar is so smooth.", mine: true, reactions: {} },
|
|
8337
|
+
{ id: "m3", text: "Ship it Friday?", mine: false, reactions: { "👍": 1 } },
|
|
8338
|
+
]
|
|
8339
|
+
const hint = "Right-click or long-press a message to react."
|
|
8340
|
+
// Every emoji that can appear needs a name: it is the pill's accessible label.
|
|
8341
|
+
const labels: Record<string, string> = {
|
|
8342
|
+
...Object.fromEntries(DEFAULT_REACTIONS.map((r) => [r.emoji, r.label])),
|
|
8343
|
+
"👀": "Eyes",
|
|
8344
|
+
}
|
|
8345
|
+
|
|
8346
|
+
export interface MessageReactionsBlockProps {
|
|
8347
|
+
className?: string
|
|
8348
|
+
/** false drops the card's surface and border. Keep it framed on a muted page: incoming bubbles are the muted surface too. */
|
|
8349
|
+
framed?: boolean
|
|
8350
|
+
/** Called when the reader adds or removes a reaction, with the message, the emoji and whether it is now on. */
|
|
8351
|
+
onReact?: (messageId: string, emoji: string, on: boolean) => void
|
|
8352
|
+
}
|
|
8353
|
+
|
|
8354
|
+
export function MessageReactionsBlock({ className, framed = true, onReact }: MessageReactionsBlockProps) {
|
|
8355
|
+
// The reader's own reactions, per message. Everyone else's are the counts above.
|
|
8356
|
+
const [mine, setMine] = useState<Record<string, string[]>>({ m1: ["🎉"] })
|
|
8357
|
+
const toggle = (messageId: string, emoji: string) => {
|
|
8358
|
+
const on = !(mine[messageId] ?? []).includes(emoji)
|
|
8359
|
+
// Decided again from `prev`, so two toggles in one batch cannot add an emoji twice.
|
|
8360
|
+
setMine((prev) => {
|
|
8361
|
+
const current = prev[messageId] ?? []
|
|
8362
|
+
const next = current.includes(emoji) ? current.filter((e) => e !== emoji) : [...current, emoji]
|
|
8363
|
+
return { ...prev, [messageId]: next }
|
|
8364
|
+
})
|
|
8365
|
+
onReact?.(messageId, emoji, on)
|
|
8366
|
+
}
|
|
8367
|
+
|
|
8368
|
+
return (
|
|
8369
|
+
<Card variant={framed ? "default" : "flat"} className={cn("w-full max-w-sm", className)}>
|
|
8370
|
+
<CardContent className="flex flex-col gap-3">
|
|
8371
|
+
{messages.map((m) => {
|
|
8372
|
+
const align = m.mine ? "end" : "start"
|
|
8373
|
+
const chosen = mine[m.id] ?? []
|
|
8374
|
+
// Others' counts, plus the reader's own: a reaction only the reader gave
|
|
8375
|
+
// is a pill of its own, ordered after the ones already there.
|
|
8376
|
+
const counts: Record<string, number> = { ...m.reactions }
|
|
8377
|
+
for (const emoji of chosen) counts[emoji] = (counts[emoji] ?? 0)
|
|
8378
|
+
const pills = Object.entries(counts).map(([emoji, others]) => ({
|
|
8379
|
+
emoji,
|
|
8380
|
+
active: chosen.includes(emoji),
|
|
8381
|
+
count: others + (chosen.includes(emoji) ? 1 : 0),
|
|
8382
|
+
}))
|
|
8383
|
+
return (
|
|
8384
|
+
<Message key={m.id} messageId={m.id} align={m.mine ? "end" : undefined}>
|
|
8385
|
+
<ContextMenu>
|
|
8386
|
+
<ContextMenuTrigger
|
|
8387
|
+
// Focusable, so Shift+F10 or the Menu key opens the same menu.
|
|
8388
|
+
render={<Bubble tabIndex={0} variant={m.mine ? "primary" : undefined} align={align} />}
|
|
8389
|
+
>
|
|
8390
|
+
{m.text}
|
|
8391
|
+
</ContextMenuTrigger>
|
|
8392
|
+
<ContextMenuContent>
|
|
8393
|
+
<MenuReactions selected={chosen} onSelect={(emoji) => toggle(m.id, emoji)} />
|
|
8394
|
+
<ContextMenuSeparator />
|
|
8395
|
+
<ContextMenuItem>Reply</ContextMenuItem>
|
|
8396
|
+
<ContextMenuItem>Copy text</ContextMenuItem>
|
|
8397
|
+
</ContextMenuContent>
|
|
8398
|
+
</ContextMenu>
|
|
8399
|
+
{/* Rendered even while empty (it hides itself), so the first reaction still celebrates. */}
|
|
8400
|
+
<BubbleReactions align={align}>
|
|
8401
|
+
{pills.map((p) => (
|
|
8402
|
+
<BubbleReaction
|
|
8403
|
+
key={p.emoji}
|
|
8404
|
+
emoji={p.emoji}
|
|
8405
|
+
label={labels[p.emoji]}
|
|
8406
|
+
count={p.count}
|
|
8407
|
+
active={p.active}
|
|
8408
|
+
onClick={() => toggle(m.id, p.emoji)}
|
|
8409
|
+
/>
|
|
8410
|
+
))}
|
|
8411
|
+
{pills.length > 0 ? (
|
|
8412
|
+
<BubbleReactionAdd selected={chosen} onSelect={(emoji) => toggle(m.id, emoji)} />
|
|
8413
|
+
) : null}
|
|
8414
|
+
</BubbleReactions>
|
|
8415
|
+
</Message>
|
|
8416
|
+
)
|
|
8417
|
+
})}
|
|
8418
|
+
</CardContent>
|
|
8419
|
+
<CardFooter className="text-caption text-muted-foreground">{hint}</CardFooter>
|
|
8420
|
+
</Card>
|
|
8421
|
+
)
|
|
8422
|
+
}
|
|
8423
|
+
```
|
|
8424
|
+
|
|
8425
|
+
---
|
|
8426
|
+
|
|
8292
8427
|
# NewsletterBlock
|
|
8293
8428
|
|
|
8294
8429
|
A newsletter sign-up card: the list's name, what it sends and how often, and an email field with Subscribe.
|
|
@@ -12180,14 +12315,16 @@ The tinted (or untinted) surface a turn's content sits on. Kept separate from Me
|
|
|
12180
12315
|
| --- | --- | --- |
|
|
12181
12316
|
| Bubble | yes | The surface itself. Holds the variant, the side, and the tail. |
|
|
12182
12317
|
| BubbleReactions | no | The row of reaction pills, just under the bubble at the message column's small gap, so it reads as belonging to that message rather than the next row. |
|
|
12183
|
-
| BubbleReaction | no | One reaction pill — emoji, count (hidden at 1), and pressed state. |
|
|
12318
|
+
| BubbleReaction | no | One reaction pill — emoji, count (hidden at 1), and pressed state. Celebrates when it becomes the reader's own. |
|
|
12319
|
+
| BubbleReactionAdd | no | The add-reaction pill at the end of the row: opens a ReactionPicker above it. |
|
|
12184
12320
|
|
|
12185
12321
|
## Subcomponents
|
|
12186
12322
|
|
|
12187
12323
|
| Name | Type | Description |
|
|
12188
12324
|
| --- | --- | --- |
|
|
12189
12325
|
| BubbleReactions | { align?: "start" \| "end" } & ComponentPropsWithRef<"div"> | Row container for reaction pills. Match `align` to the Bubble so the row hangs off the same edge. |
|
|
12190
|
-
| BubbleReaction | { emoji: ReactNode; count?: number; active?: boolean } & ComponentPropsWithRef<"button"> | One reaction pill. A toggle, not a label: `active` drives `aria-pressed` as well as the styling, and `count` is hidden at 1 because the pill already says "one". |
|
|
12326
|
+
| BubbleReaction | { emoji: ReactNode; label?: string; count?: number; active?: boolean; motion?: MotionLevel } & ComponentPropsWithRef<"button"> | One reaction pill. A toggle, not a label: `active` drives `aria-pressed` as well as the styling, `label` names it ("Party, 3"), and `count` is hidden at 1 because the pill already says "one". When it turns on — pressed, or newly added already on — the emoji blooms, copies of it burst out and the count rolls; pills the page loads with stay still. |
|
|
12327
|
+
| BubbleReactionAdd | { reactions?: Reaction[]; selected?: string[]; onSelect?: (emoji: string) => void; label?: string; motion?: MotionLevel } & ComponentPropsWithRef<"button"> | The add-reaction pill: a smiley that opens a ReactionPicker above it. Choosing an emoji closes the picker and calls `onSelect`; add the emoji to the row and its new pill celebrates on arrival. |
|
|
12191
12328
|
|
|
12192
12329
|
## Props
|
|
12193
12330
|
|
|
@@ -12208,16 +12345,23 @@ The tinted (or untinted) surface a turn's content sits on. Kept separate from Me
|
|
|
12208
12345
|
|
|
12209
12346
|
`muted`, `foreground`, `primary`, `primary-foreground`, `border`, `card`, `card-foreground`, `accent`, `accent-foreground`, `muted-foreground`, `ring`
|
|
12210
12347
|
|
|
12348
|
+
## Motion
|
|
12349
|
+
|
|
12350
|
+
- **arrival** · Bubble · _no motion_ — A bubble arrives with its Message row, which owns how a new message enters the transcript. A reaction pill that the reader just added arrives with its own celebration (below).
|
|
12351
|
+
- **response** · BubbleReaction · `motion-bloom` — Reacting is the reader's choice, so it is answered like a like: the emoji grows from nothing past its size and settles, while copies of it spray outward and fade (Burst with the emoji as its particle, the way chat apps answer a reaction). Plays when a pill turns on and when a pill mounts already on into a row that has rendered — never for the pills a page loads with. Pills inherit Pill's motion-interactive and motion-press.
|
|
12352
|
+
- **transition** · BubbleReaction · _custom (outside the recipe layer)_ — The count rolls with NumberTicker as people react. Turning a reaction off is quiet: the tint eases out and the count rolls back, with no burst. Under `subtle` or reduced motion the bloom and the spray are dropped and the tint and count alone answer.
|
|
12353
|
+
- **activity** · Bubble · _no motion_ — A bubble is static content; a message still being written is StreamingText or a Marker, not a state of the surface.
|
|
12354
|
+
|
|
12211
12355
|
## Accessibility
|
|
12212
12356
|
|
|
12213
12357
|
- The surface is a plain container with no imposed role — a bubble is presentation, and announcing one as a region would put a landmark around every line of a conversation.
|
|
12214
|
-
- Reaction pills are real buttons reporting `aria-pressed`, so the reader's own reaction is state rather than colour alone
|
|
12358
|
+
- Reaction pills are real buttons reporting `aria-pressed`, so the reader's own reaction is state rather than colour alone. Give each a `label`: it is named "Party, 3", with the emoji and its burst hidden from AT. The add-reaction pill is named "Add reaction" and opens a toolbar picker.
|
|
12215
12359
|
- `whitespace-pre-wrap` and `break-words` keep pasted logs, long URLs, and hard-wrapped text inside the surface instead of overflowing the conversation.
|
|
12216
12360
|
- Every variant meets AA against its own surface, including `primary`, which pairs the primary fill with its paired foreground token rather than a hardcoded white.
|
|
12217
12361
|
|
|
12218
12362
|
## Related
|
|
12219
12363
|
|
|
12220
|
-
- Components: Message, MessageScroller, Marker, Attachment
|
|
12364
|
+
- Components: Message, MessageScroller, Marker, Attachment, ReactionPicker
|
|
12221
12365
|
|
|
12222
12366
|
## Examples
|
|
12223
12367
|
|
|
@@ -12248,13 +12392,14 @@ import { Avatar, Bubble, CodeBlock, Message } from "@sableui/react"
|
|
|
12248
12392
|
### With reactions
|
|
12249
12393
|
|
|
12250
12394
|
```tsx
|
|
12251
|
-
import { Bubble, BubbleReaction, BubbleReactions, Message } from "@sableui/react"
|
|
12395
|
+
import { Bubble, BubbleReaction, BubbleReactionAdd, BubbleReactions, Message } from "@sableui/react"
|
|
12252
12396
|
|
|
12253
12397
|
<Message messageId="m3">
|
|
12254
12398
|
<Bubble>Shipped 0.45.0.</Bubble>
|
|
12255
12399
|
<BubbleReactions>
|
|
12256
|
-
<BubbleReaction emoji="🎉" count={3} active onClick={() => toggle("🎉")} />
|
|
12257
|
-
<BubbleReaction emoji="👀" count={1} onClick={() => toggle("👀")} />
|
|
12400
|
+
<BubbleReaction emoji="🎉" label="Party" count={3} active onClick={() => toggle("🎉")} />
|
|
12401
|
+
<BubbleReaction emoji="👀" label="Eyes" count={1} onClick={() => toggle("👀")} />
|
|
12402
|
+
<BubbleReactionAdd selected={mine} onSelect={toggle} />
|
|
12258
12403
|
</BubbleReactions>
|
|
12259
12404
|
</Message>
|
|
12260
12405
|
```
|
|
@@ -15235,6 +15380,7 @@ Use Feedback to collect lightweight sentiment, usefulness, or quality signals fr
|
|
|
15235
15380
|
|
|
15236
15381
|
- **arrival** · Popover · `motion-pop` — The form opens from its trigger, so the eye goes from the button it pressed to the field it should type in. Popover owns the recipe.
|
|
15237
15382
|
- **response** · Rating toggles · `motion-interactive` — The rating row is a choice among a few similar marks. The eased selected fill is what makes the pick read as made, not just hovered.
|
|
15383
|
+
- **response** · Chosen rating mark · `motion-bloom` — The mark itself answers the pick: it blooms past its size and settles, so choosing reads as a small decision landing rather than a fill changing. Only the chosen mark, only on choosing — nothing blooms when the form opens or a pick is let go. Expressive: under subtle the fill alone answers.
|
|
15238
15384
|
- **transition** · Thanks · `motion-tick` — Sending is the one moment the person needs to know their words arrived. The form fades out in place and a check draws itself in over it, then the popover closes. Without it the popover just vanished, which looks the same as the form being dismissed or the message lost.
|
|
15239
15385
|
- **activity** · Root · _no motion_ — The thanks shows as soon as the form is sent; delivery is the app's background work. A spinner for a one-line report would make a quick, optional gesture feel heavy.
|
|
15240
15386
|
|
|
@@ -16363,6 +16509,100 @@ import { Label } from "@sableui/react"
|
|
|
16363
16509
|
|
|
16364
16510
|
---
|
|
16365
16511
|
|
|
16512
|
+
# LikeButton
|
|
16513
|
+
|
|
16514
|
+
**Status:** stable
|
|
16515
|
+
|
|
16516
|
+
A pressed-or-not toggle for a like, a star or a save, with its count. Pressing it on fills the glyph, which blooms while a ring and a spray of dots burst from it and the count rolls up; pressing it off is quiet.
|
|
16517
|
+
|
|
16518
|
+
**Keywords:** like, heart, favorite, favourite, love, star, bookmark, save, upvote, reaction, count, toggle
|
|
16519
|
+
|
|
16520
|
+
## Usage
|
|
16521
|
+
|
|
16522
|
+
Use LikeButton for a personal, reversible endorsement that other people can see the tally of: liking a post, starring a repository, saving a recipe. It is the one place in Sable that celebrates, because the person chose it and it costs nothing to undo.
|
|
16523
|
+
|
|
16524
|
+
### Best practices
|
|
16525
|
+
|
|
16526
|
+
- Do: Pass the server's total as `count` and update it when the save lands. The button shows the viewer's own like at once, before the save, and goes back to `count` exactly whenever it changes, so a failed save that leaves `count` alone can also turn `pressed` back off.
|
|
16527
|
+
- Do: Match the glyph, family and label to the meaning: `icon="star" tone="yellow" label="Star"` for a star. The label is the accessible name, so it must say what pressing does.
|
|
16528
|
+
- Do: Use `format={{ notation: "compact" }}` once counts pass a few thousand, so a feed of buttons keeps one width.
|
|
16529
|
+
- Don't: Do not use it for a setting or a view switch (bold, mute, grid or list). Those are tools, not endorsements, and a burst on every press of a formatting control is noise; use Toggle. → use **Toggle**
|
|
16530
|
+
- Don't: Do not use it for a rating or a verdict on an answer (helpful, not helpful). That is a question with two sides; use Feedback. → use **Feedback**
|
|
16531
|
+
- Don't: Do not press it for the user. A burst is a reply to a person's choice — liking something on their behalf, or on load, turns delight into a notification.
|
|
16532
|
+
|
|
16533
|
+
## Props
|
|
16534
|
+
|
|
16535
|
+
| Name | Type | Default | Description |
|
|
16536
|
+
| --- | --- | --- | --- |
|
|
16537
|
+
| count | number | — | The total, rolled when it changes. Pressing adds or removes the viewer's like at once; the button shows `count` exactly again whenever `count` changes. Omit it for a bare glyph (an icon-size button). |
|
|
16538
|
+
| pressed | boolean | — | Controlled pressed state. |
|
|
16539
|
+
| defaultPressed | boolean | false | Initial pressed state when uncontrolled. |
|
|
16540
|
+
| onPressedChange | (pressed: boolean, event) => void | — | Called when the user presses it, with the new state. |
|
|
16541
|
+
| icon | string | "heart" | The glyph, by icon name. Its `solid` variant is shown while pressed. |
|
|
16542
|
+
| tone | PaletteColor | "red" | The palette family the glyph fills with while pressed, and the burst blooms from. A family, so it follows the theme. |
|
|
16543
|
+
| label | string | "Like" | The accessible name, read before the count. |
|
|
16544
|
+
| format | Intl.NumberFormatOptions | — | How to write the count, e.g. `{ notation: "compact" }`. |
|
|
16545
|
+
| variant | "ghost" \| "outline" \| "secondary" | "ghost" | The Button surface. |
|
|
16546
|
+
| size | "xs" \| "sm" \| "md" | "sm" | A Button size; without a count, the matching icon size. |
|
|
16547
|
+
| disabled | boolean | false | Disables it. |
|
|
16548
|
+
| motion | "full" \| "subtle" \| "off" | "full" | How much motion this component uses: `full` (default) inherits the app's policy, `subtle` keeps feedback and drops the flourish, `off` stills it. It can only turn motion down — it never overrides a reader's reduce-motion setting. The bloom and the burst are the flourish; the fill and the count changing stay. |
|
|
16549
|
+
|
|
16550
|
+
## Variants
|
|
16551
|
+
|
|
16552
|
+
- **variant**: ghost, outline, secondary
|
|
16553
|
+
- **size**: xs, sm, md
|
|
16554
|
+
- **tone**: red, orange, yellow, green, teal, blue, purple, pink
|
|
16555
|
+
|
|
16556
|
+
## Tokens used
|
|
16557
|
+
|
|
16558
|
+
`palette-dot`, `accent`, `ring`
|
|
16559
|
+
|
|
16560
|
+
## Motion
|
|
16561
|
+
|
|
16562
|
+
- **arrival** · Root · _no motion_ — It arrives with the post or row it belongs to. A page that loads with likes already given must be still: nothing blooms on mount.
|
|
16563
|
+
- **response** · Glyph · `motion-bloom` — Pressing it on is the moment. The glyph is 16px, so it needs real amplitude to read as an event: it grows from nothing past its size and settles, after a 90ms beat in which the ring leads. Inherits Button's motion-press for the press itself. Pressing off has no bloom — taking a like back is not a celebration.
|
|
16564
|
+
- **transition** · Burst · _custom (outside the recipe layer)_ — The follow-through: <Burst> draws a disc that hollows into a ring and shifts colour, then dots thrown outward in the theme's palette families. Expressive only — under `subtle` or reduced motion it renders nothing and the fill alone answers the press. The count rolls with NumberTicker.
|
|
16565
|
+
- **activity** · Root · _no motion_ — There is no in-between state to show: the like is shown at once, before it is saved.
|
|
16566
|
+
|
|
16567
|
+
## Accessibility
|
|
16568
|
+
|
|
16569
|
+
- A native <button> through Button, with `aria-pressed`. Enter and Space press it.
|
|
16570
|
+
- The accessible name is the label then the count ("Like 1,301"); the burst is aria-hidden and the rolling digits are hidden behind the count's real text.
|
|
16571
|
+
- The pressed state is carried by the filled glyph and `aria-pressed`, never by colour alone.
|
|
16572
|
+
- Under reduced motion the glyph fills and the count changes at once; the bloom and the burst are dropped.
|
|
16573
|
+
|
|
16574
|
+
## Related
|
|
16575
|
+
|
|
16576
|
+
- Components: Toggle, Feedback, NumberTicker, Button
|
|
16577
|
+
|
|
16578
|
+
## Examples
|
|
16579
|
+
|
|
16580
|
+
### A post's likes
|
|
16581
|
+
|
|
16582
|
+
```tsx
|
|
16583
|
+
import { LikeButton } from "@sableui/react"
|
|
16584
|
+
|
|
16585
|
+
<LikeButton count={post.likes} defaultPressed={post.liked} onPressedChange={(on) => api.like(post.id, on)} />
|
|
16586
|
+
```
|
|
16587
|
+
|
|
16588
|
+
### Star a repository
|
|
16589
|
+
|
|
16590
|
+
```tsx
|
|
16591
|
+
import { LikeButton } from "@sableui/react"
|
|
16592
|
+
|
|
16593
|
+
<LikeButton icon="star" tone="yellow" label="Star" variant="outline" count={repo.stars} format={{ notation: "compact" }} />
|
|
16594
|
+
```
|
|
16595
|
+
|
|
16596
|
+
### Bare glyph
|
|
16597
|
+
|
|
16598
|
+
```tsx
|
|
16599
|
+
import { LikeButton } from "@sableui/react"
|
|
16600
|
+
|
|
16601
|
+
<LikeButton label="Save recipe" />
|
|
16602
|
+
```
|
|
16603
|
+
|
|
16604
|
+
---
|
|
16605
|
+
|
|
16366
16606
|
# LineChart
|
|
16367
16607
|
|
|
16368
16608
|
**Status:** beta
|
|
@@ -19674,6 +19914,124 @@ import { RadioCard, RadioGroup } from "@sableui/react"
|
|
|
19674
19914
|
|
|
19675
19915
|
---
|
|
19676
19916
|
|
|
19917
|
+
# ReactionPicker
|
|
19918
|
+
|
|
19919
|
+
**Status:** stable
|
|
19920
|
+
|
|
19921
|
+
The quick row of emoji you react to a message with: a toolbar of large emoji toggles that bloom in one after another as it opens and magnify under the pointer, with MenuReactions as the same row inside a right-click menu.
|
|
19922
|
+
|
|
19923
|
+
**Keywords:** reaction, reactions, emoji, emoji picker, react, tapback, quick reactions, message actions, chat
|
|
19924
|
+
|
|
19925
|
+
## Usage
|
|
19926
|
+
|
|
19927
|
+
Use ReactionPicker wherever a reader chooses a reaction for something: in a Popover from an add-reaction control (BubbleReactionAdd is that, ready-made), or as a hover bar over a message. Use MenuReactions for the same row as the first group of the menu a message opens on right-click or long-press, above Reply and Copy. Both report which emoji the reader has already used, so choosing one again removes it.
|
|
19928
|
+
|
|
19929
|
+
### Best practices
|
|
19930
|
+
|
|
19931
|
+
- Do: Keep the quick set short — six to eight. It is the reactions people actually use; a full emoji catalogue belongs behind a trailing "more" control passed as children.
|
|
19932
|
+
- Do: Give every reaction a `label`. It is the accessible name and the menu's typeahead, and an emoji's own spoken name differs between platforms.
|
|
19933
|
+
- Do: Pass `selected` so the reader's own reactions show pressed, and toggle in `onSelect`: choosing a reaction you already gave takes it back.
|
|
19934
|
+
- Do: Offer the right-click menu and a visible add-reaction control together. A context menu is invisible until you know it is there; the pill is how a first-time reader finds reactions.
|
|
19935
|
+
- Don't: Do not put a ReactionPicker inside a Menu or ContextMenu. A toolbar is not a menu item, so the menu's arrow keys would skip it; use MenuReactions there. → use **MenuReactions**
|
|
19936
|
+
- Don't: Do not use it to rate an answer or collect a verdict. Reactions are social and many-valued; a helpful / not-helpful question is Feedback. → use **Feedback**
|
|
19937
|
+
|
|
19938
|
+
### Anatomy
|
|
19939
|
+
|
|
19940
|
+
| Part | Required | Description |
|
|
19941
|
+
| --- | --- | --- |
|
|
19942
|
+
| ReactionPicker | yes | The toolbar: one tab stop, arrow keys move between emoji, each a toggle with `aria-pressed`. |
|
|
19943
|
+
| MenuReactions | no | The same row as a group of checkbox menu items, for MenuContent and ContextMenuContent. Choosing one closes the menu. |
|
|
19944
|
+
|
|
19945
|
+
## Subcomponents
|
|
19946
|
+
|
|
19947
|
+
| Name | Type | Description |
|
|
19948
|
+
| --- | --- | --- |
|
|
19949
|
+
| MenuReactions | { reactions?; selected?; onSelect?; motion? } & ComponentProps<typeof Menu.Group> | The quick row as checkbox menu items, for the first group of a MenuContent or ContextMenuContent. Same props as ReactionPicker, without children. |
|
|
19950
|
+
|
|
19951
|
+
## Props
|
|
19952
|
+
|
|
19953
|
+
| Name | Type | Default | Description |
|
|
19954
|
+
| --- | --- | --- | --- |
|
|
19955
|
+
| reactions | readonly { emoji: string; label: string }[] | DEFAULT_REACTIONS | The choices, in order. The default is 👍 ❤️ 😂 🎉 😮 😢 🙏. |
|
|
19956
|
+
| selected | readonly string[] | [] | The emoji the reader has already reacted with: shown pressed, and choosing one again removes it. |
|
|
19957
|
+
| onSelect | (emoji: string) => void | — | Called with the emoji the reader chose. Toggle it in or out of `selected`. |
|
|
19958
|
+
| children | ReactNode | — | ReactionPicker only: trailing controls after the emoji, such as a button that opens a full emoji picker. |
|
|
19959
|
+
| aria-label | string | "Reactions" | The name of the toolbar or menu group. |
|
|
19960
|
+
| motion | "full" \| "subtle" \| "off" | "full" | How much motion this component uses: `full` (default) inherits the app's policy, `subtle` keeps the press and drops the wave of emoji blooming in and the magnify, `off` stills it. It can only turn motion down. |
|
|
19961
|
+
|
|
19962
|
+
## Tokens used
|
|
19963
|
+
|
|
19964
|
+
`accent`, `primary`, `ring`
|
|
19965
|
+
|
|
19966
|
+
## Motion
|
|
19967
|
+
|
|
19968
|
+
- **arrival** · Glyph · `motion-bloom` — Opening the picker is the reader's own action, so the emoji answer it: each blooms in 24ms after the one before, a short wave from first to last. The surface it sits in (a Popover or a menu) arrives with its own motion-pop. Expressive only — under `subtle` the emoji are simply there.
|
|
19969
|
+
- **response** · Glyph · _custom (outside the recipe layer)_ — The emoji under the pointer or the keyboard highlight magnifies to 1.25 on a fast standard ease, so you can see which one a release will choose; each cell also carries motion-interactive and motion-press. The magnify rides an inner layer so it never fights the bloom over `scale`.
|
|
19970
|
+
- **transition** · Cell · `motion-interactive` — Pressed and not pressed differ by a tint, eased by motion-interactive. The celebration belongs to the reaction that lands under the message (BubbleReaction), not to the picker that chose it.
|
|
19971
|
+
- **activity** · Root · _no motion_ — Choosing is instant; there is no in-between state to show.
|
|
19972
|
+
|
|
19973
|
+
## Accessibility
|
|
19974
|
+
|
|
19975
|
+
- ReactionPicker is a Base UI toolbar: one tab stop, Left/Right move between emoji, Home/End jump to the ends.
|
|
19976
|
+
- Each emoji is a button named by its `label` and reporting `aria-pressed`, so a screen-reader user hears whether choosing it adds or removes their reaction. The glyph itself is aria-hidden.
|
|
19977
|
+
- MenuReactions renders checkbox menu items (`menuitemcheckbox` with `aria-checked`), reached by the menu's arrow keys and typeahead like every other row.
|
|
19978
|
+
- Under reduced motion the emoji appear at once and do not magnify; pressed state is carried by `aria-pressed` and a tint, never motion.
|
|
19979
|
+
|
|
19980
|
+
## Related
|
|
19981
|
+
|
|
19982
|
+
- Components: Bubble, ContextMenu, Popover, Toolbar, Feedback
|
|
19983
|
+
|
|
19984
|
+
## Examples
|
|
19985
|
+
|
|
19986
|
+
### In a popover
|
|
19987
|
+
|
|
19988
|
+
```tsx
|
|
19989
|
+
import { Button, Icon, Popover, PopoverContent, PopoverTrigger, ReactionPicker } from "@sableui/react"
|
|
19990
|
+
|
|
19991
|
+
<Popover>
|
|
19992
|
+
<PopoverTrigger render={<Button variant="ghost" size="icon-sm" aria-label="Add reaction" />}>
|
|
19993
|
+
<Icon name="emoji" />
|
|
19994
|
+
</PopoverTrigger>
|
|
19995
|
+
<PopoverContent side="top" className="w-auto rounded-full p-1">
|
|
19996
|
+
<ReactionPicker selected={mine} onSelect={toggle} />
|
|
19997
|
+
</PopoverContent>
|
|
19998
|
+
</Popover>
|
|
19999
|
+
```
|
|
20000
|
+
|
|
20001
|
+
### In a right-click menu
|
|
20002
|
+
|
|
20003
|
+
```tsx
|
|
20004
|
+
import { Bubble, ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger, MenuReactions } from "@sableui/react"
|
|
20005
|
+
|
|
20006
|
+
<ContextMenu>
|
|
20007
|
+
<ContextMenuTrigger render={<Bubble />}>See you at 6.</ContextMenuTrigger>
|
|
20008
|
+
<ContextMenuContent>
|
|
20009
|
+
<MenuReactions selected={mine} onSelect={toggle} />
|
|
20010
|
+
<ContextMenuSeparator />
|
|
20011
|
+
<ContextMenuItem>Reply</ContextMenuItem>
|
|
20012
|
+
<ContextMenuItem>Copy text</ContextMenuItem>
|
|
20013
|
+
</ContextMenuContent>
|
|
20014
|
+
</ContextMenu>
|
|
20015
|
+
```
|
|
20016
|
+
|
|
20017
|
+
### A custom set
|
|
20018
|
+
|
|
20019
|
+
```tsx
|
|
20020
|
+
import { ReactionPicker } from "@sableui/react"
|
|
20021
|
+
|
|
20022
|
+
<ReactionPicker
|
|
20023
|
+
reactions={[
|
|
20024
|
+
{ emoji: "✅", label: "Done" },
|
|
20025
|
+
{ emoji: "👀", label: "Looking" },
|
|
20026
|
+
{ emoji: "🚀", label: "Shipped" },
|
|
20027
|
+
]}
|
|
20028
|
+
selected={mine}
|
|
20029
|
+
onSelect={toggle}
|
|
20030
|
+
/>
|
|
20031
|
+
```
|
|
20032
|
+
|
|
20033
|
+
---
|
|
20034
|
+
|
|
19677
20035
|
# RelativeTime
|
|
19678
20036
|
|
|
19679
20037
|
**Status:** stable
|
|
@@ -22593,7 +22951,7 @@ Use Toast for transient feedback caused by a user action: saved, failed, copied,
|
|
|
22593
22951
|
| closeIcon | ReactNode | <Icon name="xmark" /> | Override the dismiss-button glyph. The default already follows the injected icon set. |
|
|
22594
22952
|
| useToast / useToastManager | () => { toasts, add, close, update, promise } | — | Manager hook for use inside components. add({ title, description, timeout?, type?, priority?, actionProps? }) returns the new toast id and applies the same persistence default as toast.* — an error, loading, or actionProps toast stays until dismissed unless you pass a timeout. close(id), update(id, opts), and promise(p, opts) round out the API. |
|
|
22595
22953
|
| toast | (message, options?) => string & { success, error, warning, info, message, loading, promise, dismiss, update, add, custom } | — | Imperative singleton callable OUTSIDE React (event handlers, utilities, non-React code) — the Sonner-shaped surface that makes migrating a lib/toast wrapper a near drop-in. Requires a mounted <ToastProvider> (it binds the shared manager). Each call returns the toast id; toast.dismiss(id?) closes one or all; toast.promise(p, { loading, success, error }) and toast.update(id, opts) handle async + in-place updates. |
|
|
22596
|
-
| type (toast option) | "success" \| "error" \| "warning" \| "info" \| "loading" | — | Set by the toast.* helpers. Drives a
|
|
22954
|
+
| type (toast option) | "success" \| "error" \| "warning" \| "info" \| "loading" | — | Set by the toast.* helpers. Drives a leading status glyph from the shared tone list, the same one Note and InlineStatus use (success→success, error→destructive, warning→warning, info→info), which blooms in as the toast lands; loading shows a spinner, and the glyph blooms in its place when the toast settles. Both loading and error persist until updated or dismissed unless the call supplies a timeout. |
|
|
22597
22955
|
|
|
22598
22956
|
## Tokens used
|
|
22599
22957
|
|
|
@@ -22603,6 +22961,7 @@ Use Toast for transient feedback caused by a user action: saved, failed, copied,
|
|
|
22603
22961
|
|
|
22604
22962
|
- **arrival** · ToastRoot · `motion-slide-left` — A toast interrupts without being asked, so where it came from is the reader's first question. Sliding in from the viewport edge answers it and marks the toast as belonging to the edge rather than to whatever it happens to cover.
|
|
22605
22963
|
- **response** · ToastAction · `motion-interactive` — Toasts are on a timer, so the action has to look actionable at a glance — there is no time to hunt for the hit target.
|
|
22964
|
+
- **response** · Status glyph · `motion-bloom` — The glyph is what says how it went, so it lands as its own beat: it blooms in 120ms after the card, and blooms again in the spinner's place when a loading toast settles. A 16px glyph needs that amplitude to read as an answer; the card itself only slides.
|
|
22606
22965
|
- **transition** · ToastRoot · `motion-slide-left` — Leaving the same way it entered keeps the stack legible when several dismiss at once; toasts that fade in place leave the remaining ones jumping to fill gaps with no visible cause.
|
|
22607
22966
|
- **transition** · ToastRoot (stacked) · _custom (outside the recipe layer)_ — A stacked toast arrives from the anchored edge in front of the others, which step back and shrink to make room; hovering fans the deck out into the list. Moving every card, rather than snapping them, shows that the new one went on top and the old ones are still there.
|
|
22608
22967
|
- **activity** · ToastRoot · _no motion_ — A toast reports a result that has already happened. Anything still in flight belongs in the surface that started it, where the reader is still looking.
|
|
@@ -24135,7 +24494,7 @@ The `@utility` and `@custom-variant` layer in `styles.css`: what each one is, wh
|
|
|
24135
24494
|
- **Instead of** An animated fade or a hand-written `mask-image` gradient. Use `StreamingText` first; this is for a stream rendered without it.
|
|
24136
24495
|
- `<span className="stream-tail">{latestChunk}</span>`
|
|
24137
24496
|
|
|
24138
|
-
### motion (
|
|
24497
|
+
### motion (31)
|
|
24139
24498
|
|
|
24140
24499
|
- **`motion-interactive`** — The transition for interactive chrome: colour, background, border, shadow, opacity, fill, stroke, scale and translate at the fast duration and standard easing. Also removes the mobile tap delay and the platform's grey tap flash. *Use for:* On anything clickable that changes on hover, focus, press or selection: a custom row, a tile, a link, an app-owned button. It is the `response` slot, and the only transition declarer such an element needs.
|
|
24141
24500
|
- **Instead of** Tailwind's colour-only or all-property transition utilities with a hand-picked duration. Those ignore --motion-scale, skip the transform properties `motion-press` needs, and leave the 300ms tap delay on touch screens. sable-lint's `static-interactive` fires on a hover style with no recipe.
|
|
@@ -24183,6 +24542,9 @@ The `@utility` and `@custom-variant` layer in `styles.css`: what each one is, wh
|
|
|
24183
24542
|
- **`motion-arrive`** — Items a user action brings into a list settle into place one after another: a short fade down from 0.25rem. Stagger with `--motion-arrive-delay` (raw ms; the recipe scales it). Expressive. *Use for:* Only on items that are NEW because of something the user did: a folder's children on expand, a row just added, results that load in. Tree's expand already uses it.
|
|
24184
24543
|
- **Instead of** A staggered entrance on every render of a list, which turns a list into a loading delay, or an inline keyframe animation with literal durations.
|
|
24185
24544
|
- `<li className="motion-arrive" style={{ "--motion-arrive-delay": "36ms" } as CSSProperties}>{row.name}</li>`
|
|
24545
|
+
- **`motion-bloom`** — A small glyph landing in its "on" state grows from nothing past its size (1.2) and settles. The amplitude a 16px glyph needs to read as an event; surfaces never bloom. A keyframe that plays on mount, so remount the glyph (a changing `key`) to replay it. `--motion-bloom-delay` holds it at nothing first (raw ms; the recipe scales it). Expressive. *Use for:* A glyph that a person's choice turns on: a liked heart, a starred item, a status icon arriving in a toast. LikeButton and Toast already use it. Pair with <Burst> for the follow-through on a celebratory toggle.
|
|
24546
|
+
- **Instead of** A bigger motion-press or motion-pop on the whole control (a button or card that overshoots 20% lurches), or a hand-written scale keyframe with literal durations. Never on the resting state: a page that loads with a post already liked must not bloom every heart.
|
|
24547
|
+
- `<span key={likes} className={liked ? "motion-bloom" : undefined}><Icon name="heart" variant={liked ? "solid" : "regular"} /></span>`
|
|
24186
24548
|
- **`motion-size`** — Eases an element between sizes: between a keyword and a length (0 ↔ auto) through `interpolate-size: allow-keywords`, and between measured pixel sizes when paired with `useAutoSize()`, so a button whose label changes stretches to the new width instead of jumping. A superset of motion-interactive's transition list, so it can sit on a Button. The size is expressive. *Use for:* A control whose content changes length in place: a two-step confirm button, a Copy → Copied label, a chip that gains a count. ConfirmButton already uses it.
|
|
24187
24549
|
- **Instead of** A hand-written width transition, or a fixed width that clips the longer label. A content-sized box computes `width: auto` before and after its label changes, so on its own the recipe has nothing to ease — that is what `useAutoSize()` is for.
|
|
24188
24550
|
- `const size = useAutoSize<HTMLButtonElement, HTMLSpanElement>()
|