@moonwitness/ui 7.3.1 → 8.0.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 +16 -0
- package/package.json +2 -3
- package/scripts/consumer-smoke.mjs +0 -45
- package/scripts/generate-icons.mjs +0 -110
- package/scripts/generate-token-artifacts.mjs +0 -90
- package/scripts/icon-svg-to-jsx.mjs +0 -249
- package/scripts/verification-diagnostics.mjs +0 -40
- package/scripts/verify-package.mjs +0 -412
- package/src/cartoon/anime-avatar.tsx +0 -628
- package/src/cartoon/anime-stage.tsx +0 -458
- package/src/cartoon/index.tsx +0 -542
- package/src/cartoon.tsx +0 -645
- package/src/characters.ts +0 -625
- package/src/components/accordion.tsx +0 -77
- package/src/components/alert.tsx +0 -139
- package/src/components/appearance-menu.tsx +0 -181
- package/src/components/artwork-frame.tsx +0 -49
- package/src/components/audio.tsx +0 -97
- package/src/components/avatar.tsx +0 -75
- package/src/components/badge.tsx +0 -94
- package/src/components/brand-mark.tsx +0 -73
- package/src/components/breadcrumbs.tsx +0 -98
- package/src/components/button.tsx +0 -340
- package/src/components/card.tsx +0 -171
- package/src/components/character-badge.tsx +0 -58
- package/src/components/character-preview.tsx +0 -104
- package/src/components/character-stage.tsx +0 -225
- package/src/components/chart.tsx +0 -481
- package/src/components/checkbox.tsx +0 -64
- package/src/components/comic-panel.tsx +0 -301
- package/src/components/comic-theater.tsx +0 -170
- package/src/components/command.tsx +0 -189
- package/src/components/confirm-dialog.tsx +0 -129
- package/src/components/copy-button.tsx +0 -62
- package/src/components/date-picker.tsx +0 -126
- package/src/components/dialog.tsx +0 -164
- package/src/components/dna-icon.tsx +0 -77
- package/src/components/dropdown-menu.tsx +0 -87
- package/src/components/effects.tsx +0 -1021
- package/src/components/empty-state.tsx +0 -93
- package/src/components/epistemic-branch-panel.tsx +0 -101
- package/src/components/error-state.tsx +0 -137
- package/src/components/field.tsx +0 -96
- package/src/components/filter-facet-bar.tsx +0 -91
- package/src/components/inbox-popover.tsx +0 -146
- package/src/components/input.tsx +0 -25
- package/src/components/kanban-board.tsx +0 -190
- package/src/components/label.tsx +0 -19
- package/src/components/layered-scene.tsx +0 -555
- package/src/components/log-console.tsx +0 -261
- package/src/components/metric-tile.tsx +0 -99
- package/src/components/mode-picker.tsx +0 -149
- package/src/components/motion-timeline.tsx +0 -848
- package/src/components/number-input.tsx +0 -104
- package/src/components/page-header.tsx +0 -123
- package/src/components/pagination.tsx +0 -83
- package/src/components/panel.tsx +0 -121
- package/src/components/paper-note.tsx +0 -77
- package/src/components/popover.tsx +0 -72
- package/src/components/progress.tsx +0 -127
- package/src/components/quest-card.tsx +0 -319
- package/src/components/radio-group.tsx +0 -50
- package/src/components/riot-sticker.tsx +0 -151
- package/src/components/scene-particles.tsx +0 -196
- package/src/components/scene-transitions.tsx +0 -130
- package/src/components/section-ribbon.tsx +0 -94
- package/src/components/select-field.tsx +0 -27
- package/src/components/select.tsx +0 -81
- package/src/components/separator.tsx +0 -58
- package/src/components/sheet.tsx +0 -96
- package/src/components/skeleton.tsx +0 -35
- package/src/components/sketch-annotation.tsx +0 -87
- package/src/components/smart-button-box.tsx +0 -114
- package/src/components/speech-bubble.tsx +0 -116
- package/src/components/spinner.tsx +0 -69
- package/src/components/sprite-player.tsx +0 -412
- package/src/components/status-bar.tsx +0 -63
- package/src/components/status-pill.tsx +0 -68
- package/src/components/switch.tsx +0 -76
- package/src/components/table.tsx +0 -163
- package/src/components/tabs.tsx +0 -101
- package/src/components/tag-input.tsx +0 -170
- package/src/components/textarea.tsx +0 -25
- package/src/components/toast.tsx +0 -14
- package/src/components/toolbar.tsx +0 -39
- package/src/components/tooltip.tsx +0 -49
- package/src/components/update-banner.tsx +0 -220
- package/src/components/xv-primitives.tsx +0 -256
- package/src/css-exports.ts +0 -142
- package/src/dna.tsx +0 -137
- package/src/game/boss-hud.tsx +0 -384
- package/src/game/index.tsx +0 -886
- package/src/game/tactical.tsx +0 -245
- package/src/game.tsx +0 -770
- package/src/icons/activity.tsx +0 -38
- package/src/icons/add.tsx +0 -38
- package/src/icons/addon.tsx +0 -37
- package/src/icons/anime-anger.tsx +0 -37
- package/src/icons/anime-shock.tsx +0 -37
- package/src/icons/anime-sparkle.tsx +0 -38
- package/src/icons/anime-sweatdrop.tsx +0 -38
- package/src/icons/archive.tsx +0 -37
- package/src/icons/arrow-left.tsx +0 -37
- package/src/icons/arrow-right.tsx +0 -37
- package/src/icons/attachment.tsx +0 -38
- package/src/icons/bank.tsx +0 -37
- package/src/icons/bolt.tsx +0 -37
- package/src/icons/book-open.tsx +0 -37
- package/src/icons/bookmark.tsx +0 -37
- package/src/icons/boss-skull.tsx +0 -40
- package/src/icons/calendar-clock.tsx +0 -40
- package/src/icons/calendar.tsx +0 -38
- package/src/icons/check-circle.tsx +0 -38
- package/src/icons/check-square.tsx +0 -38
- package/src/icons/check.tsx +0 -37
- package/src/icons/chevron-right.tsx +0 -37
- package/src/icons/chevrons-left.tsx +0 -37
- package/src/icons/chevrons-right.tsx +0 -37
- package/src/icons/clapperboard.tsx +0 -38
- package/src/icons/clock.tsx +0 -38
- package/src/icons/close.tsx +0 -37
- package/src/icons/code.tsx +0 -37
- package/src/icons/columns.tsx +0 -38
- package/src/icons/combo-flame.tsx +0 -38
- package/src/icons/company.tsx +0 -38
- package/src/icons/credit-card.tsx +0 -38
- package/src/icons/critical-star.tsx +0 -37
- package/src/icons/currency.tsx +0 -38
- package/src/icons/delete.tsx +0 -37
- package/src/icons/document.tsx +0 -38
- package/src/icons/download.tsx +0 -37
- package/src/icons/dpad.tsx +0 -38
- package/src/icons/edit.tsx +0 -38
- package/src/icons/element-fire.tsx +0 -37
- package/src/icons/element-ice.tsx +0 -38
- package/src/icons/element-solar.tsx +0 -38
- package/src/icons/element-void.tsx +0 -38
- package/src/icons/element-volt.tsx +0 -38
- package/src/icons/element-wind.tsx +0 -37
- package/src/icons/error.tsx +0 -38
- package/src/icons/external-link.tsx +0 -38
- package/src/icons/field.tsx +0 -38
- package/src/icons/file-spreadsheet.tsx +0 -38
- package/src/icons/filter.tsx +0 -37
- package/src/icons/gacha-ticket.tsx +0 -38
- package/src/icons/gamepad.tsx +0 -40
- package/src/icons/globe.tsx +0 -38
- package/src/icons/grid.tsx +0 -40
- package/src/icons/hash.tsx +0 -37
- package/src/icons/heart-hp.tsx +0 -38
- package/src/icons/history.tsx +0 -37
- package/src/icons/home.tsx +0 -37
- package/src/icons/image.tsx +0 -39
- package/src/icons/impact-slash.tsx +0 -38
- package/src/icons/inbox.tsx +0 -38
- package/src/icons/index.ts +0 -120
- package/src/icons/info.tsx +0 -38
- package/src/icons/jobs.tsx +0 -38
- package/src/icons/katana.tsx +0 -38
- package/src/icons/key.tsx +0 -38
- package/src/icons/keyboard.tsx +0 -38
- package/src/icons/keyframe-diamond.tsx +0 -38
- package/src/icons/knowledge.tsx +0 -38
- package/src/icons/language.tsx +0 -39
- package/src/icons/lock.tsx +0 -38
- package/src/icons/logout.tsx +0 -37
- package/src/icons/loot-chest.tsx +0 -39
- package/src/icons/mail.tsx +0 -38
- package/src/icons/mana-crystal.tsx +0 -38
- package/src/icons/map-pin.tsx +0 -38
- package/src/icons/mecha-helm.tsx +0 -38
- package/src/icons/menu.tsx +0 -37
- package/src/icons/message.tsx +0 -38
- package/src/icons/model.tsx +0 -38
- package/src/icons/moon.tsx +0 -37
- package/src/icons/notification.tsx +0 -38
- package/src/icons/partner.tsx +0 -41
- package/src/icons/pause.tsx +0 -37
- package/src/icons/phone.tsx +0 -37
- package/src/icons/play.tsx +0 -37
- package/src/icons/potion-flask.tsx +0 -40
- package/src/icons/quest-scroll.tsx +0 -39
- package/src/icons/radar-ping.tsx +0 -40
- package/src/icons/refresh.tsx +0 -38
- package/src/icons/relation.tsx +0 -40
- package/src/icons/save.tsx +0 -38
- package/src/icons/search.tsx +0 -38
- package/src/icons/security.tsx +0 -38
- package/src/icons/send.tsx +0 -38
- package/src/icons/settings.tsx +0 -39
- package/src/icons/shield-crest.tsx +0 -38
- package/src/icons/shuriken.tsx +0 -38
- package/src/icons/signal-off.tsx +0 -37
- package/src/icons/signal.tsx +0 -37
- package/src/icons/skill-node.tsx +0 -40
- package/src/icons/smartphone.tsx +0 -38
- package/src/icons/sort-ascending.tsx +0 -37
- package/src/icons/sort-descending.tsx +0 -37
- package/src/icons/sort.tsx +0 -37
- package/src/icons/sparkle.tsx +0 -38
- package/src/icons/speech-burst.tsx +0 -37
- package/src/icons/story.tsx +0 -37
- package/src/icons/sun.tsx +0 -38
- package/src/icons/tag.tsx +0 -38
- package/src/icons/team.tsx +0 -40
- package/src/icons/trophy-crown.tsx +0 -39
- package/src/icons/upload.tsx +0 -37
- package/src/icons/user.tsx +0 -38
- package/src/icons/users.tsx +0 -39
- package/src/icons/visibility-off.tsx +0 -38
- package/src/icons/visibility.tsx +0 -38
- package/src/icons/volume-off.tsx +0 -37
- package/src/icons/volume.tsx +0 -37
- package/src/icons/warning.tsx +0 -38
- package/src/icons/workflow.tsx +0 -40
- package/src/icons.tsx +0 -965
- package/src/index.ts +0 -89
- package/src/lib/asset-registry.ts +0 -534
- package/src/lib/audio-runtime.ts +0 -314
- package/src/lib/character-adapter.ts +0 -370
- package/src/lib/character-registry.ts +0 -2368
- package/src/lib/cn.ts +0 -6
- package/src/lib/compose-refs.ts +0 -16
- package/src/lib/sanitize-url.ts +0 -51
- package/src/lib/scene-camera.ts +0 -483
- package/src/lib/scene-playback.ts +0 -622
- package/src/lib/scene-soundscape.ts +0 -151
- package/src/lib/scene-test-harness.ts +0 -200
- package/src/lib/scene-timeline.ts +0 -398
- package/src/lib/use-animation-visibility.ts +0 -45
- package/src/lib/use-modal-focus.ts +0 -270
- package/src/lib/use-reduced-motion.ts +0 -37
- package/src/motion/easing-presets.ts +0 -262
- package/src/motion/index.tsx +0 -894
- package/src/motion/physics.ts +0 -259
- package/src/motion/timeline-math.ts +0 -358
- package/src/motion.tsx +0 -639
- package/src/pixelfx-boundary.ts +0 -188
- package/src/pixelfx-registry.ts +0 -1190
- package/src/pixelfx-types.d.ts +0 -73
- package/src/pixelfx.tsx +0 -1022
- package/src/provider.tsx +0 -63
- package/src/skin-catalog.ts +0 -306
- package/src/skin-tokens.ts +0 -425
- package/src/ssr/init-script.ts +0 -281
- package/src/ssr/resolve-skin.ts +0 -217
- package/src/ssr/theme-mismatch-dev.ts +0 -181
- package/src/templates/battle-arena.tsx +0 -688
- package/src/templates/index.tsx +0 -314
- package/src/templates.tsx +0 -225
- package/src/themes/dna-presets.ts +0 -119
- package/src/themes/index.ts +0 -56
- package/src/themes/provider.tsx +0 -183
- package/src/themes/types.ts +0 -111
- package/src/themes.ts +0 -9
- package/src/token-exporter.ts +0 -12
- package/src/token-exporters.ts +0 -343
- package/src/token-seeds.ts +0 -335
- package/src/token-snapshot.ts +0 -179
- package/src/utils.ts +0 -58
package/src/components/card.tsx
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { forwardRef, useState, type HTMLAttributes } from "react";
|
|
3
|
-
import { JaggedBorderSvg, PixelFxComponentLayer } from "../pixelfx.js";
|
|
4
|
-
import {
|
|
5
|
-
resolveComponentFxProp,
|
|
6
|
-
type EmpirePaletteId,
|
|
7
|
-
type PixelFxEffectId,
|
|
8
|
-
type PixelFxProp,
|
|
9
|
-
} from "../pixelfx-registry.js";
|
|
10
|
-
import { cn } from "../utils.js";
|
|
11
|
-
|
|
12
|
-
export type CardVariant = "default" | "elevated" | "muted" | "interactive";
|
|
13
|
-
export type CardPadding = "none" | "sm" | "md" | "lg";
|
|
14
|
-
|
|
15
|
-
export interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
16
|
-
variant?: CardVariant;
|
|
17
|
-
padding?: CardPadding;
|
|
18
|
-
jagged?: boolean;
|
|
19
|
-
jaggedColor?: string;
|
|
20
|
-
fx?: PixelFxProp;
|
|
21
|
-
fxAura?: PixelFxEffectId | "auto" | false;
|
|
22
|
-
fxPalette?: EmpirePaletteId;
|
|
23
|
-
fxTrigger?: "always" | "hover";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const CARD_VARIANT_BORDER_COLOR: Record<CardVariant, string> = {
|
|
27
|
-
default: "var(--mw-cyan)",
|
|
28
|
-
elevated: "var(--mw-yellow)",
|
|
29
|
-
muted: "var(--mw-border-strong)",
|
|
30
|
-
interactive: "var(--mw-magenta)",
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const Card = forwardRef<HTMLDivElement, CardProps>((
|
|
34
|
-
{
|
|
35
|
-
variant = "default",
|
|
36
|
-
padding = "md",
|
|
37
|
-
jagged = true,
|
|
38
|
-
jaggedColor,
|
|
39
|
-
fx,
|
|
40
|
-
fxAura = "auto",
|
|
41
|
-
fxPalette,
|
|
42
|
-
fxTrigger,
|
|
43
|
-
className,
|
|
44
|
-
children,
|
|
45
|
-
onMouseEnter,
|
|
46
|
-
onMouseLeave,
|
|
47
|
-
onFocus,
|
|
48
|
-
onBlur,
|
|
49
|
-
...props
|
|
50
|
-
},
|
|
51
|
-
ref,
|
|
52
|
-
) => {
|
|
53
|
-
const [engaged, setEngaged] = useState(false);
|
|
54
|
-
const resolved = resolveComponentFxProp("card", variant, fx ?? fxAura);
|
|
55
|
-
const resolvedEffectId = resolved?.effectId ?? null;
|
|
56
|
-
const resolvedPalette = fxPalette ?? resolved?.paletteId ?? "empire-yellow";
|
|
57
|
-
const effectiveTrigger =
|
|
58
|
-
fxTrigger ??
|
|
59
|
-
(variant === "elevated" || variant === "interactive" ? "always" : "hover");
|
|
60
|
-
const resolvedBorderColor = jaggedColor ?? CARD_VARIANT_BORDER_COLOR[variant];
|
|
61
|
-
const fxActive = Boolean(
|
|
62
|
-
resolvedEffectId && (effectiveTrigger === "always" || engaged),
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<div
|
|
67
|
-
ref={ref}
|
|
68
|
-
className={cn("mw-ui-card", className)}
|
|
69
|
-
data-variant={variant}
|
|
70
|
-
data-padding={padding}
|
|
71
|
-
data-jagged={jagged ? "true" : undefined}
|
|
72
|
-
data-fx-aura={resolvedEffectId ?? undefined}
|
|
73
|
-
data-pixelfx={resolvedEffectId ?? undefined}
|
|
74
|
-
data-pixelfx-ready={resolvedEffectId ? "true" : undefined}
|
|
75
|
-
onMouseEnter={(event) => {
|
|
76
|
-
if (resolvedEffectId && effectiveTrigger === "hover") setEngaged(true);
|
|
77
|
-
onMouseEnter?.(event);
|
|
78
|
-
}}
|
|
79
|
-
onMouseLeave={(event) => {
|
|
80
|
-
if (resolvedEffectId && effectiveTrigger === "hover") setEngaged(false);
|
|
81
|
-
onMouseLeave?.(event);
|
|
82
|
-
}}
|
|
83
|
-
onFocus={(event) => {
|
|
84
|
-
if (resolvedEffectId && effectiveTrigger === "hover") setEngaged(true);
|
|
85
|
-
onFocus?.(event);
|
|
86
|
-
}}
|
|
87
|
-
onBlur={(event) => {
|
|
88
|
-
if (resolvedEffectId && effectiveTrigger === "hover") setEngaged(false);
|
|
89
|
-
onBlur?.(event);
|
|
90
|
-
}}
|
|
91
|
-
{...props}
|
|
92
|
-
>
|
|
93
|
-
{jagged ? <JaggedBorderSvg color={resolvedBorderColor} /> : null}
|
|
94
|
-
{resolved && resolvedEffectId ? (
|
|
95
|
-
<PixelFxComponentLayer
|
|
96
|
-
effectId={resolvedEffectId}
|
|
97
|
-
paletteId={resolvedPalette}
|
|
98
|
-
layer={resolved.layer}
|
|
99
|
-
loop
|
|
100
|
-
active={fxActive}
|
|
101
|
-
speed={resolved.speed}
|
|
102
|
-
seed={resolved.seed}
|
|
103
|
-
lightK={resolved.lightK}
|
|
104
|
-
placement="background"
|
|
105
|
-
/>
|
|
106
|
-
) : null}
|
|
107
|
-
{children}
|
|
108
|
-
</div>
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
Card.displayName = "Card";
|
|
113
|
-
|
|
114
|
-
export function CardHeader({
|
|
115
|
-
className,
|
|
116
|
-
...props
|
|
117
|
-
}: HTMLAttributes<HTMLDivElement>) {
|
|
118
|
-
return (
|
|
119
|
-
<div
|
|
120
|
-
className={className ? `mw-ui-card-header ${className}` : "mw-ui-card-header"}
|
|
121
|
-
{...props}
|
|
122
|
-
/>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function CardTitle({
|
|
127
|
-
className,
|
|
128
|
-
...props
|
|
129
|
-
}: HTMLAttributes<HTMLHeadingElement>) {
|
|
130
|
-
return (
|
|
131
|
-
<h4
|
|
132
|
-
className={className ? `mw-ui-card-title ${className}` : "mw-ui-card-title"}
|
|
133
|
-
{...props}
|
|
134
|
-
/>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function CardDescription({
|
|
139
|
-
className,
|
|
140
|
-
...props
|
|
141
|
-
}: HTMLAttributes<HTMLParagraphElement>) {
|
|
142
|
-
return (
|
|
143
|
-
<p
|
|
144
|
-
className={
|
|
145
|
-
className
|
|
146
|
-
? `mw-ui-card-description ${className}`
|
|
147
|
-
: "mw-ui-card-description"
|
|
148
|
-
}
|
|
149
|
-
{...props}
|
|
150
|
-
/>
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function CardContent({
|
|
155
|
-
className,
|
|
156
|
-
...props
|
|
157
|
-
}: HTMLAttributes<HTMLDivElement>) {
|
|
158
|
-
return <div className={className} {...props} />;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function CardFooter({
|
|
162
|
-
className,
|
|
163
|
-
...props
|
|
164
|
-
}: HTMLAttributes<HTMLDivElement>) {
|
|
165
|
-
return (
|
|
166
|
-
<div
|
|
167
|
-
className={className ? `mw-ui-card-footer ${className}` : "mw-ui-card-footer"}
|
|
168
|
-
{...props}
|
|
169
|
-
/>
|
|
170
|
-
);
|
|
171
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { getCharacterById, CHARACTER_FACTIONS } from "../characters.js";
|
|
2
|
-
import { useComponentPixelFx } from "../pixelfx.js";
|
|
3
|
-
import type { PixelFxProp } from "../pixelfx-registry.js";
|
|
4
|
-
import { cn } from "../utils.js";
|
|
5
|
-
|
|
6
|
-
export type CharacterBadgeProps = {
|
|
7
|
-
characterId: string;
|
|
8
|
-
size?: "sm" | "md" | "lg";
|
|
9
|
-
showGroup?: boolean;
|
|
10
|
-
fx?: PixelFxProp;
|
|
11
|
-
className?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function CharacterBadge({
|
|
15
|
-
characterId,
|
|
16
|
-
size = "md",
|
|
17
|
-
showGroup = true,
|
|
18
|
-
fx = "auto",
|
|
19
|
-
className = "",
|
|
20
|
-
}: CharacterBadgeProps) {
|
|
21
|
-
const pfx = useComponentPixelFx({
|
|
22
|
-
kind: "character-badge",
|
|
23
|
-
fx,
|
|
24
|
-
placement: "compact",
|
|
25
|
-
});
|
|
26
|
-
const profile = getCharacterById(characterId);
|
|
27
|
-
if (!profile) {
|
|
28
|
-
return "";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const isLore = profile.group === "moonwitness-xii" || profile.group === "extended-lore";
|
|
32
|
-
const faction = CHARACTER_FACTIONS.find((f) => f.id === profile.faction);
|
|
33
|
-
const groupLabel = faction?.label ?? profile.codename;
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<span
|
|
37
|
-
className={cn("mw-ui-character-badge", className)}
|
|
38
|
-
data-size={size}
|
|
39
|
-
data-character={profile.id}
|
|
40
|
-
data-canon={isLore ? "lore" : undefined}
|
|
41
|
-
{...pfx.dataAttributes}
|
|
42
|
-
{...pfx.handlers}
|
|
43
|
-
>
|
|
44
|
-
{pfx.layer}
|
|
45
|
-
<span
|
|
46
|
-
aria-hidden="true"
|
|
47
|
-
className={cn(
|
|
48
|
-
"mw-ui-character-badge-color",
|
|
49
|
-
size === "sm" ? "mw-ui-badge-color-sm" : size === "lg" ? "mw-ui-badge-color-lg" : "mw-ui-badge-color-md",
|
|
50
|
-
)}
|
|
51
|
-
/>
|
|
52
|
-
<span>{profile.name}</span>
|
|
53
|
-
{showGroup ? (
|
|
54
|
-
<small className="mw-ui-character-badge-group">{groupLabel}</small>
|
|
55
|
-
) : null}
|
|
56
|
-
</span>
|
|
57
|
-
);
|
|
58
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
|
-
import { Button } from "./button.js";
|
|
5
|
-
import { StatusBar } from "./status-bar.js";
|
|
6
|
-
import { SpritePlayer, type SpriteClipMetadata } from "./sprite-player.js";
|
|
7
|
-
import { getActiveSceneHarness } from "../lib/scene-test-harness.js";
|
|
8
|
-
import { useReducedMotion } from "../lib/use-reduced-motion.js";
|
|
9
|
-
|
|
10
|
-
export type CharacterPreviewProps = {
|
|
11
|
-
/** Canonical manifest asset path for the clip JSON. */
|
|
12
|
-
clipId: string;
|
|
13
|
-
/** Canonical manifest asset path for the reduced-motion still fallback. */
|
|
14
|
-
fallbackAsset: string;
|
|
15
|
-
/** Canonical manifest frame paths for the selected clip. */
|
|
16
|
-
frames?: readonly string[];
|
|
17
|
-
durationMs?: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function CharacterPreview({
|
|
21
|
-
clipId,
|
|
22
|
-
fallbackAsset,
|
|
23
|
-
frames = [fallbackAsset],
|
|
24
|
-
durationMs = 1200,
|
|
25
|
-
}: CharacterPreviewProps) {
|
|
26
|
-
const [playing, setPlaying] = useState(false);
|
|
27
|
-
const [manualReducedMotion, setManualReducedMotion] = useState<
|
|
28
|
-
boolean | undefined
|
|
29
|
-
>(undefined);
|
|
30
|
-
const harness = getActiveSceneHarness();
|
|
31
|
-
const reducedMotion = useReducedMotion(manualReducedMotion);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (harness?.reducedMotion !== undefined) {
|
|
35
|
-
setManualReducedMotion(undefined);
|
|
36
|
-
}
|
|
37
|
-
}, [harness?.reducedMotion]);
|
|
38
|
-
|
|
39
|
-
const clip = useMemo<SpriteClipMetadata>(
|
|
40
|
-
() => ({
|
|
41
|
-
id: clipId,
|
|
42
|
-
frames,
|
|
43
|
-
durationMs,
|
|
44
|
-
loop: true,
|
|
45
|
-
pingPong: true,
|
|
46
|
-
fallbackAsset,
|
|
47
|
-
width: 1024,
|
|
48
|
-
height: 1024,
|
|
49
|
-
}),
|
|
50
|
-
[clipId, frames, durationMs, fallbackAsset],
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const reset = useCallback(() => {
|
|
54
|
-
setPlaying(false);
|
|
55
|
-
}, []);
|
|
56
|
-
|
|
57
|
-
const togglePlayback = useCallback(() => {
|
|
58
|
-
if (!playing || reducedMotion) {
|
|
59
|
-
setManualReducedMotion(false);
|
|
60
|
-
setPlaying(true);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
setPlaying(false);
|
|
64
|
-
}, [playing, reducedMotion]);
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<div className="character-preview">
|
|
68
|
-
<StatusBar
|
|
69
|
-
steps={[
|
|
70
|
-
{
|
|
71
|
-
id: "playback",
|
|
72
|
-
label: "playback",
|
|
73
|
-
state: playing ? "active" : "disabled",
|
|
74
|
-
},
|
|
75
|
-
]}
|
|
76
|
-
/>
|
|
77
|
-
<div className="character-preview-surface">
|
|
78
|
-
<SpritePlayer
|
|
79
|
-
clip={clip}
|
|
80
|
-
playing={playing}
|
|
81
|
-
reducedMotion={reducedMotion}
|
|
82
|
-
label={`${clipId} character animation preview`}
|
|
83
|
-
scale={0.65}
|
|
84
|
-
/>
|
|
85
|
-
</div>
|
|
86
|
-
<div className="character-preview-controls">
|
|
87
|
-
<Button type="button" variant="magenta" onClick={togglePlayback}>
|
|
88
|
-
{playing && !reducedMotion ? "Pause" : "Play"}
|
|
89
|
-
</Button>
|
|
90
|
-
<Button type="button" variant="default" onClick={reset}>
|
|
91
|
-
Reset
|
|
92
|
-
</Button>
|
|
93
|
-
<Button
|
|
94
|
-
type="button"
|
|
95
|
-
variant="default"
|
|
96
|
-
onClick={() => setManualReducedMotion(!reducedMotion)}
|
|
97
|
-
aria-pressed={reducedMotion}
|
|
98
|
-
>
|
|
99
|
-
{reducedMotion ? "Reduced motion on" : "Reduced motion off"}
|
|
100
|
-
</Button>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
forwardRef,
|
|
5
|
-
useMemo,
|
|
6
|
-
type ComponentPropsWithoutRef,
|
|
7
|
-
type ReactNode,
|
|
8
|
-
} from "react";
|
|
9
|
-
import { useComponentPixelFx } from "../pixelfx.js";
|
|
10
|
-
import type { PixelFxProp } from "../pixelfx-registry.js";
|
|
11
|
-
import {
|
|
12
|
-
getCharacterClip,
|
|
13
|
-
getCharacterPortrait,
|
|
14
|
-
getCharacterPose,
|
|
15
|
-
type CharacterId,
|
|
16
|
-
type KuroClipId,
|
|
17
|
-
type KuroExpression,
|
|
18
|
-
type KuroPose,
|
|
19
|
-
type WalterExpression,
|
|
20
|
-
} from "../lib/asset-registry.js";
|
|
21
|
-
import { cn } from "../lib/cn.js";
|
|
22
|
-
import { useReducedMotion } from "../lib/use-reduced-motion.js";
|
|
23
|
-
import {
|
|
24
|
-
SpeechBubble,
|
|
25
|
-
type SpeechBubbleTail,
|
|
26
|
-
type SpeechBubbleVariant,
|
|
27
|
-
} from "./speech-bubble.js";
|
|
28
|
-
import { SpritePlayer } from "./sprite-player.js";
|
|
29
|
-
|
|
30
|
-
export type CharacterDisplaySize = "sm" | "md" | "lg";
|
|
31
|
-
|
|
32
|
-
export type CharacterDisplayProps = Omit<
|
|
33
|
-
ComponentPropsWithoutRef<"div">,
|
|
34
|
-
"children"
|
|
35
|
-
> & {
|
|
36
|
-
characterId?: CharacterId;
|
|
37
|
-
expression?: KuroExpression | WalterExpression;
|
|
38
|
-
pose?: KuroPose;
|
|
39
|
-
animated?: boolean;
|
|
40
|
-
clipId?: KuroClipId;
|
|
41
|
-
size?: CharacterDisplaySize;
|
|
42
|
-
basePath?: string;
|
|
43
|
-
alt?: string;
|
|
44
|
-
decorative?: boolean;
|
|
45
|
-
reducedMotion?: boolean;
|
|
46
|
-
fx?: PixelFxProp;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Displays a MoonWitness character portrait, full pose, or animated sprite clip.
|
|
51
|
-
* Automatically falls back to a static portrait when prefers-reduced-motion is active.
|
|
52
|
-
*/
|
|
53
|
-
export const CharacterDisplay = forwardRef<
|
|
54
|
-
HTMLDivElement,
|
|
55
|
-
CharacterDisplayProps
|
|
56
|
-
>(function CharacterDisplay(
|
|
57
|
-
{
|
|
58
|
-
characterId = "kuro-signal",
|
|
59
|
-
expression = "determined",
|
|
60
|
-
pose,
|
|
61
|
-
animated = false,
|
|
62
|
-
clipId = "idle",
|
|
63
|
-
size = "md",
|
|
64
|
-
basePath = "",
|
|
65
|
-
alt,
|
|
66
|
-
decorative = false,
|
|
67
|
-
reducedMotion,
|
|
68
|
-
fx = "auto",
|
|
69
|
-
className,
|
|
70
|
-
...props
|
|
71
|
-
},
|
|
72
|
-
ref,
|
|
73
|
-
) {
|
|
74
|
-
const isReducedMotion = useReducedMotion(reducedMotion);
|
|
75
|
-
const pfx = useComponentPixelFx({
|
|
76
|
-
kind: "character-stage",
|
|
77
|
-
fx: isReducedMotion ? false : fx,
|
|
78
|
-
placement: "background",
|
|
79
|
-
});
|
|
80
|
-
const shouldAnimate =
|
|
81
|
-
animated && characterId === "kuro-signal" && !isReducedMotion;
|
|
82
|
-
|
|
83
|
-
const staticAsset = useMemo(
|
|
84
|
-
() =>
|
|
85
|
-
pose && characterId === "kuro-signal"
|
|
86
|
-
? getCharacterPose(characterId, pose, { basePath })
|
|
87
|
-
: getCharacterPortrait(characterId, expression, { basePath }),
|
|
88
|
-
[basePath, characterId, expression, pose],
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const clip = useMemo(
|
|
92
|
-
() => (shouldAnimate ? getCharacterClip(clipId, { basePath }) : null),
|
|
93
|
-
[basePath, clipId, shouldAnimate],
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const resolvedAlt = decorative ? "" : (alt ?? staticAsset.alt);
|
|
97
|
-
|
|
98
|
-
return (
|
|
99
|
-
<figure
|
|
100
|
-
aria-hidden={decorative ? "true" : undefined}
|
|
101
|
-
className={cn("mw-ui-character-stage", className)}
|
|
102
|
-
data-animated={shouldAnimate ? "true" : "false"}
|
|
103
|
-
data-character={characterId}
|
|
104
|
-
data-character-id={characterId}
|
|
105
|
-
data-expression={expression}
|
|
106
|
-
data-reduced-motion={isReducedMotion ? "true" : "false"}
|
|
107
|
-
data-size={size}
|
|
108
|
-
{...pfx.dataAttributes}
|
|
109
|
-
{...pfx.handlers}
|
|
110
|
-
{...props}
|
|
111
|
-
>
|
|
112
|
-
{pfx.layer}
|
|
113
|
-
<div ref={ref} className="mw-ui-character-stage-root">
|
|
114
|
-
{shouldAnimate && clip ? (
|
|
115
|
-
<SpritePlayer
|
|
116
|
-
clip={clip}
|
|
117
|
-
label={resolvedAlt}
|
|
118
|
-
reducedMotion={isReducedMotion}
|
|
119
|
-
className="mw-ui-character-stage-sprite"
|
|
120
|
-
/>
|
|
121
|
-
) : (
|
|
122
|
-
<picture className="mw-ui-character-stage-media">
|
|
123
|
-
{staticAsset.src !== staticAsset.fallbackSrc ? (
|
|
124
|
-
<source srcSet={staticAsset.src} type="image/webp" />
|
|
125
|
-
) : null}
|
|
126
|
-
<img
|
|
127
|
-
className="mw-ui-character-stage-img"
|
|
128
|
-
src={staticAsset.fallbackSrc}
|
|
129
|
-
alt={resolvedAlt}
|
|
130
|
-
decoding="async"
|
|
131
|
-
width={size === "lg" ? 140 : size === "md" ? 96 : 64}
|
|
132
|
-
height={size === "lg" ? 140 : size === "md" ? 96 : 64}
|
|
133
|
-
/>
|
|
134
|
-
</picture>
|
|
135
|
-
)}
|
|
136
|
-
</div>
|
|
137
|
-
</figure>
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
export type CharacterReactionProps = Omit<CharacterDisplayProps, "children"> & {
|
|
142
|
-
message: ReactNode;
|
|
143
|
-
speaker?: ReactNode;
|
|
144
|
-
bubbleVariant?: SpeechBubbleVariant;
|
|
145
|
-
bubbleTail?: SpeechBubbleTail;
|
|
146
|
-
statusLabel?: string;
|
|
147
|
-
live?: "polite" | "assertive" | "off";
|
|
148
|
-
fx?: PixelFxProp;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
/** Pairs CharacterDisplay with a directional SpeechBubble and accessible status region. */
|
|
152
|
-
export const CharacterReaction = forwardRef<
|
|
153
|
-
HTMLDivElement,
|
|
154
|
-
CharacterReactionProps
|
|
155
|
-
>(function CharacterReaction(
|
|
156
|
-
{
|
|
157
|
-
message,
|
|
158
|
-
speaker,
|
|
159
|
-
bubbleVariant = "speech",
|
|
160
|
-
bubbleTail = "left",
|
|
161
|
-
statusLabel,
|
|
162
|
-
live = "polite",
|
|
163
|
-
characterId = "kuro-signal",
|
|
164
|
-
className,
|
|
165
|
-
expression,
|
|
166
|
-
pose,
|
|
167
|
-
animated,
|
|
168
|
-
clipId,
|
|
169
|
-
size,
|
|
170
|
-
basePath,
|
|
171
|
-
alt,
|
|
172
|
-
decorative,
|
|
173
|
-
reducedMotion,
|
|
174
|
-
fx = "auto",
|
|
175
|
-
...props
|
|
176
|
-
},
|
|
177
|
-
ref,
|
|
178
|
-
) {
|
|
179
|
-
const reactionReducedMotion = useReducedMotion(reducedMotion);
|
|
180
|
-
const pfx = useComponentPixelFx({
|
|
181
|
-
kind: "character-stage",
|
|
182
|
-
fx: reactionReducedMotion ? false : fx,
|
|
183
|
-
placement: "background",
|
|
184
|
-
});
|
|
185
|
-
return (
|
|
186
|
-
<div
|
|
187
|
-
ref={ref}
|
|
188
|
-
className={cn("mw-ui-character-reaction", className)}
|
|
189
|
-
data-character={characterId}
|
|
190
|
-
data-character-id={characterId}
|
|
191
|
-
data-expression={expression ?? "determined"}
|
|
192
|
-
data-reduced-motion={reactionReducedMotion ? "true" : "false"}
|
|
193
|
-
{...pfx.dataAttributes}
|
|
194
|
-
{...pfx.handlers}
|
|
195
|
-
{...props}
|
|
196
|
-
>
|
|
197
|
-
{pfx.layer}
|
|
198
|
-
<CharacterDisplay
|
|
199
|
-
characterId={characterId}
|
|
200
|
-
expression={expression}
|
|
201
|
-
pose={pose}
|
|
202
|
-
animated={animated}
|
|
203
|
-
clipId={clipId}
|
|
204
|
-
size={size}
|
|
205
|
-
basePath={basePath}
|
|
206
|
-
alt={alt}
|
|
207
|
-
decorative={decorative}
|
|
208
|
-
reducedMotion={reducedMotion}
|
|
209
|
-
/>
|
|
210
|
-
<SpeechBubble
|
|
211
|
-
variant={bubbleVariant}
|
|
212
|
-
tail={bubbleTail}
|
|
213
|
-
speaker={speaker}
|
|
214
|
-
reducedMotion={reducedMotion}
|
|
215
|
-
role={live !== "off" ? "status" : undefined}
|
|
216
|
-
data-character-id={characterId}
|
|
217
|
-
data-reduced-motion={reactionReducedMotion ? "true" : undefined}
|
|
218
|
-
aria-live={live !== "off" ? live : undefined}
|
|
219
|
-
aria-label={statusLabel}
|
|
220
|
-
>
|
|
221
|
-
{message}
|
|
222
|
-
</SpeechBubble>
|
|
223
|
-
</div>
|
|
224
|
-
);
|
|
225
|
-
});
|