SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

reactionSync

Makes every ReactionBar on the page answer at once.

tsx
import { reactionSync } from "@sdxc/ui/chat";
View code
tsx
// One host anywhere on the page carries reactionSync(); every ReactionBar then answers at once.
<span hidden mix={[reactionSync()]} />

<ReactionBar aria-label="Reactions">
	<form method="post" action="/messages/42/reactions">
		<input type="hidden" name="emoji" value="🎉" />
		<ReactionBar.Reaction emoji="🎉" label="Party popper" count={4} pressed title="You, Mira, Theo and Kenji" />
	</form>
	<form method="post" action="/messages/42/reactions">
		<input type="hidden" name="emoji" value="👀" />
		<ReactionBar.Reaction emoji="👀" label="Eyes" count={1} title="Theo" />
	</form>
	<form method="post" action="/messages/42/reactions">
		<input type="hidden" name="emoji" value="🚀" />
		<ReactionBar.Reaction emoji="🚀" label="Rocket" count={2} title="Mira and Priya" />
	</form>
</ReactionBar>

Usage

Put on one element that stays on the page, such as an island's host: from then on every reaction chip under document flips at once and posts in the background, and ui:reaction-add events add reactions in place. Submits are claimed in the capture phase, before any navigation handler sees them.

Signature

typescript
reactionSync(): MixinDescriptor<HTMLElement>

Returns a mixin with no visible effect on its host.

Examples

tsx
<span hidden mix={[reactionSync()]} />

The events, constants and types its module publishes, each imported from @sdxc/ui/chat too.

Event

ReactionAddEvent

Dispatched on a ReactionBar (or any element inside the message holding one) to add the reader's reaction: an existing chip is pressed, a missing one is cloned from the row's ReactionBar.Template, and either posts through its form.

typescript
new ReactionAddEvent(detail: ReactionAddDetail)
PropertyTypeRequiredDescription
detailreadonly ReactionAddDetailYes
Constant

REACTION_ADD_EVENT

DOM event type that asks a ReactionBar to add, or press, a reaction.

typescript
const REACTION_ADD_EVENT = "ui:reaction-add" as const
Interface

ReactionAddDetail

What a ReactionAddEvent asks for.

MemberTypeRequiredDescription
emojistringYesThe emoji as the chip's form submits it: a character, or a custom's :shortcode:.
labelstringYesWhat the emoji is called, for the chip's accessible name.
imagestringNoA custom emoji's image.
togglebooleanNoTakes the reader's reaction off when they already reacted with this emoji.
@sdxc/ui

Can’t find it? Contact us