@vetta-org/theme-ui 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +740 -20
- package/src/action-approval/AppearanceActionPickerView.tsx +2 -78
- package/src/action-approval/AppearanceApprovalDrawerView.tsx +2 -9
- package/src/action-approval/BatchTasksApprovalFrameView.tsx +4 -1
- package/src/action-approval/GenericActionApprovalView.tsx +2 -9
- package/src/action-approval/ManageActionApprovalFrameView.tsx +4 -1
- package/src/action-approval/NavigationOpenApprovalView.tsx +2 -9
- package/src/action-approval/SchedulerActionApprovalDialogView.tsx +3 -1
- package/src/action-approval/SchedulerEditApprovalDrawerView.tsx +3 -10
- package/src/action-approval/index.ts +0 -1
- package/src/activity/ActivityPanel.tsx +13 -10
- package/src/activity/ActivityPanelFrame.test.tsx +32 -0
- package/src/activity/ActivityPanelFrame.tsx +3 -2
- package/src/activity/BackgroundTasksTabPanelView.tsx +1 -1
- package/src/activity/BrowserPanelView.tsx +48 -49
- package/src/activity/CodePreview.tsx +15 -1
- package/src/activity/DebugTabPanelView.tsx +1 -1
- package/src/activity/MarkdownPreviewView.test.tsx +53 -0
- package/src/activity/MarkdownPreviewView.tsx +135 -62
- package/src/activity/PluginTabPickerView.tsx +5 -3
- package/src/activity/PortsTabPanelView.tsx +911 -0
- package/src/activity/ToolCallsSubTabView.tsx +1 -1
- package/src/activity/WorkflowTabPanelView.tsx +1 -1
- package/src/activity/index.ts +9 -0
- package/src/app/AppBackground.tsx +1 -1
- package/src/app/AppBootLoadingView.tsx +4 -2
- package/src/app-shell/DefaultWindowControls.tsx +1 -1
- package/src/app-shell/PageHeaderActionGroup.tsx +1 -1
- package/src/app-shell/PageHeaderContent.tsx +36 -7
- package/src/app-shell/PageHeaderFrame.tsx +15 -3
- package/src/app-shell/PageHeaderSidebarTrigger.tsx +1 -1
- package/src/app-shell/PageHeaderTitle.tsx +1 -1
- package/src/app-shell/WindowControlButton.tsx +1 -1
- package/src/app-shell/header-crowding.test.ts +62 -0
- package/src/app-shell/header-crowding.tsx +137 -0
- package/src/appearance/BackgroundImageFrame.tsx +1 -1
- package/src/appearance/CenterSliceImageFrame.tsx +1 -1
- package/src/appearance/CornerImageFrame.tsx +1 -1
- package/src/appearance/HorizontalSliceImageFrame.tsx +1 -1
- package/src/appearance/NineSliceImageFrame.tsx +1 -1
- package/src/appearance/ThemeSurface.tsx +1 -1
- package/src/batch-tasks/BatchProjectFoldersFieldView.tsx +2 -1
- package/src/batch-tasks/BatchTaskProjectActionsView.test.tsx +97 -0
- package/src/batch-tasks/BatchTaskProjectActionsView.tsx +45 -35
- package/src/batch-tasks/batchTaskUi.tsx +0 -29
- package/src/bottom-panel/BottomPanelView.test.tsx +43 -0
- package/src/bottom-panel/BottomPanelView.tsx +222 -0
- package/src/bottom-panel/index.ts +26 -0
- package/src/chat/AgentAvatarView.tsx +1 -1
- package/src/chat/AnnotationViews.tsx +107 -0
- package/src/chat/AskUserQuestionView.tsx +18 -11
- package/src/chat/AssistantMessageView.tsx +48 -13
- package/src/chat/AtPanelView.test.tsx +61 -0
- package/src/chat/AtPanelView.tsx +63 -38
- package/src/chat/BashTerminalCard.tsx +1 -2
- package/src/chat/ChatHeaderActionsView.tsx +74 -18
- package/src/chat/CompactionStepView.test.tsx +34 -0
- package/src/chat/CompactionStepView.tsx +85 -0
- package/src/chat/ContextRingView.test.tsx +81 -0
- package/src/chat/ContextRingView.tsx +78 -62
- package/src/chat/ExecutionModeSelectorView.tsx +20 -5
- package/src/chat/HeaderActionBarView.tsx +806 -0
- package/src/chat/HeaderActionOverflowMenu.tsx +128 -0
- package/src/chat/InlineModelPicker.test.tsx +81 -0
- package/src/chat/InlineModelPicker.tsx +201 -0
- package/src/chat/InlineTokenChip.tsx +2 -68
- package/src/chat/InputBarBackground.tsx +1 -1
- package/src/chat/InputBarPlaceholder.tsx +26 -3
- package/src/chat/LiveThinkingView.tsx +51 -37
- package/src/chat/MessageBoundaryViews.tsx +21 -0
- package/src/chat/MessageFeedContext.tsx +13 -5
- package/src/chat/MessageFeedLayoutView.tsx +29 -3
- package/src/chat/MessageFeedView.test.tsx +81 -0
- package/src/chat/MessageFeedView.tsx +72 -152
- package/src/chat/MessageInputView.tsx +6 -2
- package/src/chat/MessageLayoutView.tsx +1 -1
- package/src/chat/MessageSelectionContextMenuView.tsx +4 -1
- package/src/chat/MessageTimelineView.tsx +1 -1
- package/src/chat/MessageView.tsx +1 -1
- package/src/chat/MessageVisualView.tsx +1 -1
- package/src/chat/ModelConfiguration.tsx +283 -0
- package/src/chat/ModelSelectorTrigger.tsx +63 -0
- package/src/chat/ModelSelectorView.tsx +1037 -223
- package/src/chat/NewSession.ts +1 -37
- package/src/chat/NewSessionPicker.tsx +3 -2
- package/src/chat/ProjectSelectorView.tsx +3 -2
- package/src/chat/ReasoningStepSlider.tsx +61 -0
- package/src/chat/RemoteSessionBadgeView.tsx +24 -0
- package/src/chat/SkillPromptAreaView.tsx +5 -19
- package/src/chat/TeamMemberReplyCardView.test.tsx +33 -0
- package/src/chat/TeamMemberReplyCardView.tsx +133 -0
- package/src/chat/TextBlockView.tsx +7 -770
- package/src/chat/TodoProgress.tsx +25 -53
- package/src/chat/TodoStatusBarView.tsx +14 -5
- package/src/chat/UserMessageView.tsx +113 -33
- package/src/chat/header-action-narrow.test.ts +21 -0
- package/src/chat/header-action-narrow.ts +38 -0
- package/src/chat/index.ts +33 -27
- package/src/chat/markdown-link.ts +7 -279
- package/src/chat/message-feed-fade.css +80 -0
- package/src/chat/message-feed-fade.test.tsx +75 -0
- package/src/chat/send-button.css +4 -22
- package/src/chat/streaming-reveal.test.ts +218 -0
- package/src/chat/streaming-reveal.ts +13 -0
- package/src/file-explorer/ConfirmDeleteDialogView.tsx +2 -1
- package/src/file-explorer/FileContextMenuView.tsx +44 -11
- package/src/file-explorer/FileExplorerSettingsView.tsx +97 -0
- package/src/file-explorer/FileTreeCreateRow.tsx +1 -1
- package/src/file-explorer/FileTreeNodeView.tsx +59 -18
- package/src/file-explorer/FileTreeView.tsx +236 -129
- package/src/file-explorer/file-tree-dom.ts +23 -0
- package/src/file-explorer/file-tree-rows.test.ts +74 -0
- package/src/file-explorer/file-tree-rows.ts +168 -0
- package/src/file-explorer/index.ts +17 -0
- package/src/file-explorer/types.ts +3 -0
- package/src/file-explorer/useFileTreeMarqueeSelection.ts +24 -16
- package/src/file-preview/FilePreviewDialogView.tsx +2 -2
- package/src/file-preview/FilePreviewView.tsx +12 -2
- package/src/file-preview/ReadonlyCodeView.tsx +46 -0
- package/src/file-preview/TextFileEditorView.tsx +2 -1
- package/src/file-preview/syntax-tokens.css +1 -1
- package/src/image-assets.d.ts +4 -0
- package/src/index.ts +1 -0
- package/src/knowledge/KnowledgeHowItWorksDialogView.tsx +1 -1
- package/src/layout/AppFrame.tsx +3 -2
- package/src/layout/MainContentFrame.tsx +7 -2
- package/src/layout/ResizeHandle.tsx +68 -17
- package/src/layout/SidebarDock.tsx +75 -19
- package/src/layout/SidebarOverlay.tsx +1 -1
- package/src/layout/index.ts +1 -1
- package/src/layout/resize-handle-axis.test.ts +51 -0
- package/src/live-indicators.test.ts +43 -0
- package/src/markdown/CodeBlock.tsx +123 -0
- package/src/markdown/FileLinkBadge.tsx +77 -0
- package/src/markdown/InlineTokenChip.tsx +68 -0
- package/src/markdown/MarkdownContent.tsx +418 -0
- package/src/markdown/MarkdownImage.tsx +41 -0
- package/src/markdown/MathFormula.tsx +46 -0
- package/src/markdown/MermaidBlock.tsx +82 -0
- package/src/markdown/RichCodeBlock.tsx +127 -0
- package/src/markdown/SvgPreview.tsx +45 -0
- package/src/markdown/WebsiteIcon.tsx +94 -0
- package/src/markdown/builtin-renderers.tsx +43 -0
- package/src/markdown/definition.tsx +49 -0
- package/src/markdown/host.tsx +18 -0
- package/src/markdown/image-actions.ts +29 -0
- package/src/markdown/index.ts +12 -0
- package/src/markdown/inline-tokens.ts +187 -0
- package/src/markdown/markdown-link.ts +279 -0
- package/src/markdown/math-client.ts +116 -0
- package/src/markdown/math-render.ts +23 -0
- package/src/markdown/math-syntax.ts +80 -0
- package/src/markdown/math.worker.ts +16 -0
- package/src/markdown/nodes.ts +15 -0
- package/src/markdown/preview-policy.test.ts +31 -0
- package/src/markdown/preview-policy.ts +76 -0
- package/src/markdown/progressive-chunks.test.ts +43 -0
- package/src/markdown/progressive-chunks.ts +58 -0
- package/src/markdown/rich-labels.ts +55 -0
- package/src/markdown/rich-syntax.ts +93 -0
- package/src/markdown/stable-blocks.test.ts +90 -0
- package/src/markdown/stable-blocks.ts +124 -0
- package/src/markdown/streaming-reveal.ts +297 -0
- package/src/markdown/streaming.test.ts +57 -0
- package/src/markdown/streaming.ts +211 -0
- package/src/markdown/use-render-snapshot.ts +24 -0
- package/src/markdown/use-rich-visibility.ts +24 -0
- package/src/overlays/CommandMenuRow.tsx +77 -17
- package/src/overlays/CommandMenuView.tsx +163 -118
- package/src/overlays/ConfirmDialogView.tsx +25 -20
- package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
- package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +24 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +55 -0
- package/src/overlays/SplashOptionRow.tsx +46 -0
- package/src/overlays/SplashPanel.tsx +85 -0
- package/src/overlays/SplashParts.tsx +217 -0
- package/src/overlays/UpdateCheckerView.tsx +34 -18
- package/src/overlays/UpdateRestartDialogView.tsx +203 -53
- package/src/overlays/assets/diagnostics-banner.webp +0 -0
- package/src/overlays/command-menu-types.ts +15 -1
- package/src/overlays/command-menu.css +1 -20
- package/src/overlays/index.ts +26 -1
- package/src/plugin-ui/index.ts +10 -0
- package/src/project/ConversationTagDotsView.tsx +1 -1
- package/src/project/ConversationTagEditorDialogView.tsx +4 -1
- package/src/project/DefaultConversationSectionView.tsx +15 -24
- package/src/project/DefaultSessionListView.tsx +5 -31
- package/src/project/DefaultSessionRowView.tsx +114 -55
- package/src/project/ManageSessionsSplashView.tsx +439 -0
- package/src/project/NewProjectDialogView.tsx +3 -10
- package/src/project/ProjectContextMenuView.tsx +30 -139
- package/src/project/ProjectDetailPageView.test.tsx +140 -0
- package/src/project/ProjectDetailPageView.tsx +372 -165
- package/src/project/ProjectGroupView.tsx +1 -1
- package/src/project/ProjectRowView.tsx +29 -12
- package/src/project/ProjectSessionsView.tsx +25 -47
- package/src/project/QuickScrollOverlay.tsx +1 -1
- package/src/project/SessionContextMenuView.tsx +15 -7
- package/src/project/SessionRowMoreButton.tsx +50 -0
- package/src/project/SessionRowView.tsx +106 -63
- package/src/project/SessionTitleMarquee.tsx +54 -0
- package/src/project/SidebarProjectDisclosure.tsx +60 -0
- package/src/project/SidebarProjectsSectionView.tsx +6 -1
- package/src/project/index.ts +12 -0
- package/src/project/session-row-transition.ts +9 -0
- package/src/project/types.ts +4 -2
- package/src/project/useActiveSessionAutoScroll.ts +10 -4
- package/src/registry.ts +0 -2
- package/src/scheduler/AutomationDetailPaneView.tsx +68 -0
- package/src/scheduler/AutomationPageView.tsx +118 -121
- package/src/scheduler/ExecutionHistoryView.tsx +7 -5
- package/src/scheduler/TaskListView.tsx +52 -201
- package/src/scheduler/index.ts +7 -12
- package/src/settings/AppshotSettingsView.tsx +0 -1
- package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
- package/src/settings/BuiltinMcpSectionView.tsx +1 -1
- package/src/settings/EnvironmentGitRowView.tsx +156 -0
- package/src/settings/EnvironmentSettingsView.tsx +25 -3
- package/src/settings/GeneralSettingsView.tsx +18 -24
- package/src/settings/ImChannelGuideDialogView.tsx +2 -2
- package/src/settings/ImFeishuDialogView.tsx +1 -1
- package/src/settings/ImLegacyImportBannerView.tsx +1 -1
- package/src/settings/ImLogDrawerView.tsx +2 -1
- package/src/settings/JsonConfigInputView.tsx +171 -0
- package/src/settings/LauncherSettingsView.test.tsx +95 -0
- package/src/settings/LauncherSettingsView.tsx +273 -0
- package/src/settings/ModelsFetchedModelsDrawerView.tsx +292 -0
- package/src/settings/ModelsProvidersSectionView.tsx +26 -23
- package/src/settings/MotionSelect.tsx +9 -7
- package/src/settings/NotificationSettingsView.tsx +79 -0
- package/src/settings/PermissionsSettingsView.tsx +3 -7
- package/src/settings/PetActionGalleryView.test.tsx +163 -0
- package/src/settings/PetActionGalleryView.tsx +216 -0
- package/src/settings/PetSettingsView.test.tsx +117 -0
- package/src/settings/PetSettingsView.tsx +86 -22
- package/src/settings/PresetProviderModelsListView.tsx +141 -24
- package/src/settings/PresetProviderRowView.tsx +147 -185
- package/src/settings/ProxySettingsSectionView.tsx +182 -0
- package/src/settings/QrBindDialogView.tsx +1 -1
- package/src/settings/RemoteMcpSectionView.tsx +1 -1
- package/src/settings/SettingChrome.tsx +2 -2
- package/src/settings/SettingsAiAssistButtonView.tsx +9 -119
- package/src/settings/SettingsFormFields.tsx +4 -7
- package/src/settings/SettingsSidebarView.tsx +64 -3
- package/src/settings/ShortcutRecorderView.test.tsx +108 -0
- package/src/settings/ShortcutRecorderView.tsx +15 -9
- package/src/settings/ShortcutsSettingsView.tsx +1 -5
- package/src/settings/SpaceEditorDialogView.tsx +158 -0
- package/src/settings/SpacesSettingsView.tsx +150 -0
- package/src/settings/WebhookEndpointListView.tsx +4 -5
- package/src/settings/assets/space-editor-illustration.webp +0 -0
- package/src/settings/index.ts +59 -68
- package/src/shared/ActivityStatusDot.tsx +69 -0
- package/src/shared/AvatarStackView.tsx +13 -13
- package/src/shared/BotAvatar.tsx +11 -9
- package/src/shared/CodeBlockCopyButton.tsx +1 -1
- package/src/shared/ContextMenuView.tsx +4 -11
- package/src/shared/MarkdownTable.tsx +2 -2
- package/src/shared/SegmentedControl.test.tsx +68 -0
- package/src/shared/SegmentedControl.tsx +10 -2
- package/src/shared/SyntaxHighlightedCode.tsx +0 -0
- package/src/shared/TabBar.outline.test.tsx +59 -0
- package/src/shared/TabBar.tsx +23 -18
- package/src/shared/VettaKbd.test.tsx +52 -0
- package/src/shared/VettaKbd.tsx +100 -0
- package/src/shared/connected-tab-outline.test.ts +2 -2
- package/src/shared/connected-tab-outline.ts +2 -1
- package/src/shared/index.ts +7 -0
- package/src/shared/kbd-keys.test.ts +61 -0
- package/src/shared/kbd-keys.ts +253 -0
- package/src/shared/platform.ts +9 -0
- package/src/shared/provider-icon/icons.ts +4 -2
- package/src/shared/provider-icon/index.tsx +1 -1
- package/src/shared/provider-icon/magpie.svg +1 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +33 -24
- package/src/sidebar/DefaultSidebar.tsx +3 -1
- package/src/sidebar/MessageCenterDialogView.tsx +3 -2
- package/src/sidebar/MessageCenterEmptyState.tsx +1 -1
- package/src/sidebar/MessageCenterTabs.tsx +1 -1
- package/src/sidebar/MessageCenterToolbarButton.tsx +1 -1
- package/src/sidebar/MessageCenterTriggerView.tsx +2 -2
- package/src/sidebar/ProjectsPanelEmptyState.tsx +26 -7
- package/src/sidebar/SessionStatusIcon.tsx +16 -1
- package/src/sidebar/SettingsMenuThemeSection.tsx +1 -1
- package/src/sidebar/SettingsMenuTriggerView.test.tsx +42 -0
- package/src/sidebar/SettingsMenuTriggerView.tsx +29 -50
- package/src/sidebar/ShowMoreSessionsButton.tsx +1 -1
- package/src/sidebar/SidebarFilterSelectView.tsx +8 -16
- package/src/sidebar/SidebarNavBadgeView.tsx +1 -1
- package/src/sidebar/SidebarNavIcon.tsx +1 -1
- package/src/sidebar/SidebarNavItemButton.tsx +1 -1
- package/src/sidebar/SidebarNavMorePanel.tsx +19 -7
- package/src/sidebar/SidebarNavigation.tsx +24 -15
- package/src/sidebar/SidebarPanel.tsx +11 -2
- package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
- package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
- package/src/sidebar/SidebarSectionTriggerLabel.tsx +20 -0
- package/src/sidebar/SidebarTopBar.tsx +10 -7
- package/src/sidebar/WaitingPulseBadge.tsx +19 -0
- package/src/sidebar/index.ts +1 -16
- package/src/skills/index.ts +0 -19
- package/src/skills/skill-icon.tsx +4 -8
- package/src/styles.css +26 -6
- package/src/chat/DefaultSceneCarousel.tsx +0 -113
- package/src/chat/SceneCard.tsx +0 -138
- package/src/scheduler/HistoryDrawerView.tsx +0 -149
- package/src/scheduler/TaskFormDialogView.tsx +0 -60
- package/src/settings/AchievementNavigationButtonView.tsx +0 -90
- package/src/settings/AchievementPromotionDialogView.tsx +0 -91
- package/src/settings/AchievementSettingsView.tsx +0 -44
- package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -66
- package/src/settings/SubscriptionActionsView.tsx +0 -63
- package/src/settings/SubscriptionCardsView.tsx +0 -212
- package/src/settings/TeamDetailView.tsx +0 -148
- package/src/settings/TeamDialogsView.tsx +0 -151
- package/src/settings/TeamListView.tsx +0 -57
- package/src/settings/TeamSettingsView.tsx +0 -51
- package/src/settings/TokenActivityChartView.tsx +0 -286
- package/src/settings/UsageStatsView.tsx +0 -101
- package/src/settings/achievements/AchievementCurtains.tsx +0 -50
- package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
- package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
- package/src/settings/achievements/AchievementTitle.tsx +0 -52
- package/src/settings/achievements/index.ts +0 -13
- package/src/settings/shouldCloseEmptyApiKeyEditor.test.ts +0 -135
- package/src/settings/shouldCloseEmptyApiKeyEditor.ts +0 -40
- package/src/settings/token-activity.test.ts +0 -195
- package/src/settings/token-activity.ts +0 -320
- package/src/sidebar/AddProjectMenuItem.tsx +0 -21
- package/src/sidebar/AddProjectMenuPopoverView.tsx +0 -52
- package/src/sidebar/NotificationMessageListView.tsx +0 -136
- package/src/sidebar/SettingsMenuAccountSection.tsx +0 -32
- package/src/sidebar/SettingsMenuQuotaSection.tsx +0 -45
- package/src/skills/SceneCardView.tsx +0 -194
- package/src/skills/SkillCardView.tsx +0 -186
- package/src/skills/SkillDetailDialogView.tsx +0 -138
- package/src/skills/SkillTagGroupView.tsx +0 -56
- package/src/skills/SkillToggleSwitch.tsx +0 -31
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { JSX } from "react";
|
|
2
|
-
import { formatTokenCount } from "./token-activity";
|
|
3
|
-
|
|
4
|
-
function cn(...parts: Array<string | false | null | undefined>): string {
|
|
5
|
-
return parts.filter(Boolean).join(" ");
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type UsageStatsRange = "7d" | "30d" | "all";
|
|
9
|
-
|
|
10
|
-
export const USAGE_STATS_RANGES: UsageStatsRange[] = ["7d", "30d", "all"];
|
|
11
|
-
|
|
12
|
-
/** 可按区间下钻的指标:单位跟在数值后,卡片下方只留区间切换。 */
|
|
13
|
-
export interface UsageStatsMetric {
|
|
14
|
-
onRangeChange: (range: UsageStatsRange) => void;
|
|
15
|
-
range: UsageStatsRange;
|
|
16
|
-
total: number;
|
|
17
|
-
unit: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface UsageStatsViewProps {
|
|
21
|
-
loading?: boolean;
|
|
22
|
-
requests: UsageStatsMetric;
|
|
23
|
-
/** 连续使用天数与区间无关。 */
|
|
24
|
-
streakDays: number;
|
|
25
|
-
tokens: UsageStatsMetric;
|
|
26
|
-
labels: {
|
|
27
|
-
days: (count: number) => string;
|
|
28
|
-
range: (range: UsageStatsRange) => string;
|
|
29
|
-
streak: string;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function StatTile({
|
|
34
|
-
children,
|
|
35
|
-
unit,
|
|
36
|
-
value,
|
|
37
|
-
}: {
|
|
38
|
-
children: JSX.Element;
|
|
39
|
-
unit?: string;
|
|
40
|
-
value: string;
|
|
41
|
-
}): JSX.Element {
|
|
42
|
-
return (
|
|
43
|
-
<div className="min-w-0 rounded-lg border border-border/50 bg-background/40 px-3 py-2.5 text-center">
|
|
44
|
-
<div className="truncate text-[18px] font-semibold tabular-nums text-foreground">
|
|
45
|
-
{value}
|
|
46
|
-
{unit && <span className="ml-1 text-[11px] font-normal text-muted-foreground">{unit}</span>}
|
|
47
|
-
</div>
|
|
48
|
-
<div className="mt-1 flex items-center justify-center gap-2 text-[10px]">{children}</div>
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function MetricTile({
|
|
54
|
-
metric,
|
|
55
|
-
rangeLabel,
|
|
56
|
-
}: {
|
|
57
|
-
metric: UsageStatsMetric;
|
|
58
|
-
rangeLabel: (range: UsageStatsRange) => string;
|
|
59
|
-
}): JSX.Element {
|
|
60
|
-
return (
|
|
61
|
-
<StatTile unit={metric.unit} value={formatTokenCount(metric.total)}>
|
|
62
|
-
<>
|
|
63
|
-
{USAGE_STATS_RANGES.map((item) => (
|
|
64
|
-
<button
|
|
65
|
-
key={item}
|
|
66
|
-
type="button"
|
|
67
|
-
onClick={() => metric.onRangeChange(item)}
|
|
68
|
-
className={cn(
|
|
69
|
-
"whitespace-nowrap transition-colors",
|
|
70
|
-
metric.range === item
|
|
71
|
-
? "font-medium text-primary"
|
|
72
|
-
: "text-muted-foreground/60 hover:text-foreground",
|
|
73
|
-
)}
|
|
74
|
-
>
|
|
75
|
-
{rangeLabel(item)}
|
|
76
|
-
</button>
|
|
77
|
-
))}
|
|
78
|
-
</>
|
|
79
|
-
</StatTile>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function UsageStatsView({
|
|
84
|
-
loading,
|
|
85
|
-
requests,
|
|
86
|
-
streakDays,
|
|
87
|
-
tokens,
|
|
88
|
-
labels,
|
|
89
|
-
}: UsageStatsViewProps): JSX.Element {
|
|
90
|
-
if (loading) return <div className="h-[70px] animate-pulse rounded-lg bg-muted/40" />;
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<div className="grid grid-cols-3 gap-3">
|
|
94
|
-
<MetricTile metric={tokens} rangeLabel={labels.range} />
|
|
95
|
-
<MetricTile metric={requests} rangeLabel={labels.range} />
|
|
96
|
-
<StatTile value={labels.days(streakDays)}>
|
|
97
|
-
<span className="text-muted-foreground">{labels.streak}</span>
|
|
98
|
-
</StatTile>
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties, JSX } from "react";
|
|
2
|
-
|
|
3
|
-
export interface AchievementCurtainSideLayout {
|
|
4
|
-
top: number;
|
|
5
|
-
left?: number;
|
|
6
|
-
right?: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface AchievementCurtainsLayout {
|
|
10
|
-
height: number;
|
|
11
|
-
aspectRatio: string;
|
|
12
|
-
left: AchievementCurtainSideLayout;
|
|
13
|
-
right: AchievementCurtainSideLayout;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface AchievementCurtainsAssets {
|
|
17
|
-
left: string;
|
|
18
|
-
right: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface AchievementCurtainsProps {
|
|
22
|
-
layout: AchievementCurtainsLayout;
|
|
23
|
-
assets: AchievementCurtainsAssets;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function AchievementCurtains({ layout, assets }: AchievementCurtainsProps): JSX.Element {
|
|
27
|
-
const leftStyle: CSSProperties = {
|
|
28
|
-
...layout.left,
|
|
29
|
-
height: layout.height,
|
|
30
|
-
aspectRatio: layout.aspectRatio,
|
|
31
|
-
backgroundImage: `url("${assets.left}")`,
|
|
32
|
-
backgroundPosition: "center",
|
|
33
|
-
backgroundSize: "contain",
|
|
34
|
-
};
|
|
35
|
-
const rightStyle: CSSProperties = {
|
|
36
|
-
...layout.right,
|
|
37
|
-
height: layout.height,
|
|
38
|
-
aspectRatio: layout.aspectRatio,
|
|
39
|
-
backgroundImage: `url("${assets.right}")`,
|
|
40
|
-
backgroundPosition: "center",
|
|
41
|
-
backgroundSize: "contain",
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<div aria-hidden="true" className="pointer-events-none absolute inset-0 z-20 select-none">
|
|
46
|
-
<span className="absolute bg-no-repeat" style={leftStyle} />
|
|
47
|
-
<span className="absolute bg-no-repeat" style={rightStyle} />
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
import type { JSX } from "react";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
import { useReducedMotion } from "motion/react";
|
|
4
|
-
import {
|
|
5
|
-
AmbientLight,
|
|
6
|
-
CanvasTexture,
|
|
7
|
-
Color,
|
|
8
|
-
DirectionalLight,
|
|
9
|
-
DoubleSide,
|
|
10
|
-
ExtrudeGeometry,
|
|
11
|
-
Group,
|
|
12
|
-
LinearFilter,
|
|
13
|
-
Mesh,
|
|
14
|
-
MeshBasicMaterial,
|
|
15
|
-
MeshPhysicalMaterial,
|
|
16
|
-
PerspectiveCamera,
|
|
17
|
-
PlaneGeometry,
|
|
18
|
-
Scene,
|
|
19
|
-
Shape,
|
|
20
|
-
SRGBColorSpace,
|
|
21
|
-
Texture,
|
|
22
|
-
TextureLoader,
|
|
23
|
-
Vector2,
|
|
24
|
-
WebGLRenderer,
|
|
25
|
-
} from "three";
|
|
26
|
-
|
|
27
|
-
export interface AchievementPromotionBadge3DProps {
|
|
28
|
-
imageUrl: string;
|
|
29
|
-
onCelebrate: () => void;
|
|
30
|
-
onComplete: () => void;
|
|
31
|
-
onHideText: () => void;
|
|
32
|
-
onRevealText: () => void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const ANIMATION_DURATION_MS = 4300;
|
|
36
|
-
const BADGE_RENDER_SCALE = 0.6;
|
|
37
|
-
const BADGE_WIDTH = 2.35;
|
|
38
|
-
const BADGE_DEPTH = 0.22;
|
|
39
|
-
const OUTLINE_RESOLUTION = 512;
|
|
40
|
-
const OUTLINE_POINT_COUNT = 384;
|
|
41
|
-
|
|
42
|
-
function easeOutCubic(value: number): number {
|
|
43
|
-
return 1 - (1 - value) ** 3;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function interpolateKeyframes(
|
|
47
|
-
progress: number,
|
|
48
|
-
times: readonly number[],
|
|
49
|
-
values: readonly number[],
|
|
50
|
-
): number {
|
|
51
|
-
const lastIndex = times.length - 1;
|
|
52
|
-
if (progress <= times[0]) return values[0];
|
|
53
|
-
if (progress >= times[lastIndex]) return values[lastIndex];
|
|
54
|
-
|
|
55
|
-
for (let index = 1; index <= lastIndex; index += 1) {
|
|
56
|
-
if (progress > times[index]) continue;
|
|
57
|
-
const segmentProgress = (progress - times[index - 1]) / (times[index] - times[index - 1]);
|
|
58
|
-
return values[index - 1] + (values[index] - values[index - 1]) * segmentProgress;
|
|
59
|
-
}
|
|
60
|
-
return values[lastIndex];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function createFallbackTexture(): CanvasTexture {
|
|
64
|
-
const canvas = document.createElement("canvas");
|
|
65
|
-
canvas.width = 2;
|
|
66
|
-
canvas.height = 2;
|
|
67
|
-
const context = canvas.getContext("2d");
|
|
68
|
-
if (context) {
|
|
69
|
-
context.fillStyle = "#b9893f";
|
|
70
|
-
context.fillRect(0, 0, 2, 2);
|
|
71
|
-
}
|
|
72
|
-
return new CanvasTexture(canvas);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function smoothClosedOutline(points: readonly Vector2[]): Vector2[] {
|
|
76
|
-
let smoothed = points.map((point) => point.clone());
|
|
77
|
-
for (let pass = 0; pass < 4; pass += 1) {
|
|
78
|
-
smoothed = smoothed.map((point, index, allPoints) => {
|
|
79
|
-
const previous = allPoints[(index - 1 + allPoints.length) % allPoints.length];
|
|
80
|
-
const next = allPoints[(index + 1) % allPoints.length];
|
|
81
|
-
return new Vector2(
|
|
82
|
-
previous.x * 0.25 + point.x * 0.5 + next.x * 0.25,
|
|
83
|
-
previous.y * 0.25 + point.y * 0.5 + next.y * 0.25,
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
return smoothed;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function createBadgeShape(image: HTMLImageElement): Shape {
|
|
91
|
-
const canvas = document.createElement("canvas");
|
|
92
|
-
canvas.width = OUTLINE_RESOLUTION;
|
|
93
|
-
canvas.height = OUTLINE_RESOLUTION;
|
|
94
|
-
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
95
|
-
const aspectRatio = image.naturalWidth / image.naturalHeight;
|
|
96
|
-
const drawWidth = aspectRatio >= 1
|
|
97
|
-
? OUTLINE_RESOLUTION
|
|
98
|
-
: OUTLINE_RESOLUTION * aspectRatio;
|
|
99
|
-
const drawHeight = aspectRatio >= 1
|
|
100
|
-
? OUTLINE_RESOLUTION / aspectRatio
|
|
101
|
-
: OUTLINE_RESOLUTION;
|
|
102
|
-
const drawX = (OUTLINE_RESOLUTION - drawWidth) / 2;
|
|
103
|
-
const drawY = (OUTLINE_RESOLUTION - drawHeight) / 2;
|
|
104
|
-
context?.drawImage(image, drawX, drawY, drawWidth, drawHeight);
|
|
105
|
-
const pixels = context?.getImageData(0, 0, OUTLINE_RESOLUTION, OUTLINE_RESOLUTION).data;
|
|
106
|
-
const center = OUTLINE_RESOLUTION / 2;
|
|
107
|
-
const maxRadius = Math.SQRT2 * center;
|
|
108
|
-
const badgeHeight = BADGE_WIDTH / aspectRatio;
|
|
109
|
-
const points: Vector2[] = [];
|
|
110
|
-
|
|
111
|
-
if (pixels) {
|
|
112
|
-
for (let step = 0; step < OUTLINE_POINT_COUNT; step += 1) {
|
|
113
|
-
const angle = (step / OUTLINE_POINT_COUNT) * Math.PI * 2;
|
|
114
|
-
for (let radius = maxRadius; radius >= 0; radius -= 1) {
|
|
115
|
-
const pixelX = Math.round(center + Math.cos(angle) * radius);
|
|
116
|
-
const pixelY = Math.round(center - Math.sin(angle) * radius);
|
|
117
|
-
if (
|
|
118
|
-
pixelX < 0
|
|
119
|
-
|| pixelX >= OUTLINE_RESOLUTION
|
|
120
|
-
|| pixelY < 0
|
|
121
|
-
|| pixelY >= OUTLINE_RESOLUTION
|
|
122
|
-
) {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
const alpha = pixels[(pixelY * OUTLINE_RESOLUTION + pixelX) * 4 + 3];
|
|
126
|
-
if (alpha < 64) continue;
|
|
127
|
-
points.push(new Vector2(
|
|
128
|
-
(pixelX / OUTLINE_RESOLUTION - 0.5) * BADGE_WIDTH,
|
|
129
|
-
(0.5 - pixelY / OUTLINE_RESOLUTION) * badgeHeight,
|
|
130
|
-
));
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (points.length >= 24) return new Shape(smoothClosedOutline(points));
|
|
137
|
-
const fallback = new Shape();
|
|
138
|
-
fallback.absellipse(0, 0, BADGE_WIDTH / 2, badgeHeight / 2, 0, Math.PI * 2);
|
|
139
|
-
return fallback;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function createBadgeGeometry(shape: Shape): ExtrudeGeometry {
|
|
143
|
-
const geometry = new ExtrudeGeometry(shape, {
|
|
144
|
-
bevelEnabled: true,
|
|
145
|
-
bevelSegments: 6,
|
|
146
|
-
bevelSize: 0.025,
|
|
147
|
-
bevelThickness: 0.035,
|
|
148
|
-
curveSegments: 4,
|
|
149
|
-
depth: BADGE_DEPTH,
|
|
150
|
-
});
|
|
151
|
-
geometry.translate(0, 0, -BADGE_DEPTH / 2);
|
|
152
|
-
return geometry;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function AchievementPromotionBadge3D({
|
|
156
|
-
imageUrl,
|
|
157
|
-
onCelebrate,
|
|
158
|
-
onComplete,
|
|
159
|
-
onHideText,
|
|
160
|
-
onRevealText,
|
|
161
|
-
}: AchievementPromotionBadge3DProps): JSX.Element {
|
|
162
|
-
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
163
|
-
const reduceMotion = useReducedMotion();
|
|
164
|
-
|
|
165
|
-
useEffect(() => {
|
|
166
|
-
const canvas = canvasRef.current;
|
|
167
|
-
if (!canvas) return;
|
|
168
|
-
|
|
169
|
-
const renderer = new WebGLRenderer({
|
|
170
|
-
alpha: true,
|
|
171
|
-
antialias: true,
|
|
172
|
-
canvas,
|
|
173
|
-
powerPreference: "high-performance",
|
|
174
|
-
});
|
|
175
|
-
renderer.setClearColor(0x000000, 0);
|
|
176
|
-
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
177
|
-
renderer.outputColorSpace = SRGBColorSpace;
|
|
178
|
-
|
|
179
|
-
const scene = new Scene();
|
|
180
|
-
const camera = new PerspectiveCamera(34, 1, 0.1, 100);
|
|
181
|
-
camera.position.set(0, 0.15, 7);
|
|
182
|
-
|
|
183
|
-
scene.add(new AmbientLight(0xffffff, 2.1));
|
|
184
|
-
const keyLight = new DirectionalLight(0xffe0a3, 4.8);
|
|
185
|
-
keyLight.position.set(3, 4, 6);
|
|
186
|
-
scene.add(keyLight);
|
|
187
|
-
const rimLight = new DirectionalLight(0xc1472d, 3.2);
|
|
188
|
-
rimLight.position.set(-4, 1, -3);
|
|
189
|
-
scene.add(rimLight);
|
|
190
|
-
|
|
191
|
-
const badge = new Group();
|
|
192
|
-
badge.scale.setScalar(BADGE_RENDER_SCALE);
|
|
193
|
-
scene.add(badge);
|
|
194
|
-
|
|
195
|
-
const fallbackShape = new Shape();
|
|
196
|
-
fallbackShape.absellipse(0, 0, 1.08, 1, 0, Math.PI * 2);
|
|
197
|
-
let edgeGeometry = createBadgeGeometry(fallbackShape);
|
|
198
|
-
const edgeMaterial = new MeshPhysicalMaterial({
|
|
199
|
-
color: new Color("#c58a32"),
|
|
200
|
-
metalness: 0.86,
|
|
201
|
-
roughness: 0.22,
|
|
202
|
-
clearcoat: 0.78,
|
|
203
|
-
clearcoatRoughness: 0.16,
|
|
204
|
-
transparent: true,
|
|
205
|
-
});
|
|
206
|
-
const edge = new Mesh(edgeGeometry, edgeMaterial);
|
|
207
|
-
badge.add(edge);
|
|
208
|
-
|
|
209
|
-
const faceGeometry = new PlaneGeometry(1, 1);
|
|
210
|
-
const texture = createFallbackTexture();
|
|
211
|
-
texture.colorSpace = SRGBColorSpace;
|
|
212
|
-
texture.minFilter = LinearFilter;
|
|
213
|
-
texture.magFilter = LinearFilter;
|
|
214
|
-
const faceMaterial = new MeshBasicMaterial({
|
|
215
|
-
alphaTest: 0.02,
|
|
216
|
-
map: texture,
|
|
217
|
-
side: DoubleSide,
|
|
218
|
-
toneMapped: false,
|
|
219
|
-
transparent: true,
|
|
220
|
-
});
|
|
221
|
-
const front = new Mesh(faceGeometry, faceMaterial);
|
|
222
|
-
front.position.z = BADGE_DEPTH / 2 + 0.04;
|
|
223
|
-
front.scale.set(BADGE_WIDTH, 2.16, 1);
|
|
224
|
-
badge.add(front);
|
|
225
|
-
|
|
226
|
-
const back = new Mesh(faceGeometry, faceMaterial);
|
|
227
|
-
back.position.z = -(BADGE_DEPTH / 2 + 0.04);
|
|
228
|
-
back.rotation.y = Math.PI;
|
|
229
|
-
back.scale.copy(front.scale);
|
|
230
|
-
badge.add(back);
|
|
231
|
-
|
|
232
|
-
let active = true;
|
|
233
|
-
const loadedTexture = new TextureLoader().load(imageUrl, (nextTexture: Texture) => {
|
|
234
|
-
if (!active) {
|
|
235
|
-
nextTexture.dispose();
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
nextTexture.colorSpace = SRGBColorSpace;
|
|
239
|
-
nextTexture.minFilter = LinearFilter;
|
|
240
|
-
nextTexture.magFilter = LinearFilter;
|
|
241
|
-
faceMaterial.map = nextTexture;
|
|
242
|
-
faceMaterial.needsUpdate = true;
|
|
243
|
-
const image = nextTexture.image as HTMLImageElement;
|
|
244
|
-
const badgeHeight = BADGE_WIDTH * image.naturalHeight / image.naturalWidth;
|
|
245
|
-
front.scale.set(BADGE_WIDTH, badgeHeight, 1);
|
|
246
|
-
back.scale.copy(front.scale);
|
|
247
|
-
const nextGeometry = createBadgeGeometry(createBadgeShape(image));
|
|
248
|
-
edge.geometry = nextGeometry;
|
|
249
|
-
edgeGeometry.dispose();
|
|
250
|
-
edgeGeometry = nextGeometry;
|
|
251
|
-
texture.dispose();
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
const resizeObserver = new ResizeObserver(([entry]) => {
|
|
255
|
-
const width = Math.max(1, entry.contentRect.width);
|
|
256
|
-
const height = Math.max(1, entry.contentRect.height);
|
|
257
|
-
renderer.setSize(width, height, false);
|
|
258
|
-
camera.aspect = width / height;
|
|
259
|
-
camera.updateProjectionMatrix();
|
|
260
|
-
});
|
|
261
|
-
resizeObserver.observe(canvas);
|
|
262
|
-
|
|
263
|
-
let animationFrame = 0;
|
|
264
|
-
let celebrated = false;
|
|
265
|
-
let completed = false;
|
|
266
|
-
let textHidden = false;
|
|
267
|
-
let textRevealed = false;
|
|
268
|
-
const startTime = performance.now();
|
|
269
|
-
const materials = [edgeMaterial, faceMaterial];
|
|
270
|
-
|
|
271
|
-
const renderFrame = (time: number) => {
|
|
272
|
-
const elapsed = time - startTime;
|
|
273
|
-
const progress = Math.min(elapsed / ANIMATION_DURATION_MS, 1);
|
|
274
|
-
if (!celebrated && progress >= 0.28) {
|
|
275
|
-
celebrated = true;
|
|
276
|
-
onCelebrate();
|
|
277
|
-
}
|
|
278
|
-
if (!textRevealed && progress >= 0.52) {
|
|
279
|
-
textRevealed = true;
|
|
280
|
-
onRevealText();
|
|
281
|
-
}
|
|
282
|
-
if (textRevealed && !textHidden && progress >= 0.78) {
|
|
283
|
-
textHidden = true;
|
|
284
|
-
onHideText();
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
if (reduceMotion) {
|
|
288
|
-
badge.position.y = 0.18;
|
|
289
|
-
badge.rotation.set(0, 0, 0);
|
|
290
|
-
badge.scale.setScalar(BADGE_RENDER_SCALE);
|
|
291
|
-
} else {
|
|
292
|
-
badge.position.y = interpolateKeyframes(
|
|
293
|
-
progress,
|
|
294
|
-
[0, 0.1, 0.25, 0.36, 0.44, 0.53, 1],
|
|
295
|
-
[-1.48, -1.48, 0.86, 0.02, 0.31, 0.18, 0.18],
|
|
296
|
-
);
|
|
297
|
-
const stretch = interpolateKeyframes(
|
|
298
|
-
progress,
|
|
299
|
-
[0, 0.1, 0.2, 0.28, 0.36, 0.44, 0.53, 1],
|
|
300
|
-
[0.68, 0.68, 1.34, 1.12, 0.88, 1.08, 1, 1],
|
|
301
|
-
);
|
|
302
|
-
badge.scale.set(
|
|
303
|
-
(2 - stretch) * BADGE_RENDER_SCALE,
|
|
304
|
-
stretch * BADGE_RENDER_SCALE,
|
|
305
|
-
BADGE_RENDER_SCALE,
|
|
306
|
-
);
|
|
307
|
-
const rotationProgress = easeOutCubic(Math.min(progress / 0.58, 1));
|
|
308
|
-
badge.rotation.y = -0.8 * (1 - rotationProgress) + rotationProgress * Math.PI * 4;
|
|
309
|
-
badge.rotation.x = Math.sin(progress * Math.PI * 5) * (1 - rotationProgress) * 0.38;
|
|
310
|
-
badge.rotation.z = Math.sin(progress * Math.PI * 3) * (1 - rotationProgress) * 0.16;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const opacity = interpolateKeyframes(
|
|
314
|
-
progress,
|
|
315
|
-
[0, 0.09, 0.14, 0.78, 1],
|
|
316
|
-
[0, 0, 1, 1, 0],
|
|
317
|
-
);
|
|
318
|
-
for (const material of materials) {
|
|
319
|
-
material.opacity = opacity;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
renderer.render(scene, camera);
|
|
323
|
-
if (progress < 1) {
|
|
324
|
-
animationFrame = requestAnimationFrame(renderFrame);
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
if (!completed) {
|
|
328
|
-
completed = true;
|
|
329
|
-
onComplete();
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
animationFrame = requestAnimationFrame(renderFrame);
|
|
334
|
-
|
|
335
|
-
return () => {
|
|
336
|
-
active = false;
|
|
337
|
-
cancelAnimationFrame(animationFrame);
|
|
338
|
-
resizeObserver.disconnect();
|
|
339
|
-
loadedTexture.dispose();
|
|
340
|
-
texture.dispose();
|
|
341
|
-
edgeGeometry.dispose();
|
|
342
|
-
faceGeometry.dispose();
|
|
343
|
-
edgeMaterial.dispose();
|
|
344
|
-
faceMaterial.dispose();
|
|
345
|
-
renderer.dispose();
|
|
346
|
-
};
|
|
347
|
-
}, [imageUrl, onCelebrate, onComplete, onHideText, onRevealText, reduceMotion]);
|
|
348
|
-
|
|
349
|
-
return <canvas ref={canvasRef} className="h-full w-full" aria-hidden="true" />;
|
|
350
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, type JSX } from "react";
|
|
2
|
-
import confetti from "canvas-confetti";
|
|
3
|
-
|
|
4
|
-
export interface AchievementPromotionConfettiProps {
|
|
5
|
-
triggerToken: number;
|
|
6
|
-
colors?: readonly string[];
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const DEFAULT_COLORS = ["#f4d58a", "#d79a3b", "#b91c1c", "#f5e6c8"];
|
|
10
|
-
|
|
11
|
-
export function AchievementPromotionConfetti({
|
|
12
|
-
triggerToken,
|
|
13
|
-
colors = DEFAULT_COLORS,
|
|
14
|
-
}: AchievementPromotionConfettiProps): JSX.Element {
|
|
15
|
-
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
16
|
-
const confettiRef = useRef<ReturnType<typeof confetti.create> | null>(null);
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
const canvas = canvasRef.current;
|
|
20
|
-
if (!canvas) return;
|
|
21
|
-
const instance = confetti.create(canvas, {
|
|
22
|
-
disableForReducedMotion: true,
|
|
23
|
-
resize: true,
|
|
24
|
-
useWorker: false,
|
|
25
|
-
});
|
|
26
|
-
confettiRef.current = instance;
|
|
27
|
-
return () => {
|
|
28
|
-
instance.reset();
|
|
29
|
-
confettiRef.current = null;
|
|
30
|
-
};
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (triggerToken === 0) return;
|
|
35
|
-
const instance = confettiRef.current;
|
|
36
|
-
if (!instance) return;
|
|
37
|
-
|
|
38
|
-
const sharedOptions: confetti.Options = {
|
|
39
|
-
colors: [...colors],
|
|
40
|
-
decay: 0.94,
|
|
41
|
-
disableForReducedMotion: true,
|
|
42
|
-
gravity: 0.72,
|
|
43
|
-
particleCount: 64,
|
|
44
|
-
scalar: 0.9,
|
|
45
|
-
shapes: ["square"],
|
|
46
|
-
spread: 58,
|
|
47
|
-
startVelocity: 46,
|
|
48
|
-
ticks: 240,
|
|
49
|
-
};
|
|
50
|
-
void instance({
|
|
51
|
-
...sharedOptions,
|
|
52
|
-
angle: 58,
|
|
53
|
-
drift: 0.08,
|
|
54
|
-
origin: { x: 0.16, y: 0.48 },
|
|
55
|
-
});
|
|
56
|
-
void instance({
|
|
57
|
-
...sharedOptions,
|
|
58
|
-
angle: 122,
|
|
59
|
-
drift: -0.08,
|
|
60
|
-
origin: { x: 0.84, y: 0.48 },
|
|
61
|
-
});
|
|
62
|
-
}, [triggerToken, colors]);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<canvas
|
|
66
|
-
ref={canvasRef}
|
|
67
|
-
aria-hidden="true"
|
|
68
|
-
className="pointer-events-none absolute inset-0 h-full w-full"
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { CSSProperties, JSX } from "react";
|
|
2
|
-
|
|
3
|
-
export interface AchievementTitleLayout {
|
|
4
|
-
top: number;
|
|
5
|
-
left: number;
|
|
6
|
-
width: number;
|
|
7
|
-
aspectRatio: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface AchievementTitleProps {
|
|
11
|
-
title: string;
|
|
12
|
-
layout: AchievementTitleLayout;
|
|
13
|
-
titleImageUrl: string;
|
|
14
|
-
titleTextOffsetY: number;
|
|
15
|
-
titleColor?: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function AchievementTitle({
|
|
19
|
-
title,
|
|
20
|
-
layout,
|
|
21
|
-
titleImageUrl,
|
|
22
|
-
titleTextOffsetY,
|
|
23
|
-
titleColor = "#f4d58a",
|
|
24
|
-
}: AchievementTitleProps): JSX.Element {
|
|
25
|
-
const layoutStyle: CSSProperties = {
|
|
26
|
-
top: layout.top,
|
|
27
|
-
left: layout.left,
|
|
28
|
-
width: layout.width,
|
|
29
|
-
aspectRatio: layout.aspectRatio,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div className="relative z-30 mx-auto flex max-w-full items-center justify-center" style={layoutStyle}>
|
|
34
|
-
<img
|
|
35
|
-
aria-hidden="true"
|
|
36
|
-
alt=""
|
|
37
|
-
draggable={false}
|
|
38
|
-
src={titleImageUrl}
|
|
39
|
-
className="pointer-events-none absolute inset-0 h-full w-full select-none object-contain"
|
|
40
|
-
/>
|
|
41
|
-
<h1
|
|
42
|
-
className="relative px-20 pb-1 text-center text-[20px] font-bold"
|
|
43
|
-
style={{
|
|
44
|
-
color: titleColor,
|
|
45
|
-
transform: `translateY(${titleTextOffsetY}px)`,
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
{title}
|
|
49
|
-
</h1>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
AchievementCurtainSideLayout,
|
|
3
|
-
AchievementCurtainsAssets,
|
|
4
|
-
AchievementCurtainsLayout,
|
|
5
|
-
AchievementCurtainsProps,
|
|
6
|
-
} from "./AchievementCurtains";
|
|
7
|
-
export { AchievementCurtains } from "./AchievementCurtains";
|
|
8
|
-
export type { AchievementPromotionBadge3DProps } from "./AchievementPromotionBadge3D";
|
|
9
|
-
export { AchievementPromotionBadge3D } from "./AchievementPromotionBadge3D";
|
|
10
|
-
export type { AchievementPromotionConfettiProps } from "./AchievementPromotionConfetti";
|
|
11
|
-
export { AchievementPromotionConfetti } from "./AchievementPromotionConfetti";
|
|
12
|
-
export type { AchievementTitleLayout, AchievementTitleProps } from "./AchievementTitle";
|
|
13
|
-
export { AchievementTitle } from "./AchievementTitle";
|