@conscience-technology/ctds 0.0.0-stage → 0.1.1
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/README.md +128 -2
- package/assets/components/AppFrame/AppFrame.module.css +177 -0
- package/assets/components/AppFrame/AppFrame.tsx +93 -0
- package/assets/components/AppFrame/index.ts +6 -0
- package/assets/components/AttachmentChip/AttachmentChip.module.css +71 -0
- package/assets/components/AttachmentChip/AttachmentChip.tsx +74 -0
- package/assets/components/AttachmentChip/index.ts +2 -0
- package/assets/components/AttachmentThumb/AttachmentThumb.module.css +107 -0
- package/assets/components/AttachmentThumb/AttachmentThumb.tsx +91 -0
- package/assets/components/AttachmentThumb/index.ts +2 -0
- package/assets/components/Avatar/Avatar.module.css +167 -0
- package/assets/components/Avatar/Avatar.tsx +228 -0
- package/assets/components/Avatar/index.ts +2 -0
- package/assets/components/AvatarUpload/AvatarUpload.module.css +130 -0
- package/assets/components/AvatarUpload/AvatarUpload.tsx +139 -0
- package/assets/components/AvatarUpload/index.ts +2 -0
- package/assets/components/Badge/Badge.module.css +76 -0
- package/assets/components/Badge/Badge.tsx +68 -0
- package/assets/components/Badge/index.ts +2 -0
- package/assets/components/Breadcrumb/Breadcrumb.module.css +213 -0
- package/assets/components/Breadcrumb/Breadcrumb.tsx +279 -0
- package/assets/components/Breadcrumb/index.ts +8 -0
- package/assets/components/Button/Button.module.css +216 -0
- package/assets/components/Button/Button.tsx +149 -0
- package/assets/components/Button/index.ts +2 -0
- package/assets/components/Callout/Callout.module.css +146 -0
- package/assets/components/Callout/Callout.tsx +138 -0
- package/assets/components/Callout/index.ts +2 -0
- package/assets/components/ChatInput/ChatInput.module.css +254 -0
- package/assets/components/ChatInput/ChatInput.tsx +322 -0
- package/assets/components/ChatInput/ModelSelector.tsx +40 -0
- package/assets/components/ChatInput/SendButton.tsx +41 -0
- package/assets/components/ChatInput/index.ts +10 -0
- package/assets/components/Checkbox/Checkbox.module.css +66 -0
- package/assets/components/Checkbox/Checkbox.tsx +36 -0
- package/assets/components/Checkbox/index.ts +2 -0
- package/assets/components/Chip/Chip.module.css +128 -0
- package/assets/components/Chip/Chip.tsx +103 -0
- package/assets/components/Chip/index.ts +2 -0
- package/assets/components/ChoiceCard/ChoiceCard.module.css +142 -0
- package/assets/components/ChoiceCard/ChoiceCard.tsx +132 -0
- package/assets/components/ChoiceCard/index.ts +2 -0
- package/assets/components/ContextMenu/ContextMenu.module.css +102 -0
- package/assets/components/ContextMenu/ContextMenu.tsx +392 -0
- package/assets/components/ContextMenu/index.ts +9 -0
- package/assets/components/DatePicker/Calendar.tsx +234 -0
- package/assets/components/DatePicker/DESIGN_NOTES.md +106 -0
- package/assets/components/DatePicker/DESIGN_NOTES_TIME.md +125 -0
- package/assets/components/DatePicker/DatePicker.module.css +295 -0
- package/assets/components/DatePicker/DatePicker.tsx +387 -0
- package/assets/components/DatePicker/TimeSelector.tsx +69 -0
- package/assets/components/DatePicker/index.ts +8 -0
- package/assets/components/DatePicker/presets.ts +80 -0
- package/assets/components/DatePicker/utils.ts +148 -0
- package/assets/components/Disclosure/Disclosure.module.css +73 -0
- package/assets/components/Disclosure/Disclosure.tsx +129 -0
- package/assets/components/Disclosure/index.ts +6 -0
- package/assets/components/Drawer/Drawer.module.css +257 -0
- package/assets/components/Drawer/Drawer.tsx +126 -0
- package/assets/components/Drawer/index.ts +7 -0
- package/assets/components/EmptyState/EmptyState.module.css +102 -0
- package/assets/components/EmptyState/EmptyState.tsx +80 -0
- package/assets/components/EmptyState/index.ts +2 -0
- package/assets/components/FileIcon/FileIcon.module.css +66 -0
- package/assets/components/FileIcon/FileIcon.tsx +84 -0
- package/assets/components/FileIcon/fileExtMap.ts +112 -0
- package/assets/components/FileIcon/index.ts +9 -0
- package/assets/components/FilterButton/FilterButton.module.css +130 -0
- package/assets/components/FilterButton/FilterButton.tsx +94 -0
- package/assets/components/FilterButton/index.ts +2 -0
- package/assets/components/GalleryItem/GalleryItem.module.css +220 -0
- package/assets/components/GalleryItem/GalleryItem.tsx +163 -0
- package/assets/components/GalleryItem/index.ts +7 -0
- package/assets/components/Icon/Icon.tsx +616 -0
- package/assets/components/Icon/context.tsx +39 -0
- package/assets/components/Icon/index.ts +4 -0
- package/assets/components/IconButton/IconButton.module.css +109 -0
- package/assets/components/IconButton/IconButton.tsx +110 -0
- package/assets/components/IconButton/index.ts +2 -0
- package/assets/components/Input/Input.module.css +338 -0
- package/assets/components/Input/Input.tsx +371 -0
- package/assets/components/Input/index.ts +2 -0
- package/assets/components/ListItem/ListItem.module.css +318 -0
- package/assets/components/ListItem/ListItem.tsx +262 -0
- package/assets/components/ListItem/index.ts +9 -0
- package/assets/components/MenuItem/MenuItem.module.css +437 -0
- package/assets/components/MenuItem/MenuItem.tsx +529 -0
- package/assets/components/MenuItem/index.ts +8 -0
- package/assets/components/MetricCard/MetricCard.module.css +153 -0
- package/assets/components/MetricCard/MetricCard.tsx +140 -0
- package/assets/components/MetricCard/index.ts +2 -0
- package/assets/components/Modal/Modal.module.css +175 -0
- package/assets/components/Modal/Modal.tsx +98 -0
- package/assets/components/Modal/index.ts +2 -0
- package/assets/components/Onboarding/DocsIndex.tsx +82 -0
- package/assets/components/Onboarding/LayoutBuilder.tsx +160 -0
- package/assets/components/Onboarding/Onboarding.module.css +1394 -0
- package/assets/components/Onboarding/OnboardingAxisPanel.tsx +515 -0
- package/assets/components/Onboarding/OnboardingPage.tsx +1193 -0
- package/assets/components/Onboarding/PresetsGallery.tsx +65 -0
- package/assets/components/Onboarding/actions.ts +250 -0
- package/assets/components/Onboarding/index.ts +8 -0
- package/assets/components/Onboarding/palette.css +40 -0
- package/assets/components/Onboarding/wizardData.ts +265 -0
- package/assets/components/Pagination/Pagination.module.css +82 -0
- package/assets/components/Pagination/Pagination.tsx +248 -0
- package/assets/components/Pagination/index.ts +6 -0
- package/assets/components/ProgressBar/ProgressBar.module.css +64 -0
- package/assets/components/ProgressBar/ProgressBar.tsx +54 -0
- package/assets/components/ProgressBar/index.ts +2 -0
- package/assets/components/QuotationBar/QuotationBar.module.css +61 -0
- package/assets/components/QuotationBar/QuotationBar.tsx +48 -0
- package/assets/components/QuotationBar/index.ts +2 -0
- package/assets/components/Radio/Radio.module.css +63 -0
- package/assets/components/Radio/Radio.tsx +33 -0
- package/assets/components/Radio/index.ts +2 -0
- package/assets/components/Select/Select.module.css +151 -0
- package/assets/components/Select/Select.tsx +425 -0
- package/assets/components/Select/index.ts +10 -0
- package/assets/components/SelectableCard/SelectableCard.module.css +177 -0
- package/assets/components/SelectableCard/SelectableCard.tsx +83 -0
- package/assets/components/SelectableCard/index.ts +2 -0
- package/assets/components/Shortcut/Shortcut.module.css +56 -0
- package/assets/components/Shortcut/Shortcut.tsx +156 -0
- package/assets/components/Shortcut/index.ts +2 -0
- package/assets/components/Sidebar/Sidebar.module.css +242 -0
- package/assets/components/Sidebar/Sidebar.tsx +264 -0
- package/assets/components/Sidebar/index.ts +7 -0
- package/assets/components/SidebarSplit/SidebarSplit.module.css +126 -0
- package/assets/components/SidebarSplit/SidebarSplit.tsx +222 -0
- package/assets/components/SidebarSplit/index.ts +6 -0
- package/assets/components/Slider/Slider.module.css +120 -0
- package/assets/components/Slider/Slider.tsx +88 -0
- package/assets/components/Slider/index.ts +2 -0
- package/assets/components/SplitButton/SplitButton.module.css +190 -0
- package/assets/components/SplitButton/SplitButton.tsx +145 -0
- package/assets/components/SplitButton/index.ts +6 -0
- package/assets/components/Stepper/Stepper.module.css +182 -0
- package/assets/components/Stepper/Stepper.tsx +185 -0
- package/assets/components/Stepper/index.ts +2 -0
- package/assets/components/Switch/Switch.module.css +116 -0
- package/assets/components/Switch/Switch.tsx +58 -0
- package/assets/components/Switch/index.ts +2 -0
- package/assets/components/TableCell/TableCell.module.css +137 -0
- package/assets/components/TableCell/TableCellAvatar.tsx +42 -0
- package/assets/components/TableCell/TableCellBadge.tsx +23 -0
- package/assets/components/TableCell/TableCellIcon.tsx +39 -0
- package/assets/components/TableCell/TableCellImage.tsx +49 -0
- package/assets/components/TableCell/TableCellLink.tsx +33 -0
- package/assets/components/TableCell/TableCellMeter.tsx +55 -0
- package/assets/components/TableCell/TableCellNumber.tsx +43 -0
- package/assets/components/TableCell/TableCellText.tsx +30 -0
- package/assets/components/TableCell/index.ts +23 -0
- package/assets/components/TableHeader/TableHeader.module.css +287 -0
- package/assets/components/TableHeader/TableHeader.tsx +590 -0
- package/assets/components/TableHeader/index.ts +9 -0
- package/assets/components/TableRow/TableRow.module.css +290 -0
- package/assets/components/TableRow/TableRow.tsx +253 -0
- package/assets/components/TableRow/index.ts +8 -0
- package/assets/components/TableRowEdit/TableRowEdit.module.css +126 -0
- package/assets/components/TableRowEdit/TableRowEdit.tsx +247 -0
- package/assets/components/TableRowEdit/index.ts +2 -0
- package/assets/components/TableRowSelect/TableRowSelect.module.css +23 -0
- package/assets/components/TableRowSelect/TableRowSelect.tsx +175 -0
- package/assets/components/TableRowSelect/index.ts +2 -0
- package/assets/components/Tabs/Tabs.module.css +234 -0
- package/assets/components/Tabs/Tabs.tsx +426 -0
- package/assets/components/Tabs/index.ts +9 -0
- package/assets/components/Textarea/Textarea.module.css +318 -0
- package/assets/components/Textarea/Textarea.tsx +426 -0
- package/assets/components/Textarea/index.ts +7 -0
- package/assets/components/ThemeController.tsx +271 -0
- package/assets/components/TimePicker/TimePicker.module.css +317 -0
- package/assets/components/TimePicker/TimePicker.tsx +821 -0
- package/assets/components/TimePicker/index.ts +8 -0
- package/assets/components/TimePicker/utils.ts +115 -0
- package/assets/components/Toast/Toast.module.css +264 -0
- package/assets/components/Toast/Toast.tsx +243 -0
- package/assets/components/Toast/index.ts +15 -0
- package/assets/components/Toolbar/Toolbar.module.css +72 -0
- package/assets/components/Toolbar/Toolbar.tsx +75 -0
- package/assets/components/Toolbar/index.ts +2 -0
- package/assets/components/Tooltip/Tooltip.module.css +42 -0
- package/assets/components/Tooltip/Tooltip.tsx +332 -0
- package/assets/components/Tooltip/index.ts +2 -0
- package/assets/components/Topbar/Topbar.module.css +26 -0
- package/assets/components/Topbar/Topbar.tsx +47 -0
- package/assets/components/Topbar/index.ts +2 -0
- package/assets/components/_cn.ts +3 -0
- package/assets/components/_color.ts +48 -0
- package/assets/components/_data.ts +659 -0
- package/assets/components/_utils.css +19 -0
- package/assets/components/axisOptions.ts +24 -0
- package/assets/components/tokens.css +742 -0
- package/assets/prompts/GUIDE.md +251 -0
- package/assets/prompts/OVERRIDE.md +170 -0
- package/assets/prompts/PRINCIPLES.md +130 -0
- package/assets/prompts/axes/density.md +38 -0
- package/assets/prompts/axes/font.md +36 -0
- package/assets/prompts/axes/hue.md +36 -0
- package/assets/prompts/axes/icon.md +48 -0
- package/assets/prompts/axes/mode.md +50 -0
- package/assets/prompts/axes/motion.md +77 -0
- package/assets/prompts/axes/palette.md +35 -0
- package/assets/prompts/axes/shape.md +33 -0
- package/assets/prompts/axes/voice.md +54 -0
- package/assets/prompts/components/README.md +84 -0
- package/assets/prompts/components/app-frame.md +94 -0
- package/assets/prompts/components/attachment-chip.md +46 -0
- package/assets/prompts/components/attachment-thumb.md +49 -0
- package/assets/prompts/components/avatar.md +86 -0
- package/assets/prompts/components/badge.md +104 -0
- package/assets/prompts/components/breadcrumb.md +77 -0
- package/assets/prompts/components/button.md +99 -0
- package/assets/prompts/components/callout.md +81 -0
- package/assets/prompts/components/chat-input.md +84 -0
- package/assets/prompts/components/checkbox.md +46 -0
- package/assets/prompts/components/chip.md +84 -0
- package/assets/prompts/components/choice-card.md +127 -0
- package/assets/prompts/components/context-menu.md +145 -0
- package/assets/prompts/components/date-picker.md +104 -0
- package/assets/prompts/components/drawer.md +152 -0
- package/assets/prompts/components/empty-state.md +69 -0
- package/assets/prompts/components/file-icon.md +73 -0
- package/assets/prompts/components/filter-button.md +42 -0
- package/assets/prompts/components/form-field.md +74 -0
- package/assets/prompts/components/gallery-item.md +158 -0
- package/assets/prompts/components/icon-button.md +82 -0
- package/assets/prompts/components/icon.md +68 -0
- package/assets/prompts/components/input.md +95 -0
- package/assets/prompts/components/list-item.md +235 -0
- package/assets/prompts/components/menu-item.md +234 -0
- package/assets/prompts/components/metric-card.md +132 -0
- package/assets/prompts/components/modal.md +131 -0
- package/assets/prompts/components/pagination.md +92 -0
- package/assets/prompts/components/progress-bar.md +61 -0
- package/assets/prompts/components/quotation-bar.md +39 -0
- package/assets/prompts/components/radio.md +41 -0
- package/assets/prompts/components/select.md +104 -0
- package/assets/prompts/components/selectable-card.md +67 -0
- package/assets/prompts/components/shortcut.md +76 -0
- package/assets/prompts/components/sidebar.md +107 -0
- package/assets/prompts/components/slider.md +89 -0
- package/assets/prompts/components/split-button.md +71 -0
- package/assets/prompts/components/stepper.md +93 -0
- package/assets/prompts/components/switch.md +86 -0
- package/assets/prompts/components/table-cell.md +87 -0
- package/assets/prompts/components/table-header.md +157 -0
- package/assets/prompts/components/table-row-edit.md +129 -0
- package/assets/prompts/components/table-row-select.md +82 -0
- package/assets/prompts/components/table-row.md +156 -0
- package/assets/prompts/components/tabs.md +122 -0
- package/assets/prompts/components/textarea.md +105 -0
- package/assets/prompts/components/toast.md +149 -0
- package/assets/prompts/components/tooltip.md +71 -0
- package/assets/prompts/components/topbar.md +148 -0
- package/assets/prompts/primitives/emerge.md +43 -0
- package/assets/prompts/primitives/fade.md +31 -0
- package/assets/prompts/primitives/scale.md +32 -0
- package/assets/prompts/primitives/scroll.md +75 -0
- package/assets/prompts/primitives/slide.md +31 -0
- package/assets/prompts/themes/_SCHEMA.md +135 -0
- package/assets/prompts/themes/_TEMPLATE.md +73 -0
- package/assets/prompts/themes/expressive.md +118 -0
- package/assets/prompts/themes/pure.md +87 -0
- package/assets/prompts/themes/spare.md +73 -0
- package/assets/prompts/tokens/breakpoint.md +29 -0
- package/assets/prompts/tokens/color.md +78 -0
- package/assets/prompts/tokens/radius.md +33 -0
- package/assets/prompts/tokens/shadow.md +35 -0
- package/assets/prompts/tokens/spacing.md +86 -0
- package/assets/prompts/tokens/typography.md +76 -0
- package/assets/prompts/tokens/z-index.md +35 -0
- package/assets/public/expressive.png +0 -0
- package/assets/public/pure.png +0 -0
- package/assets/public/spare.png +0 -0
- package/assets/skill/SKILL.md +36 -0
- package/bin/ctds.js +76 -0
- package/package.json +35 -4
- package/src/commands/init.js +215 -0
- package/src/commands/update.js +275 -0
- package/src/utils/assets.js +78 -0
- package/src/utils/deps.js +51 -0
- package/src/utils/detect.js +47 -0
- package/src/utils/diff.js +52 -0
- package/src/utils/hash.js +16 -0
- package/src/utils/log.js +41 -0
- package/src/utils/meta.js +73 -0
- package/src/utils/prompt.js +28 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* Root ───────────────────────────────────────────────
|
|
2
|
+
가로 action 줄. IconButton·Button·텍스트 트리거를 품는다.
|
|
3
|
+
표현은 variant가 쥐고, 내부 구조(gap/정렬)만 공통.
|
|
4
|
+
단일 size — IconButton md(24)에 맞춘 bar 높이.
|
|
5
|
+
|
|
6
|
+
▸ Toolbar 내부 로컬 override: IconButton md 히트박스를 살짝 넓힌다.
|
|
7
|
+
기본 24 → 28. 아이콘 자체 크기는 그대로 두고 주변 여유만 확장해서
|
|
8
|
+
클릭 영역이 넉넉해지도록. */
|
|
9
|
+
.root {
|
|
10
|
+
--iconbtn-h-md: var(--control-h-sm);
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
gap: var(--space-1);
|
|
14
|
+
min-height: var(--control-h-md);
|
|
15
|
+
width: max-content;
|
|
16
|
+
padding-block: var(--space-1_5);
|
|
17
|
+
padding-inline: var(--space-2);
|
|
18
|
+
color: var(--fg);
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* stretch=true : 콘텐츠 폭이 아니라 부모 폭을 꽉 채움 (attached의 기본값). */
|
|
23
|
+
.root[data-stretch] {
|
|
24
|
+
display: flex;
|
|
25
|
+
width: 100%;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Variants ──────────────────────────────────────────── */
|
|
29
|
+
|
|
30
|
+
/* floating — 떠 있는 알약.
|
|
31
|
+
bg-elevated + 얕은 그림자 + 큰 radius. 콘텐츠 위에 살짝 떠 있는 느낌.
|
|
32
|
+
무게감은 hairline이 쥐고, 그림자는 분리감만 더한다. */
|
|
33
|
+
.root[data-variant="floating"] {
|
|
34
|
+
background: var(--bg-elevated, var(--bg));
|
|
35
|
+
border: var(--hairline) solid var(--border);
|
|
36
|
+
border-radius: var(--radius-xl);
|
|
37
|
+
box-shadow: var(--shadow-sm);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* attached — 콘텐츠에 붙은 bar.
|
|
41
|
+
자체 bg 없음 + 하단 hairline만. 에디터 상단·문서 chrome. */
|
|
42
|
+
.root[data-variant="attached"] {
|
|
43
|
+
background: transparent;
|
|
44
|
+
border: 0;
|
|
45
|
+
border-bottom: var(--hairline) solid var(--border);
|
|
46
|
+
border-radius: 0;
|
|
47
|
+
box-shadow: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Group ─────────────────────────────────────────────── */
|
|
51
|
+
.group {
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
gap: var(--space-0_5);
|
|
55
|
+
flex-shrink: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Divider ───────────────────────────────────────────────
|
|
59
|
+
세로 hairline. 그룹 사이 시각 구분.
|
|
60
|
+
굵기 --hairline 고정, 상/하 margin으로 아이콘 라인에서 살짝 안쪽. */
|
|
61
|
+
.divider {
|
|
62
|
+
width: var(--hairline);
|
|
63
|
+
align-self: stretch;
|
|
64
|
+
background: var(--border);
|
|
65
|
+
margin-inline: var(--space-1);
|
|
66
|
+
margin-block: var(--space-1_5);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Spacer ───────────────────────────────────────────── */
|
|
70
|
+
.spacer {
|
|
71
|
+
flex: 1 1 auto;
|
|
72
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, type HTMLAttributes } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../_cn";
|
|
6
|
+
import styles from "./Toolbar.module.css";
|
|
7
|
+
|
|
8
|
+
/* Root ─────────────────────────────────────────────────
|
|
9
|
+
툴바 — IconButton 중심의 action 줄. 단일 size.
|
|
10
|
+
variant:
|
|
11
|
+
- floating : 떠 있는 알약(bg-elevated + shadow-md + radius-xl)
|
|
12
|
+
- attached : 콘텐츠에 붙은 bar (transparent + 하단 hairline) */
|
|
13
|
+
export type ToolbarVariant = "floating" | "attached";
|
|
14
|
+
|
|
15
|
+
export interface ToolbarProps extends HTMLAttributes<HTMLElement> {
|
|
16
|
+
variant?: ToolbarVariant;
|
|
17
|
+
/** 가로 꽉 채울지(attached에 어울림) vs 콘텐츠 폭(floating). 기본은 variant로 자동 결정. */
|
|
18
|
+
stretch?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const ToolbarRoot = forwardRef<HTMLDivElement, ToolbarProps>(function ToolbarRoot(
|
|
22
|
+
{ variant = "floating", stretch, className, children, role = "toolbar", ...rest },
|
|
23
|
+
ref,
|
|
24
|
+
) {
|
|
25
|
+
const resolvedStretch = stretch ?? variant === "attached";
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
ref={ref}
|
|
29
|
+
role={role}
|
|
30
|
+
className={cn(styles.root, className)}
|
|
31
|
+
data-variant={variant}
|
|
32
|
+
data-stretch={resolvedStretch || undefined}
|
|
33
|
+
{...rest}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/* Group ─────────────────────────────────────────────────
|
|
41
|
+
관련 액션 묶음. 내부는 좁은 gap, 그룹 간은 Divider 또는 넓은 gap으로 구분. */
|
|
42
|
+
interface ToolbarGroupProps extends HTMLAttributes<HTMLDivElement> {}
|
|
43
|
+
|
|
44
|
+
function ToolbarGroup({ className, children, ...rest }: ToolbarGroupProps) {
|
|
45
|
+
return (
|
|
46
|
+
<div className={cn(styles.group, className)} role="group" {...rest}>
|
|
47
|
+
{children}
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Divider ───────────────────────────────────────────────
|
|
53
|
+
세로 hairline. 그룹 사이 시각 구분. */
|
|
54
|
+
function ToolbarDivider() {
|
|
55
|
+
return <div className={styles.divider} role="separator" aria-orientation="vertical" />;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Spacer ────────────────────────────────────────────────
|
|
59
|
+
좌/우 정렬용 flex:1. */
|
|
60
|
+
function ToolbarSpacer() {
|
|
61
|
+
return <div className={styles.spacer} aria-hidden />;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type ToolbarComponent = typeof ToolbarRoot & {
|
|
65
|
+
Group: typeof ToolbarGroup;
|
|
66
|
+
Divider: typeof ToolbarDivider;
|
|
67
|
+
Spacer: typeof ToolbarSpacer;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const Toolbar = ToolbarRoot as ToolbarComponent;
|
|
71
|
+
Toolbar.Group = ToolbarGroup;
|
|
72
|
+
Toolbar.Divider = ToolbarDivider;
|
|
73
|
+
Toolbar.Spacer = ToolbarSpacer;
|
|
74
|
+
|
|
75
|
+
export { Toolbar };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.content {
|
|
2
|
+
position: relative;
|
|
3
|
+
color: var(--tooltip-fg);
|
|
4
|
+
font-size: var(--text-xs);
|
|
5
|
+
line-height: var(--lh-xs);
|
|
6
|
+
max-width: 240px;
|
|
7
|
+
white-space: pre-line;
|
|
8
|
+
user-select: none;
|
|
9
|
+
z-index: var(--z-tooltip);
|
|
10
|
+
/* 배경/그림자는 SVG path에 걸림 */
|
|
11
|
+
filter: drop-shadow(var(--shadow-drop));
|
|
12
|
+
/* 앵커(트리거) 엣지에서 자라나는 느낌을 위해 Radix가 계산한 원점 사용 */
|
|
13
|
+
transform-origin: var(--radix-tooltip-content-transform-origin);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* In · Out 애니메이션은 전역 유틸 `.m-float`가 담당한다.
|
|
17
|
+
Tooltip.tsx에서 Content className에 "m-float"을 concat해 발동.
|
|
18
|
+
Radix Tooltip은 delayed-open · closed state를 데이터 어트리뷰트로 노출하므로
|
|
19
|
+
유틸이 그대로 매칭한다. */
|
|
20
|
+
|
|
21
|
+
/* SVG shape: content 크기에 딱 맞게 절대 위치 */
|
|
22
|
+
.shape {
|
|
23
|
+
position: absolute;
|
|
24
|
+
inset: 0;
|
|
25
|
+
display: block;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|
|
28
|
+
.shapePath {
|
|
29
|
+
fill: var(--tooltip-bg);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* 텍스트 레이어: SVG 위에 올라감. side별로 tail 크기만큼 패딩을 밀어줌 */
|
|
33
|
+
.text {
|
|
34
|
+
position: relative;
|
|
35
|
+
padding: var(--space-1) var(--space-2);
|
|
36
|
+
}
|
|
37
|
+
.content[data-side="top"] .text { padding-bottom: calc(var(--space-1) + var(--tail)); }
|
|
38
|
+
.content[data-side="bottom"] .text { padding-top: calc(var(--space-1) + var(--tail)); }
|
|
39
|
+
.content[data-side="left"] .text { padding-right: calc(var(--space-2) + var(--tail)); }
|
|
40
|
+
.content[data-side="right"] .text { padding-left: calc(var(--space-2) + var(--tail)); }
|
|
41
|
+
|
|
42
|
+
/* keyframes(m-emerge-*)는 globals.css의 Motion 프리미티브에서 정의됨 */
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as RadixTooltip from "@radix-ui/react-tooltip";
|
|
4
|
+
import {
|
|
5
|
+
forwardRef,
|
|
6
|
+
useEffect,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
} from "react";
|
|
12
|
+
import styles from "./Tooltip.module.css";
|
|
13
|
+
|
|
14
|
+
type Side = "top" | "right" | "bottom" | "left";
|
|
15
|
+
type Align = "start" | "center" | "end";
|
|
16
|
+
|
|
17
|
+
export interface TooltipProps {
|
|
18
|
+
content: ReactNode;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/** 튀어나올 방향. 뷰포트 충돌 시 자동 flip. 기본 top. */
|
|
21
|
+
side?: Side;
|
|
22
|
+
/** 그 방향에서의 정렬. 기본 center. */
|
|
23
|
+
align?: Align;
|
|
24
|
+
/** 트리거와의 간격 (px). 기본 6. */
|
|
25
|
+
sideOffset?: number;
|
|
26
|
+
/**
|
|
27
|
+
* 꼭지(arrow)의 위치를 중심에서 얼마나 밀지 (px).
|
|
28
|
+
* side=top/bottom이면 x축, side=left/right면 y축으로 이동.
|
|
29
|
+
* 기본 0 = 툴팁 본체의 정중앙.
|
|
30
|
+
* followMouse가 true면 이 값은 무시됩니다.
|
|
31
|
+
*/
|
|
32
|
+
arrowOffset?: number;
|
|
33
|
+
/**
|
|
34
|
+
* 마우스가 트리거 위에서 움직일 때 꼭지가 마우스를 따라가게 함.
|
|
35
|
+
* side=top/bottom일 때 x축, left/right일 때 y축을 따라감.
|
|
36
|
+
*/
|
|
37
|
+
followMouse?: boolean;
|
|
38
|
+
delayDuration?: number;
|
|
39
|
+
open?: boolean;
|
|
40
|
+
onOpenChange?: (open: boolean) => void;
|
|
41
|
+
/** 화살표 표시 여부. 기본 true. */
|
|
42
|
+
arrow?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* --- SVG path 프리셋 ---
|
|
46
|
+
body(rounded rect) + tail(삼각형)을 하나의 path로 그린다.
|
|
47
|
+
폭/높이는 사용처의 크기를 따라가고, 꼭지 위치는 CSS 변수 --arrow-x/--arrow-y로 제어. */
|
|
48
|
+
|
|
49
|
+
// 각 side별 path 함수: 컨테이너 크기(width, height)와 꼭지 위치(arrowPos), 꼭지 크기(tail), radius를 받아 path d 문자열 반환
|
|
50
|
+
const TAIL = 6; // 꼭지 크기 (side offset이 이만큼 필요)
|
|
51
|
+
const RADIUS = 6;
|
|
52
|
+
|
|
53
|
+
function buildPath(
|
|
54
|
+
side: Side,
|
|
55
|
+
w: number,
|
|
56
|
+
h: number,
|
|
57
|
+
arrowPos: number, // side가 top/bottom이면 x좌표, left/right면 y좌표
|
|
58
|
+
hasArrow: boolean
|
|
59
|
+
): string {
|
|
60
|
+
const r = Math.min(RADIUS, Math.min(w, h) / 2);
|
|
61
|
+
const t = TAIL;
|
|
62
|
+
|
|
63
|
+
if (side === "top") {
|
|
64
|
+
// body는 0..w-t 세로, arrow는 아래로 삐죽
|
|
65
|
+
const bodyH = h - t;
|
|
66
|
+
// arrow 위치는 x축, tail의 tip이 아래로 나감
|
|
67
|
+
const cx = clamp(arrowPos, r + t, w - r - t);
|
|
68
|
+
return [
|
|
69
|
+
`M${r},0`,
|
|
70
|
+
`H${w - r}`,
|
|
71
|
+
`Q${w},0 ${w},${r}`,
|
|
72
|
+
`V${bodyH - r}`,
|
|
73
|
+
`Q${w},${bodyH} ${w - r},${bodyH}`,
|
|
74
|
+
hasArrow ? `H${cx + t}` : "",
|
|
75
|
+
hasArrow ? `L${cx},${h}` : "",
|
|
76
|
+
hasArrow ? `L${cx - t},${bodyH}` : "",
|
|
77
|
+
`H${r}`,
|
|
78
|
+
`Q0,${bodyH} 0,${bodyH - r}`,
|
|
79
|
+
`V${r}`,
|
|
80
|
+
`Q0,0 ${r},0`,
|
|
81
|
+
`Z`,
|
|
82
|
+
]
|
|
83
|
+
.filter(Boolean)
|
|
84
|
+
.join(" ");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (side === "bottom") {
|
|
88
|
+
// body는 t..h 세로, arrow는 위로 삐죽
|
|
89
|
+
const bodyTop = t;
|
|
90
|
+
const cx = clamp(arrowPos, r + t, w - r - t);
|
|
91
|
+
return [
|
|
92
|
+
`M${r},${bodyTop}`,
|
|
93
|
+
hasArrow ? `H${cx - t}` : "",
|
|
94
|
+
hasArrow ? `L${cx},0` : "",
|
|
95
|
+
hasArrow ? `L${cx + t},${bodyTop}` : "",
|
|
96
|
+
`H${w - r}`,
|
|
97
|
+
`Q${w},${bodyTop} ${w},${bodyTop + r}`,
|
|
98
|
+
`V${h - r}`,
|
|
99
|
+
`Q${w},${h} ${w - r},${h}`,
|
|
100
|
+
`H${r}`,
|
|
101
|
+
`Q0,${h} 0,${h - r}`,
|
|
102
|
+
`V${bodyTop + r}`,
|
|
103
|
+
`Q0,${bodyTop} ${r},${bodyTop}`,
|
|
104
|
+
`Z`,
|
|
105
|
+
]
|
|
106
|
+
.filter(Boolean)
|
|
107
|
+
.join(" ");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (side === "left") {
|
|
111
|
+
// body는 0..w-t 가로, arrow는 오른쪽으로 삐죽
|
|
112
|
+
const bodyW = w - t;
|
|
113
|
+
const cy = clamp(arrowPos, r + t, h - r - t);
|
|
114
|
+
return [
|
|
115
|
+
`M${r},0`,
|
|
116
|
+
`H${bodyW - r}`,
|
|
117
|
+
`Q${bodyW},0 ${bodyW},${r}`,
|
|
118
|
+
hasArrow ? `V${cy - t}` : "",
|
|
119
|
+
hasArrow ? `L${w},${cy}` : "",
|
|
120
|
+
hasArrow ? `L${bodyW},${cy + t}` : "",
|
|
121
|
+
`V${h - r}`,
|
|
122
|
+
`Q${bodyW},${h} ${bodyW - r},${h}`,
|
|
123
|
+
`H${r}`,
|
|
124
|
+
`Q0,${h} 0,${h - r}`,
|
|
125
|
+
`V${r}`,
|
|
126
|
+
`Q0,0 ${r},0`,
|
|
127
|
+
`Z`,
|
|
128
|
+
]
|
|
129
|
+
.filter(Boolean)
|
|
130
|
+
.join(" ");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// right
|
|
134
|
+
// body는 t..w 가로, arrow는 왼쪽으로 삐죽
|
|
135
|
+
const bodyLeft = t;
|
|
136
|
+
const cy = clamp(arrowPos, r + t, h - r - t);
|
|
137
|
+
return [
|
|
138
|
+
`M${bodyLeft + r},0`,
|
|
139
|
+
`H${w - r}`,
|
|
140
|
+
`Q${w},0 ${w},${r}`,
|
|
141
|
+
`V${h - r}`,
|
|
142
|
+
`Q${w},${h} ${w - r},${h}`,
|
|
143
|
+
`H${bodyLeft + r}`,
|
|
144
|
+
`Q${bodyLeft},${h} ${bodyLeft},${h - r}`,
|
|
145
|
+
hasArrow ? `V${cy + t}` : "",
|
|
146
|
+
hasArrow ? `L0,${cy}` : "",
|
|
147
|
+
hasArrow ? `L${bodyLeft},${cy - t}` : "",
|
|
148
|
+
`V${r}`,
|
|
149
|
+
`Q${bodyLeft},0 ${bodyLeft + r},0`,
|
|
150
|
+
`Z`,
|
|
151
|
+
]
|
|
152
|
+
.filter(Boolean)
|
|
153
|
+
.join(" ");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function clamp(v: number, min: number, max: number) {
|
|
157
|
+
return Math.max(min, Math.min(max, v));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Radix Content를 감싼 컴포넌트. content 크기를 재서 SVG path를 다시 그린다.
|
|
162
|
+
* data-side는 Radix가 자동 flip 후 세팅해주는 값(top/right/bottom/left)을 그대로 씀.
|
|
163
|
+
*/
|
|
164
|
+
const CustomContent = forwardRef<
|
|
165
|
+
HTMLDivElement,
|
|
166
|
+
{
|
|
167
|
+
initialSide: Side;
|
|
168
|
+
align: Align;
|
|
169
|
+
sideOffset: number;
|
|
170
|
+
arrowOffset: number;
|
|
171
|
+
arrow: boolean;
|
|
172
|
+
children: ReactNode;
|
|
173
|
+
}
|
|
174
|
+
>(({ initialSide, align, sideOffset, arrowOffset, arrow, children }, ref) => {
|
|
175
|
+
const contentRef = useRef<HTMLDivElement | null>(null);
|
|
176
|
+
const [size, setSize] = useState<{ w: number; h: number } | null>(null);
|
|
177
|
+
const [side, setSide] = useState<Side>(initialSide);
|
|
178
|
+
|
|
179
|
+
// 크기 측정 + 실제 렌더링된 side(자동 flip 반영) 관측
|
|
180
|
+
useLayoutEffect(() => {
|
|
181
|
+
const el = contentRef.current;
|
|
182
|
+
if (!el) return;
|
|
183
|
+
const measure = () => {
|
|
184
|
+
const rect = el.getBoundingClientRect();
|
|
185
|
+
setSize({ w: rect.width, h: rect.height });
|
|
186
|
+
const s = el.getAttribute("data-side") as Side | null;
|
|
187
|
+
if (s) setSide(s);
|
|
188
|
+
};
|
|
189
|
+
measure();
|
|
190
|
+
const ro = new ResizeObserver(measure);
|
|
191
|
+
ro.observe(el);
|
|
192
|
+
// data-side는 Radix가 mount 후 세팅하므로 MutationObserver로 관측
|
|
193
|
+
const mo = new MutationObserver(measure);
|
|
194
|
+
mo.observe(el, { attributes: true, attributeFilter: ["data-side"] });
|
|
195
|
+
return () => {
|
|
196
|
+
ro.disconnect();
|
|
197
|
+
mo.disconnect();
|
|
198
|
+
};
|
|
199
|
+
}, []);
|
|
200
|
+
|
|
201
|
+
// arrow 위치: side에 따라 x 또는 y 좌표
|
|
202
|
+
const arrowPos = size
|
|
203
|
+
? side === "top" || side === "bottom"
|
|
204
|
+
? size.w / 2 + arrowOffset
|
|
205
|
+
: size.h / 2 + arrowOffset
|
|
206
|
+
: 0;
|
|
207
|
+
|
|
208
|
+
const d = size ? buildPath(side, size.w, size.h, arrowPos, arrow) : "";
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<RadixTooltip.Content
|
|
212
|
+
ref={(node) => {
|
|
213
|
+
contentRef.current = node;
|
|
214
|
+
if (typeof ref === "function") ref(node);
|
|
215
|
+
else if (ref) ref.current = node;
|
|
216
|
+
}}
|
|
217
|
+
className={[styles.content, "m-float"].join(" ")}
|
|
218
|
+
side={initialSide}
|
|
219
|
+
align={align}
|
|
220
|
+
sideOffset={sideOffset}
|
|
221
|
+
collisionPadding={8}
|
|
222
|
+
// side에 따라 tail 방향 패딩 확보
|
|
223
|
+
style={
|
|
224
|
+
{
|
|
225
|
+
"--tail": `${TAIL}px`,
|
|
226
|
+
} as React.CSSProperties
|
|
227
|
+
}
|
|
228
|
+
data-side-current={side}
|
|
229
|
+
>
|
|
230
|
+
{size && (
|
|
231
|
+
<svg
|
|
232
|
+
className={styles.shape}
|
|
233
|
+
width={size.w}
|
|
234
|
+
height={size.h}
|
|
235
|
+
viewBox={`0 0 ${size.w} ${size.h}`}
|
|
236
|
+
preserveAspectRatio="none"
|
|
237
|
+
aria-hidden="true"
|
|
238
|
+
>
|
|
239
|
+
<path d={d} className={styles.shapePath} />
|
|
240
|
+
</svg>
|
|
241
|
+
)}
|
|
242
|
+
<div className={styles.text}>{children}</div>
|
|
243
|
+
</RadixTooltip.Content>
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
CustomContent.displayName = "CustomContent";
|
|
247
|
+
|
|
248
|
+
export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
249
|
+
(
|
|
250
|
+
{
|
|
251
|
+
content,
|
|
252
|
+
children,
|
|
253
|
+
side = "top",
|
|
254
|
+
align = "center",
|
|
255
|
+
sideOffset = 6,
|
|
256
|
+
arrowOffset = 0,
|
|
257
|
+
followMouse = false,
|
|
258
|
+
delayDuration,
|
|
259
|
+
open,
|
|
260
|
+
onOpenChange,
|
|
261
|
+
arrow = true,
|
|
262
|
+
},
|
|
263
|
+
ref
|
|
264
|
+
) => {
|
|
265
|
+
const triggerRef = useRef<HTMLElement | null>(null);
|
|
266
|
+
const [mouseOffset, setMouseOffset] = useState(0);
|
|
267
|
+
|
|
268
|
+
// followMouse: 트리거 위에서의 마우스 좌표를 arrow 위치로 환산
|
|
269
|
+
useEffect(() => {
|
|
270
|
+
if (!followMouse) return;
|
|
271
|
+
const el = triggerRef.current;
|
|
272
|
+
if (!el) return;
|
|
273
|
+
const onMove = (e: MouseEvent) => {
|
|
274
|
+
const rect = el.getBoundingClientRect();
|
|
275
|
+
if (side === "top" || side === "bottom") {
|
|
276
|
+
const cx = rect.left + rect.width / 2;
|
|
277
|
+
setMouseOffset(e.clientX - cx);
|
|
278
|
+
} else {
|
|
279
|
+
const cy = rect.top + rect.height / 2;
|
|
280
|
+
setMouseOffset(e.clientY - cy);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
el.addEventListener("mousemove", onMove);
|
|
284
|
+
return () => el.removeEventListener("mousemove", onMove);
|
|
285
|
+
}, [followMouse, side]);
|
|
286
|
+
|
|
287
|
+
const effectiveArrowOffset = followMouse ? mouseOffset : arrowOffset;
|
|
288
|
+
|
|
289
|
+
return (
|
|
290
|
+
<RadixTooltip.Root
|
|
291
|
+
delayDuration={delayDuration}
|
|
292
|
+
open={open}
|
|
293
|
+
onOpenChange={onOpenChange}
|
|
294
|
+
>
|
|
295
|
+
<RadixTooltip.Trigger asChild ref={triggerRef as React.RefObject<HTMLButtonElement>}>
|
|
296
|
+
{children}
|
|
297
|
+
</RadixTooltip.Trigger>
|
|
298
|
+
<RadixTooltip.Portal>
|
|
299
|
+
<CustomContent
|
|
300
|
+
ref={ref}
|
|
301
|
+
initialSide={side}
|
|
302
|
+
align={align}
|
|
303
|
+
sideOffset={sideOffset}
|
|
304
|
+
arrowOffset={effectiveArrowOffset}
|
|
305
|
+
arrow={arrow}
|
|
306
|
+
>
|
|
307
|
+
{content}
|
|
308
|
+
</CustomContent>
|
|
309
|
+
</RadixTooltip.Portal>
|
|
310
|
+
</RadixTooltip.Root>
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
Tooltip.displayName = "Tooltip";
|
|
316
|
+
|
|
317
|
+
export const TooltipProvider = ({
|
|
318
|
+
delayDuration = 300,
|
|
319
|
+
skipDelayDuration = 300,
|
|
320
|
+
children,
|
|
321
|
+
}: {
|
|
322
|
+
delayDuration?: number;
|
|
323
|
+
skipDelayDuration?: number;
|
|
324
|
+
children: ReactNode;
|
|
325
|
+
}) => (
|
|
326
|
+
<RadixTooltip.Provider
|
|
327
|
+
delayDuration={delayDuration}
|
|
328
|
+
skipDelayDuration={skipDelayDuration}
|
|
329
|
+
>
|
|
330
|
+
{children}
|
|
331
|
+
</RadixTooltip.Provider>
|
|
332
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* Root ─────────────────────────────────────────────────
|
|
2
|
+
투명. 배경·보더·그림자 없음. children 자유 배치.
|
|
3
|
+
size는 높이만 결정 — padding/gap은 동일. */
|
|
4
|
+
.root {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: var(--space-2);
|
|
8
|
+
height: var(--topbar-h);
|
|
9
|
+
padding-inline: var(--space-5);
|
|
10
|
+
background: transparent;
|
|
11
|
+
border: 0;
|
|
12
|
+
box-shadow: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.root[data-size="sm"] {
|
|
16
|
+
height: var(--topbar-h-sm);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.root[data-size="md"] {
|
|
20
|
+
height: var(--topbar-h-md);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/* Spacer ───────────────────────────────────────────── */
|
|
24
|
+
.spacer {
|
|
25
|
+
flex: 1 1 auto;
|
|
26
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, type HTMLAttributes } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../_cn";
|
|
6
|
+
import styles from "./Topbar.module.css";
|
|
7
|
+
|
|
8
|
+
/* Root ─────────────────────────────────────────────────
|
|
9
|
+
자유 슬롯 컨테이너. 자체 표현(bg/border/shadow) 없음.
|
|
10
|
+
컨테이너 표현은 상위 AppFrame variant가 담당.
|
|
11
|
+
size는 세로 높이만 결정 (sm=얇게, md=기본). */
|
|
12
|
+
export type TopbarSize = "sm" | "md";
|
|
13
|
+
|
|
14
|
+
export interface TopbarProps extends HTMLAttributes<HTMLElement> {
|
|
15
|
+
size?: TopbarSize;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const TopbarRoot = forwardRef<HTMLElement, TopbarProps>(function TopbarRoot(
|
|
19
|
+
{ size = "md", className, children, ...rest },
|
|
20
|
+
ref,
|
|
21
|
+
) {
|
|
22
|
+
return (
|
|
23
|
+
<header
|
|
24
|
+
ref={ref}
|
|
25
|
+
className={cn(styles.root, className)}
|
|
26
|
+
data-size={size}
|
|
27
|
+
{...rest}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</header>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/* Spacer ───────────────────────────────────────────────
|
|
35
|
+
좌/우 정렬용 flex:1 빈 블록. */
|
|
36
|
+
function TopbarSpacer() {
|
|
37
|
+
return <div className={styles.spacer} aria-hidden />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type TopbarComponent = typeof TopbarRoot & {
|
|
41
|
+
Spacer: typeof TopbarSpacer;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const Topbar = TopbarRoot as TopbarComponent;
|
|
45
|
+
Topbar.Spacer = TopbarSpacer;
|
|
46
|
+
|
|
47
|
+
export { Topbar };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type OKLCH = { l: number; c: number; h: number };
|
|
2
|
+
|
|
3
|
+
export function hexToOklch(hex: string): OKLCH | null {
|
|
4
|
+
const rgb = hexToRgb(hex);
|
|
5
|
+
if (!rgb) return null;
|
|
6
|
+
const [lr, lg, lb] = rgb.map(srgbToLinear) as [number, number, number];
|
|
7
|
+
const l =
|
|
8
|
+
Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb);
|
|
9
|
+
const m =
|
|
10
|
+
Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb);
|
|
11
|
+
const s =
|
|
12
|
+
Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb);
|
|
13
|
+
const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
|
|
14
|
+
const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
15
|
+
const b = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
16
|
+
const C = Math.sqrt(a * a + b * b);
|
|
17
|
+
let H = (Math.atan2(b, a) * 180) / Math.PI;
|
|
18
|
+
if (H < 0) H += 360;
|
|
19
|
+
return { l: L, c: C, h: H };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function hexToHue(hex: string): number | null {
|
|
23
|
+
const oklch = hexToOklch(hex);
|
|
24
|
+
return oklch ? Math.round(oklch.h) : null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function isValidHex(hex: string): boolean {
|
|
28
|
+
return /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(hex.trim());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function hexToRgb(hex: string): [number, number, number] | null {
|
|
32
|
+
const clean = hex.trim().replace(/^#/, "");
|
|
33
|
+
if (!/^([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(clean)) return null;
|
|
34
|
+
const expanded =
|
|
35
|
+
clean.length === 3
|
|
36
|
+
? clean.split("").map((c) => c + c).join("")
|
|
37
|
+
: clean;
|
|
38
|
+
const num = parseInt(expanded, 16);
|
|
39
|
+
return [(num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff].map((v) => v / 255) as [
|
|
40
|
+
number,
|
|
41
|
+
number,
|
|
42
|
+
number,
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function srgbToLinear(v: number): number {
|
|
47
|
+
return v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
|
|
48
|
+
}
|