Add emoji confetti bursts and component playground.

Support app.relay.emoji_confetti on jumbo emoji clicks with canvas physics,
per-emoji particle profiles, and a fixed overlay that does not affect scroll.
Also add a Vite playground for live component previews and theme hover preview.
This commit is contained in:
2026-07-29 20:40:43 +10:00
parent ea7642f0bb
commit 0da4f0d6cb
48 changed files with 3689 additions and 46 deletions
+37 -10
View File
@@ -27,6 +27,7 @@ import {
MATRIX_SPOILER_REASON_PROPERTY_NAME,
} from '../../../types/matrix/common';
import { StationeryMedia, hashStationerySeed, stationeryMediaRot } from './StationeryMedia';
import { getJumboEmojiInteractionProps, JumboEmojiClickHandler } from '../../features/room/emoji-confetti/jumboEmojiInteraction';
import { FALLBACK_MIMETYPE, getBlobSafeMimeType } from '../../utils/mimeTypes';
import { parseGeoUri, scaleYDimension } from '../../utils/common';
import { resolveAttachmentBoxSize } from '../../state/mediaDimensionCache';
@@ -78,8 +79,9 @@ type MTextProps = {
renderBody: (props: RenderBodyProps) => ReactNode;
renderUrlsPreview?: (urls: string[]) => ReactNode;
style?: CSSProperties;
onJumboEmojiClick?: JumboEmojiClickHandler;
};
export function MText({ edited, content, renderBody, renderUrlsPreview, style }: MTextProps) {
export function MText({ edited, content, renderBody, renderUrlsPreview, style, onJumboEmojiClick }: MTextProps) {
const { body, formatted_body: customBody } = content;
if (typeof body !== 'string') return <BrokenContent />;
@@ -89,13 +91,20 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }:
: undefined;
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
const isJumboEmoji = JUMBO_EMOJI_REG.test(trimmedBody);
const jumboEmojiInteraction = getJumboEmojiInteractionProps({
body: trimmedBody,
isJumboEmoji,
onJumboEmojiClick,
});
return (
<>
<MessageTextBody
preWrap={typeof customBody !== 'string'}
jumboEmoji={JUMBO_EMOJI_REG.test(trimmedBody)}
jumboEmoji={isJumboEmoji}
style={style}
{...jumboEmojiInteraction}
>
{renderBody({
body: trimmedBody,
@@ -114,6 +123,7 @@ type MEmoteProps = {
content: Record<string, unknown>;
renderBody: (props: RenderBodyProps) => ReactNode;
renderUrlsPreview?: (urls: string[]) => ReactNode;
onJumboEmojiClick?: JumboEmojiClickHandler;
};
export function MEmote({
displayName,
@@ -121,6 +131,7 @@ export function MEmote({
content,
renderBody,
renderUrlsPreview,
onJumboEmojiClick,
}: MEmoteProps) {
const { body, formatted_body: customBody } = content;
@@ -131,20 +142,28 @@ export function MEmote({
: undefined;
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
const isJumboEmoji = JUMBO_EMOJI_REG.test(trimmedBody);
const jumboEmojiInteraction = getJumboEmojiInteractionProps({
body: trimmedBody,
isJumboEmoji,
onJumboEmojiClick,
});
return (
<>
<MessageTextBody
emote
preWrap={typeof customBody !== 'string'}
jumboEmoji={JUMBO_EMOJI_REG.test(trimmedBody)}
jumboEmoji={isJumboEmoji}
>
<b>{`${displayName} `}</b>
{renderBody({
body: trimmedBody,
customBody: trimmedCustomBody,
})}
{edited && <MessageEditedContent />}
<span {...jumboEmojiInteraction}>
{renderBody({
body: trimmedBody,
customBody: trimmedCustomBody,
})}
{edited && <MessageEditedContent />}
</span>
</MessageTextBody>
{renderUrlsPreview && urls && urls.length > 0 && renderUrlsPreview(urls)}
</>
@@ -156,8 +175,9 @@ type MNoticeProps = {
content: Record<string, unknown>;
renderBody: (props: RenderBodyProps) => ReactNode;
renderUrlsPreview?: (urls: string[]) => ReactNode;
onJumboEmojiClick?: JumboEmojiClickHandler;
};
export function MNotice({ edited, content, renderBody, renderUrlsPreview }: MNoticeProps) {
export function MNotice({ edited, content, renderBody, renderUrlsPreview, onJumboEmojiClick }: MNoticeProps) {
const { body, formatted_body: customBody } = content;
if (typeof body !== 'string') return <BrokenContent />;
@@ -167,13 +187,20 @@ export function MNotice({ edited, content, renderBody, renderUrlsPreview }: MNot
: undefined;
const urlsMatch = renderUrlsPreview && trimmedBody.match(URL_REG);
const urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
const isJumboEmoji = JUMBO_EMOJI_REG.test(trimmedBody);
const jumboEmojiInteraction = getJumboEmojiInteractionProps({
body: trimmedBody,
isJumboEmoji,
onJumboEmojiClick,
});
return (
<>
<MessageTextBody
notice
preWrap={typeof customBody !== 'string'}
jumboEmoji={JUMBO_EMOJI_REG.test(trimmedBody)}
jumboEmoji={isJumboEmoji}
{...jumboEmojiInteraction}
>
{renderBody({
body: trimmedBody,
@@ -243,6 +243,9 @@ export const MessageTextBody = recipe({
overflow: 'visible',
overflowY: 'visible',
paddingBottom: config.space.S200,
cursor: 'pointer',
position: 'relative',
zIndex: 5,
},
},
emote: {
@@ -263,6 +266,8 @@ globalStyle(`${jumboEmojiClass} .${htmlCss.EmoticonBase}`, {
padding: 0,
overflow: 'visible',
verticalAlign: 'middle',
position: 'relative',
zIndex: 1,
});
globalStyle(`${jumboEmojiClass} .${htmlCss.Emoticon.classNames.base}`, {