@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
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@contui/ui",
|
|
3
|
+
"description": "A quiet, dense design system for tool UI: one default look, a theme builder, Base UI primitives and Tailwind v4.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/joan-verhulst/continuum.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/joan-verhulst/continuum#readme",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"*.css"
|
|
20
|
+
],
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./charts": {
|
|
28
|
+
"types": "./dist/charts/index.d.ts",
|
|
29
|
+
"default": "./dist/charts/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./styles.css": "./dist/styles.css",
|
|
32
|
+
"./theme.css": "./src/styles/theme.css",
|
|
33
|
+
"./tokens.css": "./src/styles/tokens.css",
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"bin": {
|
|
37
|
+
"contui": "./cli/contui.mjs"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@base-ui/react": "1.8.0",
|
|
41
|
+
"class-variance-authority": "^0.7.1",
|
|
42
|
+
"clsx": "^2.1.1",
|
|
43
|
+
"lucide-react": "^1.60.0",
|
|
44
|
+
"react-day-picker": "10.0.0",
|
|
45
|
+
"tailwind-merge": "^3.4.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"react": ">=19",
|
|
49
|
+
"react-dom": ">=19"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"react": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"react-dom": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: continuum-fix-padding
|
|
3
|
+
description: Use this skill to work out and fix the padding and gaps of a component, screen or page with Continuum's spacing formula, so spacing follows what each box holds (its type size, how much text, the boxes and rows inside it) and always lands on a Tailwind spacing class, never an arbitrary value. Use it whenever a padding or gap is not drawn by a part, and when asked to fix, check, tune or derive spacing, even if the user only says how it looks ("fix padding", "spacing looks off", "this card feels cramped", "too much space between the title and the description"), or invoked as /continuum-fix-padding with a file, component or page. Not for a control's height or side padding, a panel's width, or which parts go on a screen (continuum-taste).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Fix padding
|
|
7
|
+
|
|
8
|
+
Spacing here is derived, not picked. A box's padding follows its content: the size of its type, how much text it holds and the boxes inside it. Gaps between texts follow the text after them. Every result is snapped to a Tailwind spacing step and written as a class (`p-6`, `gap-1.5`), never as `p-[22px]` or an inline style.
|
|
9
|
+
|
|
10
|
+
## The formula
|
|
11
|
+
|
|
12
|
+
Defaults are in `scripts/spacing.ts` (the same file as `src/lib/spacing.ts` in the Continuum repo, and exported from `@contui/ui`):
|
|
13
|
+
|
|
14
|
+
| Term | Rule | Default |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| Type size of a box | the font size **averaged over its lines** (each inner box counts as one line at its own size), never the largest; one big figure must not pad a whole card | |
|
|
17
|
+
| Padding of a box of text | `k × size × (1 + α·log₂ lines)` | k 0.75, α 0.6 |
|
|
18
|
+
| Padding of a box of boxes | at least `r ×` the inner boxes' padding | r 1.5 |
|
|
19
|
+
| Gap between alike boxes | `g ×` the inner boxes' padding (cards in a row, a list's items) | g 1.1 |
|
|
20
|
+
| Gap between unlike blocks | in a group with no surface (the page column, a section), each block **claims its own room** and the gap is the sum: room = `c × size × (1 + γ·log₂ lines)`, every line and row it holds counted. A page head over a dense table lands near 64, over ten rows near 56; a bare title over a short card near 32 | c 0.375, γ 1.85 |
|
|
21
|
+
| Gap between unlike blocks inside a card | the same sum, each block claiming `i ×` its room and counting at most its first `n` lines, so a long list does not push its own title away: a stat card's figure → its badge 12, a card's title → its list near 14. Never the alike-box gap here | i 0.6, n 3 |
|
|
22
|
+
| Gap between two texts | `t ×` the size of the text **after** the gap `× (1 + β·log₂ lines either side)`; tight for a pair, loose between blocks | pair 0.25, block 1.5, β 0.6 |
|
|
23
|
+
| Cap | no padding past 48px | |
|
|
24
|
+
| Scale | snap to Tailwind steps: 0, 0.5 … 3.5 (every 2px), 4, 5 … 12, 14, 16, 20, 24 | |
|
|
25
|
+
|
|
26
|
+
A **pair** is two texts that belong together: a header and its subheader, a label and its value, a figure and its caption. Everything else that follows a text is a **block**.
|
|
27
|
+
|
|
28
|
+
A **group without a surface** (a section, a row of cards, a stack with no border or fill) gets no padding, only gaps, and passes its children's padding on to the box around it. Its children are **free-standing blocks** (a page head, a table, a chart, a section) that each claim their own room, unless they are **alike** (a grid of cards, a stack of the same card, a list), which share one gap from their padding: mark such a group `"set": true` (a `row` is a set unless `"set": false`).
|
|
29
|
+
|
|
30
|
+
Siblings compute their own padding; they do not share the fullest one's.
|
|
31
|
+
|
|
32
|
+
## What it covers, and what it does not
|
|
33
|
+
|
|
34
|
+
Covers: boxes that hold content (cards, panels, sheet and dialog bodies, sections, list rows, empty states, popovers with text) and the gaps between texts and between boxes.
|
|
35
|
+
|
|
36
|
+
Leave alone:
|
|
37
|
+
- **Controls with a fixed height** (buttons, inputs, selects, chips, badges, tabs, nav items, menu items): their side padding is fixed per kind and their height comes from the height scale.
|
|
38
|
+
- **Page-level insets** that a layout component sets (`PageContent`'s top padding, the 8px panel gutter).
|
|
39
|
+
- **Widths** of panels, popups and fixed columns (the sidebar, a toast, a popover, a menu's minimum): they are fixed pixel tokens, not spacing, and never follow the spacing unit. Padding a box never changes its width class.
|
|
40
|
+
- Anything the user marked as deliberate.
|
|
41
|
+
|
|
42
|
+
## Workflow
|
|
43
|
+
|
|
44
|
+
1. **Read the target** (the file, component or page named). Find each box that holds content and each run of text, and note its Tailwind type class.
|
|
45
|
+
2. **Map type to px** with the theme: in Continuum `text-xxs` 11, `text-xs` 13, `text-sm` 14, `text-base` 16, `text-lg` 18, `text-xl` 20, `text-2xl` 24, `text-3xl` 31 (the scale tool UI uses; the values themselves live in the Continuum skill's `references/foundations.md`). In another project read its `--text-*` tokens.
|
|
46
|
+
3. **Count lines.** Measure them in the running app where you can (`Range.getClientRects()` on the text, or a screenshot at the real width). Otherwise give the text and let the script estimate about eight words to a line, and say that you estimated.
|
|
47
|
+
4. **Write the box tree** as JSON and run the script from the skill's folder:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{ "id": "card", "children": [
|
|
51
|
+
{ "text": "Seats", "size": 13 },
|
|
52
|
+
{ "text": "8 of 10", "size": 24, "pair": true },
|
|
53
|
+
{ "text": "Two left to assign", "size": 13, "pair": true }
|
|
54
|
+
] }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
node scripts/compute.ts tree.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
It prints, per box, the padding class and each gap with what it sits between. Use `"surface": false` for a group with no border or fill, `"row": true` for a horizontal one, and `--params '{"k":0.8}'` only when the user asks to try other constants.
|
|
62
|
+
5. **Compare with the code.** List each box's current padding and gaps against the result. A difference of one step or less is noise unless the user asked for exact values; a larger one is a fix.
|
|
63
|
+
6. **Apply** the classes: `p-*` for padding (keep `px-*`/`py-*` only where the component deliberately differs per side, and say so), `gap-*` on the flex or grid parent for gaps, rather than margins on children. Never write an arbitrary value; if a result seems to need one, the tree is wrong, so look again at sizes, pairs and surfaces.
|
|
64
|
+
7. **Check it** with a screenshot of the result at its real width, sparse and dense content if both occur. If something reads off, say which term caused it (usually a pair marked as a block, or a box that should have no surface) rather than nudging a value by hand.
|
|
65
|
+
8. **Report** a short table: box, before, after, why.
|
|
66
|
+
|
|
67
|
+
## When the formula and the eye disagree
|
|
68
|
+
|
|
69
|
+
The constants were judged by eye on a whole billing screen, with every term tuned against the others. If a result looks wrong after the tree is right, do not override it in the one component: raise it with the user, since the fix belongs in the constants, and try new ones with `--params` first.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Works a component's padding and gaps out with Continuum's spacing formula and prints them as
|
|
3
|
+
* Tailwind classes. Give it the box tree as JSON, as a file or on stdin:
|
|
4
|
+
*
|
|
5
|
+
* node scripts/compute.ts tree.json
|
|
6
|
+
*
|
|
7
|
+
* A box: { "id": "card", "surface": true, "row": false, "children": [...] }
|
|
8
|
+
* `surface: false` is a group with no border or fill of its own (a page column, a section, a
|
|
9
|
+
* row of cards): it gets no padding, only gaps, and passes its children's padding on. Its
|
|
10
|
+
* children stand free: each claims its own room and the gap between them is the sum (a page
|
|
11
|
+
* head over a dense table lands near 64), unless they are alike.
|
|
12
|
+
* `set: true` marks a group of alike items (a grid of cards, a stack of the same card, a
|
|
13
|
+
* list): they share one gap from their padding. A `row` is a set unless `set: false`.
|
|
14
|
+
* A text: { "text": "Billing", "size": 24 } or { "lines": 3, "size": 13 }
|
|
15
|
+
* `pair: true` when it belongs with the text before it (a subheader, a value, a caption).
|
|
16
|
+
* Give `lines` when you measured them; otherwise they are estimated from `text`.
|
|
17
|
+
*
|
|
18
|
+
* Pass `--params '{"k":0.8}'` to try other constants.
|
|
19
|
+
*/
|
|
20
|
+
import { readFileSync } from 'node:fs';
|
|
21
|
+
import {
|
|
22
|
+
blockGap,
|
|
23
|
+
blockRoom,
|
|
24
|
+
boxGap,
|
|
25
|
+
boxPadding,
|
|
26
|
+
estimateLines,
|
|
27
|
+
insideRoom,
|
|
28
|
+
type SpacingParams,
|
|
29
|
+
snapToSpacing,
|
|
30
|
+
spacingClass,
|
|
31
|
+
spacingDefaults,
|
|
32
|
+
textGap,
|
|
33
|
+
typeSize,
|
|
34
|
+
} from './spacing.ts';
|
|
35
|
+
|
|
36
|
+
type TextNode = { text?: string; lines?: number; size: number; pair?: boolean };
|
|
37
|
+
type BoxNode = { id: string; surface?: boolean; row?: boolean; set?: boolean; children: Node[] };
|
|
38
|
+
type Node = TextNode | BoxNode;
|
|
39
|
+
|
|
40
|
+
type Result = {
|
|
41
|
+
id: string;
|
|
42
|
+
surface: boolean;
|
|
43
|
+
padding: number;
|
|
44
|
+
/** What the box around it steps past. */
|
|
45
|
+
reach: number;
|
|
46
|
+
/** The room it claims beside an unlike block, unsnapped. */
|
|
47
|
+
room: number;
|
|
48
|
+
/** Its type size, averaged over its lines and inner boxes. */
|
|
49
|
+
size: number;
|
|
50
|
+
/** Its lines of content: its own, and one for each box inside it. */
|
|
51
|
+
lines: number;
|
|
52
|
+
gaps: { between: string; px: number; className: string }[];
|
|
53
|
+
children: Result[];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const isBox = (node: Node): node is BoxNode => 'children' in node;
|
|
57
|
+
const runOf = (node: TextNode): TypeRun => ({
|
|
58
|
+
size: node.size,
|
|
59
|
+
lines: node.lines ?? estimateLines(node.text ?? ''),
|
|
60
|
+
});
|
|
61
|
+
const nameOf = (node: Node) =>
|
|
62
|
+
isBox(node) ? node.id : JSON.stringify(node.text ?? `${node.lines} lines`);
|
|
63
|
+
|
|
64
|
+
const solve = (box: BoxNode, params: SpacingParams): Result => {
|
|
65
|
+
const children = box.children.map(child => (isBox(child) ? solve(child, params) : child));
|
|
66
|
+
const boxes = children.filter((child): child is Result => 'reach' in child);
|
|
67
|
+
const texts = children.filter((child): child is TextNode => !('reach' in child));
|
|
68
|
+
const reaches = boxes.map(child => child.reach);
|
|
69
|
+
const ownRuns = texts.map(runOf);
|
|
70
|
+
const inner = boxes.map(child => ({ padding: child.reach, size: child.size }));
|
|
71
|
+
|
|
72
|
+
const surface = box.surface !== false;
|
|
73
|
+
const alike = box.set ?? Boolean(box.row);
|
|
74
|
+
// Beside an unlike block, each claims its room: standing free, all of it; inside a box with a
|
|
75
|
+
// surface (a card), its insideRoom.
|
|
76
|
+
const roomOf = (index: number) => {
|
|
77
|
+
const solved = children[index];
|
|
78
|
+
const { size, lines } =
|
|
79
|
+
solved && 'reach' in solved ? solved : runOf(box.children[index] as TextNode);
|
|
80
|
+
if (!surface) {
|
|
81
|
+
return solved && 'reach' in solved
|
|
82
|
+
? solved.room
|
|
83
|
+
: blockRoom({ runs: [{ size, lines }] }, params);
|
|
84
|
+
}
|
|
85
|
+
return insideRoom({ size, lines }, params);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const gaps: Result['gaps'] = [];
|
|
89
|
+
box.children.forEach((child, index) => {
|
|
90
|
+
const before = box.children[index - 1];
|
|
91
|
+
if (!before) return;
|
|
92
|
+
const between = `${nameOf(before)} → ${nameOf(child)}`;
|
|
93
|
+
const px =
|
|
94
|
+
isBox(child) || isBox(before)
|
|
95
|
+
? snapToSpacing(
|
|
96
|
+
// Alike boxes share one gap from their padding; unlike ones, inside a card or
|
|
97
|
+
// standing free, each claim their own room.
|
|
98
|
+
alike ? boxGap(reaches, params) : blockGap(roomOf(index - 1), roomOf(index)),
|
|
99
|
+
)
|
|
100
|
+
: snapToSpacing(
|
|
101
|
+
textGap(
|
|
102
|
+
{ before: runOf(before), after: runOf(child), pair: Boolean(child.pair) },
|
|
103
|
+
params,
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
gaps.push({ between, px, className: spacingClass(box.row ? 'gap-x' : 'gap', px) });
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const padding = surface
|
|
110
|
+
? snapToSpacing(boxPadding({ runs: ownRuns, children: inner }, params))
|
|
111
|
+
: 0;
|
|
112
|
+
const size = typeSize([...ownRuns, ...inner.map(child => ({ size: child.size, lines: 1 }))]);
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
id: box.id,
|
|
116
|
+
surface,
|
|
117
|
+
padding,
|
|
118
|
+
reach: surface ? padding : Math.max(0, ...reaches),
|
|
119
|
+
room: blockRoom({ runs: ownRuns, children: inner }, params),
|
|
120
|
+
size,
|
|
121
|
+
lines: [...ownRuns, ...inner.map(() => ({ lines: 1 }))].reduce(
|
|
122
|
+
(sum, run) => sum + run.lines,
|
|
123
|
+
0,
|
|
124
|
+
),
|
|
125
|
+
gaps,
|
|
126
|
+
children: boxes,
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const print = (result: Result, depth = 0) => {
|
|
131
|
+
const indent = ' '.repeat(depth);
|
|
132
|
+
const pad = result.surface
|
|
133
|
+
? `${spacingClass('p', result.padding)} (${result.padding}px)`
|
|
134
|
+
: 'no surface: gaps only';
|
|
135
|
+
console.log(`${indent}${result.id}: ${pad}`);
|
|
136
|
+
for (const gap of result.gaps) {
|
|
137
|
+
console.log(
|
|
138
|
+
`${indent} ${gap.className.padEnd(9)} ${String(gap.px).padStart(2)}px ${gap.between}`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
for (const child of result.children) print(child, depth + 1);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const args = process.argv.slice(2);
|
|
145
|
+
const paramsAt = args.indexOf('--params');
|
|
146
|
+
const params: SpacingParams = {
|
|
147
|
+
...spacingDefaults,
|
|
148
|
+
...(paramsAt >= 0 ? JSON.parse(args[paramsAt + 1] ?? '{}') : {}),
|
|
149
|
+
};
|
|
150
|
+
const file = args.find(
|
|
151
|
+
(arg, index) => !arg.startsWith('--') && (paramsAt < 0 || index !== paramsAt + 1),
|
|
152
|
+
);
|
|
153
|
+
const tree = JSON.parse(readFileSync(file ?? 0, 'utf8')) as BoxNode;
|
|
154
|
+
|
|
155
|
+
print(solve(tree, params));
|
|
@@ -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
|
+
};
|