@conscience-technology/ovenn 0.6.7 → 0.7.2
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/assets/components/AIMessage/AIMessage.module.css +23 -1
- package/assets/components/AIMessage/AIMessage.tsx +27 -7
- package/assets/components/Accordion/Accordion.module.css +3 -0
- package/assets/components/AppFrame/AppFrame.module.css +2 -0
- package/assets/components/AttachmentItem/AttachmentItem.module.css +50 -13
- package/assets/components/AttachmentItem/AttachmentItem.tsx +25 -8
- package/assets/components/AttachmentThumb/AttachmentThumb.module.css +12 -9
- package/assets/components/Avatar/Avatar.module.css +26 -11
- package/assets/components/Avatar/Avatar.tsx +1 -1
- package/assets/components/AvatarUpload/AvatarUpload.module.css +4 -3
- package/assets/components/Badge/Badge.module.css +96 -70
- package/assets/components/Badge/Badge.tsx +33 -25
- package/assets/components/Breadcrumb/Breadcrumb.module.css +8 -4
- package/assets/components/Breadcrumb/Breadcrumb.tsx +1 -1
- package/assets/components/Bubble/Bubble.module.css +6 -0
- package/assets/components/Button/Button.module.css +6 -0
- package/assets/components/Calendar/Calendar.module.css +244 -0
- package/assets/components/Calendar/Calendar.tsx +419 -0
- package/assets/components/Calendar/index.ts +2 -0
- package/assets/components/Callout/Callout.module.css +54 -7
- package/assets/components/Callout/Callout.tsx +26 -2
- package/assets/components/Callout/index.ts +1 -1
- package/assets/components/Canvas/Canvas.module.css +75 -0
- package/assets/components/Canvas/Canvas.tsx +699 -0
- package/assets/components/Canvas/alignment.ts +34 -0
- package/assets/components/Canvas/clipboard.ts +30 -0
- package/assets/components/Canvas/collision.ts +67 -0
- package/assets/components/Canvas/edgeOptions.ts +11 -0
- package/assets/components/Canvas/graph.ts +11 -0
- package/assets/components/Canvas/history.ts +41 -0
- package/assets/components/Canvas/index.ts +4 -0
- package/assets/components/Canvas/selection.ts +56 -0
- package/assets/components/Canvas/tokens.css +61 -0
- package/assets/components/Canvas/types.ts +27 -0
- package/assets/components/Canvas/useCanvasSettlement.ts +79 -0
- package/assets/components/CanvasEdge/CanvasEdge.module.css +62 -0
- package/assets/components/CanvasEdge/CanvasEdge.tsx +121 -0
- package/assets/components/CanvasEdge/geometry.ts +350 -0
- package/assets/components/CanvasEdge/index.ts +4 -0
- package/assets/components/CanvasEdge/interactions.ts +14 -0
- package/assets/components/CanvasEdge/tokens.css +29 -0
- package/assets/components/CanvasNode/CanvasNode.module.css +234 -30
- package/assets/components/CanvasNode/CanvasNode.tsx +95 -28
- package/assets/components/CanvasNode/index.ts +1 -1
- package/assets/components/CanvasNode/runningOutline.ts +59 -0
- package/assets/components/CanvasNode/tokens.css +76 -13
- package/assets/components/Card/Card.module.css +5 -0
- package/assets/components/Chart/Chart.module.css +278 -0
- package/assets/components/Chart/Chart.tsx +385 -0
- package/assets/components/Chart/entrance.tsx +57 -0
- package/assets/components/Chart/index.ts +14 -0
- package/assets/components/ChatComposer/ChatComposer.module.css +17 -0
- package/assets/components/ChatComposer/ChatComposer.tsx +131 -0
- package/assets/components/ChatComposer/index.ts +2 -0
- package/assets/components/ChatInput/ChatInput.module.css +197 -30
- package/assets/components/ChatInput/ChatInput.tsx +137 -45
- package/assets/components/ChatInput/SendButton.tsx +4 -1
- package/assets/components/ChatInput/index.ts +5 -0
- package/assets/components/ChatMessage/ChatMessage.module.css +19 -0
- package/assets/components/ChatMessage/ChatMessage.tsx +63 -0
- package/assets/components/ChatMessage/index.ts +2 -0
- package/assets/components/ChatReactions/ChatReactions.module.css +15 -0
- package/assets/components/ChatReactions/ChatReactions.tsx +58 -0
- package/assets/components/ChatReactions/index.ts +2 -0
- package/assets/components/Checkbox/Checkbox.module.css +39 -0
- package/assets/components/Checkbox/Checkbox.tsx +99 -14
- package/assets/components/Checkbox/index.ts +1 -1
- package/assets/components/CheckboxCard/CheckboxCard.module.css +1 -177
- package/assets/components/CheckboxCard/CheckboxCard.tsx +6 -72
- package/assets/components/Chip/Chip.module.css +20 -30
- package/assets/components/Code/Code.module.css +1 -0
- package/assets/components/CodeBlock/CodeBlock.module.css +113 -13
- package/assets/components/CodeBlock/CodeBlock.tsx +114 -29
- package/assets/components/CodeBlock/SyntaxHighlight.tsx +20 -0
- package/assets/components/CodeBlock/diff-lines.ts +21 -0
- package/assets/components/CodeBlock/index.ts +2 -1
- package/assets/components/CodeBlock/line-preview.ts +7 -0
- package/assets/components/CodeBlock/syntax-highlighter.ts +96 -0
- package/assets/components/CodeBlock/use-syntax-tokens.ts +17 -0
- package/assets/components/ColorArea/ColorArea.module.css +3 -0
- package/assets/components/ColorField/ColorField.module.css +19 -190
- package/assets/components/ColorField/ColorField.tsx +116 -107
- package/assets/components/ColorPicker/ColorPicker.module.css +310 -0
- package/assets/components/ColorPicker/ColorPicker.tsx +387 -0
- package/assets/components/ColorPicker/index.ts +16 -0
- package/assets/components/ColorSlider/ColorSlider.module.css +15 -12
- package/assets/components/ColorSlider/ColorSlider.tsx +3 -3
- package/assets/components/ColorSwatch/ColorSwatch.module.css +2 -2
- package/assets/components/ColorSwatchPicker/ColorSwatchPicker.module.css +4 -3
- package/assets/components/Combobox/Combobox.module.css +21 -4
- package/assets/components/Combobox/Combobox.tsx +38 -22
- package/assets/components/CommandPalette/CommandPalette.module.css +19 -24
- package/assets/components/CommandPalette/CommandPalette.tsx +7 -5
- package/assets/components/Comment/Comment.module.css +25 -0
- package/assets/components/Comment/Comment.tsx +44 -0
- package/assets/components/Comment/CommentComposer.module.css +26 -0
- package/assets/components/Comment/CommentComposer.tsx +56 -0
- package/assets/components/Comment/CommentEditor.module.css +8 -0
- package/assets/components/Comment/CommentEditor.tsx +43 -0
- package/assets/components/Comment/CommentMentionInput.module.css +9 -0
- package/assets/components/Comment/CommentMentionInput.tsx +150 -0
- package/assets/components/Comment/index.ts +9 -0
- package/assets/components/Comment/types.ts +1 -0
- package/assets/components/ContextMenu/ContextMenu.module.css +5 -2
- package/assets/components/ContextMenu/ContextMenu.tsx +5 -0
- package/assets/components/ControlGroup/ControlGroup.module.css +20 -7
- package/assets/components/DataTable/DataTable.module.css +2 -0
- package/assets/components/DatePicker/DateField.tsx +72 -25
- package/assets/components/DatePicker/DatePicker.module.css +56 -54
- package/assets/components/DatePicker/DatePicker.tsx +86 -40
- package/assets/components/DatePicker/TimeSelector.tsx +1 -1
- package/assets/components/Disclosure/Disclosure.module.css +1 -0
- package/assets/components/Drawer/Drawer.module.css +23 -19
- package/assets/components/Drawer/Drawer.tsx +20 -24
- package/assets/components/DropdownMenu/DropdownMenu.tsx +5 -0
- package/assets/components/EmojiPicker/EmojiGlyph.module.css +2 -0
- package/assets/components/EmojiPicker/EmojiGlyph.tsx +12 -0
- package/assets/components/EmojiPicker/EmojiPicker.module.css +43 -0
- package/assets/components/EmojiPicker/EmojiPicker.tsx +143 -0
- package/assets/components/EmojiPicker/UNICODE-LICENSE.txt +39 -0
- package/assets/components/EmojiPicker/data.ts +41 -0
- package/assets/components/EmojiPicker/emojiData-0.json +1 -0
- package/assets/components/EmojiPicker/emojiData-1.json +1 -0
- package/assets/components/EmojiPicker/emojiData-2.json +1 -0
- package/assets/components/EmojiPicker/emojiData-3.json +1 -0
- package/assets/components/EmojiPicker/emojiData.sources.json +35 -0
- package/assets/components/EmojiPicker/emojiData.ts +8 -0
- package/assets/components/EmojiPicker/emojiFallbacks.json +1 -0
- package/assets/components/EmojiPicker/index.ts +4 -0
- package/assets/components/EmptyState/EmptyState.module.css +2 -2
- package/assets/components/EventChip/EventChip.module.css +120 -53
- package/assets/components/EventChip/EventChip.tsx +54 -6
- package/assets/components/EventChip/index.ts +1 -1
- package/assets/components/EventListItem/EventListItem.module.css +3 -0
- package/assets/components/EventListItem/EventListItem.tsx +15 -8
- package/assets/components/FileIcon/FileIcon.module.css +6 -6
- package/assets/components/FileUpload/FileUpload.module.css +10 -3
- package/assets/components/FileUpload/FileUpload.tsx +5 -9
- package/assets/components/FileUpload/FileUploadItem.tsx +34 -0
- package/assets/components/GalleryItem/GalleryItem.module.css +16 -19
- package/assets/components/GeneratedImage/GeneratedImage.module.css +2 -0
- package/assets/components/Icon/Icon.tsx +264 -1088
- package/assets/components/Icon/LucideFamilyIcon.tsx +436 -0
- package/assets/components/Icon/MissingIcon.tsx +25 -0
- package/assets/components/Icon/SolarFamilyIcon.tsx +443 -0
- package/assets/components/Icon/catalogNames.ts +8 -0
- package/assets/components/Icon/context.tsx +1 -1
- package/assets/components/Icon/index.ts +2 -0
- package/assets/components/Icon/lucideCatalog.ts +11358 -0
- package/assets/components/Icon/phosphorCatalog.ts +3052 -0
- package/assets/components/Icon/solarCatalog.ts +16064 -0
- package/assets/components/IconButton/IconButton.module.css +3 -2
- package/assets/components/Input/Input.module.css +63 -22
- package/assets/components/Input/Input.tsx +21 -10
- package/assets/components/Kanban/Kanban.module.css +6 -0
- package/assets/components/ListItem/ListItem.module.css +9 -6
- package/assets/components/MenuItem/MenuItem.module.css +24 -22
- package/assets/components/MenuItem/MenuItem.tsx +12 -12
- package/assets/components/MessageActions/MessageActions.module.css +38 -2
- package/assets/components/MessageActions/MessageActions.tsx +53 -28
- package/assets/components/MessageQuote/MessageQuote.module.css +1 -0
- package/assets/components/MessageSources/MessageSources.module.css +2 -0
- package/assets/components/MessageState/MessageState.module.css +1 -1
- package/assets/components/MetricCard/MetricCard.module.css +96 -108
- package/assets/components/MetricCard/MetricCard.tsx +45 -23
- package/assets/components/MetricCard/tokens.css +10 -0
- package/assets/components/MiniCalendar/MiniCalendar.module.css +130 -0
- package/assets/components/MiniCalendar/MiniCalendar.tsx +161 -0
- package/assets/components/MiniCalendar/index.ts +2 -0
- package/assets/components/Modal/Modal.module.css +13 -4
- package/assets/components/Modal/Modal.tsx +4 -0
- package/assets/components/Onboarding/LayoutBuilder.tsx +12 -50
- package/assets/components/Onboarding/Onboarding.module.css +211 -278
- package/assets/components/Onboarding/OnboardingAxisPanel.tsx +81 -125
- package/assets/components/Onboarding/OnboardingPage.tsx +244 -467
- package/assets/components/Onboarding/actions.ts +5 -0
- package/assets/components/Onboarding/palette.css +8 -0
- package/assets/components/Onboarding/wizardData.ts +8 -8
- package/assets/components/ProgressBar/ProgressBar.module.css +42 -8
- package/assets/components/ProgressBar/ProgressBar.tsx +5 -6
- package/assets/components/ProgressBar/index.ts +0 -1
- package/assets/components/QuotationBar/QuotationBar.module.css +2 -0
- package/assets/components/Radio/Radio.module.css +2 -0
- package/assets/components/RadioCard/RadioCard.module.css +96 -3
- package/assets/components/RadioCard/RadioCard.tsx +76 -13
- package/assets/components/RadioCard/index.ts +1 -1
- package/assets/components/SegmentedChart/SegmentedChart.module.css +16 -0
- package/assets/components/SegmentedChart/SegmentedChart.tsx +25 -8
- package/assets/components/Select/Select.module.css +9 -7
- package/assets/components/Select/Select.tsx +22 -6
- package/assets/components/Shortcut/Shortcut.module.css +2 -0
- package/assets/components/Sidebar/Sidebar.module.css +1 -0
- package/assets/components/Sidebar/Sidebar.tsx +2 -2
- package/assets/components/Skeleton/Skeleton.module.css +33 -0
- package/assets/components/Skeleton/Skeleton.tsx +20 -0
- package/assets/components/Skeleton/index.ts +2 -0
- package/assets/components/Skeleton/tokens.css +11 -0
- package/assets/components/Slider/Slider.module.css +3 -0
- package/assets/components/Slider/Slider.tsx +7 -2
- package/assets/components/Spinner/LottiePlayer.tsx +4 -4
- package/assets/components/Spinner/Spinner.module.css +3 -0
- package/assets/components/Spinner/lottieManifest.ts +3 -0
- package/assets/components/Stepper/Stepper.module.css +56 -8
- package/assets/components/Stepper/Stepper.tsx +13 -4
- package/assets/components/Switch/Switch.module.css +55 -42
- package/assets/components/Switch/Switch.tsx +6 -2
- package/assets/components/Switch/index.ts +1 -1
- package/assets/components/TabStrip/TabStrip.module.css +5 -1
- package/assets/components/TableCell/TableCell.module.css +8 -1
- package/assets/components/TableCell/TableCellBadge.tsx +7 -3
- package/assets/components/TableCell/TableCellImage.tsx +1 -1
- package/assets/components/TableCell/TableCellTag.tsx +23 -0
- package/assets/components/TableCell/index.ts +3 -0
- package/assets/components/TableHeader/TableHeader.module.css +4 -0
- package/assets/components/TableRow/TableRow.module.css +3 -0
- package/assets/components/TableRowEdit/TableRowEdit.module.css +2 -0
- package/assets/components/TableToolbar/TableToolbar.module.css +1 -0
- package/assets/components/Tabs/Tabs.module.css +23 -8
- package/assets/components/Tabs/Tabs.tsx +4 -3
- package/assets/components/Tag/Tag.module.css +101 -0
- package/assets/components/Tag/Tag.tsx +55 -0
- package/assets/components/Tag/index.ts +2 -0
- package/assets/components/TemplateBoundary/TemplateBoundary.tsx +22 -18
- package/assets/components/TemplateBoundary/types.ts +2 -0
- package/assets/components/Textarea/Textarea.module.css +30 -226
- package/assets/components/Textarea/Textarea.tsx +2 -2
- package/assets/components/ThemeController.tsx +30 -3
- package/assets/components/TimePicker/TimePicker.module.css +17 -4
- package/assets/components/TimePicker/TimePicker.tsx +102 -23
- package/assets/components/TimelineView/TimelineEventBar.tsx +109 -0
- package/assets/components/TimelineView/TimelineView.module.css +203 -0
- package/assets/components/TimelineView/TimelineView.tsx +137 -0
- package/assets/components/TimelineView/axis.ts +62 -0
- package/assets/components/TimelineView/index.ts +3 -0
- package/assets/components/TimelineView/layout.ts +56 -0
- package/assets/components/TimelineView/move.ts +51 -0
- package/assets/components/TimelineView/useTimelineDrag.ts +215 -0
- package/assets/components/TimelineView/useTimelineZoom.ts +92 -0
- package/assets/components/Toast/Toast.module.css +20 -0
- package/assets/components/Toast/Toast.tsx +1 -1
- package/assets/components/Toolbar/Toolbar.module.css +31 -24
- package/assets/components/Toolbar/Toolbar.tsx +4 -3
- package/assets/components/Tooltip/Tooltip.module.css +10 -0
- package/assets/components/Tooltip/Tooltip.tsx +50 -15
- package/assets/components/TopLoader/TopLoader.module.css +1 -0
- package/assets/components/TreeNav/TreeNav.module.css +1 -0
- package/assets/components/UserMessage/UserMessage.module.css +110 -1
- package/assets/components/UserMessage/UserMessage.tsx +138 -16
- package/assets/components/UserMessage/index.ts +4 -0
- package/assets/components/_color.ts +2 -2
- package/assets/components/_data.ts +37 -31
- package/assets/components/_utils.css +36 -5
- package/assets/components/axisOptions.ts +2 -0
- package/assets/components/component-registry.json +1731 -94
- package/assets/components/index.ts +23 -0
- package/assets/components/materialScope.tsx +11 -0
- package/assets/components/reset.css +1 -0
- package/assets/components/themeBootScript.ts +3 -2
- package/assets/components/tokens.css +308 -71
- package/assets/components/useChartEntrance.ts +119 -0
- package/assets/prompts/ASSEMBLY.md +20 -7
- package/assets/prompts/CATALOG.md +110 -92
- package/assets/prompts/FEEDBACK_PROCESS.md +19 -0
- package/assets/prompts/PRINCIPLES.md +25 -1
- package/assets/prompts/TEMPLATE_PREVIEWS.md +21 -0
- package/assets/prompts/WORKFLOW_DESIGN.md +48 -70
- package/assets/prompts/axes/font.md +12 -1
- package/assets/prompts/axes/icon.md +6 -4
- package/assets/prompts/axes/material.md +40 -0
- package/assets/prompts/axes/motion.md +2 -0
- package/assets/prompts/axes/palette.md +10 -2
- package/assets/prompts/axes/shape.md +8 -0
- package/assets/prompts/axes/voice.md +4 -0
- package/assets/prompts/components/README.md +3 -3
- package/assets/prompts/components/_variants.md +35 -35
- package/assets/prompts/components/accordion.md +15 -15
- package/assets/prompts/components/ai-message.md +14 -12
- package/assets/prompts/components/app-frame.md +16 -16
- package/assets/prompts/components/attachment-item.md +38 -31
- package/assets/prompts/components/attachment-thumb.md +14 -12
- package/assets/prompts/components/avatar-upload.md +10 -10
- package/assets/prompts/components/avatar.md +16 -16
- package/assets/prompts/components/badge.md +32 -97
- package/assets/prompts/components/breadcrumb.md +25 -24
- package/assets/prompts/components/bubble.md +13 -13
- package/assets/prompts/components/button-group.md +1 -1
- package/assets/prompts/components/button.md +36 -36
- package/assets/prompts/components/calendar.md +151 -0
- package/assets/prompts/components/callout.md +39 -23
- package/assets/prompts/components/canvas-edge.md +70 -0
- package/assets/prompts/components/canvas-node.md +27 -10
- package/assets/prompts/components/canvas.md +85 -0
- package/assets/prompts/components/card.md +31 -31
- package/assets/prompts/components/chart-bar.md +77 -0
- package/assets/prompts/components/chart-pie.md +63 -0
- package/assets/prompts/components/chart-radar.md +56 -0
- package/assets/prompts/components/chart-radial.md +56 -0
- package/assets/prompts/components/chart.md +129 -0
- package/assets/prompts/components/chat-composer.md +71 -0
- package/assets/prompts/components/chat-input.md +82 -27
- package/assets/prompts/components/chat-message.md +48 -0
- package/assets/prompts/components/chat-reactions.md +38 -0
- package/assets/prompts/components/checkbox-card.md +26 -45
- package/assets/prompts/components/checkbox.md +40 -17
- package/assets/prompts/components/chip.md +34 -34
- package/assets/prompts/components/code-block.md +109 -65
- package/assets/prompts/components/code.md +4 -4
- package/assets/prompts/components/color-area.md +9 -9
- package/assets/prompts/components/color-field.md +17 -13
- package/assets/prompts/components/color-picker.md +173 -0
- package/assets/prompts/components/color-slider.md +14 -14
- package/assets/prompts/components/color-swatch-picker.md +8 -8
- package/assets/prompts/components/color-swatch.md +9 -9
- package/assets/prompts/components/combobox.md +5 -2
- package/assets/prompts/components/command-palette.md +31 -30
- package/assets/prompts/components/comment.md +75 -0
- package/assets/prompts/components/context-menu.md +28 -25
- package/assets/prompts/components/control-group.md +4 -4
- package/assets/prompts/components/data-table.md +9 -0
- package/assets/prompts/components/date-picker.md +41 -23
- package/assets/prompts/components/disclosure.md +10 -10
- package/assets/prompts/components/drawer.md +29 -18
- package/assets/prompts/components/dropdown-menu.md +23 -21
- package/assets/prompts/components/emoji-picker.md +45 -0
- package/assets/prompts/components/empty-state.md +20 -18
- package/assets/prompts/components/event-chip.md +70 -28
- package/assets/prompts/components/event-list-item.md +32 -28
- package/assets/prompts/components/file-icon.md +18 -19
- package/assets/prompts/components/file-upload.md +1 -1
- package/assets/prompts/components/gallery-item.md +24 -23
- package/assets/prompts/components/generated-image.md +10 -10
- package/assets/prompts/components/hint.md +19 -19
- package/assets/prompts/components/icon-button.md +16 -16
- package/assets/prompts/components/icon.md +42 -17
- package/assets/prompts/components/input.md +49 -46
- package/assets/prompts/components/kanban.md +35 -35
- package/assets/prompts/components/list-item.md +50 -41
- package/assets/prompts/components/menu-item.md +49 -44
- package/assets/prompts/components/message-actions.md +15 -6
- package/assets/prompts/components/message-quote.md +7 -7
- package/assets/prompts/components/message-sources.md +10 -10
- package/assets/prompts/components/message-state.md +17 -17
- package/assets/prompts/components/message-table.md +5 -5
- package/assets/prompts/components/metric-card.md +57 -109
- package/assets/prompts/components/mini-calendar.md +77 -0
- package/assets/prompts/components/modal.md +40 -39
- package/assets/prompts/components/multi-select.md +4 -1
- package/assets/prompts/components/onboarding.md +23 -19
- package/assets/prompts/components/page-header.md +42 -33
- package/assets/prompts/components/pagination.md +17 -17
- package/assets/prompts/components/progress-bar.md +26 -13
- package/assets/prompts/components/quotation-bar.md +10 -10
- package/assets/prompts/components/radio-card.md +34 -117
- package/assets/prompts/components/radio.md +9 -9
- package/assets/prompts/components/segmented-chart.md +19 -5
- package/assets/prompts/components/select.md +29 -25
- package/assets/prompts/components/shortcut.md +11 -11
- package/assets/prompts/components/sidebar.md +67 -58
- package/assets/prompts/components/skeleton.md +47 -0
- package/assets/prompts/components/slider.md +18 -18
- package/assets/prompts/components/spinner.md +16 -16
- package/assets/prompts/components/stepper.md +29 -15
- package/assets/prompts/components/switch.md +30 -26
- package/assets/prompts/components/tab-strip.md +32 -31
- package/assets/prompts/components/table-cell.md +9 -7
- package/assets/prompts/components/table-header.md +16 -16
- package/assets/prompts/components/table-row-edit.md +19 -19
- package/assets/prompts/components/table-row-select.md +9 -9
- package/assets/prompts/components/table-row.md +29 -20
- package/assets/prompts/components/table-toolbar.md +9 -0
- package/assets/prompts/components/tabs.md +30 -27
- package/assets/prompts/components/tag.md +54 -0
- package/assets/prompts/components/textarea.md +16 -15
- package/assets/prompts/components/time-picker.md +22 -14
- package/assets/prompts/components/timeline-view.md +129 -0
- package/assets/prompts/components/toast.md +43 -42
- package/assets/prompts/components/toolbar.md +36 -23
- package/assets/prompts/components/tooltip.md +36 -17
- package/assets/prompts/components/top-loader.md +12 -12
- package/assets/prompts/components/topbar.md +43 -34
- package/assets/prompts/components/tree-nav.md +10 -10
- package/assets/prompts/components/user-message.md +23 -12
- package/assets/prompts/design-examples/README.md +1 -1
- package/assets/prompts/design-examples/ai-chat-full-page.png +0 -0
- package/assets/prompts/design-examples/catalog.json +124 -1
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.module.css +346 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.tsx +375 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/FullPageChat.tsx +8 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/REFERENCE.md +19 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useChatDemo.ts +139 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useDemoTextStream.ts +30 -0
- package/assets/prompts/primitives/emerge.md +2 -0
- package/assets/prompts/templates/README.md +1 -1
- package/assets/prompts/templates/ains.md +9 -1
- package/assets/prompts/templates/aurora.md +5 -4
- package/assets/prompts/templates/minimal.md +14 -6
- package/assets/prompts/templates/onboarding.md +156 -0
- package/assets/prompts/templates/workspace.md +16 -11
- package/assets/prompts/tokens/color.md +11 -4
- package/assets/prompts/tokens/material.md +51 -0
- package/assets/prompts/tokens/radius.md +34 -0
- package/assets/prompts/tokens/typography.md +24 -2
- package/assets/prompts/use-cases/chart-chart-area.md +1334 -0
- package/assets/prompts/use-cases/chart-chart-bar.md +1886 -0
- package/assets/prompts/use-cases/chart-chart-pie.md +1031 -0
- package/assets/prompts/use-cases/chart-chart-radar.md +785 -0
- package/assets/prompts/use-cases/chart-chart-radial.md +988 -0
- package/assets/prompts/use-cases/chart-segmented-chart.md +262 -0
- package/assets/prompts/use-cases/chat-chat-composer.md +529 -0
- package/assets/prompts/use-cases/chat-chat-input.md +1766 -0
- package/assets/prompts/use-cases/data-comment.md +360 -0
- package/assets/prompts/use-cases/data-data-table.md +249 -0
- package/assets/prompts/use-cases/data-list-item.md +1056 -0
- package/assets/prompts/use-cases/data-metric-card.md +673 -0
- package/assets/prompts/use-cases/data-table-row.md +966 -0
- package/assets/prompts/use-cases/data-table-toolbar.md +481 -0
- package/assets/prompts/use-cases/feedback-drawer.md +1168 -0
- package/assets/prompts/use-cases/feedback-progress-bar.md +432 -0
- package/assets/prompts/use-cases/general-toolbar.md +854 -0
- package/assets/prompts/use-cases/general-tooltip.md +652 -0
- package/assets/prompts/use-cases/input-checkbox.md +443 -0
- package/assets/prompts/use-cases/structure-card.md +603 -0
- package/assets/prompts/use-cases/structure-page-header.md +755 -0
- package/assets/prompts/use-cases/structure-sidebar.md +1132 -0
- package/assets/prompts/use-cases/structure-topbar.md +1196 -0
- package/assets/public/ovenn-wordmark.svg +19 -0
- package/assets/skills/ovenn-wireframe/SKILL.md +17 -4
- package/package.json +10 -2
- package/src/commands/info.js +1 -1
- package/src/utils/design-examples.js +3 -4
- package/assets/prompts/templates/glass-button.md +0 -336
|
@@ -0,0 +1,1031 @@
|
|
|
1
|
+
# Pie Chart 사용 사례 소스
|
|
2
|
+
|
|
3
|
+
<!-- Generated by scripts/build-use-cases.mjs. Edit original TSX/CSS, then regenerate. -->
|
|
4
|
+
|
|
5
|
+
### 사례 목록
|
|
6
|
+
|
|
7
|
+
- Acquisition sources card
|
|
8
|
+
|
|
9
|
+
문서: /en/components/chart/chart-pie#use-cases
|
|
10
|
+
|
|
11
|
+
문서 페이지에서 렌더하는 사례입니다.
|
|
12
|
+
|
|
13
|
+
### 조회 방법
|
|
14
|
+
|
|
15
|
+
get_guide(topic="use-cases/chart-chart-pie", sections=["사례 목록", "파일 목록"])로 먼저 확인하고, 필요한 Section 또는 Source 파일 헤딩만 sections로 조회하세요. 전체 문서는 문서 페이지의 다른 예제도 포함합니다. 공용 컴포넌트 계약은 get_component로 읽고, 예제의 docs 전용 셸·locale·import 경로는 대상 프로젝트에 맞게 조합하세요. 이 연결은 디자인 승인이나 기능 검증을 뜻하지 않습니다.
|
|
16
|
+
|
|
17
|
+
### 파일 목록
|
|
18
|
+
|
|
19
|
+
- `web/app/[lang]/components/chart/chart-pie/_strings.tsx`
|
|
20
|
+
- `web/app/[lang]/components/chart/chart-pie/page.module.css`
|
|
21
|
+
- `web/app/[lang]/components/chart/chart-pie/page.tsx`
|
|
22
|
+
- `web/examples/ChartCardExamples.module.css`
|
|
23
|
+
- `web/examples/ChartCardExamples.tsx`
|
|
24
|
+
- `web/examples/TrafficComparisonExample.module.css`
|
|
25
|
+
- `web/examples/TrafficComparisonExample.tsx`
|
|
26
|
+
|
|
27
|
+
### Section: web/app/[lang]/components/chart/chart-pie/page.tsx#use-cases
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
<section id="use-cases">
|
|
31
|
+
<h2>{!en ? "사용 사례" : "In Use"}</h2>
|
|
32
|
+
<h3>{en ? "Acquisition sources card" : "유입 경로 카드"}</h3>
|
|
33
|
+
<ExampleBlock previewWidth="full"><AcquisitionCardExample /></ExampleBlock>
|
|
34
|
+
</section>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Source: web/app/[lang]/components/chart/chart-pie/_strings.tsx
|
|
38
|
+
|
|
39
|
+
````tsx
|
|
40
|
+
import type { ReactNode } from "react";
|
|
41
|
+
|
|
42
|
+
type Strings = {
|
|
43
|
+
title: string;
|
|
44
|
+
lead: ReactNode;
|
|
45
|
+
browsers: [string, string, string, string, string];
|
|
46
|
+
visitors: string;
|
|
47
|
+
totalVisitors: string;
|
|
48
|
+
usage: { heading: string; desc: ReactNode };
|
|
49
|
+
labels: { heading: string; desc: ReactNode; custom: ReactNode };
|
|
50
|
+
legend: { heading: string; desc: ReactNode };
|
|
51
|
+
donut: { heading: string; desc: ReactNode; active: ReactNode; text: ReactNode };
|
|
52
|
+
stacked: { heading: string; desc: ReactNode };
|
|
53
|
+
api: {
|
|
54
|
+
heading: string;
|
|
55
|
+
desc: ReactNode;
|
|
56
|
+
officialDocs: string;
|
|
57
|
+
columns: { prop: string; type: string; default: string; desc: string };
|
|
58
|
+
data: string;
|
|
59
|
+
dataKey: string;
|
|
60
|
+
nameKey: string;
|
|
61
|
+
innerRadius: string;
|
|
62
|
+
outerRadius: string;
|
|
63
|
+
paddingAngle: string;
|
|
64
|
+
label: string;
|
|
65
|
+
shape: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const en: Strings = {
|
|
70
|
+
title: "Pie Chart",
|
|
71
|
+
lead: "Shows how each category contributes to a whole. Use Bar Chart when small differences need to be compared precisely.",
|
|
72
|
+
browsers: ["Chrome", "Safari", "Firefox", "Edge", "Other"],
|
|
73
|
+
visitors: "Visitors",
|
|
74
|
+
totalVisitors: "Total visitors",
|
|
75
|
+
usage: {
|
|
76
|
+
heading: "Usage",
|
|
77
|
+
desc: "Use for a small number of categories that add up to one whole.",
|
|
78
|
+
},
|
|
79
|
+
labels: {
|
|
80
|
+
heading: "Labels",
|
|
81
|
+
desc: "Show value labels when readers need exact amounts without hovering.",
|
|
82
|
+
custom: "Show category names and percentages when the chart needs to stand on its own.",
|
|
83
|
+
|
|
84
|
+
},
|
|
85
|
+
legend: {
|
|
86
|
+
heading: "Legend",
|
|
87
|
+
desc: "Use the detailed legend to compare values, or compact to identify categories. Select an item to emphasize its slice; select it again to restore all slices.",
|
|
88
|
+
},
|
|
89
|
+
donut: {
|
|
90
|
+
heading: "Donut",
|
|
91
|
+
desc: "Use a donut when the center is needed for a summary.",
|
|
92
|
+
active: "Emphasize the hovered slice when readers need to inspect one category.",
|
|
93
|
+
text: "Reserve the center for the total or the selected value.",
|
|
94
|
+
},
|
|
95
|
+
stacked: {
|
|
96
|
+
heading: "Stacked Donut",
|
|
97
|
+
desc: "Keep the same category order when comparing two distributions.",
|
|
98
|
+
},
|
|
99
|
+
api: {
|
|
100
|
+
heading: "API Reference",
|
|
101
|
+
desc: "For slice, label, and shape options, see the",
|
|
102
|
+
officialDocs: "Pie documentation",
|
|
103
|
+
columns: { prop: "Prop", type: "Type", default: "Default", desc: "Description" },
|
|
104
|
+
data: "Array of category rows",
|
|
105
|
+
dataKey: "Numeric value key used to calculate angles",
|
|
106
|
+
nameKey: "Category name key used by tooltip and legend",
|
|
107
|
+
innerRadius: "Inner radius; values above zero create a donut",
|
|
108
|
+
outerRadius: "Outer radius or a function for per-slice emphasis",
|
|
109
|
+
paddingAngle: "Angular gap between slices",
|
|
110
|
+
label: "Default, declarative, or custom slice label",
|
|
111
|
+
shape: "Custom sector renderer; isActive identifies the hovered slice",
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const ko: Strings = {
|
|
116
|
+
title: "Pie Chart",
|
|
117
|
+
lead: "전체에서 각 항목이 차지하는 비중을 보여줘요. 작은 차이를 정확히 비교할 때는 Bar Chart를 사용해요.",
|
|
118
|
+
browsers: ["크롬", "사파리", "파이어폭스", "엣지", "기타"],
|
|
119
|
+
visitors: "방문자",
|
|
120
|
+
totalVisitors: "전체 방문자",
|
|
121
|
+
usage: {
|
|
122
|
+
heading: "사용법",
|
|
123
|
+
desc: "하나의 전체를 이루는 소수 항목의 비중을 비교할 때 사용해요.",
|
|
124
|
+
},
|
|
125
|
+
labels: {
|
|
126
|
+
heading: "라벨",
|
|
127
|
+
desc: "마우스를 올리지 않아도 정확한 수치를 읽어야 할 때 라벨을 표시해요.",
|
|
128
|
+
custom: "차트만으로 내용을 이해해야 할 때는 항목명과 비율을 함께 표시해요.",
|
|
129
|
+
},
|
|
130
|
+
legend: {
|
|
131
|
+
heading: "범례",
|
|
132
|
+
desc: "수치 비교에는 기본형, 항목 구분에는 컴팩트형 범례를 사용해요. 범례를 선택하면 해당 조각이 강조되고, 다시 선택하면 전체를 표시해요.",
|
|
133
|
+
},
|
|
134
|
+
donut: {
|
|
135
|
+
heading: "도넛",
|
|
136
|
+
desc: "중앙에 요약 값을 표시해야 할 때 도넛을 사용해요.",
|
|
137
|
+
active: "한 항목을 자세히 살펴볼 수 있도록 마우스를 올린 조각을 강조해요.",
|
|
138
|
+
text: "중앙에는 합계나 선택한 값 하나만 표시해요.",
|
|
139
|
+
},
|
|
140
|
+
stacked: {
|
|
141
|
+
heading: "중첩 도넛",
|
|
142
|
+
desc: "두 분포를 비교할 때는 같은 항목 순서를 유지해요.",
|
|
143
|
+
},
|
|
144
|
+
api: {
|
|
145
|
+
heading: "속성",
|
|
146
|
+
desc: "조각·라벨·형태 옵션은",
|
|
147
|
+
officialDocs: "Pie 문서",
|
|
148
|
+
columns: { prop: "속성", type: "타입", default: "기본값", desc: "설명" },
|
|
149
|
+
data: "카테고리 행 배열",
|
|
150
|
+
dataKey: "각도를 계산할 숫자 값 키",
|
|
151
|
+
nameKey: "툴팁과 범례에서 사용할 카테고리 이름 키",
|
|
152
|
+
innerRadius: "내부 반지름. 0보다 크면 도넛 형태",
|
|
153
|
+
outerRadius: "외부 반지름 또는 조각별 강조 함수",
|
|
154
|
+
paddingAngle: "조각 사이 각도 간격",
|
|
155
|
+
label: "기본·선언형·커스텀 조각 라벨",
|
|
156
|
+
shape: "커스텀 조각 렌더러. isActive로 호버 조각 식별",
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export const strings: Record<"en" | "ko", Strings> = { en, ko };
|
|
161
|
+
````
|
|
162
|
+
|
|
163
|
+
### Source: web/app/[lang]/components/chart/chart-pie/page.module.css
|
|
164
|
+
|
|
165
|
+
````css
|
|
166
|
+
.playgroundChart,
|
|
167
|
+
.pieChart {
|
|
168
|
+
width: 100%;
|
|
169
|
+
max-width: calc(var(--size-24) * 4);
|
|
170
|
+
aspect-ratio: 1;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.widePieChart {
|
|
174
|
+
width: 100%;
|
|
175
|
+
max-width: calc(var(--size-24) * 5);
|
|
176
|
+
aspect-ratio: 16 / 9;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.emphasizedSector {
|
|
180
|
+
transform: scale(1);
|
|
181
|
+
opacity: 1;
|
|
182
|
+
transition:
|
|
183
|
+
transform var(--duration-slower) var(--ease-in-out),
|
|
184
|
+
opacity var(--duration-slow) var(--ease-out);
|
|
185
|
+
will-change: transform;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.emphasizedSector[data-selected="true"] {
|
|
189
|
+
transform: scale(1.025);
|
|
190
|
+
transition-timing-function: var(--ease-emphasized);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.emphasizedSector[data-muted="true"] {
|
|
194
|
+
transform: scale(0.995);
|
|
195
|
+
opacity: 0.24;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.emphasizedSector[data-active="true"] {
|
|
199
|
+
transform: scale(1.075);
|
|
200
|
+
transition-timing-function: var(--ease-emphasized);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.selectableLabel {
|
|
204
|
+
opacity: 1;
|
|
205
|
+
transition: opacity var(--duration-slow) var(--ease-in-out);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.selectableLabel[data-muted="true"] {
|
|
209
|
+
opacity: 0;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.centerValue {
|
|
213
|
+
fill: var(--fg-strong);
|
|
214
|
+
font-size: var(--text-xl);
|
|
215
|
+
font-weight: var(--font-weight-semibold);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.centerLabel {
|
|
219
|
+
fill: var(--fg-muted);
|
|
220
|
+
font-size: var(--text-xs);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.legendDemo {
|
|
224
|
+
display: flex;
|
|
225
|
+
flex-wrap: wrap;
|
|
226
|
+
align-items: center;
|
|
227
|
+
justify-content: center;
|
|
228
|
+
column-gap: var(--space-4);
|
|
229
|
+
row-gap: var(--space-1);
|
|
230
|
+
width: 100%;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.legendDemo .withLegend {
|
|
234
|
+
flex: 1 1 calc(var(--size-24) * 2.5);
|
|
235
|
+
min-width: 0;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.compactDemo {
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
gap: var(--space-2);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.legendDemo .playgroundChart,
|
|
244
|
+
.legendDemo .pieChart {
|
|
245
|
+
max-width: calc(var(--size-24) * 2.5);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.legendDemo .labelledChart {
|
|
249
|
+
max-width: calc(var(--size-24) * 4);
|
|
250
|
+
}
|
|
251
|
+
````
|
|
252
|
+
|
|
253
|
+
### Source: web/app/[lang]/components/chart/chart-pie/page.tsx
|
|
254
|
+
|
|
255
|
+
````tsx
|
|
256
|
+
"use client";
|
|
257
|
+
|
|
258
|
+
import { AcquisitionCardExample } from "@/examples/ChartCardExamples";
|
|
259
|
+
import { useMemo, useState } from "react";
|
|
260
|
+
import { usePathname } from "next/navigation";
|
|
261
|
+
import {
|
|
262
|
+
Label,
|
|
263
|
+
Pie,
|
|
264
|
+
PieChart,
|
|
265
|
+
Sector,
|
|
266
|
+
type PieLabelRenderProps,
|
|
267
|
+
type PieSectorShapeProps,
|
|
268
|
+
} from "recharts";
|
|
269
|
+
import {
|
|
270
|
+
ChartContainer,
|
|
271
|
+
ChartTooltip,
|
|
272
|
+
ChartTooltipContent,
|
|
273
|
+
type ChartConfig,
|
|
274
|
+
} from "@/components/Chart";
|
|
275
|
+
import { ChartItemLegend } from "../../../../_components/ChartItemLegend";
|
|
276
|
+
import { ExampleBlock } from "../../../../_components/ExampleBlock";
|
|
277
|
+
import { Playground } from "../../../../_components/Playground";
|
|
278
|
+
import { DocsTable } from "../../../../_components/DocsTable";
|
|
279
|
+
import { localeFromPathname } from "../../../../_dict";
|
|
280
|
+
import { strings } from "./_strings";
|
|
281
|
+
import styles from "./page.module.css";
|
|
282
|
+
|
|
283
|
+
const SHAPES = ["pie", "donut"] as const;
|
|
284
|
+
type ShapeMode = (typeof SHAPES)[number];
|
|
285
|
+
const LABELS = ["none", "value", "name"] as const;
|
|
286
|
+
type LabelMode = (typeof LABELS)[number];
|
|
287
|
+
const LEGEND_TYPES = ["detailed", "compact"] as const;
|
|
288
|
+
type LegendType = (typeof LEGEND_TYPES)[number];
|
|
289
|
+
|
|
290
|
+
function emphasizedShape(props: PieSectorShapeProps, selectedKey?: string | null) {
|
|
291
|
+
const { className, isActive, style, ...sectorProps } = props;
|
|
292
|
+
const row = props.payload as { browser?: string } | undefined;
|
|
293
|
+
const isSelected = selectedKey != null && row?.browser === selectedKey;
|
|
294
|
+
const isMuted = selectedKey != null && row?.browser !== selectedKey;
|
|
295
|
+
return (
|
|
296
|
+
<Sector
|
|
297
|
+
{...sectorProps}
|
|
298
|
+
className={[className, styles.emphasizedSector].filter(Boolean).join(" ")}
|
|
299
|
+
data-active={isActive ? "true" : "false"}
|
|
300
|
+
data-selected={isSelected ? "true" : "false"}
|
|
301
|
+
data-muted={isMuted ? "true" : "false"}
|
|
302
|
+
style={{
|
|
303
|
+
...style,
|
|
304
|
+
transformOrigin: `${props.cx ?? 0}px ${props.cy ?? 0}px`,
|
|
305
|
+
}}
|
|
306
|
+
/>
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function labelGeometry(props: PieLabelRenderProps) {
|
|
311
|
+
const cx = Number(props.cx ?? 0);
|
|
312
|
+
const cy = Number(props.cy ?? 0);
|
|
313
|
+
const outerRadius = Number(props.outerRadius ?? 0);
|
|
314
|
+
const midAngle = Number(props.midAngle ?? 0);
|
|
315
|
+
const angle = -midAngle * (Math.PI / 180);
|
|
316
|
+
const startRadius = outerRadius + 2;
|
|
317
|
+
const bendRadius = outerRadius + 14;
|
|
318
|
+
const startX = cx + startRadius * Math.cos(angle);
|
|
319
|
+
const startY = cy + startRadius * Math.sin(angle);
|
|
320
|
+
const bendX = cx + bendRadius * Math.cos(angle);
|
|
321
|
+
const bendY = cy + bendRadius * Math.sin(angle);
|
|
322
|
+
const isRight = bendX >= cx;
|
|
323
|
+
const endX = bendX + (isRight ? 12 : -12);
|
|
324
|
+
const textX = endX + (isRight ? 4 : -4);
|
|
325
|
+
|
|
326
|
+
return { startX, startY, bendX, bendY, endX, textX, isRight };
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function isLabelMuted(props: PieLabelRenderProps, selectedKey?: string | null) {
|
|
330
|
+
const row = props.payload as { browser?: string } | undefined;
|
|
331
|
+
return selectedKey != null && row?.browser !== selectedKey;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function renderLeaderLine(props: PieLabelRenderProps, selectedKey?: string | null) {
|
|
335
|
+
const { startX, startY, bendX, bendY, endX } = labelGeometry(props);
|
|
336
|
+
return (
|
|
337
|
+
<path
|
|
338
|
+
className={styles.selectableLabel}
|
|
339
|
+
data-muted={isLabelMuted(props, selectedKey) ? "true" : "false"}
|
|
340
|
+
d={`M ${startX} ${startY} L ${bendX} ${bendY} L ${endX} ${bendY}`}
|
|
341
|
+
fill="none"
|
|
342
|
+
stroke={props.stroke ?? "var(--fg-subtle)"}
|
|
343
|
+
strokeWidth={1}
|
|
344
|
+
/>
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function renderLabelText(props: PieLabelRenderProps, text: string, selectedKey?: string | null) {
|
|
349
|
+
const { bendY, textX, isRight } = labelGeometry(props);
|
|
350
|
+
return (
|
|
351
|
+
<text
|
|
352
|
+
className={styles.selectableLabel}
|
|
353
|
+
data-muted={isLabelMuted(props, selectedKey) ? "true" : "false"}
|
|
354
|
+
x={textX}
|
|
355
|
+
y={bendY}
|
|
356
|
+
textAnchor={isRight ? "start" : "end"}
|
|
357
|
+
dominantBaseline="central"
|
|
358
|
+
fill={`color-mix(in oklab, ${props.fill ?? "var(--fg-muted)"} 72%, var(--fg))`}
|
|
359
|
+
>
|
|
360
|
+
{text}
|
|
361
|
+
</text>
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function renderValueLabel(props: PieLabelRenderProps, selectedKey?: string | null) {
|
|
366
|
+
return renderLabelText(props, String(props.value ?? ""), selectedKey);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function renderPercentLabel(props: PieLabelRenderProps, selectedKey?: string | null) {
|
|
370
|
+
const row = props.payload as { label?: string } | undefined;
|
|
371
|
+
const percent = Math.round((props.percent ?? 0) * 100);
|
|
372
|
+
return renderLabelText(props, `${row?.label ?? ""} ${percent}%`, selectedKey);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export default function ChartPiePage() {
|
|
376
|
+
const pathname = usePathname() ?? "/";
|
|
377
|
+
const en = localeFromPathname(pathname) === "en";
|
|
378
|
+
const t = strings[en ? "en" : "ko"];
|
|
379
|
+
|
|
380
|
+
const data = useMemo(
|
|
381
|
+
() => [
|
|
382
|
+
{ browser: "chrome", label: strings.en.browsers[0], visitors: 275, desktop: 180, mobile: 95, fill: "var(--color-chrome)" },
|
|
383
|
+
{ browser: "safari", label: strings.en.browsers[1], visitors: 200, desktop: 110, mobile: 90, fill: "var(--color-safari)" },
|
|
384
|
+
{ browser: "firefox", label: strings.en.browsers[2], visitors: 187, desktop: 130, mobile: 57, fill: "var(--color-firefox)" },
|
|
385
|
+
{ browser: "edge", label: strings.en.browsers[3], visitors: 173, desktop: 125, mobile: 48, fill: "var(--color-edge)" },
|
|
386
|
+
{ browser: "other", label: strings.en.browsers[4], visitors: 90, desktop: 50, mobile: 40, fill: "var(--color-other)" },
|
|
387
|
+
],
|
|
388
|
+
[strings.en.browsers],
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
const config = useMemo<ChartConfig>(
|
|
392
|
+
() =>
|
|
393
|
+
({
|
|
394
|
+
visitors: { label: strings.en.visitors },
|
|
395
|
+
chrome: { label: strings.en.browsers[0], color: "var(--chart-1)" },
|
|
396
|
+
safari: { label: strings.en.browsers[1], color: "var(--chart-2)" },
|
|
397
|
+
firefox: { label: strings.en.browsers[2], color: "var(--chart-3)" },
|
|
398
|
+
edge: { label: strings.en.browsers[3], color: "var(--chart-4)" },
|
|
399
|
+
other: { label: strings.en.browsers[4], color: "var(--chart-5)" },
|
|
400
|
+
}) satisfies ChartConfig,
|
|
401
|
+
[strings.en.browsers, strings.en.visitors],
|
|
402
|
+
);
|
|
403
|
+
|
|
404
|
+
const total = useMemo(() => data.reduce((sum, row) => sum + row.visitors, 0), [data]);
|
|
405
|
+
const [pgShape, setPgShape] = useState<ShapeMode>("donut");
|
|
406
|
+
const [pgLabel, setPgLabel] = useState<LabelMode>("none");
|
|
407
|
+
const [pgLegend, setPgLegend] = useState(true);
|
|
408
|
+
const [legendType, setLegendType] = useState<LegendType>("detailed");
|
|
409
|
+
const [pgSeparator, setPgSeparator] = useState(true);
|
|
410
|
+
const [pgActive, setPgActive] = useState(true);
|
|
411
|
+
const [pgSoloSlice, setPgSoloSlice] = useState<string | null>(null);
|
|
412
|
+
const [legendSoloSlice, setLegendSoloSlice] = useState<string | null>(null);
|
|
413
|
+
const legendItems = data.map((row) => ({ id: row.browser, label: row.label, value: row.visitors, color: config[row.browser].color }));
|
|
414
|
+
|
|
415
|
+
return (
|
|
416
|
+
<>
|
|
417
|
+
<h1 className="page-title">{t.title}</h1>
|
|
418
|
+
<p className="page-lead">{t.lead}</p>
|
|
419
|
+
|
|
420
|
+
<section id="usage" className="section-first">
|
|
421
|
+
<h2>{t.usage.heading}</h2>
|
|
422
|
+
<p className="desc">{t.usage.desc}</p>
|
|
423
|
+
<ExampleBlock
|
|
424
|
+
code={`import { Pie, PieChart } from "recharts";
|
|
425
|
+
import { ChartContainer } from "@/components/Chart";
|
|
426
|
+
|
|
427
|
+
<ChartContainer config={config}>
|
|
428
|
+
<PieChart accessibilityLayer>
|
|
429
|
+
<Pie data={data} dataKey="visitors" nameKey="browser" />
|
|
430
|
+
</PieChart>
|
|
431
|
+
</ChartContainer>`}
|
|
432
|
+
>
|
|
433
|
+
<ChartContainer config={config} className={styles.pieChart}>
|
|
434
|
+
<PieChart accessibilityLayer>
|
|
435
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="browser" hideLabel />} />
|
|
436
|
+
<Pie data={data} dataKey="visitors" nameKey="browser" stroke="var(--bg)" strokeWidth={2} isAnimationActive={false} />
|
|
437
|
+
</PieChart>
|
|
438
|
+
</ChartContainer>
|
|
439
|
+
</ExampleBlock>
|
|
440
|
+
</section>
|
|
441
|
+
|
|
442
|
+
<Playground
|
|
443
|
+
axes={[
|
|
444
|
+
{ label: "shape", value: pgShape, onChange: (v) => setPgShape(v as ShapeMode), options: SHAPES },
|
|
445
|
+
{ label: "labels", value: pgLabel, onChange: (v) => setPgLabel(v as LabelMode), options: LABELS },
|
|
446
|
+
{ label: "legend type", value: legendType, onChange: (v) => setLegendType(v as LegendType), options: LEGEND_TYPES },
|
|
447
|
+
]}
|
|
448
|
+
toggles={[
|
|
449
|
+
{ label: "legend", value: pgLegend, onChange: setPgLegend },
|
|
450
|
+
{ label: "separator", value: pgSeparator, onChange: setPgSeparator },
|
|
451
|
+
{ label: "active shape", value: pgActive, onChange: setPgActive },
|
|
452
|
+
]}
|
|
453
|
+
>
|
|
454
|
+
<div className={`${styles.legendDemo} ${pgLegend && legendType === "compact" ? styles.compactDemo : ""}`}>
|
|
455
|
+
<ChartContainer config={config} className={`${styles.playgroundChart} ${pgLabel !== "none" ? styles.labelledChart : ""} ${pgLegend && legendType === "detailed" ? styles.withLegend : ""}`}>
|
|
456
|
+
<PieChart accessibilityLayer>
|
|
457
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="browser" hideLabel />} />
|
|
458
|
+
<Pie
|
|
459
|
+
data={data}
|
|
460
|
+
dataKey="visitors"
|
|
461
|
+
nameKey="browser"
|
|
462
|
+
innerRadius={pgShape === "donut" ? 58 : 0}
|
|
463
|
+
outerRadius={90}
|
|
464
|
+
stroke={pgSeparator ? "var(--bg)" : "transparent"}
|
|
465
|
+
strokeWidth={pgSeparator ? 2 : 0}
|
|
466
|
+
label={
|
|
467
|
+
pgLabel === "value"
|
|
468
|
+
? (props) => renderValueLabel(props, pgSoloSlice)
|
|
469
|
+
: pgLabel === "name"
|
|
470
|
+
? (props) => renderPercentLabel(props, pgSoloSlice)
|
|
471
|
+
: false
|
|
472
|
+
}
|
|
473
|
+
labelLine={pgLabel !== "none" ? (props) => renderLeaderLine(props, pgSoloSlice) : false}
|
|
474
|
+
shape={pgActive || pgSoloSlice ? (props) => emphasizedShape(props, pgSoloSlice) : undefined}
|
|
475
|
+
isAnimationActive={false}
|
|
476
|
+
/>
|
|
477
|
+
</PieChart>
|
|
478
|
+
</ChartContainer>
|
|
479
|
+
{pgLegend && <ChartItemLegend items={legendItems} compact={legendType === "compact"} selected={pgSoloSlice}
|
|
480
|
+
onSelect={(key) => setPgSoloSlice((prev) => prev === key ? null : key)} />}
|
|
481
|
+
</div>
|
|
482
|
+
</Playground>
|
|
483
|
+
|
|
484
|
+
<section id="labels">
|
|
485
|
+
<h2>{t.labels.heading}</h2>
|
|
486
|
+
<p className="desc">{t.labels.desc}</p>
|
|
487
|
+
<ExampleBlock code={`<Pie data={data} dataKey="visitors" label={({ value }) => value} />`}>
|
|
488
|
+
<ChartContainer config={config} className={styles.pieChart}>
|
|
489
|
+
<PieChart accessibilityLayer>
|
|
490
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="browser" hideLabel />} />
|
|
491
|
+
<Pie
|
|
492
|
+
data={data}
|
|
493
|
+
dataKey="visitors"
|
|
494
|
+
nameKey="browser"
|
|
495
|
+
label={renderValueLabel}
|
|
496
|
+
labelLine={renderLeaderLine}
|
|
497
|
+
isAnimationActive={false}
|
|
498
|
+
/>
|
|
499
|
+
</PieChart>
|
|
500
|
+
</ChartContainer>
|
|
501
|
+
</ExampleBlock>
|
|
502
|
+
|
|
503
|
+
<p className="desc">{t.labels.custom}</p>
|
|
504
|
+
<ExampleBlock code={`<Pie data={data} dataKey="visitors" label={({ payload, percent }) => ...} />`}>
|
|
505
|
+
<ChartContainer config={config} className={styles.widePieChart}>
|
|
506
|
+
<PieChart accessibilityLayer margin={{ left: 48, right: 48 }}>
|
|
507
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="browser" hideLabel />} />
|
|
508
|
+
<Pie
|
|
509
|
+
data={data}
|
|
510
|
+
dataKey="visitors"
|
|
511
|
+
nameKey="browser"
|
|
512
|
+
label={renderPercentLabel}
|
|
513
|
+
labelLine={renderLeaderLine}
|
|
514
|
+
isAnimationActive={false}
|
|
515
|
+
/>
|
|
516
|
+
</PieChart>
|
|
517
|
+
</ChartContainer>
|
|
518
|
+
</ExampleBlock>
|
|
519
|
+
|
|
520
|
+
</section>
|
|
521
|
+
|
|
522
|
+
<section id="legend">
|
|
523
|
+
<h2>{t.legend.heading}</h2>
|
|
524
|
+
<p className="desc">{t.legend.desc}</p>
|
|
525
|
+
<ExampleBlock code={`const [solo, setSolo] = useState<string | null>(null);
|
|
526
|
+
|
|
527
|
+
<div className={styles.legendDemo}>
|
|
528
|
+
<ChartContainer config={config}>...</ChartContainer>
|
|
529
|
+
<ChartItemLegend
|
|
530
|
+
items={items}
|
|
531
|
+
selected={solo}
|
|
532
|
+
onSelect={(key) => setSolo((prev) => prev === key ? null : key)}
|
|
533
|
+
/>
|
|
534
|
+
</div>
|
|
535
|
+
|
|
536
|
+
// Names only, below the chart:
|
|
537
|
+
// <ChartItemLegend compact items={items} selected={solo} onSelect={toggleSlice} />`}>
|
|
538
|
+
<div className={styles.legendDemo}>
|
|
539
|
+
<ChartContainer config={config} className={`${styles.pieChart} ${styles.withLegend}`}>
|
|
540
|
+
<PieChart accessibilityLayer>
|
|
541
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="browser" hideLabel />} />
|
|
542
|
+
<Pie
|
|
543
|
+
data={data}
|
|
544
|
+
dataKey="visitors"
|
|
545
|
+
nameKey="browser"
|
|
546
|
+
shape={(props) => emphasizedShape(props, legendSoloSlice)}
|
|
547
|
+
isAnimationActive={false}
|
|
548
|
+
/>
|
|
549
|
+
</PieChart>
|
|
550
|
+
</ChartContainer>
|
|
551
|
+
<ChartItemLegend items={legendItems} selected={legendSoloSlice}
|
|
552
|
+
onSelect={(key) => setLegendSoloSlice((prev) => prev === key ? null : key)} />
|
|
553
|
+
</div>
|
|
554
|
+
</ExampleBlock>
|
|
555
|
+
</section>
|
|
556
|
+
|
|
557
|
+
<section id="donut">
|
|
558
|
+
<h2>{t.donut.heading}</h2>
|
|
559
|
+
<p className="desc">{t.donut.desc}</p>
|
|
560
|
+
<ExampleBlock code={`<Pie data={data} dataKey="visitors" innerRadius={58} outerRadius={90} />`}>
|
|
561
|
+
<ChartContainer config={config} className={styles.pieChart}>
|
|
562
|
+
<PieChart accessibilityLayer>
|
|
563
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="browser" hideLabel />} />
|
|
564
|
+
<Pie data={data} dataKey="visitors" nameKey="browser" innerRadius={58} outerRadius={90} isAnimationActive={false} />
|
|
565
|
+
</PieChart>
|
|
566
|
+
</ChartContainer>
|
|
567
|
+
</ExampleBlock>
|
|
568
|
+
|
|
569
|
+
<p className="desc">{t.donut.active}</p>
|
|
570
|
+
<ExampleBlock code={`<Pie data={data} dataKey="visitors" innerRadius={58} shape={emphasizedShape} />`}>
|
|
571
|
+
<ChartContainer config={config} className={styles.pieChart}>
|
|
572
|
+
<PieChart accessibilityLayer>
|
|
573
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="browser" hideLabel />} />
|
|
574
|
+
<Pie data={data} dataKey="visitors" nameKey="browser" innerRadius={58} outerRadius={86} shape={(props) => emphasizedShape(props)} isAnimationActive={false} />
|
|
575
|
+
</PieChart>
|
|
576
|
+
</ChartContainer>
|
|
577
|
+
</ExampleBlock>
|
|
578
|
+
|
|
579
|
+
<p className="desc">{t.donut.text}</p>
|
|
580
|
+
<ExampleBlock code={`<Pie data={data} dataKey="visitors" innerRadius={58}>
|
|
581
|
+
<Label position="center" content={...} />
|
|
582
|
+
</Pie>`}>
|
|
583
|
+
<ChartContainer config={config} className={styles.pieChart}>
|
|
584
|
+
<PieChart accessibilityLayer>
|
|
585
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="browser" hideLabel />} />
|
|
586
|
+
<Pie data={data} dataKey="visitors" nameKey="browser" innerRadius={58} outerRadius={90} isAnimationActive={false}>
|
|
587
|
+
<Label
|
|
588
|
+
position="center"
|
|
589
|
+
content={({ viewBox }) => {
|
|
590
|
+
if (!viewBox || !("cx" in viewBox) || !("cy" in viewBox)) return null;
|
|
591
|
+
return (
|
|
592
|
+
<text x={viewBox.cx} y={viewBox.cy} textAnchor="middle" dominantBaseline="middle">
|
|
593
|
+
<tspan x={viewBox.cx} y={viewBox.cy} className={styles.centerValue}>{total.toLocaleString()}</tspan>
|
|
594
|
+
<tspan x={viewBox.cx} y={Number(viewBox.cy) + 22} className={styles.centerLabel}>{strings.en.totalVisitors}</tspan>
|
|
595
|
+
</text>
|
|
596
|
+
);
|
|
597
|
+
}}
|
|
598
|
+
/>
|
|
599
|
+
</Pie>
|
|
600
|
+
</PieChart>
|
|
601
|
+
</ChartContainer>
|
|
602
|
+
</ExampleBlock>
|
|
603
|
+
</section>
|
|
604
|
+
|
|
605
|
+
<section id="stacked">
|
|
606
|
+
<h2>{t.stacked.heading}</h2>
|
|
607
|
+
<p className="desc">{t.stacked.desc}</p>
|
|
608
|
+
<ExampleBlock code={`<Pie data={data} dataKey="desktop" innerRadius={48} outerRadius={70} />
|
|
609
|
+
<Pie data={data} dataKey="mobile" innerRadius={76} outerRadius={98} />`}>
|
|
610
|
+
<ChartContainer config={config} className={styles.pieChart}>
|
|
611
|
+
<PieChart accessibilityLayer>
|
|
612
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="browser" hideLabel />} />
|
|
613
|
+
<Pie data={data} dataKey="desktop" nameKey="browser" innerRadius={44} outerRadius={66} stroke="var(--bg)" isAnimationActive={false} />
|
|
614
|
+
<Pie data={data} dataKey="mobile" nameKey="browser" innerRadius={72} outerRadius={94} stroke="var(--bg)" isAnimationActive={false} />
|
|
615
|
+
</PieChart>
|
|
616
|
+
</ChartContainer>
|
|
617
|
+
</ExampleBlock>
|
|
618
|
+
</section>
|
|
619
|
+
|
|
620
|
+
<section id="use-cases">
|
|
621
|
+
<h2>{!en ? "사용 사례" : "In Use"}</h2>
|
|
622
|
+
<h3>{en ? "Acquisition sources card" : "유입 경로 카드"}</h3>
|
|
623
|
+
<ExampleBlock previewWidth="full"><AcquisitionCardExample /></ExampleBlock>
|
|
624
|
+
</section>
|
|
625
|
+
|
|
626
|
+
<section id="api">
|
|
627
|
+
<h2>{t.api.heading}</h2>
|
|
628
|
+
<p className="desc">
|
|
629
|
+
{t.api.desc}{" "}
|
|
630
|
+
<a href="https://recharts.github.io/en-US/api/Pie" target="_blank" rel="noreferrer">{t.api.officialDocs}</a>{en ? "." : "에서 확인하세요."}
|
|
631
|
+
</p>
|
|
632
|
+
<h3>Pie</h3>
|
|
633
|
+
<DocsTable
|
|
634
|
+
columns={[
|
|
635
|
+
{ key: "prop", label: t.api.columns.prop, width: 160 },
|
|
636
|
+
{ key: "type", label: t.api.columns.type, flex: true, minWidth: 220 },
|
|
637
|
+
{ key: "default", label: t.api.columns.default, width: 120 },
|
|
638
|
+
{ key: "desc", label: t.api.columns.desc, flex: true, minWidth: 260 },
|
|
639
|
+
]}
|
|
640
|
+
rows={[
|
|
641
|
+
{ prop: "data", type: "object[]", default: "-", desc: t.api.data },
|
|
642
|
+
{ prop: "dataKey", type: "DataKey", default: "-", desc: t.api.dataKey },
|
|
643
|
+
{ prop: "nameKey", type: "DataKey", default: '"name"', desc: t.api.nameKey },
|
|
644
|
+
{ prop: "innerRadius", type: "number | string", default: "0", desc: t.api.innerRadius },
|
|
645
|
+
{ prop: "outerRadius", type: "number | string | function", default: '"80%"', desc: t.api.outerRadius },
|
|
646
|
+
{ prop: "paddingAngle", type: "number", default: "0", desc: t.api.paddingAngle },
|
|
647
|
+
{ prop: "label", type: "boolean | object | function", default: "false", desc: t.api.label },
|
|
648
|
+
{ prop: "shape", type: "ReactElement | function", default: "-", desc: t.api.shape },
|
|
649
|
+
]}
|
|
650
|
+
/>
|
|
651
|
+
</section>
|
|
652
|
+
</>
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
````
|
|
656
|
+
|
|
657
|
+
### Source: web/examples/ChartCardExamples.module.css
|
|
658
|
+
|
|
659
|
+
````css
|
|
660
|
+
.card {
|
|
661
|
+
--chart-card-width: 384px; /* lint-hardcoded: ignore */
|
|
662
|
+
--chart-card-wide: 560px; /* lint-hardcoded: ignore */
|
|
663
|
+
--chart-card-plot-height: 208px; /* lint-hardcoded: ignore */
|
|
664
|
+
--chart-card-round-size: 208px; /* lint-hardcoded: ignore */
|
|
665
|
+
display: flex;
|
|
666
|
+
flex-direction: column;
|
|
667
|
+
gap: var(--space-4);
|
|
668
|
+
width: 100%;
|
|
669
|
+
max-width: var(--chart-card-width);
|
|
670
|
+
min-width: 0;
|
|
671
|
+
padding-top: var(--space-6);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.wide {
|
|
675
|
+
max-width: var(--chart-card-wide);
|
|
676
|
+
--comparison-chart-height: 248px; /* lint-hardcoded: ignore */
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
.header {
|
|
680
|
+
display: flex;
|
|
681
|
+
flex-direction: column;
|
|
682
|
+
gap: var(--space-1);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.header h3 {
|
|
686
|
+
margin: 0;
|
|
687
|
+
font-size: var(--text-base);
|
|
688
|
+
font-weight: var(--font-weight-semibold);
|
|
689
|
+
line-height: var(--lh-tight);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
.header > span,
|
|
693
|
+
.center > span,
|
|
694
|
+
.goalCaption {
|
|
695
|
+
color: var(--fg-muted);
|
|
696
|
+
font-size: var(--text-sm);
|
|
697
|
+
line-height: var(--lh-base);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
.metric {
|
|
701
|
+
display: flex;
|
|
702
|
+
align-items: baseline;
|
|
703
|
+
gap: var(--space-2);
|
|
704
|
+
font-size: var(--text-3xl);
|
|
705
|
+
font-weight: var(--font-weight-book);
|
|
706
|
+
line-height: var(--lh-tight);
|
|
707
|
+
font-variant-numeric: tabular-nums;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
.metric > span {
|
|
711
|
+
font-size: var(--text-sm);
|
|
712
|
+
color: var(--fg-muted);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
.cartesian {
|
|
716
|
+
height: var(--chart-card-plot-height);
|
|
717
|
+
aspect-ratio: auto;
|
|
718
|
+
min-width: 0;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
.donutWrap {
|
|
722
|
+
position: relative;
|
|
723
|
+
display: grid;
|
|
724
|
+
place-items: center;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.donut,
|
|
728
|
+
.radial {
|
|
729
|
+
width: var(--chart-card-round-size);
|
|
730
|
+
max-width: 100%;
|
|
731
|
+
height: var(--chart-card-round-size);
|
|
732
|
+
aspect-ratio: 1;
|
|
733
|
+
align-self: center;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
.center {
|
|
737
|
+
position: absolute;
|
|
738
|
+
display: flex;
|
|
739
|
+
flex-direction: column;
|
|
740
|
+
align-items: center;
|
|
741
|
+
gap: 0;
|
|
742
|
+
pointer-events: none;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
.center strong {
|
|
746
|
+
font-size: var(--text-3xl);
|
|
747
|
+
font-weight: var(--font-weight-book);
|
|
748
|
+
line-height: var(--lh-tight);
|
|
749
|
+
font-variant-numeric: tabular-nums;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
.center > span {
|
|
753
|
+
font-size: var(--text-xs);
|
|
754
|
+
line-height: var(--lh-tight);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
.radar {
|
|
758
|
+
height: auto;
|
|
759
|
+
aspect-ratio: 1.3;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.goalValue {
|
|
763
|
+
fill: var(--fg);
|
|
764
|
+
font-size: var(--text-4xl);
|
|
765
|
+
font-weight: var(--font-weight-book);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
.percent {
|
|
769
|
+
fill: var(--fg-muted);
|
|
770
|
+
font-size: var(--text-base);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
.goalCaption {
|
|
774
|
+
margin: 0;
|
|
775
|
+
text-align: center;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
.goalCaption strong {
|
|
779
|
+
color: var(--fg);
|
|
780
|
+
font-weight: var(--font-weight-medium);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/* Keep Button padding and hover area; align its content with the card heading. */
|
|
784
|
+
.breakdown {
|
|
785
|
+
margin-inline: calc((var(--space-3) + var(--hairline)) * -1);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
.breakdown > ul {
|
|
789
|
+
width: 100%;
|
|
790
|
+
max-width: none;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
@media (max-width: 360px) {
|
|
794
|
+
.radar {
|
|
795
|
+
aspect-ratio: 1.4;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
````
|
|
799
|
+
|
|
800
|
+
### Source: web/examples/ChartCardExamples.tsx
|
|
801
|
+
|
|
802
|
+
````tsx
|
|
803
|
+
"use client";
|
|
804
|
+
|
|
805
|
+
import { useId, useState, type ReactNode } from "react";
|
|
806
|
+
import {
|
|
807
|
+
Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, Label, Pie, PieChart,
|
|
808
|
+
PolarAngleAxis, PolarGrid, PolarRadiusAxis, Radar, RadarChart,
|
|
809
|
+
RadialBar, RadialBarChart, XAxis,
|
|
810
|
+
} from "recharts";
|
|
811
|
+
import { Card } from "@/components/Card";
|
|
812
|
+
import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@/components/Chart";
|
|
813
|
+
import { ChartItemLegend } from "@/app/_components/ChartItemLegend";
|
|
814
|
+
import { TrafficComparisonExample } from "./TrafficComparisonExample";
|
|
815
|
+
import styles from "./ChartCardExamples.module.css";
|
|
816
|
+
|
|
817
|
+
function ChartCard({ title, period, children, wide = false }: {
|
|
818
|
+
title: string; period: string; children: ReactNode; wide?: boolean;
|
|
819
|
+
}) {
|
|
820
|
+
return <Card variant="framed" className={`${styles.card} ${wide ? styles.wide : ""}`}>
|
|
821
|
+
<div className={styles.header}><h3>{title}</h3><span>{period}</span></div>
|
|
822
|
+
{children}
|
|
823
|
+
</Card>;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
export function TrafficCardExample() {
|
|
827
|
+
return <ChartCard title="Website traffic" period="Today · 10:30 AM" wide>
|
|
828
|
+
<TrafficComparisonExample />
|
|
829
|
+
</ChartCard>;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
const revenue = [
|
|
833
|
+
{ day: "Mon", revenue: 2400 }, { day: "Tue", revenue: 3200 },
|
|
834
|
+
{ day: "Wed", revenue: 2800 }, { day: "Thu", revenue: 4100 },
|
|
835
|
+
{ day: "Fri", revenue: 3600 }, { day: "Sat", revenue: 4800 }, { day: "Sun", revenue: 4200 },
|
|
836
|
+
];
|
|
837
|
+
const revenueConfig = { revenue: { label: "Revenue", color: "var(--chart-1)" } } satisfies ChartConfig;
|
|
838
|
+
|
|
839
|
+
export function RevenueCardExample() {
|
|
840
|
+
const gradient = `revenue-${useId().replace(/:/g, "")}`;
|
|
841
|
+
const total = revenue.reduce((sum, row) => sum + row.revenue, 0);
|
|
842
|
+
return <ChartCard title="Weekly revenue" period="Oct 26 – Nov 1">
|
|
843
|
+
<div className={styles.metric}>{total.toLocaleString("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })}</div>
|
|
844
|
+
<ChartContainer config={revenueConfig} className={styles.cartesian} aria-label="Daily revenue for October 26 to November 1">
|
|
845
|
+
<AreaChart data={revenue} accessibilityLayer margin={{ left: 12, right: 12, top: 16, bottom: 0 }}>
|
|
846
|
+
<defs><linearGradient id={gradient} x1="0" y1="0" x2="0" y2="1">
|
|
847
|
+
<stop offset="0%" stopColor="var(--color-revenue)" stopOpacity={0.24} />
|
|
848
|
+
<stop offset="100%" stopColor="var(--color-revenue)" stopOpacity={0} />
|
|
849
|
+
</linearGradient></defs>
|
|
850
|
+
<CartesianGrid vertical={false} />
|
|
851
|
+
<XAxis dataKey="day" tickLine={false} axisLine={false} tickMargin={10} interval="preserveStartEnd" />
|
|
852
|
+
<ChartTooltip content={<ChartTooltipContent indicator="line" />} />
|
|
853
|
+
<Area dataKey="revenue" type="monotone" fill={`url(#${gradient})`} stroke="var(--color-revenue)" isAnimationActive={false} />
|
|
854
|
+
</AreaChart>
|
|
855
|
+
</ChartContainer>
|
|
856
|
+
</ChartCard>;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
const support = [
|
|
860
|
+
{ day: "Mon", tickets: 42 }, { day: "Tue", tickets: 58 }, { day: "Wed", tickets: 35 },
|
|
861
|
+
{ day: "Thu", tickets: 47 }, { day: "Fri", tickets: 64 },
|
|
862
|
+
];
|
|
863
|
+
const supportConfig = { tickets: { label: "Tickets", color: "var(--chart-1)" } } satisfies ChartConfig;
|
|
864
|
+
|
|
865
|
+
export function SupportCardExample() {
|
|
866
|
+
return <ChartCard title="Support requests" period="Oct 26–30">
|
|
867
|
+
<div className={styles.metric}>{support.reduce((sum, row) => sum + row.tickets, 0)}<span>tickets</span></div>
|
|
868
|
+
<ChartContainer config={supportConfig} className={styles.cartesian} aria-label="Support requests by weekday">
|
|
869
|
+
<BarChart data={support} accessibilityLayer maxBarSize={32} margin={{ top: 16, right: 0, bottom: 0, left: 0 }}>
|
|
870
|
+
<CartesianGrid vertical={false} />
|
|
871
|
+
<XAxis dataKey="day" tickLine={false} axisLine={false} tickMargin={10} interval="preserveStartEnd" />
|
|
872
|
+
<ChartTooltip cursor={false} content={<ChartTooltipContent />} />
|
|
873
|
+
<Bar dataKey="tickets" fill="var(--color-tickets)" radius={[6, 6, 0, 0]} isAnimationActive={false} />
|
|
874
|
+
</BarChart>
|
|
875
|
+
</ChartContainer>
|
|
876
|
+
</ChartCard>;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
const acquisition = [
|
|
880
|
+
{ id: "organic", label: "Organic search", value: 1820, color: "var(--chart-1)" },
|
|
881
|
+
{ id: "direct", label: "Direct", value: 1140, color: "var(--chart-2)" },
|
|
882
|
+
{ id: "referral", label: "Referral", value: 680, color: "var(--chart-3)" },
|
|
883
|
+
{ id: "social", label: "Social", value: 360, color: "var(--chart-4)" },
|
|
884
|
+
];
|
|
885
|
+
const acquisitionConfig = Object.fromEntries(acquisition.map(row => [row.id, { label: row.label, color: row.color }])) satisfies ChartConfig;
|
|
886
|
+
|
|
887
|
+
export function AcquisitionCardExample() {
|
|
888
|
+
const [selected, setSelected] = useState<string | null>(null);
|
|
889
|
+
const current = acquisition.find(row => row.id === selected);
|
|
890
|
+
const value = current?.value ?? acquisition.reduce((sum, row) => sum + row.value, 0);
|
|
891
|
+
return <ChartCard title="Acquisition sources" period="October 2026">
|
|
892
|
+
<div className={styles.donutWrap}>
|
|
893
|
+
<ChartContainer config={acquisitionConfig} className={styles.donut} aria-label="October visitors by acquisition source">
|
|
894
|
+
<PieChart accessibilityLayer>
|
|
895
|
+
<ChartTooltip content={<ChartTooltipContent nameKey="id" hideLabel />} />
|
|
896
|
+
<Pie data={acquisition} dataKey="value" nameKey="id" innerRadius="72%" outerRadius="92%" paddingAngle={3} stroke="var(--bg)" isAnimationActive={false}>
|
|
897
|
+
{acquisition.map(row => <Cell key={row.id} fill={`var(--color-${row.id})`} opacity={selected && selected !== row.id ? 0.18 : 1} />)}
|
|
898
|
+
</Pie>
|
|
899
|
+
</PieChart>
|
|
900
|
+
</ChartContainer>
|
|
901
|
+
<div className={styles.center} aria-live="polite"><strong>{value.toLocaleString("en-US")}</strong><span>{current?.label ?? "Visitors"}</span></div>
|
|
902
|
+
</div>
|
|
903
|
+
<div className={styles.breakdown}><ChartItemLegend items={acquisition} selected={selected} onSelect={key => setSelected(value => value === key ? null : key)} /></div>
|
|
904
|
+
</ChartCard>;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
const quality = [
|
|
908
|
+
{ axis: "Speed", current: 86, previous: 62 }, { axis: "Reliability", current: 92, previous: 78 },
|
|
909
|
+
{ axis: "Ease of use", current: 78, previous: 65 }, { axis: "Features", current: 84, previous: 72 },
|
|
910
|
+
{ axis: "Support", current: 90, previous: 80 },
|
|
911
|
+
];
|
|
912
|
+
const qualityConfig = {
|
|
913
|
+
current: { label: "Current release", color: "var(--chart-1)" },
|
|
914
|
+
previous: { label: "Previous release", color: "var(--chart-3)" },
|
|
915
|
+
} satisfies ChartConfig;
|
|
916
|
+
|
|
917
|
+
export function QualityCardExample() {
|
|
918
|
+
const [selected, setSelected] = useState<string | null>(null);
|
|
919
|
+
return <ChartCard title="Product quality" period="Score out of 100">
|
|
920
|
+
<ChartContainer config={qualityConfig} className={styles.radar} aria-label="Current and previous release quality scores out of 100">
|
|
921
|
+
<RadarChart data={quality} accessibilityLayer outerRadius="60%">
|
|
922
|
+
<PolarGrid radialLines={false} />
|
|
923
|
+
<PolarAngleAxis dataKey="axis" tickLine={false} tickSize={4} />
|
|
924
|
+
<PolarRadiusAxis domain={[0, 100]} tick={false} axisLine={false} />
|
|
925
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
926
|
+
<Radar dataKey="previous" hide={selected === "current"} stroke="var(--color-previous)" fill="var(--color-previous)" fillOpacity={0.08} isAnimationActive={false} />
|
|
927
|
+
<Radar dataKey="current" hide={selected === "previous"} stroke="var(--color-current)" fill="var(--color-current)" fillOpacity={0.16} isAnimationActive={false} />
|
|
928
|
+
</RadarChart>
|
|
929
|
+
</ChartContainer>
|
|
930
|
+
<ChartItemLegend compact items={Object.entries(qualityConfig).map(([id, row]) => ({ id, label: row.label, color: row.color, value: 0 }))}
|
|
931
|
+
selected={selected} onSelect={key => setSelected(value => value === key ? null : key)} />
|
|
932
|
+
</ChartCard>;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
const goal = { completed: 72, target: 100 };
|
|
936
|
+
const goalConfig = { completed: { label: "Completed", color: "var(--chart-1)" } } satisfies ChartConfig;
|
|
937
|
+
|
|
938
|
+
export function GoalCardExample() {
|
|
939
|
+
const percentage = Math.round(goal.completed / goal.target * 100);
|
|
940
|
+
return <ChartCard title="Monthly goal" period="November 2026">
|
|
941
|
+
<ChartContainer config={goalConfig} className={styles.radial} aria-label={`${goal.completed} of ${goal.target} reports completed, ${percentage}%`}>
|
|
942
|
+
<RadialBarChart data={[goal]} accessibilityLayer startAngle={90} endAngle={-270} innerRadius="78%" outerRadius="100%" barSize={14}>
|
|
943
|
+
<PolarAngleAxis type="number" domain={[0, goal.target]} tick={false} />
|
|
944
|
+
<RadialBar dataKey="completed" fill="var(--color-completed)" background={{ fill: "var(--bg-muted)" }} cornerRadius={8} isAnimationActive={false} />
|
|
945
|
+
<PolarRadiusAxis tick={false} tickLine={false} axisLine={false}>
|
|
946
|
+
<Label position="center" content={({ x, y }) => {
|
|
947
|
+
if (x == null || y == null) return null;
|
|
948
|
+
return <text x={x} y={y} textAnchor="middle" dominantBaseline="central" className={styles.goalValue}>{percentage}<tspan className={styles.percent}>%</tspan></text>;
|
|
949
|
+
}} />
|
|
950
|
+
</PolarRadiusAxis>
|
|
951
|
+
</RadialBarChart>
|
|
952
|
+
</ChartContainer>
|
|
953
|
+
<p className={styles.goalCaption}><strong>{goal.completed}</strong> of {goal.target} reports completed</p>
|
|
954
|
+
</ChartCard>;
|
|
955
|
+
}
|
|
956
|
+
````
|
|
957
|
+
|
|
958
|
+
### Source: web/examples/TrafficComparisonExample.module.css
|
|
959
|
+
|
|
960
|
+
````css
|
|
961
|
+
.chart {
|
|
962
|
+
width: 100%;
|
|
963
|
+
min-width: 0;
|
|
964
|
+
height: var(--comparison-chart-height, 320px); /* lint-hardcoded: ignore */
|
|
965
|
+
aspect-ratio: auto;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
.currentLine,
|
|
969
|
+
.previousLine {
|
|
970
|
+
display: inline-block;
|
|
971
|
+
width: var(--space-3);
|
|
972
|
+
height: 0;
|
|
973
|
+
flex-shrink: 0;
|
|
974
|
+
border-top: 2px solid var(--color-today); /* lint-hardcoded: ignore */
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
.previousLine {
|
|
978
|
+
border-top-style: dotted;
|
|
979
|
+
border-top-color: var(--color-yesterday);
|
|
980
|
+
}
|
|
981
|
+
````
|
|
982
|
+
|
|
983
|
+
### Source: web/examples/TrafficComparisonExample.tsx
|
|
984
|
+
|
|
985
|
+
````tsx
|
|
986
|
+
"use client";
|
|
987
|
+
|
|
988
|
+
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
|
|
989
|
+
import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@/components/Chart";
|
|
990
|
+
import styles from "./TrafficComparisonExample.module.css";
|
|
991
|
+
|
|
992
|
+
const today = [0, 0, 1720, 2100, 2280, 1950, 2800, 2200, 2480, 2890, 3300, 3250, 3905];
|
|
993
|
+
const yesterday = [0, 430, 260, 450, 510, 780, 520, 760, 470, 790, 1260, 1430, 2545];
|
|
994
|
+
const minutes = [0, 30, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 630];
|
|
995
|
+
const data = today.map((value, index) => ({ minute: minutes[index], today: value as number | null, yesterday: yesterday[index] as number | null }));
|
|
996
|
+
data.push({ minute: 1439, today: null, yesterday: null });
|
|
997
|
+
|
|
998
|
+
function CurrentLine() { return <span className={styles.currentLine} />; }
|
|
999
|
+
function PreviousLine() { return <span className={styles.previousLine} />; }
|
|
1000
|
+
const config = {
|
|
1001
|
+
today: { label: "Today", color: "var(--chart-1)", icon: CurrentLine },
|
|
1002
|
+
yesterday: { label: "Yesterday", color: "var(--fg-muted)", icon: PreviousLine },
|
|
1003
|
+
} satisfies ChartConfig;
|
|
1004
|
+
|
|
1005
|
+
function formatTime(value: number) {
|
|
1006
|
+
const hour = Math.floor(value / 60);
|
|
1007
|
+
const minute = Math.floor(value % 60);
|
|
1008
|
+
return `${hour % 12 || 12}:${String(minute).padStart(2, "0")}${hour < 12 ? "AM" : "PM"}`;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
export function TrafficComparisonExample() {
|
|
1012
|
+
return <ChartContainer config={config} className={styles.chart} role="group"
|
|
1013
|
+
aria-label="Website visitors by time. At 10:30AM, today has 3,905 visitors and yesterday had 2,545.">
|
|
1014
|
+
<LineChart data={data} accessibilityLayer margin={{ top: 12, right: 16, bottom: 8, left: 0 }}>
|
|
1015
|
+
<CartesianGrid vertical={false} strokeOpacity={0.45} />
|
|
1016
|
+
<XAxis dataKey="minute" type="number" domain={[0, 1439]} ticks={[0, 720, 1439]}
|
|
1017
|
+
tickFormatter={formatTime} tickLine={false} axisLine={false} tickMargin={12} minTickGap={32} />
|
|
1018
|
+
<YAxis domain={[0, 5000]} ticks={[0, 1000, 2000, 3000, 4000, 5000]} interval={0} width={40}
|
|
1019
|
+
tickFormatter={(value: number) => value === 0 ? "0" : `${value / 1000}K`}
|
|
1020
|
+
tickLine={false} axisLine={false} tickMargin={8} />
|
|
1021
|
+
<ChartTooltip cursor={{ stroke: "var(--fg-muted)", strokeWidth: 1 }}
|
|
1022
|
+
content={<ChartTooltipContent indicator="line" labelFormatter={(value) => `Today at ${formatTime(Number(value))}`} />} />
|
|
1023
|
+
<ChartLegend align="left" content={<ChartLegendContent />} />
|
|
1024
|
+
<Line dataKey="today" type="monotone" stroke="var(--color-today)" strokeWidth={1.75}
|
|
1025
|
+
dot={false} activeDot={{ r: 4, fill: "var(--bg)", stroke: "var(--color-today)", strokeWidth: 1.75 }} isAnimationActive={false} />
|
|
1026
|
+
<Line dataKey="yesterday" type="linear" stroke="var(--color-yesterday)" strokeWidth={1.5}
|
|
1027
|
+
strokeDasharray="2 4" strokeLinecap="round" dot={false} activeDot={false} isAnimationActive={false} />
|
|
1028
|
+
</LineChart>
|
|
1029
|
+
</ChartContainer>;
|
|
1030
|
+
}
|
|
1031
|
+
````
|