@behavioral-agentic-design-system/core 0.42.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +38 -8
- package/scripts/a11y-lint.cjs +101 -14
- package/scripts/bads-sync.mjs +1 -1
- package/scripts/build-tokens.cjs +122 -7
- package/scripts/check-dark-contrast.mjs +204 -0
- package/scripts/check-flush-edges.mjs +245 -0
- package/scripts/check-spec.mjs +73 -0
- package/scripts/deal-directions.mjs +186 -0
- package/scripts/design-system-advisory/README.md +239 -0
- package/scripts/design-system-advisory/check-copy-punctuation.mjs +44 -0
- package/scripts/design-system-advisory/check-even-padding.mjs +35 -0
- package/scripts/design-system-advisory/check-hand-built-button.mjs +46 -0
- package/scripts/design-system-advisory/check-html-nesting.mjs +51 -0
- package/scripts/design-system-advisory/check-icon-sizing.mjs +79 -0
- package/scripts/design-system-advisory/check-label-case.mjs +92 -0
- package/scripts/design-system-advisory/check-native-form-controls.mjs +53 -0
- package/scripts/design-system-advisory/check-radius.mjs +56 -0
- package/scripts/design-system-advisory/check-raw-values.mjs +61 -0
- package/scripts/design-system-advisory/check-small-text.mjs +72 -0
- package/scripts/design-system-advisory/check-tap-target.mjs +70 -0
- package/scripts/design-system-advisory/defaults.mjs +90 -0
- package/scripts/design-system-advisory/fixtures/clean.tsx.fixture +12 -0
- package/scripts/design-system-advisory/fixtures/violations.tsx.fixture +19 -0
- package/scripts/design-system-advisory/lib.mjs +255 -0
- package/scripts/design-system-advisory/run.mjs +189 -0
- package/scripts/design-system-advisory/workflow.yml +82 -0
- package/scripts/health-report.mjs +20 -14
- package/scripts/lib/copy-strings.mjs +146 -0
- package/scripts/lib/counted-lint.mjs +100 -0
- package/scripts/lib/dark-contrast.mjs +120 -0
- package/scripts/lib/flush-edges.mjs +294 -0
- package/scripts/lib/lab-lint.mjs +62 -0
- package/scripts/lib/marketing-library.mjs +129 -0
- package/scripts/lib/mount-page.mjs +25 -0
- package/scripts/lib/on-system.mjs +249 -0
- package/scripts/lib/random.mjs +22 -0
- package/scripts/lib/source-scan.mjs +173 -0
- package/scripts/lib/spec-parse.d.mts +25 -0
- package/scripts/lib/spec-parse.mjs +188 -0
- package/scripts/lib/tells.mjs +366 -0
- package/scripts/lint-arbitrary-tokens.mjs +47 -0
- package/scripts/lint-component-token-refs.mjs +63 -0
- package/scripts/lint-content-hierarchy.mjs +114 -0
- package/scripts/lint-control-baseline.mjs +72 -0
- package/scripts/lint-copy-punctuation.mjs +60 -0
- package/scripts/lint-css-vars.mjs +175 -0
- package/scripts/lint-even-padding.mjs +58 -0
- package/scripts/lint-html-nesting.mjs +116 -0
- package/scripts/lint-label-case.mjs +219 -0
- package/scripts/lint-live-ctas.mjs +138 -0
- package/scripts/lint-microanimation.mjs +2 -2
- package/scripts/lint-proximity.mjs +181 -0
- package/scripts/lint-slop.mjs +1 -1
- package/scripts/lint-spacing-scale.mjs +78 -0
- package/scripts/lint-target-size.cjs +132 -0
- package/scripts/lint-token-primitives.mjs +307 -0
- package/scripts/on-system-score.mjs +95 -0
- package/scripts/size-audit.cjs +2 -2
- package/scripts/slop-rules.mjs +1 -1
- package/scripts/source-images.mjs +180 -0
- package/scripts/ux-tells.mjs +80 -0
- package/scripts/wcag-audit.cjs +25 -4
- package/src/api/brand-colors.ts +3 -0
- package/src/api/brand-fonts.ts +3 -0
- package/src/api/brand-mark.ts +6 -1
- package/src/api/dev-write-guard.ts +53 -0
- package/src/api/layers/file.ts +9 -4
- package/src/api/onboarding-extract.ts +85 -30
- package/src/api/onboarding.ts +3 -0
- package/src/api/save-tokens.ts +3 -0
- package/src/api/site-auth.ts +14 -2
- package/src/app/layout.tsx +6 -0
- package/src/app/preview/canvas/page.tsx +12 -0
- package/src/app/preview/components/page.tsx +828 -14
- package/src/app/preview/sticker-sheet/page.tsx +329 -0
- package/src/app/preview/sticker-sheet/specimens.tsx +296 -0
- package/src/app/preview/studio/blank-screen.tsx +143 -0
- package/src/app/preview/studio/page.tsx +7 -0
- package/src/app/shell.tsx +164 -47
- package/src/components/Foundations/Colors.stories.tsx +119 -8
- package/src/components/canvas/canvas.tsx +458 -0
- package/src/components/canvas/layout.ts +72 -0
- package/src/components/canvas/parse-canvas.ts +32 -0
- package/src/components/canvas/sample.ts +90 -0
- package/src/components/canvas/spec-frame.tsx +43 -0
- package/src/components/canvas/types.ts +33 -0
- package/src/components/docs-tab.tsx +7 -7
- package/src/components/home-recent.tsx +73 -0
- package/src/components/home-tab.tsx +19 -14
- package/src/components/layers-tab.tsx +2 -2
- package/src/components/markdown-preview.tsx +60 -12
- package/src/components/onboarding-wizard.tsx +1 -1
- package/src/components/studio/control-panel.tsx +299 -0
- package/src/components/studio/control-row.tsx +77 -0
- package/src/components/studio/preview-frame.tsx +165 -0
- package/src/components/studio/preview-pane.tsx +247 -0
- package/src/components/studio/studio.tsx +133 -128
- package/src/components/studio/types.ts +218 -0
- package/src/components/studio/use-studio-tweaks.ts +128 -0
- package/src/components/studio/use-studio-view-state.ts +72 -0
- package/src/components/ui/autocomplete.tsx +1 -1
- package/src/components/ui/avatar.tsx +4 -0
- package/src/components/ui/chart.tsx +134 -42
- package/src/components/ui/checkbox-group.tsx +1 -1
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/color-picker.tsx +20 -4
- package/src/components/ui/combobox.tsx +1 -0
- package/src/components/ui/command.tsx +1 -1
- package/src/components/ui/data-table.tsx +64 -3
- package/src/components/ui/date-field.tsx +1 -1
- package/src/components/ui/date-picker.tsx +2 -0
- package/src/components/ui/date-range-picker.tsx +4 -0
- package/src/components/ui/editable.tsx +1 -0
- package/src/components/ui/faceted-filter.tsx +187 -0
- package/src/components/ui/file-upload.tsx +21 -2
- package/src/components/ui/gauge-chart.tsx +18 -4
- package/src/components/ui/heatmap.tsx +3 -1
- package/src/components/ui/inline-edit.tsx +175 -0
- package/src/components/ui/input-group.tsx +5 -2
- package/src/components/ui/month-picker.tsx +1 -1
- package/src/components/ui/multi-select.tsx +1 -0
- package/src/components/ui/number-input.tsx +28 -5
- package/src/components/ui/otp-input.tsx +208 -0
- package/src/components/ui/phone-input.tsx +274 -0
- package/src/components/ui/radio-group.tsx +2 -2
- package/src/components/ui/search-input.tsx +1 -1
- package/src/components/ui/sparkline.tsx +33 -4
- package/src/components/ui/spinner.tsx +23 -4
- package/src/components/ui/table.tsx +9 -0
- package/src/components/ui/tags-input.tsx +1 -1
- package/src/components/ui/timer.tsx +1 -0
- package/src/components/ui/transfer-list.tsx +13 -26
- package/src/components/ui/week-picker.tsx +1 -13
- package/src/components/ui/year-picker.tsx +1 -1
- package/src/data/component-added.json +966 -0
- package/src/data/docs-index.ts +35 -2
- package/src/data/history.json +161 -161
- package/src/data/sticker-sheet.json +9244 -0
- package/src/docs-trace-globs.json +1 -0
- package/src/hooks/use-global-mono-font.ts +1 -0
- package/src/hooks/use-global-primary-color.ts +1 -0
- package/src/hooks/use-global-sans-font.ts +1 -0
- package/src/hooks/use-global-serif-font.ts +1 -0
- package/src/hooks/use-global-type-scale.ts +17 -2
- package/src/hooks/use-mobile.ts +2 -0
- package/src/hooks/use-sync-type-scale.ts +7 -11
- package/src/lib/chart-motion.ts +41 -0
- package/src/lib/get-icon-color.ts +1 -1
- package/src/lib/spec-parse.ts +4 -0
- package/src/lib/svg-sanitize.ts +19 -9
- package/src/stories/Accordion.stories.tsx +7 -0
- package/src/stories/ActionBar.stories.tsx +5 -0
- package/src/stories/Affix.stories.tsx +4 -0
- package/src/stories/AiBadge.stories.tsx +9 -7
- package/src/stories/Alert.stories.tsx +13 -0
- package/src/stories/AlertDialog.stories.tsx +4 -0
- package/src/stories/Anchor.stories.tsx +5 -0
- package/src/stories/AngleSlider.stories.tsx +6 -3
- package/src/stories/AspectRatio.stories.tsx +4 -0
- package/src/stories/Autocomplete.stories.tsx +8 -0
- package/src/stories/Avatar.stories.tsx +10 -0
- package/src/stories/Badge.stories.tsx +14 -6
- package/src/stories/Blockquote.stories.tsx +6 -0
- package/src/stories/BottomNavigation.stories.tsx +4 -0
- package/src/stories/Breadcrumb.stories.tsx +3 -0
- package/src/stories/Burger.stories.tsx +1 -0
- package/src/stories/Button.stories.tsx +24 -0
- package/src/stories/ButtonGroup.stories.tsx +9 -0
- package/src/stories/Calendar.stories.tsx +3 -0
- package/src/stories/Canvas.stories.tsx +45 -0
- package/src/stories/Card.stories.tsx +4 -0
- package/src/stories/Carousel.stories.tsx +6 -0
- package/src/stories/Cascader.stories.tsx +4 -0
- package/src/stories/Chart.stories.tsx +46 -1
- package/src/stories/ChatBubble.stories.tsx +8 -2
- package/src/stories/ChatMarker.stories.tsx +1 -0
- package/src/stories/Checkbox.stories.tsx +40 -0
- package/src/stories/CheckboxCard.stories.tsx +8 -0
- package/src/stories/CheckboxGroup.stories.tsx +19 -0
- package/src/stories/Chip.stories.tsx +10 -19
- package/src/stories/CircularProgress.stories.tsx +13 -27
- package/src/stories/Clipboard.stories.tsx +6 -0
- package/src/stories/CloseButton.stories.tsx +6 -4
- package/src/stories/Code.stories.tsx +8 -1
- package/src/stories/Collapsible.stories.tsx +2 -0
- package/src/stories/ColorPicker.stories.tsx +46 -0
- package/src/stories/ColorSwatch.stories.tsx +1 -0
- package/src/stories/Combobox.stories.tsx +9 -0
- package/src/stories/Command.stories.tsx +2 -0
- package/src/stories/Container.stories.tsx +8 -0
- package/src/stories/ContextMenu.stories.tsx +9 -0
- package/src/stories/CopyButton.stories.tsx +12 -36
- package/src/stories/DataList.stories.tsx +8 -0
- package/src/stories/DataTable.stories.tsx +39 -0
- package/src/stories/DateField.stories.tsx +28 -0
- package/src/stories/DatePicker.stories.tsx +34 -0
- package/src/stories/DateRangePicker.stories.tsx +32 -0
- package/src/stories/Dialog.stories.tsx +8 -0
- package/src/stories/Drawer.stories.tsx +6 -0
- package/src/stories/DropdownMenu.stories.tsx +2 -0
- package/src/stories/Editable.stories.tsx +12 -0
- package/src/stories/EmptyState.stories.tsx +9 -0
- package/src/stories/FacetedFilter.stories.tsx +197 -0
- package/src/stories/Field.stories.tsx +7 -0
- package/src/stories/Fieldset.stories.tsx +8 -0
- package/src/stories/FileButton.stories.tsx +4 -0
- package/src/stories/FileUpload.stories.tsx +16 -17
- package/src/stories/FloatLabel.stories.tsx +3 -8
- package/src/stories/FloatingActionButton.stories.tsx +10 -0
- package/src/stories/FloatingIndicator.stories.tsx +4 -0
- package/src/stories/FloatingPanel.stories.tsx +6 -0
- package/src/stories/FocusTrap.stories.tsx +5 -0
- package/src/stories/FormatByte.stories.tsx +6 -0
- package/src/stories/FormatDate.stories.tsx +8 -0
- package/src/stories/FormatNumber.stories.tsx +9 -0
- package/src/stories/GaugeChart.stories.tsx +9 -3
- package/src/stories/Heatmap.stories.tsx +11 -0
- package/src/stories/Highlight.stories.tsx +6 -0
- package/src/stories/HoverCard.stories.tsx +4 -0
- package/src/stories/Image.stories.tsx +9 -0
- package/src/stories/Indicator.stories.tsx +19 -0
- package/src/stories/InlineEdit.stories.tsx +106 -0
- package/src/stories/Input.stories.tsx +7 -0
- package/src/stories/InputClearButton.stories.tsx +3 -0
- package/src/stories/InputGroup.stories.tsx +40 -0
- package/src/stories/Kbd.stories.tsx +7 -1
- package/src/stories/KeyboardShortcut.stories.tsx +2 -0
- package/src/stories/Label.stories.tsx +2 -0
- package/src/stories/Link.stories.tsx +9 -0
- package/src/stories/List.stories.tsx +8 -0
- package/src/stories/Listbox.stories.tsx +1 -0
- package/src/stories/LoadingDots.stories.tsx +5 -3
- package/src/stories/LoadingOverlay.stories.tsx +5 -1
- package/src/stories/Mark.stories.tsx +5 -0
- package/src/stories/MarkdownPreview.stories.tsx +53 -0
- package/src/stories/Marquee.stories.tsx +4 -0
- package/src/stories/Masonry.stories.tsx +5 -0
- package/src/stories/Menubar.stories.tsx +3 -0
- package/src/stories/Meter.stories.tsx +11 -17
- package/src/stories/MonthPicker.stories.tsx +26 -1
- package/src/stories/MotionToggle.stories.tsx +1 -0
- package/src/stories/MultiSelect.stories.tsx +9 -0
- package/src/stories/NativeSelect.stories.tsx +1 -0
- package/src/stories/NavLink.stories.tsx +7 -0
- package/src/stories/NavigationMenu.stories.tsx +5 -0
- package/src/stories/NavigationRail.stories.tsx +10 -0
- package/src/stories/Notification.stories.tsx +13 -34
- package/src/stories/NumberInput.stories.tsx +33 -1
- package/src/stories/OtpInput.stories.tsx +110 -0
- package/src/stories/Overlay.stories.tsx +5 -1
- package/src/stories/Pagination.stories.tsx +8 -0
- package/src/stories/PasswordInput.stories.tsx +2 -0
- package/src/stories/PhoneInput.stories.tsx +127 -0
- package/src/stories/PinInput.stories.tsx +9 -2
- package/src/stories/Popover.stories.tsx +2 -0
- package/src/stories/Progress.stories.tsx +6 -1
- package/src/stories/Prose.stories.tsx +8 -0
- package/src/stories/QrCode.stories.tsx +2 -0
- package/src/stories/Questionnaire.stories.tsx +7 -0
- package/src/stories/RadioGroup.stories.tsx +40 -0
- package/src/stories/RatingGroup.stories.tsx +8 -4
- package/src/stories/Resizable.stories.tsx +4 -2
- package/src/stories/Result.stories.tsx +3 -0
- package/src/stories/Reveal.stories.tsx +2 -0
- package/src/stories/RollingNumber.stories.tsx +5 -0
- package/src/stories/ScrollArea.stories.tsx +3 -1
- package/src/stories/SearchInput.stories.tsx +10 -6
- package/src/stories/SegmentedControl.stories.tsx +11 -0
- package/src/stories/Select.stories.tsx +7 -0
- package/src/stories/Separator.stories.tsx +6 -0
- package/src/stories/Sheet.stories.tsx +5 -0
- package/src/stories/Sidebar.stories.tsx +40 -1
- package/src/stories/SimpleGrid.stories.tsx +5 -0
- package/src/stories/Skeleton.stories.tsx +8 -0
- package/src/stories/SkeletonTable.stories.tsx +6 -5
- package/src/stories/SkipLink.stories.tsx +3 -0
- package/src/stories/Slider.stories.tsx +2 -1
- package/src/stories/Sonner.stories.tsx +7 -0
- package/src/stories/Sparkline.stories.tsx +14 -1
- package/src/stories/Spinner.stories.tsx +20 -10
- package/src/stories/Spoiler.stories.tsx +5 -0
- package/src/stories/Squircle.stories.tsx +7 -0
- package/src/stories/Stack.stories.tsx +7 -0
- package/src/stories/StatusBadge.stories.tsx +12 -6
- package/src/stories/Stepper.stories.tsx +5 -0
- package/src/stories/Switch.stories.tsx +4 -0
- package/src/stories/Table.stories.tsx +10 -1
- package/src/stories/Tabs.stories.tsx +8 -0
- package/src/stories/Tag.stories.tsx +13 -5
- package/src/stories/TagsInput.stories.tsx +15 -0
- package/src/stories/Text.stories.tsx +12 -0
- package/src/stories/Textarea.stories.tsx +9 -0
- package/src/stories/ThemeIcon.stories.tsx +6 -3
- package/src/stories/TimePicker.stories.tsx +2 -0
- package/src/stories/Timeline.stories.tsx +12 -0
- package/src/stories/Timer.stories.tsx +30 -0
- package/src/stories/Toggle.stories.tsx +7 -5
- package/src/stories/ToggleGroup.stories.tsx +5 -0
- package/src/stories/ToggleTip.stories.tsx +4 -0
- package/src/stories/Toolbar.stories.tsx +6 -0
- package/src/stories/Tooltip.stories.tsx +3 -0
- package/src/stories/Tour.stories.tsx +3 -0
- package/src/stories/TransferList.stories.tsx +7 -0
- package/src/stories/TreeSelect.stories.tsx +4 -0
- package/src/stories/TreeView.stories.tsx +5 -0
- package/src/stories/TypingIndicator.stories.tsx +4 -0
- package/src/stories/VisuallyHidden.stories.tsx +3 -0
- package/src/stories/Watermark.stories.tsx +6 -0
- package/src/stories/WeekPicker.stories.tsx +25 -1
- package/src/stories/WordRotate.stories.tsx +5 -0
- package/src/stories/YearPicker.stories.tsx +26 -11
- package/src/stories/story-groups.json +22 -16
- package/src/styles.css +50 -2
- package/src/tokens.json +86 -58
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import {
|
|
5
|
+
Columns2,
|
|
6
|
+
Maximize2,
|
|
7
|
+
Monitor,
|
|
8
|
+
Moon,
|
|
9
|
+
PanelLeftOpen,
|
|
10
|
+
Smartphone,
|
|
11
|
+
Sun,
|
|
12
|
+
SunMoon,
|
|
13
|
+
Tablet,
|
|
14
|
+
} from "lucide-react";
|
|
15
|
+
import { Button } from "../ui/button";
|
|
16
|
+
import { SegmentedControl, SegmentedControlItem } from "../ui/segmented-control";
|
|
17
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip";
|
|
18
|
+
import { PreviewFrame } from "./preview-frame";
|
|
19
|
+
import {
|
|
20
|
+
STUDIO_SUBJECTS,
|
|
21
|
+
STUDIO_THEMES,
|
|
22
|
+
STUDIO_VIEWPORTS,
|
|
23
|
+
type StudioPreviewTheme,
|
|
24
|
+
type StudioSubject,
|
|
25
|
+
type StudioViewport,
|
|
26
|
+
type StudioViewState,
|
|
27
|
+
} from "./types";
|
|
28
|
+
|
|
29
|
+
const VIEWPORT_ICON: Record<StudioViewport, ReactNode> = {
|
|
30
|
+
fill: <Maximize2 strokeWidth={1.5} aria-hidden="true" />,
|
|
31
|
+
"390": <Smartphone strokeWidth={1.5} aria-hidden="true" />,
|
|
32
|
+
"768": <Tablet strokeWidth={1.5} aria-hidden="true" />,
|
|
33
|
+
"1280": <Monitor strokeWidth={1.5} aria-hidden="true" />,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const VIEWPORT_LABEL: Record<StudioViewport, string> = {
|
|
37
|
+
fill: "Fill width",
|
|
38
|
+
"390": "390 pixels",
|
|
39
|
+
"768": "768 pixels",
|
|
40
|
+
"1280": "1280 pixels",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* One icon-only viewport option with a tooltip. It is a component with its own `value`
|
|
45
|
+
* prop (not a bare Tooltip child) so SegmentedControl can still count and index it.
|
|
46
|
+
*/
|
|
47
|
+
function ViewportItem({
|
|
48
|
+
value,
|
|
49
|
+
onSelect,
|
|
50
|
+
}: {
|
|
51
|
+
value: StudioViewport;
|
|
52
|
+
onSelect: (value: StudioViewport) => void;
|
|
53
|
+
}) {
|
|
54
|
+
return (
|
|
55
|
+
<Tooltip>
|
|
56
|
+
<TooltipTrigger asChild>
|
|
57
|
+
{/* Explicit onClick: the tooltip trigger's merged props spread after the item's own
|
|
58
|
+
handler, so without this the Radix onClick would replace the selection click. */}
|
|
59
|
+
<SegmentedControlItem
|
|
60
|
+
value={value}
|
|
61
|
+
aria-label={VIEWPORT_LABEL[value]}
|
|
62
|
+
className="min-w-11 px-2"
|
|
63
|
+
onClick={() => onSelect(value)}
|
|
64
|
+
>
|
|
65
|
+
{VIEWPORT_ICON[value]}
|
|
66
|
+
</SegmentedControlItem>
|
|
67
|
+
</TooltipTrigger>
|
|
68
|
+
<TooltipContent>{VIEWPORT_LABEL[value]}</TooltipContent>
|
|
69
|
+
</Tooltip>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const THEME_ICON: Record<StudioPreviewTheme, ReactNode> = {
|
|
74
|
+
match: <SunMoon strokeWidth={1.5} aria-hidden="true" />,
|
|
75
|
+
light: <Sun strokeWidth={1.5} aria-hidden="true" />,
|
|
76
|
+
dark: <Moon strokeWidth={1.5} aria-hidden="true" />,
|
|
77
|
+
both: <Columns2 strokeWidth={1.5} aria-hidden="true" />,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Icon-only theme option with a tooltip; accessible name stays the visible label. */
|
|
81
|
+
function ThemeItem({
|
|
82
|
+
value,
|
|
83
|
+
label,
|
|
84
|
+
onSelect,
|
|
85
|
+
}: {
|
|
86
|
+
value: StudioPreviewTheme;
|
|
87
|
+
label: string;
|
|
88
|
+
onSelect: (value: StudioPreviewTheme) => void;
|
|
89
|
+
}) {
|
|
90
|
+
return (
|
|
91
|
+
<Tooltip>
|
|
92
|
+
<TooltipTrigger asChild>
|
|
93
|
+
<SegmentedControlItem
|
|
94
|
+
value={value}
|
|
95
|
+
aria-label={label}
|
|
96
|
+
className="min-w-11 px-2"
|
|
97
|
+
onClick={() => onSelect(value)}
|
|
98
|
+
>
|
|
99
|
+
{THEME_ICON[value]}
|
|
100
|
+
</SegmentedControlItem>
|
|
101
|
+
</TooltipTrigger>
|
|
102
|
+
<TooltipContent>{label}</TooltipContent>
|
|
103
|
+
</Tooltip>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function subjectLabel(subject: StudioSubject): string {
|
|
108
|
+
return STUDIO_SUBJECTS.find((s) => s.value === subject)?.label ?? subject;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function themeLabel(theme: StudioPreviewTheme): string {
|
|
112
|
+
return STUDIO_THEMES.find((t) => t.value === theme)?.label ?? theme;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function PreviewPane({
|
|
116
|
+
view,
|
|
117
|
+
setView,
|
|
118
|
+
appDark,
|
|
119
|
+
isMobile,
|
|
120
|
+
onExpandControls,
|
|
121
|
+
}: {
|
|
122
|
+
view: StudioViewState;
|
|
123
|
+
setView: <K extends keyof StudioViewState>(key: K, value: StudioViewState[K]) => void;
|
|
124
|
+
appDark: boolean;
|
|
125
|
+
isMobile: boolean;
|
|
126
|
+
/** Non-null only while the controls pane is collapsed. */
|
|
127
|
+
onExpandControls: (() => void) | null;
|
|
128
|
+
}) {
|
|
129
|
+
// On mobile there is one frame at Fill and no Both. The URL may still say otherwise.
|
|
130
|
+
const theme: StudioPreviewTheme = isMobile && view.theme === "both" ? "match" : view.theme;
|
|
131
|
+
const viewport: StudioViewport = isMobile ? "fill" : view.viewport;
|
|
132
|
+
const both = theme === "both";
|
|
133
|
+
const width = both ? null : (STUDIO_VIEWPORTS.find((v) => v.value === viewport)?.width ?? null);
|
|
134
|
+
|
|
135
|
+
const subject = STUDIO_SUBJECTS.find((s) => s.value === view.subject) ?? STUDIO_SUBJECTS[0];
|
|
136
|
+
|
|
137
|
+
const forcedFor = (t: StudioPreviewTheme): boolean | null =>
|
|
138
|
+
t === "match" ? null : t === "dark";
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<TooltipProvider>
|
|
142
|
+
<div data-slot="studio-preview-pane" className="flex h-full min-h-0 min-w-0 flex-col">
|
|
143
|
+
<div className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 px-2 py-1">
|
|
144
|
+
{onExpandControls ? (
|
|
145
|
+
<Tooltip>
|
|
146
|
+
<TooltipTrigger asChild>
|
|
147
|
+
<Button
|
|
148
|
+
variant="ghost"
|
|
149
|
+
size="icon-xl"
|
|
150
|
+
aria-label="Show controls"
|
|
151
|
+
onClick={onExpandControls}
|
|
152
|
+
>
|
|
153
|
+
<PanelLeftOpen strokeWidth={1.5} aria-hidden="true" />
|
|
154
|
+
</Button>
|
|
155
|
+
</TooltipTrigger>
|
|
156
|
+
<TooltipContent>Show controls</TooltipContent>
|
|
157
|
+
</Tooltip>
|
|
158
|
+
) : null}
|
|
159
|
+
|
|
160
|
+
<SegmentedControl
|
|
161
|
+
label="Preview subject"
|
|
162
|
+
value={view.subject}
|
|
163
|
+
onValueChange={(v) => setView("subject", v as StudioSubject)}
|
|
164
|
+
>
|
|
165
|
+
{STUDIO_SUBJECTS.map((s) => (
|
|
166
|
+
<SegmentedControlItem key={s.value} value={s.value} className="px-2">
|
|
167
|
+
{s.label}
|
|
168
|
+
</SegmentedControlItem>
|
|
169
|
+
))}
|
|
170
|
+
</SegmentedControl>
|
|
171
|
+
|
|
172
|
+
{isMobile ? null : (
|
|
173
|
+
<>
|
|
174
|
+
<SegmentedControl
|
|
175
|
+
label="Preview width"
|
|
176
|
+
value={viewport}
|
|
177
|
+
disabled={both}
|
|
178
|
+
onValueChange={(v) => setView("viewport", v as StudioViewport)}
|
|
179
|
+
>
|
|
180
|
+
{STUDIO_VIEWPORTS.map((v) => (
|
|
181
|
+
<ViewportItem
|
|
182
|
+
key={v.value}
|
|
183
|
+
value={v.value}
|
|
184
|
+
onSelect={(next) => setView("viewport", next)}
|
|
185
|
+
/>
|
|
186
|
+
))}
|
|
187
|
+
</SegmentedControl>
|
|
188
|
+
|
|
189
|
+
<SegmentedControl
|
|
190
|
+
label="Preview theme"
|
|
191
|
+
value={theme}
|
|
192
|
+
onValueChange={(v) => setView("theme", v as StudioPreviewTheme)}
|
|
193
|
+
>
|
|
194
|
+
{STUDIO_THEMES.map((t) => (
|
|
195
|
+
<ThemeItem
|
|
196
|
+
key={t.value}
|
|
197
|
+
value={t.value}
|
|
198
|
+
label={t.label}
|
|
199
|
+
onSelect={(next) => setView("theme", next)}
|
|
200
|
+
/>
|
|
201
|
+
))}
|
|
202
|
+
</SegmentedControl>
|
|
203
|
+
</>
|
|
204
|
+
)}
|
|
205
|
+
|
|
206
|
+
{both ? (
|
|
207
|
+
<p className="ml-auto min-w-0 truncate text-xs text-muted-foreground">
|
|
208
|
+
Width follows the pane in Both
|
|
209
|
+
</p>
|
|
210
|
+
) : null}
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<div className="flex min-h-0 flex-1 gap-4 bg-muted p-4">
|
|
214
|
+
{both ? (
|
|
215
|
+
<>
|
|
216
|
+
<PreviewFrame
|
|
217
|
+
src={subject.src}
|
|
218
|
+
forcedDark={false}
|
|
219
|
+
appDark={appDark}
|
|
220
|
+
width={null}
|
|
221
|
+
caption="Light"
|
|
222
|
+
title={`Studio preview, ${subjectLabel(view.subject)}, Light`}
|
|
223
|
+
/>
|
|
224
|
+
<PreviewFrame
|
|
225
|
+
src={subject.src}
|
|
226
|
+
forcedDark={true}
|
|
227
|
+
appDark={appDark}
|
|
228
|
+
width={null}
|
|
229
|
+
caption="Dark"
|
|
230
|
+
title={`Studio preview, ${subjectLabel(view.subject)}, Dark`}
|
|
231
|
+
/>
|
|
232
|
+
</>
|
|
233
|
+
) : (
|
|
234
|
+
<PreviewFrame
|
|
235
|
+
src={subject.src}
|
|
236
|
+
forcedDark={forcedFor(theme)}
|
|
237
|
+
appDark={appDark}
|
|
238
|
+
width={width}
|
|
239
|
+
caption={themeLabel(theme)}
|
|
240
|
+
title={`Studio preview, ${subjectLabel(view.subject)}, ${themeLabel(theme)}`}
|
|
241
|
+
/>
|
|
242
|
+
)}
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
</TooltipProvider>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
@@ -1,153 +1,158 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import DashboardDemo from "@/components/examples/dashboard";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { usePanelRef } from "react-resizable-panels";
|
|
5
|
+
import {
|
|
6
|
+
ResizableHandle,
|
|
7
|
+
ResizablePanel,
|
|
8
|
+
ResizablePanelGroup,
|
|
9
|
+
} from "@behavioral-agentic-design-system/core/components/ui/resizable";
|
|
11
10
|
import {
|
|
12
11
|
SegmentedControl,
|
|
13
12
|
SegmentedControlItem,
|
|
14
13
|
} from "@behavioral-agentic-design-system/core/components/ui/segmented-control";
|
|
14
|
+
import { useIsMobile } from "@behavioral-agentic-design-system/core/hooks/use-mobile";
|
|
15
|
+
import { ControlPanel } from "./control-panel";
|
|
16
|
+
import { PreviewPane } from "./preview-pane";
|
|
17
|
+
import { useStudioViewState } from "./use-studio-view-state";
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
|
-
* Studio
|
|
18
|
-
*
|
|
19
|
-
* Replaces the Customize tab, and absorbs what Cards showed. The problem it
|
|
20
|
-
* solves is that those were separate destinations: you changed a token in one
|
|
21
|
-
* and had to navigate to another to see what it did, which meant the authoring
|
|
22
|
-
* surface could not show you the consequence of authoring.
|
|
23
|
-
*
|
|
24
|
-
* ONE architectural constraint decides this whole component, and it is why the
|
|
25
|
-
* specimens are rendered INLINE rather than in an <IframePreview> like every
|
|
26
|
-
* other showcase surface:
|
|
27
|
-
*
|
|
28
|
-
* `useTokenOverrides` writes to `document.documentElement.style`.
|
|
29
|
-
*
|
|
30
|
-
* An iframe is a separate document with its own documentElement, so an iframed
|
|
31
|
-
* specimen would keep its old values until reloaded. Inline, the specimens sit
|
|
32
|
-
* under the same root the overrides are written to, so a colour change repaints
|
|
33
|
-
* them on the same frame with no wiring at all. Do not "tidy" this into an
|
|
34
|
-
* iframe later — the live repaint is the feature, and the iframe is what broke
|
|
35
|
-
* it in the first place.
|
|
20
|
+
* Studio: tweak on the left, see the result on the right.
|
|
36
21
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
22
|
+
* Plan: docs/plans/2026-10-07-studio-screen.md. Token values live in the
|
|
23
|
+
* existing global hooks (localStorage plus storage events). View state
|
|
24
|
+
* (subject, width, theme, panel mode, collapse) lives in the URL.
|
|
39
25
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
26
|
+
* The preview is an iframe. The old comment here claimed an iframe would keep
|
|
27
|
+
* stale values; that was measured and does not hold, because every preview
|
|
28
|
+
* route mounts the global hooks, which listen for the `storage` event (see the
|
|
29
|
+
* first acceptance criterion of WP3 in the plan). The iframe is what gives an
|
|
30
|
+
* independent theme and real viewport widths.
|
|
45
31
|
*/
|
|
46
32
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const SPECIMENS = [
|
|
52
|
-
{ id: "cards", label: "Cards" },
|
|
53
|
-
{ id: "dashboard", label: "Dashboard" },
|
|
54
|
-
] as const;
|
|
33
|
+
function isTypingTarget(el: EventTarget | null): boolean {
|
|
34
|
+
if (!(el instanceof HTMLElement)) return false;
|
|
35
|
+
return el.closest("input, textarea, select, [contenteditable]:not([contenteditable='false'])") !== null;
|
|
36
|
+
}
|
|
55
37
|
|
|
56
|
-
export default function Studio() {
|
|
57
|
-
const
|
|
58
|
-
const
|
|
38
|
+
export default function Studio({ dark }: { dark: boolean }) {
|
|
39
|
+
const { state: view, set } = useStudioViewState();
|
|
40
|
+
const isMobile = useIsMobile();
|
|
41
|
+
const panelRef = usePanelRef();
|
|
42
|
+
const [mobileView, setMobileView] = useState<"tweak" | "preview">("tweak");
|
|
59
43
|
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (typeof window === "undefined") return;
|
|
64
|
-
try {
|
|
65
|
-
if (window.localStorage.getItem(COLLAPSE_KEY) === "1") setCollapsed(true);
|
|
66
|
-
} catch {
|
|
67
|
-
// Storage disabled — open is the safe default.
|
|
68
|
-
}
|
|
69
|
-
});
|
|
44
|
+
// Latest collapse flag for callbacks that must not close over a stale value.
|
|
45
|
+
const collapsedRef = useRef(view.controlsCollapsed);
|
|
46
|
+
collapsedRef.current = view.controlsCollapsed;
|
|
70
47
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return next;
|
|
48
|
+
// View state drives the panel: covers the URL restore after mount.
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (isMobile) return;
|
|
51
|
+
const panel = panelRef.current;
|
|
52
|
+
if (!panel) return;
|
|
53
|
+
const id = requestAnimationFrame(() => {
|
|
54
|
+
if (view.controlsCollapsed && !panel.isCollapsed()) panel.collapse();
|
|
55
|
+
else if (!view.controlsCollapsed && panel.isCollapsed()) panel.expand();
|
|
80
56
|
});
|
|
81
|
-
|
|
57
|
+
return () => cancelAnimationFrame(id);
|
|
58
|
+
}, [view.controlsCollapsed, isMobile, panelRef]);
|
|
82
59
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<Button
|
|
91
|
-
variant="ghost"
|
|
92
|
-
size="icon"
|
|
93
|
-
onClick={toggle}
|
|
94
|
-
aria-label="Collapse controls"
|
|
95
|
-
className="size-11"
|
|
96
|
-
>
|
|
97
|
-
<PanelLeftClose className="size-4" strokeWidth={1.5} />
|
|
98
|
-
</Button>
|
|
99
|
-
</div>
|
|
100
|
-
<ScrollArea className="min-h-0 flex-1">
|
|
101
|
-
{/* The existing, working panels — re-housed, not rewritten. They
|
|
102
|
-
already carry their own previews (swatches, font specimens),
|
|
103
|
-
which is what makes a decision legible instead of a raw value. */}
|
|
104
|
-
<div className="flex flex-col gap-10 px-4 py-5">
|
|
105
|
-
{/* Re-homed here when Studio replaced CustomizeTab. Renders null
|
|
106
|
-
on a single-discipline fork, so upstream sees nothing. */}
|
|
107
|
-
<DisciplineSection />
|
|
108
|
-
<ColorPalette />
|
|
109
|
-
</div>
|
|
110
|
-
</ScrollArea>
|
|
111
|
-
</div>
|
|
112
|
-
)}
|
|
60
|
+
// The panel drives view state: covers drag-to-collapse and the keyboard.
|
|
61
|
+
const handleResize = useCallback(() => {
|
|
62
|
+
const panel = panelRef.current;
|
|
63
|
+
if (!panel) return;
|
|
64
|
+
const collapsed = panel.isCollapsed();
|
|
65
|
+
if (collapsed !== collapsedRef.current) set("controlsCollapsed", collapsed);
|
|
66
|
+
}, [panelRef, set]);
|
|
113
67
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
68
|
+
const collapse = useCallback(() => set("controlsCollapsed", true), [set]);
|
|
69
|
+
const expand = useCallback(() => set("controlsCollapsed", false), [set]);
|
|
70
|
+
|
|
71
|
+
// Mod+\ toggles the controls (Figma's hide-UI chord). Ignored while typing.
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (isMobile) return;
|
|
74
|
+
const onKey = (e: KeyboardEvent) => {
|
|
75
|
+
if (!(e.metaKey || e.ctrlKey) || e.key !== "\\") return;
|
|
76
|
+
if (isTypingTarget(e.target)) return;
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
set("controlsCollapsed", !collapsedRef.current);
|
|
79
|
+
};
|
|
80
|
+
window.addEventListener("keydown", onKey);
|
|
81
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
82
|
+
}, [isMobile, set]);
|
|
83
|
+
|
|
84
|
+
const preview = (
|
|
85
|
+
<PreviewPane
|
|
86
|
+
view={view}
|
|
87
|
+
setView={set}
|
|
88
|
+
appDark={dark}
|
|
89
|
+
isMobile={isMobile}
|
|
90
|
+
onExpandControls={view.controlsCollapsed ? expand : null}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
if (isMobile) {
|
|
95
|
+
return (
|
|
96
|
+
<div className="flex size-full min-h-0 flex-col">
|
|
97
|
+
<div className="flex shrink-0 items-center px-4 py-2">
|
|
128
98
|
<SegmentedControl
|
|
129
|
-
value={
|
|
130
|
-
onValueChange={
|
|
131
|
-
label="
|
|
99
|
+
value={mobileView}
|
|
100
|
+
onValueChange={(v) => setMobileView(v as "tweak" | "preview")}
|
|
101
|
+
label="Studio view"
|
|
132
102
|
>
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
{s.label}
|
|
136
|
-
</SegmentedControlItem>
|
|
137
|
-
))}
|
|
103
|
+
<SegmentedControlItem value="tweak">Controls</SegmentedControlItem>
|
|
104
|
+
<SegmentedControlItem value="preview">Preview</SegmentedControlItem>
|
|
138
105
|
</SegmentedControl>
|
|
139
|
-
<p className="truncate text-sm text-muted-foreground">
|
|
140
|
-
Real compositions. They repaint as you change a value.
|
|
141
|
-
</p>
|
|
142
106
|
</div>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
</
|
|
107
|
+
{/* Both stay mounted so the iframe never cold-loads twice. */}
|
|
108
|
+
<div className="min-h-0 flex-1" hidden={mobileView !== "tweak"}>
|
|
109
|
+
<ControlPanel
|
|
110
|
+
mode={view.panel}
|
|
111
|
+
onModeChange={(m) => set("panel", m)}
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
<div className="min-h-0 flex-1" hidden={mobileView !== "preview"}>
|
|
115
|
+
{preview}
|
|
116
|
+
</div>
|
|
150
117
|
</div>
|
|
151
|
-
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<ResizablePanelGroup
|
|
123
|
+
orientation="horizontal"
|
|
124
|
+
className="size-full min-h-0"
|
|
125
|
+
resizeTargetMinimumSize={{ coarse: 44, fine: 44 }}
|
|
126
|
+
>
|
|
127
|
+
<ResizablePanel
|
|
128
|
+
id="studio-controls"
|
|
129
|
+
panelRef={panelRef}
|
|
130
|
+
defaultSize="340px"
|
|
131
|
+
minSize="280px"
|
|
132
|
+
maxSize="480px"
|
|
133
|
+
collapsible
|
|
134
|
+
collapsedSize="0px"
|
|
135
|
+
onResize={handleResize}
|
|
136
|
+
>
|
|
137
|
+
<div className="h-full min-h-0 overflow-hidden">
|
|
138
|
+
<ControlPanel
|
|
139
|
+
mode={view.panel}
|
|
140
|
+
onModeChange={(m) => set("panel", m)}
|
|
141
|
+
onCollapse={collapse}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
</ResizablePanel>
|
|
145
|
+
<ResizableHandle
|
|
146
|
+
className="bg-transparent after:w-11"
|
|
147
|
+
aria-label="Resize controls"
|
|
148
|
+
style={{
|
|
149
|
+
transitionDuration: "var(--duration-fast)",
|
|
150
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
<ResizablePanel id="studio-preview" minSize="360px">
|
|
154
|
+
<div className="h-full min-h-0 min-w-0">{preview}</div>
|
|
155
|
+
</ResizablePanel>
|
|
156
|
+
</ResizablePanelGroup>
|
|
152
157
|
);
|
|
153
158
|
}
|