@contui/ui 0.0.0-stage → 0.1.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/LICENSE +30 -0
- package/README.md +150 -2
- package/cli/contui.mjs +250 -0
- package/dist/charts/area-chart.d.ts +8 -0
- package/dist/charts/area-chart.js +9 -0
- package/dist/charts/bar-chart.d.ts +9 -0
- package/dist/charts/bar-chart.js +10 -0
- package/dist/charts/bubble-chart.d.ts +60 -0
- package/dist/charts/bubble-chart.js +392 -0
- package/dist/charts/bullet-chart.d.ts +53 -0
- package/dist/charts/bullet-chart.js +123 -0
- package/dist/charts/candlestick-chart.d.ts +77 -0
- package/dist/charts/candlestick-chart.js +558 -0
- package/dist/charts/cartesian.d.ts +121 -0
- package/dist/charts/cartesian.js +625 -0
- package/dist/charts/chart-card.d.ts +80 -0
- package/dist/charts/chart-card.js +114 -0
- package/dist/charts/donut-chart.d.ts +40 -0
- package/dist/charts/donut-chart.js +88 -0
- package/dist/charts/funnel-chart.d.ts +16 -0
- package/dist/charts/funnel-chart.js +164 -0
- package/dist/charts/horizontal-bar-chart.d.ts +67 -0
- package/dist/charts/horizontal-bar-chart.js +481 -0
- package/dist/charts/index.d.ts +21 -0
- package/dist/charts/index.js +32 -0
- package/dist/charts/legend.d.ts +23 -0
- package/dist/charts/legend.js +22 -0
- package/dist/charts/lib/candlestick-window.d.ts +15 -0
- package/dist/charts/lib/candlestick-window.js +23 -0
- package/dist/charts/lib/color.d.ts +39 -0
- package/dist/charts/lib/color.js +83 -0
- package/dist/charts/lib/format.d.ts +11 -0
- package/dist/charts/lib/format.js +33 -0
- package/dist/charts/lib/frame.d.ts +6 -0
- package/dist/charts/lib/frame.js +6 -0
- package/dist/charts/lib/layout.d.ts +11 -0
- package/dist/charts/lib/layout.js +71 -0
- package/dist/charts/lib/path.d.ts +35 -0
- package/dist/charts/lib/path.js +203 -0
- package/dist/charts/lib/scale.d.ts +41 -0
- package/dist/charts/lib/scale.js +80 -0
- package/dist/charts/lib/use-active.d.ts +18 -0
- package/dist/charts/lib/use-active.js +71 -0
- package/dist/charts/lib/use-size.d.ts +9 -0
- package/dist/charts/lib/use-size.js +40 -0
- package/dist/charts/line-chart.d.ts +7 -0
- package/dist/charts/line-chart.js +8 -0
- package/dist/charts/radar-chart.d.ts +27 -0
- package/dist/charts/radar-chart.js +165 -0
- package/dist/charts/rose-chart.d.ts +35 -0
- package/dist/charts/rose-chart.js +242 -0
- package/dist/charts/sparkline.d.ts +35 -0
- package/dist/charts/sparkline.js +110 -0
- package/dist/charts/tooltip.d.ts +35 -0
- package/dist/charts/tooltip.js +22 -0
- package/dist/charts/treemap.d.ts +28 -0
- package/dist/charts/treemap.js +103 -0
- package/dist/charts/uptime-strip.d.ts +40 -0
- package/dist/charts/uptime-strip.js +178 -0
- package/dist/components/accordion.d.ts +31 -0
- package/dist/components/accordion.js +34 -0
- package/dist/components/activity-item.d.ts +12 -0
- package/dist/components/activity-item.js +6 -0
- package/dist/components/alert.d.ts +21 -0
- package/dist/components/alert.js +58 -0
- package/dist/components/assistant-answer.d.ts +52 -0
- package/dist/components/assistant-answer.js +40 -0
- package/dist/components/assistant-prompt.d.ts +63 -0
- package/dist/components/assistant-prompt.js +122 -0
- package/dist/components/avatar.d.ts +28 -0
- package/dist/components/avatar.js +75 -0
- package/dist/components/badge.d.ts +16 -0
- package/dist/components/badge.js +33 -0
- package/dist/components/bar-list.d.ts +65 -0
- package/dist/components/bar-list.js +119 -0
- package/dist/components/block-slider.d.ts +43 -0
- package/dist/components/block-slider.js +63 -0
- package/dist/components/branch-graph.d.ts +87 -0
- package/dist/components/branch-graph.js +231 -0
- package/dist/components/breadcrumb.d.ts +41 -0
- package/dist/components/breadcrumb.js +53 -0
- package/dist/components/button.d.ts +23 -0
- package/dist/components/button.js +108 -0
- package/dist/components/calendar.d.ts +5 -0
- package/dist/components/calendar.js +90 -0
- package/dist/components/card.d.ts +65 -0
- package/dist/components/card.js +104 -0
- package/dist/components/chat-attachment.d.ts +47 -0
- package/dist/components/chat-attachment.js +63 -0
- package/dist/components/chat-event.d.ts +7 -0
- package/dist/components/chat-event.js +7 -0
- package/dist/components/chat-message.d.ts +59 -0
- package/dist/components/chat-message.js +91 -0
- package/dist/components/chat-reference.d.ts +20 -0
- package/dist/components/chat-reference.js +41 -0
- package/dist/components/chat-shared.d.ts +21 -0
- package/dist/components/chat-shared.js +23 -0
- package/dist/components/chat-suggestions.d.ts +59 -0
- package/dist/components/chat-suggestions.js +88 -0
- package/dist/components/chat-thread.d.ts +39 -0
- package/dist/components/chat-thread.js +172 -0
- package/dist/components/chat-typing.d.ts +35 -0
- package/dist/components/chat-typing.js +66 -0
- package/dist/components/checkbox.d.ts +18 -0
- package/dist/components/checkbox.js +33 -0
- package/dist/components/checklist.d.ts +26 -0
- package/dist/components/checklist.js +18 -0
- package/dist/components/chip.d.ts +29 -0
- package/dist/components/chip.js +61 -0
- package/dist/components/code-input.d.ts +40 -0
- package/dist/components/code-input.js +285 -0
- package/dist/components/color-picker.d.ts +38 -0
- package/dist/components/color-picker.js +855 -0
- package/dist/components/combobox.d.ts +75 -0
- package/dist/components/combobox.js +112 -0
- package/dist/components/command-menu.d.ts +58 -0
- package/dist/components/command-menu.js +166 -0
- package/dist/components/copy-button.d.ts +16 -0
- package/dist/components/copy-button.js +31 -0
- package/dist/components/data-grid.d.ts +50 -0
- package/dist/components/data-grid.js +599 -0
- package/dist/components/date-picker.d.ts +109 -0
- package/dist/components/date-picker.js +268 -0
- package/dist/components/description-list.d.ts +12 -0
- package/dist/components/description-list.js +10 -0
- package/dist/components/dialog.d.ts +57 -0
- package/dist/components/dialog.js +140 -0
- package/dist/components/dock.d.ts +45 -0
- package/dist/components/dock.js +79 -0
- package/dist/components/drop-zone.d.ts +46 -0
- package/dist/components/drop-zone.js +101 -0
- package/dist/components/dropdown-menu.d.ts +50 -0
- package/dist/components/dropdown-menu.js +78 -0
- package/dist/components/editable-cell.d.ts +34 -0
- package/dist/components/editable-cell.js +89 -0
- package/dist/components/empty-state.d.ts +17 -0
- package/dist/components/empty-state.js +9 -0
- package/dist/components/field.d.ts +43 -0
- package/dist/components/field.js +75 -0
- package/dist/components/filter-condition.d.ts +188 -0
- package/dist/components/filter-condition.js +113 -0
- package/dist/components/filter-menu.d.ts +57 -0
- package/dist/components/filter-menu.js +46 -0
- package/dist/components/header-bar.d.ts +84 -0
- package/dist/components/header-bar.js +94 -0
- package/dist/components/hold-button.d.ts +15 -0
- package/dist/components/hold-button.js +88 -0
- package/dist/components/icon-tile.d.ts +12 -0
- package/dist/components/icon-tile.js +29 -0
- package/dist/components/info-tip.d.ts +13 -0
- package/dist/components/info-tip.js +26 -0
- package/dist/components/input.d.ts +17 -0
- package/dist/components/input.js +83 -0
- package/dist/components/kbd.d.ts +6 -0
- package/dist/components/kbd.js +7 -0
- package/dist/components/menu-item.d.ts +56 -0
- package/dist/components/menu-item.js +94 -0
- package/dist/components/message-composer.d.ts +75 -0
- package/dist/components/message-composer.js +199 -0
- package/dist/components/nav-rail.d.ts +31 -0
- package/dist/components/nav-rail.js +85 -0
- package/dist/components/notice.d.ts +45 -0
- package/dist/components/notice.js +66 -0
- package/dist/components/optimistic-undo.d.ts +28 -0
- package/dist/components/optimistic-undo.js +43 -0
- package/dist/components/option-row.d.ts +15 -0
- package/dist/components/option-row.js +14 -0
- package/dist/components/page-content.d.ts +11 -0
- package/dist/components/page-content.js +31 -0
- package/dist/components/pagination.d.ts +34 -0
- package/dist/components/pagination.js +41 -0
- package/dist/components/popover.d.ts +27 -0
- package/dist/components/popover.js +25 -0
- package/dist/components/progress.d.ts +33 -0
- package/dist/components/progress.js +75 -0
- package/dist/components/radio-group.d.ts +7 -0
- package/dist/components/radio-group.js +33 -0
- package/dist/components/readonly-field.d.ts +33 -0
- package/dist/components/readonly-field.js +80 -0
- package/dist/components/segmented-control.d.ts +21 -0
- package/dist/components/segmented-control.js +108 -0
- package/dist/components/select.d.ts +42 -0
- package/dist/components/select.js +86 -0
- package/dist/components/separator.d.ts +10 -0
- package/dist/components/separator.js +7 -0
- package/dist/components/setting-row.d.ts +53 -0
- package/dist/components/setting-row.js +93 -0
- package/dist/components/sidebar-switcher.d.ts +47 -0
- package/dist/components/sidebar-switcher.js +20 -0
- package/dist/components/sidebar.d.ts +220 -0
- package/dist/components/sidebar.js +327 -0
- package/dist/components/skeleton.d.ts +18 -0
- package/dist/components/skeleton.js +23 -0
- package/dist/components/slider.d.ts +15 -0
- package/dist/components/slider.js +28 -0
- package/dist/components/spinner.d.ts +14 -0
- package/dist/components/spinner.js +19 -0
- package/dist/components/status-dot.d.ts +24 -0
- package/dist/components/status-dot.js +35 -0
- package/dist/components/stepper.d.ts +60 -0
- package/dist/components/stepper.js +197 -0
- package/dist/components/switch.d.ts +9 -0
- package/dist/components/switch.js +26 -0
- package/dist/components/table-cell.d.ts +38 -0
- package/dist/components/table-cell.js +107 -0
- package/dist/components/table-context.d.ts +48 -0
- package/dist/components/table-context.js +69 -0
- package/dist/components/table-head.d.ts +42 -0
- package/dist/components/table-head.js +188 -0
- package/dist/components/table-tree.d.ts +96 -0
- package/dist/components/table-tree.js +137 -0
- package/dist/components/table.d.ts +78 -0
- package/dist/components/table.js +119 -0
- package/dist/components/tabs.d.ts +27 -0
- package/dist/components/tabs.js +79 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/textarea.js +20 -0
- package/dist/components/theme.d.ts +41 -0
- package/dist/components/theme.js +60 -0
- package/dist/components/thinking.d.ts +68 -0
- package/dist/components/thinking.js +94 -0
- package/dist/components/toast.d.ts +39 -0
- package/dist/components/toast.js +110 -0
- package/dist/components/toolbar.d.ts +25 -0
- package/dist/components/toolbar.js +92 -0
- package/dist/components/tooltip.d.ts +23 -0
- package/dist/components/tooltip.js +27 -0
- package/dist/components/top-nav.d.ts +129 -0
- package/dist/components/top-nav.js +211 -0
- package/dist/components/truncate.d.ts +29 -0
- package/dist/components/truncate.js +138 -0
- package/dist/deprecated.d.ts +43 -0
- package/dist/deprecated.js +47 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +93 -0
- package/dist/lib/cn.d.ts +5 -0
- package/dist/lib/cn.js +14 -0
- package/dist/lib/color.d.ts +136 -0
- package/dist/lib/color.js +307 -0
- package/dist/lib/contrast.d.ts +53 -0
- package/dist/lib/contrast.js +169 -0
- package/dist/lib/create-theme.d.ts +240 -0
- package/dist/lib/create-theme.js +461 -0
- package/dist/lib/harmony.d.ts +102 -0
- package/dist/lib/harmony.js +426 -0
- package/dist/lib/import-theme.d.ts +22 -0
- package/dist/lib/import-theme.js +221 -0
- package/dist/lib/overflow-scroll.d.ts +25 -0
- package/dist/lib/overflow-scroll.js +66 -0
- package/dist/lib/radio-toggle-render.d.ts +3 -0
- package/dist/lib/radio-toggle-render.js +9 -0
- package/dist/lib/reorder.d.ts +38 -0
- package/dist/lib/reorder.js +193 -0
- package/dist/lib/spacing.d.ts +101 -0
- package/dist/lib/spacing.js +118 -0
- package/dist/lib/tailwind-palette.d.ts +5 -0
- package/dist/lib/tailwind-palette.js +351 -0
- package/dist/lib/truncate.d.ts +18 -0
- package/dist/lib/truncate.js +69 -0
- package/dist/lib/use-single-value.d.ts +5 -0
- package/dist/lib/use-single-value.js +17 -0
- package/dist/styles.css +7988 -0
- package/mcp/server.mjs +87590 -0
- package/package.json +58 -5
- package/skills/continuum-fix-padding/SKILL.md +69 -0
- package/skills/continuum-fix-padding/scripts/compute.ts +155 -0
- package/skills/continuum-fix-padding/scripts/spacing.ts +189 -0
- package/skills/continuum-taste/SKILL.md +186 -0
- package/skills/continuum-taste/assets/tokens.css +647 -0
- package/skills/continuum-taste/references/charts.md +375 -0
- package/skills/continuum-taste/references/components.md +1369 -0
- package/skills/continuum-taste/references/foundations.md +539 -0
- package/skills/continuum-taste/references/media/canvas.md +75 -0
- package/skills/continuum-taste/references/media/css.md +61 -0
- package/skills/continuum-taste/references/media/react.md +161 -0
- package/skills/continuum-taste/references/method.md +87 -0
- package/skills/continuum-taste/references/pages.md +391 -0
- package/skills/continuum-taste/references/patterns.md +77 -0
- package/skills/continuum-taste/references/screens/agent.tsx +450 -0
- package/skills/continuum-taste/references/screens/analytics-overview.tsx +377 -0
- package/skills/continuum-taste/references/screens/checkout-funnel.tsx +193 -0
- package/skills/continuum-taste/references/screens/customer.tsx +475 -0
- package/skills/continuum-taste/references/screens/customers.tsx +608 -0
- package/skills/continuum-taste/references/screens/index.tsx +72 -0
- package/skills/continuum-taste/references/screens/invoice-editor.tsx +558 -0
- package/skills/continuum-taste/references/screens/new-customer.tsx +205 -0
- package/skills/continuum-taste/references/screens/overview.tsx +196 -0
- package/skills/continuum-taste/references/screens/report-generator.tsx +329 -0
- package/skills/continuum-taste/references/screens/risk-report.tsx +577 -0
- package/skills/continuum-taste/references/screens/sequence-editor.tsx +455 -0
- package/skills/continuum-taste/references/screens/settings.tsx +288 -0
- package/skills/continuum-taste/references/screens/shared.tsx +204 -0
- package/skills/continuum-taste/references/screens/sign-in.tsx +104 -0
- package/skills/continuum-taste/references/screens/workspace.tsx +596 -0
- package/skills/continuum-taste/references/theming.md +95 -0
- package/src/charts/area-chart.tsx +17 -0
- package/src/charts/bar-chart.tsx +15 -0
- package/src/charts/bubble-chart.tsx +913 -0
- package/src/charts/bullet-chart.tsx +419 -0
- package/src/charts/candlestick-chart.tsx +1242 -0
- package/src/charts/cartesian.tsx +1437 -0
- package/src/charts/chart-card.tsx +394 -0
- package/src/charts/donut-chart.tsx +299 -0
- package/src/charts/funnel-chart.tsx +373 -0
- package/src/charts/horizontal-bar-chart.tsx +991 -0
- package/src/charts/index.ts +76 -0
- package/src/charts/legend.tsx +59 -0
- package/src/charts/lib/candlestick-window.ts +42 -0
- package/src/charts/lib/color.ts +110 -0
- package/src/charts/lib/format.ts +42 -0
- package/src/charts/lib/frame.ts +6 -0
- package/src/charts/lib/layout.ts +78 -0
- package/src/charts/lib/path.ts +225 -0
- package/src/charts/lib/scale.ts +91 -0
- package/src/charts/lib/use-active.ts +87 -0
- package/src/charts/lib/use-size.ts +45 -0
- package/src/charts/line-chart.tsx +16 -0
- package/src/charts/radar-chart.tsx +485 -0
- package/src/charts/rose-chart.tsx +553 -0
- package/src/charts/sparkline.tsx +293 -0
- package/src/charts/tooltip.tsx +105 -0
- package/src/charts/treemap.tsx +271 -0
- package/src/charts/uptime-strip.tsx +469 -0
- package/src/components/accordion.tsx +136 -0
- package/src/components/activity-item.tsx +43 -0
- package/src/components/alert.tsx +135 -0
- package/src/components/assistant-answer.tsx +185 -0
- package/src/components/assistant-prompt.tsx +352 -0
- package/src/components/avatar.tsx +157 -0
- package/src/components/badge.tsx +55 -0
- package/src/components/bar-list.tsx +350 -0
- package/src/components/block-slider.tsx +189 -0
- package/src/components/branch-graph.tsx +580 -0
- package/src/components/breadcrumb.tsx +173 -0
- package/src/components/button.tsx +157 -0
- package/src/components/calendar.tsx +154 -0
- package/src/components/card.tsx +296 -0
- package/src/components/chat-attachment.tsx +255 -0
- package/src/components/chat-event.tsx +34 -0
- package/src/components/chat-message.tsx +332 -0
- package/src/components/chat-reference.tsx +100 -0
- package/src/components/chat-shared.ts +41 -0
- package/src/components/chat-suggestions.tsx +188 -0
- package/src/components/chat-thread.tsx +348 -0
- package/src/components/chat-typing.tsx +155 -0
- package/src/components/checkbox.tsx +83 -0
- package/src/components/checklist.tsx +146 -0
- package/src/components/chip.tsx +152 -0
- package/src/components/code-input.tsx +406 -0
- package/src/components/color-picker.tsx +1385 -0
- package/src/components/combobox.tsx +420 -0
- package/src/components/command-menu.tsx +405 -0
- package/src/components/copy-button.tsx +87 -0
- package/src/components/data-grid.tsx +965 -0
- package/src/components/date-picker.tsx +652 -0
- package/src/components/description-list.tsx +39 -0
- package/src/components/dialog.tsx +367 -0
- package/src/components/dock.tsx +192 -0
- package/src/components/drop-zone.tsx +283 -0
- package/src/components/dropdown-menu.tsx +323 -0
- package/src/components/editable-cell.tsx +219 -0
- package/src/components/empty-state.tsx +50 -0
- package/src/components/field.tsx +148 -0
- package/src/components/filter-condition.tsx +463 -0
- package/src/components/filter-menu.tsx +196 -0
- package/src/components/header-bar.tsx +220 -0
- package/src/components/hold-button.tsx +146 -0
- package/src/components/icon-tile.tsx +43 -0
- package/src/components/info-tip.tsx +87 -0
- package/src/components/input.tsx +136 -0
- package/src/components/kbd.tsx +17 -0
- package/src/components/menu-item.tsx +216 -0
- package/src/components/message-composer.tsx +458 -0
- package/src/components/nav-rail.tsx +235 -0
- package/src/components/notice.tsx +133 -0
- package/src/components/optimistic-undo.ts +68 -0
- package/src/components/option-row.tsx +54 -0
- package/src/components/page-content.tsx +44 -0
- package/src/components/pagination.tsx +182 -0
- package/src/components/popover.tsx +113 -0
- package/src/components/progress.tsx +222 -0
- package/src/components/radio-group.tsx +80 -0
- package/src/components/readonly-field.tsx +251 -0
- package/src/components/segmented-control.tsx +205 -0
- package/src/components/select.tsx +259 -0
- package/src/components/separator.tsx +30 -0
- package/src/components/setting-row.tsx +277 -0
- package/src/components/sidebar-switcher.tsx +134 -0
- package/src/components/sidebar.tsx +804 -0
- package/src/components/skeleton.tsx +57 -0
- package/src/components/slider.tsx +106 -0
- package/src/components/spinner.tsx +43 -0
- package/src/components/status-dot.tsx +100 -0
- package/src/components/stepper.tsx +459 -0
- package/src/components/switch.tsx +54 -0
- package/src/components/table-cell.tsx +239 -0
- package/src/components/table-context.ts +135 -0
- package/src/components/table-head.tsx +393 -0
- package/src/components/table-tree.tsx +357 -0
- package/src/components/table.tsx +295 -0
- package/src/components/tabs.tsx +191 -0
- package/src/components/textarea.tsx +44 -0
- package/src/components/theme.tsx +120 -0
- package/src/components/thinking.tsx +295 -0
- package/src/components/toast.tsx +308 -0
- package/src/components/toolbar.tsx +166 -0
- package/src/components/tooltip.tsx +84 -0
- package/src/components/top-nav.tsx +660 -0
- package/src/components/truncate.tsx +234 -0
- package/src/deprecated.ts +61 -0
- package/src/index.ts +184 -0
- package/src/lib/cn.ts +22 -0
- package/src/lib/color.ts +469 -0
- package/src/lib/contrast.ts +220 -0
- package/src/lib/create-theme.ts +659 -0
- package/src/lib/harmony.ts +609 -0
- package/src/lib/import-theme.ts +272 -0
- package/src/lib/overflow-scroll.tsx +108 -0
- package/src/lib/radio-toggle-render.tsx +15 -0
- package/src/lib/reorder.ts +222 -0
- package/src/lib/spacing.ts +189 -0
- package/src/lib/tailwind-palette.ts +355 -0
- package/src/lib/truncate.ts +79 -0
- package/src/lib/use-single-value.ts +23 -0
- package/src/styles/continuum.css +3 -0
- package/src/styles/theme.css +524 -0
- package/src/styles/tokens.css +647 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The spacing formula: padding and gaps worked out from what a box holds rather than picked, and
|
|
3
|
+
* always landing on a Tailwind spacing step, never an arbitrary value. It covers boxes that hold
|
|
4
|
+
* content (cards, sections, panels, sheets, list rows) and the gaps between texts; a control's
|
|
5
|
+
* side padding stays fixed per kind, since its height already decides it.
|
|
6
|
+
*
|
|
7
|
+
* - A box of text pads by its type and its amount: k × size × (1 + α·log₂ lines), where size is
|
|
8
|
+
* the type size averaged over its lines, so one large figure does not size a whole card.
|
|
9
|
+
* - A box of boxes pads at least a step past its children: r × their padding.
|
|
10
|
+
* - Between alike boxes (cards in a row, a list's rows): g × their padding.
|
|
11
|
+
* - Between unlike blocks (a page head and its table, a chart and a section; inside a card, a title
|
|
12
|
+
* and its list, a figure and its badge): each claims its own room, growing with what it holds,
|
|
13
|
+
* and the gap is the sum. Inside a box with a surface a block claims less (× inside) and counts
|
|
14
|
+
* only its first lines (insideLines), so a long list does not push its own title away.
|
|
15
|
+
* - Between texts: t × the size of the text after the gap (type sets the space above a line in that
|
|
16
|
+
* line's own size), tight for a pair that belongs together and loose between blocks, growing with
|
|
17
|
+
* the lines either side: × (1 + β·log₂ lines).
|
|
18
|
+
*
|
|
19
|
+
* Kept free of imports so a script can load it on its own (the continuum-fix-padding skill runs it with Node).
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export type SpacingParams = {
|
|
23
|
+
/** Padding per px of type. */
|
|
24
|
+
k: number;
|
|
25
|
+
/** How fast a box's padding grows with the lines it holds. */
|
|
26
|
+
alpha: number;
|
|
27
|
+
/** A box of boxes pads at least this times its children's padding. */
|
|
28
|
+
nesting: number;
|
|
29
|
+
/** The gap between boxes, as a share of their padding. */
|
|
30
|
+
gapRatio: number;
|
|
31
|
+
/** The gap within a pair (a header and subheader, a label and value, a figure and caption). */
|
|
32
|
+
tight: number;
|
|
33
|
+
/** The gap between blocks of text. */
|
|
34
|
+
loose: number;
|
|
35
|
+
/** How fast a gap between texts grows with the lines either side of it. */
|
|
36
|
+
beta: number;
|
|
37
|
+
/** The room a free-standing block claims, per px of its type. */
|
|
38
|
+
room: number;
|
|
39
|
+
/** How fast that room grows with the lines and rows the block holds. */
|
|
40
|
+
roomGrowth: number;
|
|
41
|
+
/** The share of its room a block claims inside a box with a surface (a card), beside an unlike block. */
|
|
42
|
+
inside: number;
|
|
43
|
+
/** The most lines a block counts toward its room inside a box with a surface. */
|
|
44
|
+
insideLines: number;
|
|
45
|
+
/** No padding past this, in px. */
|
|
46
|
+
cap: number;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** The balance judged on a billing screen in the spacing lab, 4 Nov 2026. */
|
|
50
|
+
export const spacingDefaults: SpacingParams = {
|
|
51
|
+
k: 0.75,
|
|
52
|
+
alpha: 0.6,
|
|
53
|
+
nesting: 1.5,
|
|
54
|
+
gapRatio: 1.1,
|
|
55
|
+
tight: 0.25,
|
|
56
|
+
loose: 1.5,
|
|
57
|
+
beta: 0.6,
|
|
58
|
+
/* Fitted 16 Nov 2026 to Joan's anchors: a page head over a dense table about 64, over ten rows
|
|
59
|
+
about 56, a bare title over a short settings card about 32. */
|
|
60
|
+
room: 0.375,
|
|
61
|
+
roomGrowth: 1.85,
|
|
62
|
+
/* Fitted 17 Nov 2026 to the cards Continuum draws by eye (a stat card's badge 12 under its
|
|
63
|
+
figure, a card's title 16 over its list): off by about 1px on average across them. */
|
|
64
|
+
inside: 0.6,
|
|
65
|
+
insideLines: 3,
|
|
66
|
+
cap: 48,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The Tailwind steps a result may land on, in units of `--spacing` (4px): half steps to 4, then
|
|
71
|
+
* whole steps, then wider ones, as Tailwind's own scale runs.
|
|
72
|
+
*/
|
|
73
|
+
export const spacingSteps = [
|
|
74
|
+
0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24,
|
|
75
|
+
] as const;
|
|
76
|
+
|
|
77
|
+
export type SpacingStep = (typeof spacingSteps)[number];
|
|
78
|
+
|
|
79
|
+
const unit = 4;
|
|
80
|
+
|
|
81
|
+
/** The nearest Tailwind step to a length in px. */
|
|
82
|
+
export const toSpacingStep = (px: number): SpacingStep => {
|
|
83
|
+
let best: SpacingStep = 0;
|
|
84
|
+
for (const step of spacingSteps) {
|
|
85
|
+
if (Math.abs(step * unit - px) < Math.abs(best * unit - px)) best = step;
|
|
86
|
+
}
|
|
87
|
+
return best;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** A length in px, snapped to the scale and written as a class: `spacingClass('p', 22)` is `p-5`. */
|
|
91
|
+
export const spacingClass = (prefix: string, px: number) => `${prefix}-${toSpacingStep(px)}`;
|
|
92
|
+
|
|
93
|
+
/** A length in px snapped to the scale, still in px. */
|
|
94
|
+
export const snapToSpacing = (px: number) => toSpacingStep(px) * unit;
|
|
95
|
+
|
|
96
|
+
export type TypeRun = {
|
|
97
|
+
/** Font size in px. */
|
|
98
|
+
size: number;
|
|
99
|
+
/** Rendered lines; measure them where you can, about eight words of body text to a line otherwise. */
|
|
100
|
+
lines: number;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** About eight words of body text to a line, for when the lines cannot be measured. */
|
|
104
|
+
export const estimateLines = (text: string) =>
|
|
105
|
+
Math.max(1, text.trim().split(/\s+/).filter(Boolean).length / 8);
|
|
106
|
+
|
|
107
|
+
/** A box's type size: averaged over its lines, so a large figure among small lines does not set it. */
|
|
108
|
+
export const typeSize = (runs: readonly TypeRun[]) => {
|
|
109
|
+
const total = runs.reduce((sum, run) => sum + run.lines, 0);
|
|
110
|
+
return total > 0 ? runs.reduce((sum, run) => sum + run.size * run.lines, 0) / total : 0;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type InnerBox = {
|
|
114
|
+
/** The inner box's padding in px; for a group with no surface, its children's. */
|
|
115
|
+
padding: number;
|
|
116
|
+
/** The inner box's type size, which counts as one line of this box's content. */
|
|
117
|
+
size: number;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* A box's padding in px, unsnapped: from its own text and the boxes inside it (each one line of
|
|
122
|
+
* content at its own type size), and at least a step past those boxes' padding.
|
|
123
|
+
*/
|
|
124
|
+
export const boxPadding = (
|
|
125
|
+
{ runs, children = [] }: { runs: readonly TypeRun[]; children?: readonly InnerBox[] },
|
|
126
|
+
params: SpacingParams = spacingDefaults,
|
|
127
|
+
) => {
|
|
128
|
+
const all = [...runs, ...children.map(child => ({ size: child.size, lines: 1 }))];
|
|
129
|
+
const amount = all.reduce((sum, run) => sum + run.lines, 0);
|
|
130
|
+
const fromContent =
|
|
131
|
+
params.k * typeSize(all) * (1 + params.alpha * Math.log2(Math.max(1, amount)));
|
|
132
|
+
const fromChildren = Math.max(0, ...children.map(child => child.padding)) * params.nesting;
|
|
133
|
+
return Math.min(Math.max(fromContent, fromChildren), params.cap);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/** The gap between alike sibling boxes (cards in a row, a list's rows) in px, unsnapped, from their padding. */
|
|
137
|
+
export const boxGap = (children: readonly number[], params: SpacingParams = spacingDefaults) =>
|
|
138
|
+
Math.max(0, ...children) * params.gapRatio;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The room a free-standing block claims on the side facing another block, in px, unsnapped, from
|
|
142
|
+
* what it holds (its texts, and each box inside it as one line at its own size), whether or not it
|
|
143
|
+
* has a surface: room × size × (1 + growth·log₂ lines). It grows faster with amount than padding
|
|
144
|
+
* does, so a dense table claims far more than a short card: a page head of a title and a line about
|
|
145
|
+
* 20, a table of twenty rows about 44, a short settings card about 12.
|
|
146
|
+
*/
|
|
147
|
+
export const blockRoom = (
|
|
148
|
+
{ runs, children = [] }: { runs: readonly TypeRun[]; children?: readonly InnerBox[] },
|
|
149
|
+
params: SpacingParams = spacingDefaults,
|
|
150
|
+
) => {
|
|
151
|
+
const all = [...runs, ...children.map(child => ({ size: child.size, lines: 1 }))];
|
|
152
|
+
const lines = all.reduce((sum, run) => sum + run.lines, 0);
|
|
153
|
+
return params.room * typeSize(all) * (1 + params.roomGrowth * Math.log2(Math.max(1, lines)));
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The room a block claims beside an unlike block inside a box with a surface (a card's title over
|
|
158
|
+
* its list, a figure over its badge), in px, unsnapped: the free-standing room, scaled by `inside`
|
|
159
|
+
* and counting at most `insideLines` lines, since inside a card both blocks are seen together and a
|
|
160
|
+
* list's length should not push its own title away. A stat card's figure over its badge lands on 12,
|
|
161
|
+
* a card's title over its list near 14.
|
|
162
|
+
*/
|
|
163
|
+
export const insideRoom = ({ size, lines }: TypeRun, params: SpacingParams = spacingDefaults) =>
|
|
164
|
+
params.inside *
|
|
165
|
+
blockRoom({ runs: [{ size, lines: Math.min(lines, params.insideLines) }] }, params);
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The gap between two unlike blocks (a page head and its table, a chart and the section under it;
|
|
169
|
+
* inside a card, each with its insideRoom), in px, unsnapped: each brings its own room, so the gap is
|
|
170
|
+
* the sum, and it grows with how much either side holds. A page head over a dense table lands near
|
|
171
|
+
* 64; a bare title over a short card near 32.
|
|
172
|
+
*/
|
|
173
|
+
export const blockGap = (before: number, after: number) => before + after;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The gap between two texts in px, unsnapped: sized by the text after it, tight within a pair and
|
|
177
|
+
* loose between blocks, and wider the more lines sit either side.
|
|
178
|
+
*/
|
|
179
|
+
export const textGap = (
|
|
180
|
+
{ before, after, pair }: { before: TypeRun; after: TypeRun; pair: boolean },
|
|
181
|
+
params: SpacingParams = spacingDefaults,
|
|
182
|
+
) => {
|
|
183
|
+
const around = before.lines + after.lines - 1;
|
|
184
|
+
return (
|
|
185
|
+
after.size *
|
|
186
|
+
(pair ? params.tight : params.loose) *
|
|
187
|
+
(1 + params.beta * Math.log2(Math.max(1, around)))
|
|
188
|
+
);
|
|
189
|
+
};
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
// biome-ignore-all lint/suspicious/noApproximativeNumericConstant: Tailwind's own measured values, not stand-ins for a constant.
|
|
2
|
+
/*
|
|
3
|
+
* Tailwind CSS 4.3.3's default palette, as oklch triples [lightness 0–1, chroma, hue] for the steps 50 to
|
|
4
|
+
* 950. The ramp engine in color.ts reads its curves off these: the lightness, the share of the gamut and
|
|
5
|
+
* the hue drift of every step, by hue. Generated from tailwindcss/theme.css (MIT, Tailwind Labs); do not
|
|
6
|
+
* edit by hand.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type PaletteRamp = readonly (readonly [number, number, number])[];
|
|
10
|
+
|
|
11
|
+
/** The seventeen chromatic families. */
|
|
12
|
+
export const tailwindHues: Record<string, PaletteRamp> = {
|
|
13
|
+
red: [
|
|
14
|
+
[0.971, 0.013, 17.38],
|
|
15
|
+
[0.936, 0.032, 17.717],
|
|
16
|
+
[0.885, 0.062, 18.334],
|
|
17
|
+
[0.808, 0.114, 19.571],
|
|
18
|
+
[0.704, 0.191, 22.216],
|
|
19
|
+
[0.637, 0.237, 25.331],
|
|
20
|
+
[0.577, 0.245, 27.325],
|
|
21
|
+
[0.505, 0.213, 27.518],
|
|
22
|
+
[0.444, 0.177, 26.899],
|
|
23
|
+
[0.396, 0.141, 25.723],
|
|
24
|
+
[0.258, 0.092, 26.042],
|
|
25
|
+
],
|
|
26
|
+
orange: [
|
|
27
|
+
[0.98, 0.016, 73.684],
|
|
28
|
+
[0.954, 0.038, 75.164],
|
|
29
|
+
[0.901, 0.076, 70.697],
|
|
30
|
+
[0.837, 0.128, 66.29],
|
|
31
|
+
[0.75, 0.183, 55.934],
|
|
32
|
+
[0.705, 0.213, 47.604],
|
|
33
|
+
[0.646, 0.222, 41.116],
|
|
34
|
+
[0.553, 0.195, 38.402],
|
|
35
|
+
[0.47, 0.157, 37.304],
|
|
36
|
+
[0.408, 0.123, 38.172],
|
|
37
|
+
[0.266, 0.079, 36.259],
|
|
38
|
+
],
|
|
39
|
+
amber: [
|
|
40
|
+
[0.987, 0.022, 95.277],
|
|
41
|
+
[0.962, 0.059, 95.617],
|
|
42
|
+
[0.924, 0.12, 95.746],
|
|
43
|
+
[0.879, 0.169, 91.605],
|
|
44
|
+
[0.828, 0.189, 84.429],
|
|
45
|
+
[0.769, 0.188, 70.08],
|
|
46
|
+
[0.666, 0.179, 58.318],
|
|
47
|
+
[0.555, 0.163, 48.998],
|
|
48
|
+
[0.473, 0.137, 46.201],
|
|
49
|
+
[0.414, 0.112, 45.904],
|
|
50
|
+
[0.279, 0.077, 45.635],
|
|
51
|
+
],
|
|
52
|
+
yellow: [
|
|
53
|
+
[0.987, 0.026, 102.212],
|
|
54
|
+
[0.973, 0.071, 103.193],
|
|
55
|
+
[0.945, 0.129, 101.54],
|
|
56
|
+
[0.905, 0.182, 98.111],
|
|
57
|
+
[0.852, 0.199, 91.936],
|
|
58
|
+
[0.795, 0.184, 86.047],
|
|
59
|
+
[0.681, 0.162, 75.834],
|
|
60
|
+
[0.554, 0.135, 66.442],
|
|
61
|
+
[0.476, 0.114, 61.907],
|
|
62
|
+
[0.421, 0.095, 57.708],
|
|
63
|
+
[0.286, 0.066, 53.813],
|
|
64
|
+
],
|
|
65
|
+
lime: [
|
|
66
|
+
[0.986, 0.031, 120.757],
|
|
67
|
+
[0.967, 0.067, 122.328],
|
|
68
|
+
[0.938, 0.127, 124.321],
|
|
69
|
+
[0.897, 0.196, 126.665],
|
|
70
|
+
[0.841, 0.238, 128.85],
|
|
71
|
+
[0.768, 0.233, 130.85],
|
|
72
|
+
[0.648, 0.2, 131.684],
|
|
73
|
+
[0.532, 0.157, 131.589],
|
|
74
|
+
[0.453, 0.124, 130.933],
|
|
75
|
+
[0.405, 0.101, 131.063],
|
|
76
|
+
[0.274, 0.072, 132.109],
|
|
77
|
+
],
|
|
78
|
+
green: [
|
|
79
|
+
[0.982, 0.018, 155.826],
|
|
80
|
+
[0.962, 0.044, 156.743],
|
|
81
|
+
[0.925, 0.084, 155.995],
|
|
82
|
+
[0.871, 0.15, 154.449],
|
|
83
|
+
[0.792, 0.209, 151.711],
|
|
84
|
+
[0.723, 0.219, 149.579],
|
|
85
|
+
[0.627, 0.194, 149.214],
|
|
86
|
+
[0.527, 0.154, 150.069],
|
|
87
|
+
[0.448, 0.119, 151.328],
|
|
88
|
+
[0.393, 0.095, 152.535],
|
|
89
|
+
[0.266, 0.065, 152.934],
|
|
90
|
+
],
|
|
91
|
+
emerald: [
|
|
92
|
+
[0.979, 0.021, 166.113],
|
|
93
|
+
[0.95, 0.052, 163.051],
|
|
94
|
+
[0.905, 0.093, 164.15],
|
|
95
|
+
[0.845, 0.143, 164.978],
|
|
96
|
+
[0.765, 0.177, 163.223],
|
|
97
|
+
[0.696, 0.17, 162.48],
|
|
98
|
+
[0.596, 0.145, 163.225],
|
|
99
|
+
[0.508, 0.118, 165.612],
|
|
100
|
+
[0.432, 0.095, 166.913],
|
|
101
|
+
[0.378, 0.077, 168.94],
|
|
102
|
+
[0.262, 0.051, 172.552],
|
|
103
|
+
],
|
|
104
|
+
teal: [
|
|
105
|
+
[0.984, 0.014, 180.72],
|
|
106
|
+
[0.953, 0.051, 180.801],
|
|
107
|
+
[0.91, 0.096, 180.426],
|
|
108
|
+
[0.855, 0.138, 181.071],
|
|
109
|
+
[0.777, 0.152, 181.912],
|
|
110
|
+
[0.704, 0.14, 182.503],
|
|
111
|
+
[0.6, 0.118, 184.704],
|
|
112
|
+
[0.511, 0.096, 186.391],
|
|
113
|
+
[0.437, 0.078, 188.216],
|
|
114
|
+
[0.386, 0.063, 188.416],
|
|
115
|
+
[0.277, 0.046, 192.524],
|
|
116
|
+
],
|
|
117
|
+
cyan: [
|
|
118
|
+
[0.984, 0.019, 200.873],
|
|
119
|
+
[0.956, 0.045, 203.388],
|
|
120
|
+
[0.917, 0.08, 205.041],
|
|
121
|
+
[0.865, 0.127, 207.078],
|
|
122
|
+
[0.789, 0.154, 211.53],
|
|
123
|
+
[0.715, 0.143, 215.221],
|
|
124
|
+
[0.609, 0.126, 221.723],
|
|
125
|
+
[0.52, 0.105, 223.128],
|
|
126
|
+
[0.45, 0.085, 224.283],
|
|
127
|
+
[0.398, 0.07, 227.392],
|
|
128
|
+
[0.302, 0.056, 229.695],
|
|
129
|
+
],
|
|
130
|
+
sky: [
|
|
131
|
+
[0.977, 0.013, 236.62],
|
|
132
|
+
[0.951, 0.026, 236.824],
|
|
133
|
+
[0.901, 0.058, 230.902],
|
|
134
|
+
[0.828, 0.111, 230.318],
|
|
135
|
+
[0.746, 0.16, 232.661],
|
|
136
|
+
[0.685, 0.169, 237.323],
|
|
137
|
+
[0.588, 0.158, 241.966],
|
|
138
|
+
[0.5, 0.134, 242.749],
|
|
139
|
+
[0.443, 0.11, 240.79],
|
|
140
|
+
[0.391, 0.09, 240.876],
|
|
141
|
+
[0.293, 0.066, 243.157],
|
|
142
|
+
],
|
|
143
|
+
blue: [
|
|
144
|
+
[0.97, 0.014, 254.604],
|
|
145
|
+
[0.932, 0.032, 255.585],
|
|
146
|
+
[0.882, 0.059, 254.128],
|
|
147
|
+
[0.809, 0.105, 251.813],
|
|
148
|
+
[0.707, 0.165, 254.624],
|
|
149
|
+
[0.623, 0.214, 259.815],
|
|
150
|
+
[0.546, 0.245, 262.881],
|
|
151
|
+
[0.488, 0.243, 264.376],
|
|
152
|
+
[0.424, 0.199, 265.638],
|
|
153
|
+
[0.379, 0.146, 265.522],
|
|
154
|
+
[0.282, 0.091, 267.935],
|
|
155
|
+
],
|
|
156
|
+
indigo: [
|
|
157
|
+
[0.962, 0.018, 272.314],
|
|
158
|
+
[0.93, 0.034, 272.788],
|
|
159
|
+
[0.87, 0.065, 274.039],
|
|
160
|
+
[0.785, 0.115, 274.713],
|
|
161
|
+
[0.673, 0.182, 276.935],
|
|
162
|
+
[0.585, 0.233, 277.117],
|
|
163
|
+
[0.511, 0.262, 276.966],
|
|
164
|
+
[0.457, 0.24, 277.023],
|
|
165
|
+
[0.398, 0.195, 277.366],
|
|
166
|
+
[0.359, 0.144, 278.697],
|
|
167
|
+
[0.257, 0.09, 281.288],
|
|
168
|
+
],
|
|
169
|
+
violet: [
|
|
170
|
+
[0.969, 0.016, 293.756],
|
|
171
|
+
[0.943, 0.029, 294.588],
|
|
172
|
+
[0.894, 0.057, 293.283],
|
|
173
|
+
[0.811, 0.111, 293.571],
|
|
174
|
+
[0.702, 0.183, 293.541],
|
|
175
|
+
[0.606, 0.25, 292.717],
|
|
176
|
+
[0.541, 0.281, 293.009],
|
|
177
|
+
[0.491, 0.27, 292.581],
|
|
178
|
+
[0.432, 0.232, 292.759],
|
|
179
|
+
[0.38, 0.189, 293.745],
|
|
180
|
+
[0.283, 0.141, 291.089],
|
|
181
|
+
],
|
|
182
|
+
purple: [
|
|
183
|
+
[0.977, 0.014, 308.299],
|
|
184
|
+
[0.946, 0.033, 307.174],
|
|
185
|
+
[0.902, 0.063, 306.703],
|
|
186
|
+
[0.827, 0.119, 306.383],
|
|
187
|
+
[0.714, 0.203, 305.504],
|
|
188
|
+
[0.627, 0.265, 303.9],
|
|
189
|
+
[0.558, 0.288, 302.321],
|
|
190
|
+
[0.496, 0.265, 301.924],
|
|
191
|
+
[0.438, 0.218, 303.724],
|
|
192
|
+
[0.381, 0.176, 304.987],
|
|
193
|
+
[0.291, 0.149, 302.717],
|
|
194
|
+
],
|
|
195
|
+
fuchsia: [
|
|
196
|
+
[0.977, 0.017, 320.058],
|
|
197
|
+
[0.952, 0.037, 318.852],
|
|
198
|
+
[0.903, 0.076, 319.62],
|
|
199
|
+
[0.833, 0.145, 321.434],
|
|
200
|
+
[0.74, 0.238, 322.16],
|
|
201
|
+
[0.667, 0.295, 322.15],
|
|
202
|
+
[0.591, 0.293, 322.896],
|
|
203
|
+
[0.518, 0.253, 323.949],
|
|
204
|
+
[0.452, 0.211, 324.591],
|
|
205
|
+
[0.401, 0.17, 325.612],
|
|
206
|
+
[0.293, 0.136, 325.661],
|
|
207
|
+
],
|
|
208
|
+
pink: [
|
|
209
|
+
[0.971, 0.014, 343.198],
|
|
210
|
+
[0.948, 0.028, 342.258],
|
|
211
|
+
[0.899, 0.061, 343.231],
|
|
212
|
+
[0.823, 0.12, 346.018],
|
|
213
|
+
[0.718, 0.202, 349.761],
|
|
214
|
+
[0.656, 0.241, 354.308],
|
|
215
|
+
[0.592, 0.249, 0.584],
|
|
216
|
+
[0.525, 0.223, 3.958],
|
|
217
|
+
[0.459, 0.187, 3.815],
|
|
218
|
+
[0.408, 0.153, 2.432],
|
|
219
|
+
[0.284, 0.109, 3.907],
|
|
220
|
+
],
|
|
221
|
+
rose: [
|
|
222
|
+
[0.969, 0.015, 12.422],
|
|
223
|
+
[0.941, 0.03, 12.58],
|
|
224
|
+
[0.892, 0.058, 10.001],
|
|
225
|
+
[0.81, 0.117, 11.638],
|
|
226
|
+
[0.712, 0.194, 13.428],
|
|
227
|
+
[0.645, 0.246, 16.439],
|
|
228
|
+
[0.586, 0.253, 17.585],
|
|
229
|
+
[0.514, 0.222, 16.935],
|
|
230
|
+
[0.455, 0.188, 13.697],
|
|
231
|
+
[0.41, 0.159, 10.272],
|
|
232
|
+
[0.271, 0.105, 12.094],
|
|
233
|
+
],
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/** The greys, achromatic or faintly tinted. */
|
|
237
|
+
export const tailwindGreys: Record<string, PaletteRamp> = {
|
|
238
|
+
slate: [
|
|
239
|
+
[0.984, 0.003, 247.858],
|
|
240
|
+
[0.968, 0.007, 247.896],
|
|
241
|
+
[0.929, 0.013, 255.508],
|
|
242
|
+
[0.869, 0.022, 252.894],
|
|
243
|
+
[0.704, 0.04, 256.788],
|
|
244
|
+
[0.554, 0.046, 257.417],
|
|
245
|
+
[0.446, 0.043, 257.281],
|
|
246
|
+
[0.372, 0.044, 257.287],
|
|
247
|
+
[0.279, 0.041, 260.031],
|
|
248
|
+
[0.208, 0.042, 265.755],
|
|
249
|
+
[0.129, 0.042, 264.695],
|
|
250
|
+
],
|
|
251
|
+
gray: [
|
|
252
|
+
[0.985, 0.002, 247.839],
|
|
253
|
+
[0.967, 0.003, 264.542],
|
|
254
|
+
[0.928, 0.006, 264.531],
|
|
255
|
+
[0.872, 0.01, 258.338],
|
|
256
|
+
[0.707, 0.022, 261.325],
|
|
257
|
+
[0.551, 0.027, 264.364],
|
|
258
|
+
[0.446, 0.03, 256.802],
|
|
259
|
+
[0.373, 0.034, 259.733],
|
|
260
|
+
[0.278, 0.033, 256.848],
|
|
261
|
+
[0.21, 0.034, 264.665],
|
|
262
|
+
[0.13, 0.028, 261.692],
|
|
263
|
+
],
|
|
264
|
+
zinc: [
|
|
265
|
+
[0.985, 0, 0],
|
|
266
|
+
[0.967, 0.001, 286.375],
|
|
267
|
+
[0.92, 0.004, 286.32],
|
|
268
|
+
[0.871, 0.006, 286.286],
|
|
269
|
+
[0.705, 0.015, 286.067],
|
|
270
|
+
[0.552, 0.016, 285.938],
|
|
271
|
+
[0.442, 0.017, 285.786],
|
|
272
|
+
[0.37, 0.013, 285.805],
|
|
273
|
+
[0.274, 0.006, 286.033],
|
|
274
|
+
[0.21, 0.006, 285.885],
|
|
275
|
+
[0.141, 0.005, 285.823],
|
|
276
|
+
],
|
|
277
|
+
neutral: [
|
|
278
|
+
[0.985, 0, 0],
|
|
279
|
+
[0.97, 0, 0],
|
|
280
|
+
[0.922, 0, 0],
|
|
281
|
+
[0.87, 0, 0],
|
|
282
|
+
[0.708, 0, 0],
|
|
283
|
+
[0.556, 0, 0],
|
|
284
|
+
[0.439, 0, 0],
|
|
285
|
+
[0.371, 0, 0],
|
|
286
|
+
[0.269, 0, 0],
|
|
287
|
+
[0.205, 0, 0],
|
|
288
|
+
[0.145, 0, 0],
|
|
289
|
+
],
|
|
290
|
+
stone: [
|
|
291
|
+
[0.985, 0.001, 106.423],
|
|
292
|
+
[0.97, 0.001, 106.424],
|
|
293
|
+
[0.923, 0.003, 48.717],
|
|
294
|
+
[0.869, 0.005, 56.366],
|
|
295
|
+
[0.709, 0.01, 56.259],
|
|
296
|
+
[0.553, 0.013, 58.071],
|
|
297
|
+
[0.444, 0.011, 73.639],
|
|
298
|
+
[0.374, 0.01, 67.558],
|
|
299
|
+
[0.268, 0.007, 34.298],
|
|
300
|
+
[0.216, 0.006, 56.043],
|
|
301
|
+
[0.147, 0.004, 49.25],
|
|
302
|
+
],
|
|
303
|
+
mauve: [
|
|
304
|
+
[0.985, 0, 0],
|
|
305
|
+
[0.96, 0.003, 325.6],
|
|
306
|
+
[0.922, 0.005, 325.62],
|
|
307
|
+
[0.865, 0.012, 325.68],
|
|
308
|
+
[0.711, 0.019, 323.02],
|
|
309
|
+
[0.542, 0.034, 322.5],
|
|
310
|
+
[0.435, 0.029, 321.78],
|
|
311
|
+
[0.364, 0.029, 323.89],
|
|
312
|
+
[0.263, 0.024, 320.12],
|
|
313
|
+
[0.212, 0.019, 322.12],
|
|
314
|
+
[0.145, 0.008, 326],
|
|
315
|
+
],
|
|
316
|
+
olive: [
|
|
317
|
+
[0.988, 0.003, 106.5],
|
|
318
|
+
[0.966, 0.005, 106.5],
|
|
319
|
+
[0.93, 0.007, 106.5],
|
|
320
|
+
[0.88, 0.011, 106.6],
|
|
321
|
+
[0.737, 0.021, 106.9],
|
|
322
|
+
[0.58, 0.031, 107.3],
|
|
323
|
+
[0.466, 0.025, 107.3],
|
|
324
|
+
[0.394, 0.023, 107.4],
|
|
325
|
+
[0.286, 0.016, 107.4],
|
|
326
|
+
[0.228, 0.013, 107.4],
|
|
327
|
+
[0.153, 0.006, 107.1],
|
|
328
|
+
],
|
|
329
|
+
mist: [
|
|
330
|
+
[0.987, 0.002, 197.1],
|
|
331
|
+
[0.963, 0.002, 197.1],
|
|
332
|
+
[0.925, 0.005, 214.3],
|
|
333
|
+
[0.872, 0.007, 219.6],
|
|
334
|
+
[0.723, 0.014, 214.4],
|
|
335
|
+
[0.56, 0.021, 213.5],
|
|
336
|
+
[0.45, 0.017, 213.2],
|
|
337
|
+
[0.378, 0.015, 216],
|
|
338
|
+
[0.275, 0.011, 216.9],
|
|
339
|
+
[0.218, 0.008, 223.9],
|
|
340
|
+
[0.148, 0.004, 228.8],
|
|
341
|
+
],
|
|
342
|
+
taupe: [
|
|
343
|
+
[0.986, 0.002, 67.8],
|
|
344
|
+
[0.96, 0.002, 17.2],
|
|
345
|
+
[0.922, 0.005, 34.3],
|
|
346
|
+
[0.868, 0.007, 39.5],
|
|
347
|
+
[0.714, 0.014, 41.2],
|
|
348
|
+
[0.547, 0.021, 43.1],
|
|
349
|
+
[0.438, 0.017, 39.3],
|
|
350
|
+
[0.367, 0.016, 35.7],
|
|
351
|
+
[0.268, 0.011, 36.5],
|
|
352
|
+
[0.214, 0.009, 43.1],
|
|
353
|
+
[0.147, 0.004, 49.3],
|
|
354
|
+
],
|
|
355
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Where a name is cut when it is truncated in the middle: the end it keeps whole, worked out from
|
|
3
|
+
* what kind of string it is. The start is never counted here; it fills whatever width is left.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// A file extension: a dot, then 1–6 letters or digits with at least one letter (".pdf", ".mp4",
|
|
7
|
+
// ".tar"), so a version ("v1.2") or an amount ("4.50") is not read as one.
|
|
8
|
+
const extension = /\.(?=[a-z0-9]{0,5}[a-z])[a-z0-9]{1,6}$/i;
|
|
9
|
+
|
|
10
|
+
// Where a name is naturally broken: the start of the tail is moved back to one of these.
|
|
11
|
+
const separators = /[-_ .]/;
|
|
12
|
+
|
|
13
|
+
// A path's last part is kept whole when it is no longer than this; longer, it is cut as a file name.
|
|
14
|
+
const segmentMax = 24;
|
|
15
|
+
|
|
16
|
+
/** The last piece of `stem` from a separator between `min` and `max` characters from its end. */
|
|
17
|
+
const piece = (stem: string, min: number, max: number, fallback: number) => {
|
|
18
|
+
for (let n = min; n <= Math.min(max, stem.length - 1); n++) {
|
|
19
|
+
if (separators.test(stem[stem.length - n] ?? '')) {
|
|
20
|
+
return stem.slice(-n);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const n = Math.min(fallback, stem.length - 1);
|
|
24
|
+
return n > 0 ? stem.slice(-n) : '';
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** The end of a file name kept whole: its extension and the last word of its name. */
|
|
28
|
+
const fileTail = (name: string) => {
|
|
29
|
+
const ext = name.match(extension)?.[0];
|
|
30
|
+
if (!ext || ext.length >= name.length) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const stem = name.slice(0, -ext.length);
|
|
34
|
+
return piece(stem, 3, 10, 6) + ext;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The end of `text` that a middle truncation keeps whole, so the part that tells one name from the
|
|
39
|
+
* next always shows:
|
|
40
|
+
* - a path keeps its last part (`/donut-chart.tsx`), or that part's file-name end when it is long;
|
|
41
|
+
* - a file name keeps its extension and the last word before it (`-final.pdf`);
|
|
42
|
+
* - a hash or an ID keeps its last 4 characters (`9c1b`), as it is read and compared;
|
|
43
|
+
* - other text keeps its last word, or 8 characters.
|
|
44
|
+
*/
|
|
45
|
+
export const truncationTail = (text: string): string => {
|
|
46
|
+
const slash = Math.max(text.lastIndexOf('/'), text.lastIndexOf('\\'));
|
|
47
|
+
if (slash >= 0 && slash < text.length - 1) {
|
|
48
|
+
const segment = text.slice(slash);
|
|
49
|
+
if (segment.length <= segmentMax) {
|
|
50
|
+
return segment;
|
|
51
|
+
}
|
|
52
|
+
return fileTail(segment) ?? segment.slice(-8);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const file = fileTail(text);
|
|
56
|
+
if (file) {
|
|
57
|
+
return file;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!/\s/.test(text)) {
|
|
61
|
+
return text.slice(-4);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return piece(text, 4, 14, 8);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* `text` split for a middle truncation: the `head` that narrows to an ellipsis and the `tail` kept
|
|
69
|
+
* whole. `end` is how many characters the tail keeps; left out, `truncationTail` decides by the
|
|
70
|
+
* kind of string. A text too short to cut has an empty tail.
|
|
71
|
+
*/
|
|
72
|
+
export const splitForTruncation = (text: string, end?: number) => {
|
|
73
|
+
const tail = end === undefined ? truncationTail(text) : end > 0 ? text.slice(-end) : '';
|
|
74
|
+
// Cutting only pays when the head keeps a few characters of its own beside the ellipsis.
|
|
75
|
+
if (tail.length === 0 || text.length - tail.length < 4) {
|
|
76
|
+
return { head: text, tail: '' };
|
|
77
|
+
}
|
|
78
|
+
return { head: text.slice(0, text.length - tail.length), tail };
|
|
79
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base UI's ToggleGroup hands back an empty array when the pressed item is
|
|
7
|
+
* clicked again, which would leave the group empty. Segmented controls and the dock must always keep one value.
|
|
8
|
+
*/
|
|
9
|
+
export const useSingleValue = (
|
|
10
|
+
value: string | undefined,
|
|
11
|
+
defaultValue: string | undefined,
|
|
12
|
+
onValueChange: ((value: string) => void) | undefined,
|
|
13
|
+
) => {
|
|
14
|
+
const [uncontrolled, setUncontrolled] = useState(defaultValue ?? '');
|
|
15
|
+
|
|
16
|
+
const select = (next: string) => {
|
|
17
|
+
if (!next) return;
|
|
18
|
+
if (value === undefined) setUncontrolled(next);
|
|
19
|
+
onValueChange?.(next);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return [value ?? uncontrolled, select] as const;
|
|
23
|
+
};
|