@sdxc/ui 2026.10.29 → 2026.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +187 -113
- package/dist/{behaviors → app/behaviors}/drag-session.js +1 -1
- package/dist/{behaviors → app/behaviors}/toaster.js +1 -1
- package/dist/{components → app}/chart.d.ts +1 -1
- package/dist/{components → app}/chart.js +18 -34
- package/dist/{components → app}/context-menu.d.ts +2 -2
- package/dist/{components → app}/context-menu.js +8 -7
- package/dist/{components → app}/drop-indicator.js +3 -3
- package/dist/{components → app}/drop-zone.js +3 -3
- package/dist/{components → app}/empty.d.ts +1 -1
- package/dist/{components → app}/empty.js +11 -21
- package/dist/{components → app}/file-trigger.js +2 -2
- package/dist/{components → app}/grid-list.d.ts +1 -1
- package/dist/{components → app}/grid-list.js +16 -18
- package/dist/app/index.d.ts +41 -0
- package/dist/app/index.js +41 -0
- package/dist/{components → app}/menubar.js +5 -7
- package/dist/{mixins → app/mixins}/drag-reorder.js +1 -1
- package/dist/{mixins → app/mixins}/drop-zone.js +1 -1
- package/dist/{mixins → app/mixins}/grid-list-keys.js +2 -2
- package/dist/{mixins → app/mixins}/menubar-keys.js +2 -2
- package/dist/{mixins → app/mixins}/resize-handle.js +3 -3
- package/dist/{mixins/treeKeys.js → app/mixins/tree-keys.js} +2 -2
- package/dist/{components → app}/resizable.js +7 -10
- package/dist/{components → app}/shortcut-list.js +4 -3
- package/dist/{components → app}/skeleton.js +3 -3
- package/dist/{styles → app/styles}/chart-palette.d.ts +1 -1
- package/dist/{styles → app/styles}/graphic-host.d.ts +1 -1
- package/dist/{styles → app/styles}/legend-toggle.d.ts +1 -1
- package/dist/{components → app}/table.js +12 -15
- package/dist/{components → app}/toast.js +18 -24
- package/dist/{components → app}/toolbar.js +3 -3
- package/dist/{components → app}/tree.d.ts +1 -1
- package/dist/{components → app}/tree.js +10 -14
- package/dist/{utils → app/utils}/chart-path.d.ts +1 -1
- package/dist/{utils → app/utils}/chart-path.js +2 -2
- package/dist/{utils → app/utils}/chart-scale.js +1 -1
- package/dist/behaviors/index.d.ts +0 -5
- package/dist/behaviors/index.js +0 -5
- package/dist/{components → chat}/attachment.d.ts +1 -1
- package/dist/{components → chat}/attachment.js +17 -23
- package/dist/{behaviors → chat/behaviors}/scroll-follow-model.js +1 -1
- package/dist/{components → chat}/bubble.js +14 -14
- package/dist/chat/index.d.ts +16 -0
- package/dist/chat/index.js +16 -0
- package/dist/{components → chat}/marker.js +6 -8
- package/dist/{components → chat}/message-scroller.d.ts +1 -1
- package/dist/{components → chat}/message-scroller.js +12 -18
- package/dist/{components → chat}/message.js +10 -12
- package/dist/{mixins → chat/mixins}/message-follow.js +2 -2
- package/dist/{components → color}/color-area.js +7 -10
- package/dist/{components → color}/color-field.js +7 -6
- package/dist/{components → color}/color-picker.d.ts +1 -1
- package/dist/{components → color}/color-picker.js +9 -12
- package/dist/{components → color}/color-slider.js +10 -13
- package/dist/{components → color}/color-swatch-picker.js +4 -5
- package/dist/{components → color}/color-swatch.js +3 -4
- package/dist/{components → color}/color-wheel.js +5 -6
- package/dist/color/index.d.ts +21 -0
- package/dist/color/index.js +21 -0
- package/dist/{mixins → color/mixins}/color-area-drag.d.ts +1 -1
- package/dist/{mixins → color/mixins}/color-area-drag.js +2 -2
- package/dist/{mixins → color/mixins}/color-preview.js +1 -1
- package/dist/{mixins → color/mixins}/color-wheel-drag.js +1 -1
- package/dist/{styles → color/styles}/rtl-aware-gradient-direction.d.ts +1 -1
- package/dist/components/accordion.d.ts +3 -3
- package/dist/components/accordion.js +19 -15
- package/dist/components/alert-dialog.js +5 -4
- package/dist/components/alert.js +10 -20
- package/dist/components/aspect-ratio.js +3 -4
- package/dist/components/avatar.d.ts +6 -6
- package/dist/components/avatar.js +56 -8
- package/dist/components/badge.js +11 -9
- package/dist/components/breadcrumbs.js +7 -9
- package/dist/components/button.d.ts +8 -6
- package/dist/components/button.js +22 -14
- package/dist/components/calendar.js +13 -24
- package/dist/components/card.js +9 -11
- package/dist/components/carousel.d.ts +1 -1
- package/dist/components/carousel.js +12 -20
- package/dist/components/checkbox-group.js +3 -3
- package/dist/components/checkbox.js +2 -2
- package/dist/components/combobox.js +6 -6
- package/dist/components/command.js +10 -14
- package/dist/components/cta-group.d.ts +30 -14
- package/dist/components/cta-group.js +29 -10
- package/dist/components/date-field.js +2 -1
- package/dist/components/date-picker.js +4 -5
- package/dist/components/date-range-picker.js +3 -2
- package/dist/components/description.js +2 -1
- package/dist/components/dialog-dismiss.d.ts +18 -0
- package/dist/components/dialog-dismiss.js +15 -0
- package/dist/components/dialog.js +11 -15
- package/dist/components/disclosure.js +10 -14
- package/dist/components/drawer.js +3 -4
- package/dist/components/field-error.js +3 -3
- package/dist/components/form.js +2 -1
- package/dist/components/group.js +3 -3
- package/dist/components/header.js +3 -3
- package/dist/components/heading-scope.js +2 -1
- package/dist/components/heading.d.ts +4 -4
- package/dist/components/heading.js +7 -7
- package/dist/components/highlight.js +17 -12
- package/dist/components/hover-card.js +6 -8
- package/dist/components/image-placeholder.js +13 -19
- package/dist/components/index.d.ts +6 -38
- package/dist/components/index.js +6 -38
- package/dist/components/input.js +3 -4
- package/dist/components/item.js +10 -19
- package/dist/components/keyboard.js +3 -3
- package/dist/components/label.js +2 -1
- package/dist/components/link-button.d.ts +7 -5
- package/dist/components/link-button.js +16 -11
- package/dist/components/link.js +3 -4
- package/dist/components/listbox.js +6 -11
- package/dist/components/menu.js +5 -6
- package/dist/components/meter.js +5 -6
- package/dist/components/modal.js +9 -11
- package/dist/components/nav-link.d.ts +1 -1
- package/dist/components/nav-link.js +3 -4
- package/dist/components/navigation-menu.js +17 -23
- package/dist/components/number-field.js +8 -10
- package/dist/components/otp-field.js +2 -1
- package/dist/components/overlay-arrow.js +3 -4
- package/dist/components/pagination.js +8 -10
- package/dist/components/popover.js +3 -4
- package/dist/components/progress-bar.js +5 -5
- package/dist/components/radio-group.js +5 -7
- package/dist/components/range-calendar.js +3 -3
- package/dist/components/scroll-area.js +4 -5
- package/dist/components/search-field.js +8 -11
- package/dist/components/section.js +2 -1
- package/dist/components/select.js +10 -22
- package/dist/components/selection-indicator.js +3 -3
- package/dist/components/sentinel-row.js +3 -3
- package/dist/components/separator.js +3 -3
- package/dist/components/shared-element.js +2 -1
- package/dist/components/sheet.js +6 -7
- package/dist/components/sidebar.js +48 -76
- package/dist/components/slider.js +8 -10
- package/dist/components/spinner.js +3 -3
- package/dist/components/switch.js +3 -3
- package/dist/components/tabs.js +9 -12
- package/dist/components/tag-group.js +7 -9
- package/dist/components/text-field.js +2 -1
- package/dist/components/text.js +2 -1
- package/dist/components/textarea.js +3 -4
- package/dist/components/time-field.js +2 -1
- package/dist/components/toggle-button.js +5 -7
- package/dist/components/tooltip.js +3 -3
- package/dist/components/typeset.js +128 -123
- package/dist/components/youtube-embed.js +2 -1
- package/dist/docs/anchor-heading.d.ts +41 -0
- package/dist/docs/anchor-heading.js +62 -0
- package/dist/docs/callout.d.ts +46 -0
- package/dist/docs/callout.js +61 -0
- package/dist/docs/code-block.d.ts +74 -0
- package/dist/docs/code-block.js +322 -0
- package/dist/docs/code-tabs-sync.d.ts +26 -0
- package/dist/docs/code-tabs-sync.js +12 -0
- package/dist/docs/code-tabs.d.ts +53 -0
- package/dist/docs/code-tabs.js +102 -0
- package/dist/docs/copy-button.d.ts +31 -0
- package/dist/docs/copy-button.js +49 -0
- package/dist/docs/docs-feedback.d.ts +55 -0
- package/dist/docs/docs-feedback.js +72 -0
- package/dist/docs/docs-footer.d.ts +40 -0
- package/dist/docs/docs-footer.js +45 -0
- package/dist/docs/docs-hub.d.ts +93 -0
- package/dist/docs/docs-hub.js +142 -0
- package/dist/docs/docs-layout.d.ts +90 -0
- package/dist/docs/docs-layout.js +166 -0
- package/dist/docs/docs-nav-tools.d.ts +25 -0
- package/dist/docs/docs-nav-tools.js +14 -0
- package/dist/docs/docs-nav.d.ts +53 -0
- package/dist/docs/docs-nav.js +76 -0
- package/dist/docs/docs-not-found.d.ts +68 -0
- package/dist/docs/docs-not-found.js +100 -0
- package/dist/docs/docs-page-header.d.ts +55 -0
- package/dist/docs/docs-page-header.js +54 -0
- package/dist/docs/docs-pager.d.ts +46 -0
- package/dist/docs/docs-pager.js +74 -0
- package/dist/docs/file-tree.d.ts +57 -0
- package/dist/docs/file-tree.js +142 -0
- package/dist/docs/index.d.ts +38 -0
- package/dist/docs/index.js +38 -0
- package/dist/docs/install-command.d.ts +54 -0
- package/dist/docs/install-command.js +33 -0
- package/dist/docs/mixins/code-tabs-sync.d.ts +47 -0
- package/dist/docs/mixins/code-tabs-sync.js +137 -0
- package/dist/docs/mixins/copy-feedback.d.ts +25 -0
- package/dist/docs/mixins/copy-feedback.js +49 -0
- package/dist/docs/mixins/copy-from-url.d.ts +27 -0
- package/dist/docs/mixins/copy-from-url.js +95 -0
- package/dist/docs/mixins/docs-nav-tools.d.ts +27 -0
- package/dist/docs/mixins/docs-nav-tools.js +97 -0
- package/dist/docs/mixins/toc-spy.d.ts +30 -0
- package/dist/docs/mixins/toc-spy.js +165 -0
- package/dist/docs/next-steps.d.ts +45 -0
- package/dist/docs/next-steps.js +79 -0
- package/dist/docs/page-actions.d.ts +77 -0
- package/dist/docs/page-actions.js +78 -0
- package/dist/docs/plan-notice.d.ts +28 -0
- package/dist/docs/plan-notice.js +33 -0
- package/dist/docs/props-table.d.ts +64 -0
- package/dist/docs/props-table.js +147 -0
- package/dist/docs/steps.d.ts +51 -0
- package/dist/docs/steps.js +112 -0
- package/dist/docs/table-of-contents.d.ts +49 -0
- package/dist/docs/table-of-contents.js +139 -0
- package/dist/docs/ui-label.d.ts +51 -0
- package/dist/docs/ui-label.js +64 -0
- package/dist/docs/utils/docs-tree.d.ts +81 -0
- package/dist/docs/utils/docs-tree.js +57 -0
- package/dist/docs/utils/reveal-in-scroller.d.ts +19 -0
- package/dist/docs/utils/reveal-in-scroller.js +43 -0
- package/dist/landing/accent-text.d.ts +47 -0
- package/dist/landing/accent-text.js +107 -0
- package/dist/landing/animations/entrance.d.ts +40 -0
- package/dist/landing/animations/entrance.js +52 -0
- package/dist/landing/announcement-chip.d.ts +45 -0
- package/dist/landing/announcement-chip.js +36 -0
- package/dist/landing/author-band.d.ts +78 -0
- package/dist/landing/author-band.js +190 -0
- package/dist/landing/bento.d.ts +99 -0
- package/dist/landing/bento.js +138 -0
- package/dist/landing/changelog-strip.d.ts +74 -0
- package/dist/landing/changelog-strip.js +201 -0
- package/dist/{patterns → landing}/check-row.js +5 -7
- package/dist/{patterns → landing}/closing-cta.d.ts +4 -4
- package/dist/{patterns → landing}/closing-cta.js +8 -8
- package/dist/landing/code-stage.d.ts +93 -0
- package/dist/landing/code-stage.js +434 -0
- package/dist/landing/crosshair.d.ts +44 -0
- package/dist/landing/crosshair.js +48 -0
- package/dist/landing/curriculum.d.ts +79 -0
- package/dist/landing/curriculum.js +194 -0
- package/dist/landing/drawn-chart.d.ts +74 -0
- package/dist/landing/drawn-chart.js +377 -0
- package/dist/landing/event-ticker.d.ts +71 -0
- package/dist/landing/event-ticker.js +331 -0
- package/dist/landing/fan-out-diagram.d.ts +70 -0
- package/dist/landing/fan-out-diagram.js +481 -0
- package/dist/{patterns → landing}/faq-band.d.ts +7 -5
- package/dist/{patterns → landing}/faq-band.js +11 -12
- package/dist/landing/feature-band.d.ts +108 -0
- package/dist/landing/feature-band.js +67 -0
- package/dist/landing/feature.d.ts +148 -0
- package/dist/landing/feature.js +219 -0
- package/dist/landing/flow-diagram.d.ts +62 -0
- package/dist/landing/flow-diagram.js +240 -0
- package/dist/{patterns → landing}/icon-well.d.ts +17 -7
- package/dist/landing/icon-well.js +31 -0
- package/dist/landing/index.d.ts +52 -0
- package/dist/landing/index.js +52 -0
- package/dist/{patterns → landing}/install-tabs.js +4 -5
- package/dist/landing/landing-header.d.ts +103 -0
- package/dist/landing/landing-header.js +110 -0
- package/dist/landing/landing-hero.d.ts +119 -0
- package/dist/landing/landing-hero.js +172 -0
- package/dist/landing/landing-section.d.ts +110 -0
- package/dist/landing/landing-section.js +183 -0
- package/dist/landing/logo-cloud.d.ts +56 -0
- package/dist/landing/logo-cloud.js +160 -0
- package/dist/landing/logo-sentence.d.ts +38 -0
- package/dist/landing/logo-sentence.js +51 -0
- package/dist/landing/marquee.d.ts +44 -0
- package/dist/landing/marquee.js +97 -0
- package/dist/landing/motion-loop.d.ts +43 -0
- package/dist/landing/motion-loop.js +42 -0
- package/dist/landing/pricing-band.d.ts +94 -0
- package/dist/landing/pricing-band.js +151 -0
- package/dist/landing/product-frame.d.ts +108 -0
- package/dist/landing/product-frame.js +202 -0
- package/dist/{patterns → landing}/proof-strip.d.ts +4 -4
- package/dist/{patterns → landing}/proof-strip.js +3 -3
- package/dist/landing/rails.d.ts +45 -0
- package/dist/landing/rails.js +69 -0
- package/dist/landing/rotating-text.d.ts +44 -0
- package/dist/landing/rotating-text.js +67 -0
- package/dist/landing/segmented-stage.d.ts +75 -0
- package/dist/landing/segmented-stage.js +141 -0
- package/dist/landing/sequence-diagram.d.ts +65 -0
- package/dist/landing/sequence-diagram.js +348 -0
- package/dist/landing/site-footer.d.ts +100 -0
- package/dist/landing/site-footer.js +274 -0
- package/dist/landing/site-header.d.ts +126 -0
- package/dist/landing/site-header.js +595 -0
- package/dist/{components → landing}/split.d.ts +14 -4
- package/dist/{components → landing}/split.js +30 -21
- package/dist/landing/sponsor-wall.d.ts +81 -0
- package/dist/landing/sponsor-wall.js +241 -0
- package/dist/{components → landing}/stat-strip.d.ts +31 -4
- package/dist/landing/stat-strip.js +105 -0
- package/dist/landing/step-list.d.ts +73 -0
- package/dist/landing/step-list.js +182 -0
- package/dist/landing/styles/card-grid.d.ts +115 -0
- package/dist/landing/styles/card-grid.js +295 -0
- package/dist/{patterns → landing}/tabbed-stage.d.ts +26 -8
- package/dist/landing/tabbed-stage.js +233 -0
- package/dist/landing/testimonial-band.d.ts +110 -0
- package/dist/landing/testimonial-band.js +164 -0
- package/dist/landing/typed-terminal.d.ts +62 -0
- package/dist/landing/typed-terminal.js +233 -0
- package/dist/landing/utils/pause-toggle.d.ts +37 -0
- package/dist/landing/utils/pause-toggle.js +71 -0
- package/dist/mixins/copy-to-clipboard.d.ts +6 -0
- package/dist/mixins/copy-to-clipboard.js +17 -1
- package/dist/mixins/dialog-dismiss.d.ts +21 -0
- package/dist/mixins/dialog-dismiss.js +62 -0
- package/dist/mixins/index.d.ts +2 -15
- package/dist/mixins/index.js +2 -15
- package/dist/styles/index.d.ts +2 -5
- package/dist/styles/index.js +2 -5
- package/dist/styles/landing.d.ts +200 -0
- package/dist/styles/landing.js +516 -0
- package/dist/styles/surface-control.d.ts +18 -0
- package/dist/styles/surface-control.js +31 -0
- package/dist/utils/eyebrow.d.ts +39 -0
- package/dist/utils/eyebrow.js +21 -0
- package/dist/utils/index.d.ts +1 -5
- package/dist/utils/index.js +1 -5
- package/package.json +14 -4
- package/src/theme.css +87 -22
- package/dist/components/feature.d.ts +0 -102
- package/dist/components/feature.js +0 -151
- package/dist/components/logo-cloud.d.ts +0 -42
- package/dist/components/logo-cloud.js +0 -41
- package/dist/components/marketing-header.d.ts +0 -71
- package/dist/components/marketing-header.js +0 -81
- package/dist/components/marketing-section.d.ts +0 -81
- package/dist/components/marketing-section.js +0 -103
- package/dist/components/stat-strip.js +0 -64
- package/dist/patterns/accent-text.d.ts +0 -30
- package/dist/patterns/accent-text.js +0 -17
- package/dist/patterns/announcement-chip.d.ts +0 -41
- package/dist/patterns/announcement-chip.js +0 -49
- package/dist/patterns/bento.d.ts +0 -67
- package/dist/patterns/bento.js +0 -95
- package/dist/patterns/code-stage.d.ts +0 -63
- package/dist/patterns/code-stage.js +0 -82
- package/dist/patterns/feature-band.d.ts +0 -85
- package/dist/patterns/feature-band.js +0 -50
- package/dist/patterns/icon-well.js +0 -38
- package/dist/patterns/index.d.ts +0 -23
- package/dist/patterns/index.js +0 -23
- package/dist/patterns/landing-hero.d.ts +0 -93
- package/dist/patterns/landing-hero.js +0 -126
- package/dist/patterns/product-frame.d.ts +0 -60
- package/dist/patterns/product-frame.js +0 -70
- package/dist/patterns/step-list.d.ts +0 -45
- package/dist/patterns/step-list.js +0 -84
- package/dist/patterns/tabbed-stage.js +0 -77
- package/dist/styles/marketing.d.ts +0 -120
- package/dist/styles/marketing.js +0 -225
- package/dist/utils/semantic-color-panel.d.ts +0 -35
- package/dist/utils/semantic-color-panel.js +0 -28
- /package/dist/{behaviors → app/behaviors}/drag-session.d.ts +0 -0
- /package/dist/{behaviors → app/behaviors}/resize-session.d.ts +0 -0
- /package/dist/{behaviors → app/behaviors}/resize-session.js +0 -0
- /package/dist/{behaviors → app/behaviors}/selection-model.d.ts +0 -0
- /package/dist/{behaviors → app/behaviors}/selection-model.js +0 -0
- /package/dist/{behaviors → app/behaviors}/toaster.d.ts +0 -0
- /package/dist/{components → app}/drop-indicator.d.ts +0 -0
- /package/dist/{components → app}/drop-zone.d.ts +0 -0
- /package/dist/{components → app}/file-trigger.d.ts +0 -0
- /package/dist/{components → app}/menubar.d.ts +0 -0
- /package/dist/{mixins → app/mixins}/chart-tooltip.d.ts +0 -0
- /package/dist/{mixins → app/mixins}/chart-tooltip.js +0 -0
- /package/dist/{mixins → app/mixins}/context-menu.d.ts +0 -0
- /package/dist/{mixins → app/mixins}/context-menu.js +0 -0
- /package/dist/{mixins → app/mixins}/drag-reorder.d.ts +0 -0
- /package/dist/{mixins → app/mixins}/drop-zone.d.ts +0 -0
- /package/dist/{mixins → app/mixins}/grid-list-keys.d.ts +0 -0
- /package/dist/{mixins → app/mixins}/menubar-keys.d.ts +0 -0
- /package/dist/{mixins → app/mixins}/resize-handle.d.ts +0 -0
- /package/dist/{mixins/treeKeys.d.ts → app/mixins/tree-keys.d.ts} +0 -0
- /package/dist/{components → app}/resizable.d.ts +0 -0
- /package/dist/{components → app}/shortcut-list.d.ts +0 -0
- /package/dist/{components → app}/skeleton.d.ts +0 -0
- /package/dist/{styles → app/styles}/chart-palette.js +0 -0
- /package/dist/{styles → app/styles}/graphic-host.js +0 -0
- /package/dist/{styles → app/styles}/legend-toggle.js +0 -0
- /package/dist/{components → app}/table.d.ts +0 -0
- /package/dist/{components → app}/toast.d.ts +0 -0
- /package/dist/{components → app}/toolbar.d.ts +0 -0
- /package/dist/{utils → app/utils}/chart-marker-indices.d.ts +0 -0
- /package/dist/{utils → app/utils}/chart-marker-indices.js +0 -0
- /package/dist/{utils → app/utils}/chart-scale.d.ts +0 -0
- /package/dist/{behaviors → chat/behaviors}/scroll-follow-model.d.ts +0 -0
- /package/dist/{components → chat}/bubble.d.ts +0 -0
- /package/dist/{components → chat}/marker.d.ts +0 -0
- /package/dist/{components → chat}/message.d.ts +0 -0
- /package/dist/{mixins → chat/mixins}/attachment-trigger.d.ts +0 -0
- /package/dist/{mixins → chat/mixins}/attachment-trigger.js +0 -0
- /package/dist/{mixins → chat/mixins}/message-follow.d.ts +0 -0
- /package/dist/{components → color}/color-area.d.ts +0 -0
- /package/dist/{components → color}/color-field.d.ts +0 -0
- /package/dist/{components → color}/color-slider.d.ts +0 -0
- /package/dist/{components → color}/color-swatch-picker.d.ts +0 -0
- /package/dist/{components → color}/color-swatch.d.ts +0 -0
- /package/dist/{components → color}/color-wheel.d.ts +0 -0
- /package/dist/{mixins → color/mixins}/color-channel-sync.d.ts +0 -0
- /package/dist/{mixins → color/mixins}/color-channel-sync.js +0 -0
- /package/dist/{mixins → color/mixins}/color-preview.d.ts +0 -0
- /package/dist/{mixins → color/mixins}/color-wheel-drag.d.ts +0 -0
- /package/dist/{styles → color/styles}/rtl-aware-gradient-direction.js +0 -0
- /package/dist/{utils → color/utils}/hue-spectrum.d.ts +0 -0
- /package/dist/{utils → color/utils}/hue-spectrum.js +0 -0
- /package/dist/{patterns → landing}/check-row.d.ts +0 -0
- /package/dist/{patterns → landing}/install-tabs.d.ts +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A titled mono panel for install samples, CLI output, or code snippets on a
|
|
3
|
+
* landing, optionally highlighted, numbered, or split into file tabs that switch
|
|
4
|
+
* through a radio group alone. The actions slot holds a copy control the page supplies.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Prop types for {@link CodeStage}.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace CodeStage {
|
|
14
|
+
/**
|
|
15
|
+
* Surface treatment: a raised code card, a darker terminal panel, or a slab
|
|
16
|
+
* that stays dark in both schemes and holds a translucent code sheet.
|
|
17
|
+
*/
|
|
18
|
+
type Variant = "code" | "terminal" | "slab";
|
|
19
|
+
/**
|
|
20
|
+
* One file of a tabbed stage: the tab's label and the source its panel shows.
|
|
21
|
+
*/
|
|
22
|
+
interface Tab {
|
|
23
|
+
/** Visible tab label, typically a file name. */
|
|
24
|
+
label: RemixNode;
|
|
25
|
+
/** Optional glyph drawn before the label. */
|
|
26
|
+
icon?: RemixNode;
|
|
27
|
+
/** Source the panel shows; a string highlights and numbers. */
|
|
28
|
+
content: RemixNode;
|
|
29
|
+
/** Language this file highlights as; falls back to the stage's `language`. */
|
|
30
|
+
language?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Per-part styling for chrome the stage renders besides its host.
|
|
34
|
+
*/
|
|
35
|
+
interface PartsProps {
|
|
36
|
+
/** Styling for the optional title bar. */
|
|
37
|
+
header?: TagProps<"div">["mix"];
|
|
38
|
+
/** Styling for each mono body that wraps code. */
|
|
39
|
+
body?: TagProps<"pre">["mix"];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Props accepted by {@link CodeStage}.
|
|
43
|
+
*/
|
|
44
|
+
interface Props extends Omit<TagProps<"div">, "title"> {
|
|
45
|
+
/** Surface treatment. Defaults to {@link DEFAULT_VARIANT}. */
|
|
46
|
+
variant?: Variant;
|
|
47
|
+
/** Optional title or path shown in the header; tabs take its place. */
|
|
48
|
+
title?: RemixNode;
|
|
49
|
+
/** Optional trailing control in the header — typically a copy button. */
|
|
50
|
+
actions?: RemixNode;
|
|
51
|
+
/**
|
|
52
|
+
* Highlights string content as this language (any name or alias
|
|
53
|
+
* `@sdxc/highlight` resolves). Element children render as given.
|
|
54
|
+
*/
|
|
55
|
+
language?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Numbers each line in a gutter beside the code. Numbering reads lines from
|
|
58
|
+
* a string; any other content renders unnumbered.
|
|
59
|
+
*/
|
|
60
|
+
lineNumbers?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Files shown as header tabs, switched by a radio group with no script; the
|
|
63
|
+
* first is selected and the stage keeps the tallest file's height.
|
|
64
|
+
*/
|
|
65
|
+
tabs?: Tab[];
|
|
66
|
+
/** Radio group name for `tabs`; defaults to an id unique to this stage. */
|
|
67
|
+
name?: string;
|
|
68
|
+
/** Per-part styling for header and body. */
|
|
69
|
+
parts?: PartsProps;
|
|
70
|
+
/** Mono body content when `tabs` is omitted — a command, snippet, or output. */
|
|
71
|
+
children?: RemixNode;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Renders an optional titled or tabbed header and a mono body that keeps every
|
|
76
|
+
* line intact and scrolls sideways inside the panel when a line outgrows it.
|
|
77
|
+
* The stage takes its content's height, so beside taller copy it sits at the top.
|
|
78
|
+
*
|
|
79
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
80
|
+
* @returns The render function producing the stage's markup.
|
|
81
|
+
* @example
|
|
82
|
+
* <CodeStage title="install.sh" actions={copyControl}>bun add @sdxc/ui</CodeStage>
|
|
83
|
+
* @example
|
|
84
|
+
* <CodeStage variant="slab" language="ts" lineNumbers>{snippet}</CodeStage>
|
|
85
|
+
* @example
|
|
86
|
+
* <CodeStage tabs={[{ label: "worker.ts", content: worker, language: "ts" }]} />
|
|
87
|
+
*/
|
|
88
|
+
export declare function CodeStage(handle: Handle<CodeStage.Props>): () => import("remix/component").RemixElement;
|
|
89
|
+
/**
|
|
90
|
+
* Alias for {@link CodeStage} with terminal chrome — same props, same host.
|
|
91
|
+
* Prefer this name when the sample is a shell session rather than a file.
|
|
92
|
+
*/
|
|
93
|
+
export declare const TerminalPanel: typeof CodeStage;
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "remix/component/jsx-runtime";
|
|
2
|
+
import { tokenize } from "@sdxc/highlight";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { border, fg } from "@sdxc/u/color";
|
|
5
|
+
import { raw, mergeMix } from "@sdxc/u/general";
|
|
6
|
+
import { hstack, vstack } from "@sdxc/u/layout";
|
|
7
|
+
import { overflowX } from "@sdxc/u/overflow";
|
|
8
|
+
import { m } from "@sdxc/u/size";
|
|
9
|
+
import { when } from "@sdxc/u/state";
|
|
10
|
+
import { font, text, weight } from "@sdxc/u/typography";
|
|
11
|
+
import { landingSurface } from "../styles/landing.js";
|
|
12
|
+
/** Corner radius of a framed window or panel; a page sets `--ui-landing-radius-frame` once. */
|
|
13
|
+
const FRAME_RADIUS = "var(--ui-landing-radius-frame, 0.75rem)";
|
|
14
|
+
/** Panel chrome {@link CodeStage} applies when `variant` is omitted. */
|
|
15
|
+
const DEFAULT_VARIANT = "code";
|
|
16
|
+
/** Light ink a slab sets its code in, readable on the slab in both schemes. */
|
|
17
|
+
const SLAB_INK = "oklch(0.93 0 0)";
|
|
18
|
+
/** Header text and rules on the dark terminal panel, derived from the page canvas. */
|
|
19
|
+
const TERMINAL_MUTED = "color-mix(in oklab, Canvas 70%, transparent)";
|
|
20
|
+
/**
|
|
21
|
+
* Inline start of the code, shared by the body's padding and the header's, so a
|
|
22
|
+
* title or tab strip starts on the code's column.
|
|
23
|
+
*/
|
|
24
|
+
const INSET = "var(--ui-code-stage-inset, 1rem)";
|
|
25
|
+
/** Fixed header height, the same in every variant so stacked stages line up. */
|
|
26
|
+
const HEADER_HEIGHT = "2.5rem";
|
|
27
|
+
/** Size and leading the code is set at; the slab keeps its 24px rhythm. */
|
|
28
|
+
const CODE_FONT_SIZE = "0.8125rem";
|
|
29
|
+
/** The gutter's share of the line ink: 60% reads at 4.5:1 or better on every panel. */
|
|
30
|
+
const GUTTER_INK = "color-mix(in oklab, currentColor 60%, transparent)";
|
|
31
|
+
/**
|
|
32
|
+
* Token colors as `[light, dark]` pairs, the light and dark GitHub palettes the
|
|
33
|
+
* shared highlight stylesheet ships, used when no page palette declares the
|
|
34
|
+
* matching `--highlight-*` property.
|
|
35
|
+
*/
|
|
36
|
+
const TOKEN_PALETTE = {
|
|
37
|
+
comment: ["#6a737d", "#8b949e"],
|
|
38
|
+
keyword: ["#d73a49", "#ff7b72"],
|
|
39
|
+
operator: ["#d73a49", "#ff7b72"],
|
|
40
|
+
string: ["#032f62", "#a5d6ff"],
|
|
41
|
+
builtin: ["#032f62", "#a5d6ff"],
|
|
42
|
+
"attr-name": ["#032f62", "#a5d6ff"],
|
|
43
|
+
"attr-value": ["#032f62", "#a5d6ff"],
|
|
44
|
+
number: ["#005cc5", "#79c0ff"],
|
|
45
|
+
boolean: ["#005cc5", "#79c0ff"],
|
|
46
|
+
constant: ["#005cc5", "#79c0ff"],
|
|
47
|
+
property: ["#005cc5", "#79c0ff"],
|
|
48
|
+
tag: ["#005cc5", "#79c0ff"],
|
|
49
|
+
function: ["#6f42c1", "#d2a8ff"],
|
|
50
|
+
"class-name": ["#6f42c1", "#d2a8ff"],
|
|
51
|
+
regex: ["#e36209", "#ffa657"],
|
|
52
|
+
variable: ["#e36209", "#ffa657"],
|
|
53
|
+
punctuation: ["#24292f", "#e6edf3"],
|
|
54
|
+
inserted: ["#22863a", "#7ee787"],
|
|
55
|
+
deleted: ["#b31d28", "#ffa198"],
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The slab is dark in both schemes, so it re-points every token property at the
|
|
59
|
+
* dark palette, whatever the page's palette declares for its own scheme.
|
|
60
|
+
*/
|
|
61
|
+
const SLAB_TOKENS = Object.fromEntries(Object.entries(TOKEN_PALETTE).map(([type, [, dark]]) => [`--highlight-${type}`, dark]));
|
|
62
|
+
/**
|
|
63
|
+
* The terminal panel inverts the page's scheme, so each token property takes the
|
|
64
|
+
* palette of the opposite scheme.
|
|
65
|
+
*/
|
|
66
|
+
const TERMINAL_TOKENS = Object.fromEntries(Object.entries(TOKEN_PALETTE).map(([type, [light, dark]]) => [
|
|
67
|
+
`--highlight-${type}`,
|
|
68
|
+
`light-dark(${dark}, ${light})`,
|
|
69
|
+
]));
|
|
70
|
+
/**
|
|
71
|
+
* Renders an optional titled or tabbed header and a mono body that keeps every
|
|
72
|
+
* line intact and scrolls sideways inside the panel when a line outgrows it.
|
|
73
|
+
* The stage takes its content's height, so beside taller copy it sits at the top.
|
|
74
|
+
*
|
|
75
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
76
|
+
* @returns The render function producing the stage's markup.
|
|
77
|
+
* @example
|
|
78
|
+
* <CodeStage title="install.sh" actions={copyControl}>bun add @sdxc/ui</CodeStage>
|
|
79
|
+
* @example
|
|
80
|
+
* <CodeStage variant="slab" language="ts" lineNumbers>{snippet}</CodeStage>
|
|
81
|
+
* @example
|
|
82
|
+
* <CodeStage tabs={[{ label: "worker.ts", content: worker, language: "ts" }]} />
|
|
83
|
+
*/
|
|
84
|
+
export function CodeStage(handle) {
|
|
85
|
+
return () => {
|
|
86
|
+
let { actions, children, language, lineNumbers, mix, name, parts, tabs, title, variant, ...rest } = handle.props;
|
|
87
|
+
let resolvedVariant = variant ?? DEFAULT_VARIANT;
|
|
88
|
+
let files = tabs ?? [];
|
|
89
|
+
let hasTabs = files.length > 0;
|
|
90
|
+
let showHeader = hasTabs || title !== undefined || actions !== undefined;
|
|
91
|
+
let single = hasTabs ? null : paint(children, language, lineNumbers === true);
|
|
92
|
+
let groupName = name ?? `code-stage-${handle.id}`;
|
|
93
|
+
return (_jsxs("div", { ...rest, "data-slot": "code-stage", "data-variant": resolvedVariant, mix: mergeMix([
|
|
94
|
+
vstack({ gap: 0, align: "stretch" }),
|
|
95
|
+
raw({ minInlineSize: 0, maxInlineSize: "100%", blockSize: "fit-content" }),
|
|
96
|
+
hostSurface(resolvedVariant),
|
|
97
|
+
single?.lineCount ? raw(gutterProperty(single.lineCount)) : [],
|
|
98
|
+
], mix), children: [showHeader ? (_jsxs("div", { "data-slot": "code-stage-header", mix: [headerChrome(resolvedVariant, hasTabs), parts?.header], children: [hasTabs ? (_jsx("div", { "data-slot": "code-stage-tabs", mix: [hstack({ gap: 1, align: "center" })], children: files.map((tab, index) => (_jsx(TabControl, { tab: tab, inputId: `${groupName}-tab-${index}`, name: groupName, value: String(index), defaultChecked: index === 0, variant: resolvedVariant }))) })) : (_jsxs("span", { mix: [raw({ display: "inline-flex", alignItems: "center", minInlineSize: 0 })], children: [single?.lineCount ? (_jsx("span", { "aria-hidden": "true", "data-slot": "code-stage-gutter-spacer", mix: [
|
|
99
|
+
font("mono"),
|
|
100
|
+
raw({
|
|
101
|
+
fontSize: CODE_FONT_SIZE,
|
|
102
|
+
flexShrink: 0,
|
|
103
|
+
inlineSize: "var(--ui-code-stage-gutter)",
|
|
104
|
+
}),
|
|
105
|
+
] })) : null, title ? _jsx(StageTitle, { variant: resolvedVariant, children: title }) : null] })), actions] })) : null, hasTabs ? (_jsx("div", { "data-slot": "code-stage-panels", mix: [
|
|
106
|
+
raw({
|
|
107
|
+
display: "grid",
|
|
108
|
+
gridTemplate: "minmax(0, 1fr) / minmax(0, 1fr)",
|
|
109
|
+
minInlineSize: 0,
|
|
110
|
+
}),
|
|
111
|
+
], children: files.map((tab, index) => {
|
|
112
|
+
let painted = paint(tab.content, tab.language ?? language, lineNumbers === true);
|
|
113
|
+
let inputId = `${groupName}-tab-${index}`;
|
|
114
|
+
return (_jsx(CodeBody, { variant: resolvedVariant, lineCount: painted.lineCount, "data-slot": "code-stage-panel", mix: [
|
|
115
|
+
raw({ gridArea: "1 / 1", visibility: "hidden" }),
|
|
116
|
+
when(`:is([data-slot="code-stage"]:has([id="${inputId}"]:checked)) &`, raw({ visibility: "visible" })),
|
|
117
|
+
painted.lineCount ? raw(gutterProperty(painted.lineCount)) : [],
|
|
118
|
+
parts?.body,
|
|
119
|
+
], children: painted.nodes }));
|
|
120
|
+
}) })) : (_jsx(CodeBody, { variant: resolvedVariant, lineCount: single?.lineCount ?? null, mix: parts?.body, children: single?.nodes }))] }));
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The header's title at 12px in the muted ink of its variant, a step below the
|
|
125
|
+
* 13px code so the code reads first.
|
|
126
|
+
*
|
|
127
|
+
* @param handle Runtime handle carrying the title's props.
|
|
128
|
+
* @returns The render function producing the title.
|
|
129
|
+
*/
|
|
130
|
+
function StageTitle(handle) {
|
|
131
|
+
return () => {
|
|
132
|
+
let { children, variant } = handle.props;
|
|
133
|
+
return (_jsx("span", { "data-slot": "code-stage-title", mix: [
|
|
134
|
+
font("mono"),
|
|
135
|
+
text("xs"),
|
|
136
|
+
weight("medium"),
|
|
137
|
+
raw({ minInlineSize: 0, overflow: "hidden", textOverflow: "ellipsis" }),
|
|
138
|
+
variant === "code"
|
|
139
|
+
? fg("neutral")
|
|
140
|
+
: raw({ color: variant === "slab" ? "rgb(255 255 255 / 0.6)" : TERMINAL_MUTED }),
|
|
141
|
+
], children: children }));
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* One file tab: a visually hidden radio and the label that selects it. The
|
|
146
|
+
* label lifts onto the raised surface while its radio is checked, and its panel
|
|
147
|
+
* reveals through the stage's `:has()` rule.
|
|
148
|
+
*
|
|
149
|
+
* @param handle Runtime handle carrying the tab's props.
|
|
150
|
+
* @returns The render function producing the radio and its label.
|
|
151
|
+
*/
|
|
152
|
+
function TabControl(handle) {
|
|
153
|
+
return () => {
|
|
154
|
+
let { defaultChecked, inputId, name, tab, value, variant } = handle.props;
|
|
155
|
+
let isCode = variant === "code";
|
|
156
|
+
return (_jsxs(_Fragment, { children: [_jsx("input", { type: "radio", name: name, id: inputId, value: value, defaultChecked: defaultChecked, mix: [visuallyHidden()] }), _jsxs("label", { htmlFor: inputId, "data-slot": "code-stage-tab", mix: [
|
|
157
|
+
raw({
|
|
158
|
+
display: "inline-flex",
|
|
159
|
+
alignItems: "center",
|
|
160
|
+
gap: "0.375rem",
|
|
161
|
+
paddingBlock: "0.25rem",
|
|
162
|
+
paddingInline: "0.625rem",
|
|
163
|
+
borderRadius: "0.375rem",
|
|
164
|
+
fontSize: "0.875rem",
|
|
165
|
+
lineHeight: "1.25rem",
|
|
166
|
+
fontWeight: 500,
|
|
167
|
+
cursor: "pointer",
|
|
168
|
+
whiteSpace: "nowrap",
|
|
169
|
+
color: isCode
|
|
170
|
+
? "var(--ui-neutral-fg, color-mix(in oklab, currentColor 70%, transparent))"
|
|
171
|
+
: "color-mix(in oklab, currentColor 70%, transparent)",
|
|
172
|
+
}),
|
|
173
|
+
when(":is(input:checked) + &", raw(isCode
|
|
174
|
+
? {
|
|
175
|
+
backgroundColor: "var(--ui-surface-raised, Canvas)",
|
|
176
|
+
boxShadow: "0 0 0 1px var(--ui-landing-hairline, color-mix(in oklch, CanvasText 8%, transparent))",
|
|
177
|
+
color: "var(--ui-neutral-fg-emphasis, CanvasText)",
|
|
178
|
+
}
|
|
179
|
+
: {
|
|
180
|
+
backgroundColor: "color-mix(in oklab, currentColor 14%, transparent)",
|
|
181
|
+
color: "inherit",
|
|
182
|
+
})),
|
|
183
|
+
when(":is(input:focus-visible) + &", raw({
|
|
184
|
+
outline: "2px solid var(--ui-brand-ring, Highlight)",
|
|
185
|
+
outlineOffset: "-2px",
|
|
186
|
+
})),
|
|
187
|
+
], children: [tab.icon ? (_jsx("span", { "aria-hidden": "true", mix: [raw({ display: "inline-flex" })], children: tab.icon })) : null, tab.label] })] }));
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The mono `pre` one file renders into: it scrolls sideways inside the panel and,
|
|
192
|
+
* when numbered, counts each `[data-line]` into a gutter whose numbers sit at
|
|
193
|
+
* 60% ink behind a hairline.
|
|
194
|
+
*
|
|
195
|
+
* @param handle Runtime handle carrying the body's props.
|
|
196
|
+
* @returns The render function producing the `pre`.
|
|
197
|
+
*/
|
|
198
|
+
function CodeBody(handle) {
|
|
199
|
+
return () => {
|
|
200
|
+
let { children, lineCount, mix, variant, ...rest } = handle.props;
|
|
201
|
+
let numbered = lineCount !== null;
|
|
202
|
+
return (_jsx("pre", { ...rest, "data-line-numbers": numbered ? "true" : undefined, mix: mergeMix([
|
|
203
|
+
m(0),
|
|
204
|
+
raw({ paddingBlock: "1rem", paddingInline: `${INSET} 1rem`, minInlineSize: 0 }),
|
|
205
|
+
font("mono"),
|
|
206
|
+
overflowX("auto"),
|
|
207
|
+
bodySurface(variant),
|
|
208
|
+
numbered ? gutterRules(variant) : [],
|
|
209
|
+
], mix), children: children }));
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* The gutter width a numbered body declares: digits for the longest number plus
|
|
214
|
+
* 1ch of padding, the 1px hairline and 1ch before the code. Resolved in the mono
|
|
215
|
+
* face wherever it is read, so the header can start its title on the code column.
|
|
216
|
+
*
|
|
217
|
+
* @param lineCount Lines the body numbers; 10 or more widens every number alike.
|
|
218
|
+
* @returns The custom property declaration.
|
|
219
|
+
*/
|
|
220
|
+
function gutterProperty(lineCount) {
|
|
221
|
+
let digits = Math.max(2, String(lineCount).length);
|
|
222
|
+
return { "--ui-code-stage-gutter": `calc(${digits}ch + 2ch + 1px)` };
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Counter rules for a numbered body. Each line's number is an inline-block of its
|
|
226
|
+
* own and the code an inline-block beside it, so tab stops count from the code
|
|
227
|
+
* column and a leading tab indents a full tab width.
|
|
228
|
+
*
|
|
229
|
+
* @param variant Resolved surface treatment, which picks the hairline.
|
|
230
|
+
* @returns The mixins the numbered `pre` applies.
|
|
231
|
+
*/
|
|
232
|
+
function gutterRules(variant) {
|
|
233
|
+
return [
|
|
234
|
+
raw({ counterReset: "line" }),
|
|
235
|
+
when("& > [data-line]", raw({ counterIncrement: "line" })),
|
|
236
|
+
when("& > [data-line] > [data-code]", raw({ display: "inline-block", verticalAlign: "top" })),
|
|
237
|
+
when("& > [data-line]::before", raw({
|
|
238
|
+
content: "counter(line)",
|
|
239
|
+
display: "inline-block",
|
|
240
|
+
verticalAlign: "top",
|
|
241
|
+
boxSizing: "content-box",
|
|
242
|
+
inlineSize: "calc(var(--ui-code-stage-gutter) - 2ch - 1px)",
|
|
243
|
+
paddingInlineEnd: "1ch",
|
|
244
|
+
marginInlineEnd: "1ch",
|
|
245
|
+
borderInlineEnd: `1px solid ${variant === "code"
|
|
246
|
+
? "var(--ui-landing-hairline, color-mix(in oklch, CanvasText 8%, transparent))"
|
|
247
|
+
: "color-mix(in oklab, currentColor 18%, transparent)"}`,
|
|
248
|
+
textAlign: "end",
|
|
249
|
+
color: GUTTER_INK,
|
|
250
|
+
userSelect: "none",
|
|
251
|
+
})),
|
|
252
|
+
];
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* The header's chrome for a variant: one 40px height with symmetric block
|
|
256
|
+
* padding so its content centres, the code's inline start, and a rule under it
|
|
257
|
+
* on every panel but an untabbed slab.
|
|
258
|
+
*
|
|
259
|
+
* @param variant Resolved surface treatment.
|
|
260
|
+
* @param hasTabs Whether the header holds a tab strip, which tints it on a card.
|
|
261
|
+
* @returns The mixins the header applies.
|
|
262
|
+
*/
|
|
263
|
+
function headerChrome(variant, hasTabs) {
|
|
264
|
+
let rule = variant === "code"
|
|
265
|
+
? "var(--ui-landing-hairline, color-mix(in oklch, CanvasText 8%, transparent))"
|
|
266
|
+
: "color-mix(in oklab, currentColor 18%, transparent)";
|
|
267
|
+
return [
|
|
268
|
+
hstack({ gap: 2, align: "center", justify: "between" }),
|
|
269
|
+
raw({
|
|
270
|
+
boxSizing: "border-box",
|
|
271
|
+
blockSize: HEADER_HEIGHT,
|
|
272
|
+
flexShrink: 0,
|
|
273
|
+
paddingBlock: 0,
|
|
274
|
+
paddingInline: hasTabs ? `calc(${INSET} - 0.625rem) 0.5rem` : `${INSET} 0.5rem`,
|
|
275
|
+
minInlineSize: 0,
|
|
276
|
+
}),
|
|
277
|
+
variant === "slab" && !hasTabs ? [] : raw({ borderBlockEnd: `1px solid ${rule}` }),
|
|
278
|
+
variant === "code" && hasTabs
|
|
279
|
+
? raw({
|
|
280
|
+
backgroundColor: "color-mix(in oklch, CanvasText 3%, transparent)",
|
|
281
|
+
borderStartStartRadius: "inherit",
|
|
282
|
+
borderStartEndRadius: "inherit",
|
|
283
|
+
})
|
|
284
|
+
: [],
|
|
285
|
+
];
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The host's surface for a variant, emitted as one rule so no two mixins race
|
|
289
|
+
* for the same property: the raised landing surface for `code`, a bordered
|
|
290
|
+
* dark panel for `terminal`, and a 4px-padded slab dark in both schemes. The
|
|
291
|
+
* dark panels re-point the token colors at the palette that reads on them.
|
|
292
|
+
*
|
|
293
|
+
* @param variant Resolved surface treatment.
|
|
294
|
+
* @returns The mixins the host applies.
|
|
295
|
+
*/
|
|
296
|
+
function hostSurface(variant) {
|
|
297
|
+
if (variant === "terminal") {
|
|
298
|
+
return [
|
|
299
|
+
raw({ borderRadius: FRAME_RADIUS }),
|
|
300
|
+
border({ color: "neutral", width: 1, style: "solid" }),
|
|
301
|
+
raw({
|
|
302
|
+
...TERMINAL_TOKENS,
|
|
303
|
+
backgroundColor: "color-mix(in oklab, CanvasText 92%, Canvas)",
|
|
304
|
+
color: "Canvas",
|
|
305
|
+
}),
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
if (variant === "slab") {
|
|
309
|
+
return [
|
|
310
|
+
raw({
|
|
311
|
+
...SLAB_TOKENS,
|
|
312
|
+
padding: "4px",
|
|
313
|
+
borderRadius: FRAME_RADIUS,
|
|
314
|
+
backgroundColor: "oklch(0.18 0.005 260)",
|
|
315
|
+
color: SLAB_INK,
|
|
316
|
+
colorScheme: "dark",
|
|
317
|
+
}),
|
|
318
|
+
];
|
|
319
|
+
}
|
|
320
|
+
return [landingSurface()];
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* The `pre`'s type, ink and sheet for a variant. Every variant keeps lines
|
|
324
|
+
* whole (`white-space: pre`) and scrolls sideways; code and terminal set 13px at
|
|
325
|
+
* 1.6, and the slab's white/8 sheet inside a white/10 ring sets 13px on 24px.
|
|
326
|
+
*
|
|
327
|
+
* @param variant Resolved surface treatment.
|
|
328
|
+
* @returns The mixin the `pre` applies.
|
|
329
|
+
*/
|
|
330
|
+
function bodySurface(variant) {
|
|
331
|
+
let common = { overscrollBehaviorInline: "contain", whiteSpace: "pre", tabSize: "4" };
|
|
332
|
+
if (variant === "slab") {
|
|
333
|
+
return raw({
|
|
334
|
+
...common,
|
|
335
|
+
fontSize: CODE_FONT_SIZE,
|
|
336
|
+
lineHeight: "1.5rem",
|
|
337
|
+
color: SLAB_INK,
|
|
338
|
+
backgroundColor: "rgb(255 255 255 / 0.08)",
|
|
339
|
+
boxShadow: "inset 0 0 0 1px rgb(255 255 255 / 0.1)",
|
|
340
|
+
borderRadius: `calc(${FRAME_RADIUS} - 4px)`,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
return raw({
|
|
344
|
+
...common,
|
|
345
|
+
fontSize: CODE_FONT_SIZE,
|
|
346
|
+
lineHeight: 1.6,
|
|
347
|
+
color: variant === "terminal" ? "Canvas" : "var(--ui-neutral-fg-emphasis, CanvasText)",
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Turns a stage's content into `pre` children: a string highlights when a
|
|
352
|
+
* language is named and, when numbered, splits into one `[data-line]` per line
|
|
353
|
+
* holding that line's tokens. Newlines stay between the lines so copied text
|
|
354
|
+
* keeps its shape, and a single trailing newline never numbers an empty line.
|
|
355
|
+
*
|
|
356
|
+
* @param content The stage's or tab's content.
|
|
357
|
+
* @param language Language to highlight as, if any.
|
|
358
|
+
* @param lineNumbers Whether to number the lines.
|
|
359
|
+
* @returns The children to render and how many lines were numbered.
|
|
360
|
+
*/
|
|
361
|
+
function paint(content, language, lineNumbers) {
|
|
362
|
+
let source = textOf(content);
|
|
363
|
+
if (source === null)
|
|
364
|
+
return { nodes: content, lineCount: null };
|
|
365
|
+
if (!lineNumbers) {
|
|
366
|
+
return { nodes: language ? renderRuns(tokenize(source, language)) : content, lineCount: null };
|
|
367
|
+
}
|
|
368
|
+
let trimmed = source.replace(/\r?\n$/, "");
|
|
369
|
+
let runs = language ? tokenize(trimmed, language) : [{ type: "plain", value: trimmed }];
|
|
370
|
+
let lines = splitLines(runs);
|
|
371
|
+
let nodes = [];
|
|
372
|
+
for (let [index, line] of lines.entries()) {
|
|
373
|
+
if (index > 0)
|
|
374
|
+
nodes.push("\n");
|
|
375
|
+
nodes.push(_jsx("span", { "data-line": "", children: _jsx("span", { "data-code": "", children: renderRuns(line) }) }));
|
|
376
|
+
}
|
|
377
|
+
return { nodes, lineCount: lines.length };
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Splits tokens at newlines so each line owns its tokens; a token spanning lines
|
|
381
|
+
* (a block comment, a template literal) becomes one token per line, same type.
|
|
382
|
+
*
|
|
383
|
+
* @param runs Tokens covering the source once, in order.
|
|
384
|
+
* @returns One token list per source line.
|
|
385
|
+
*/
|
|
386
|
+
function splitLines(runs) {
|
|
387
|
+
let lines = [[]];
|
|
388
|
+
for (let run of runs) {
|
|
389
|
+
for (let [index, piece] of run.value.split(/\r?\n/).entries()) {
|
|
390
|
+
if (index > 0)
|
|
391
|
+
lines.push([]);
|
|
392
|
+
if (piece.length > 0)
|
|
393
|
+
lines[lines.length - 1]?.push({ type: run.type, value: piece });
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return lines;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Renders tokens as text and `span.token.<type>` elements, the class contract the
|
|
400
|
+
* shared highlight stylesheet colors. Each span also carries its color as
|
|
401
|
+
* `var(--highlight-<type>)` with a scheme-aware fallback, so code reads in color
|
|
402
|
+
* on a page that never loaded that stylesheet.
|
|
403
|
+
*
|
|
404
|
+
* @param runs Tokens to render.
|
|
405
|
+
* @returns The rendered nodes.
|
|
406
|
+
*/
|
|
407
|
+
function renderRuns(runs) {
|
|
408
|
+
return runs.map((run) => {
|
|
409
|
+
if (run.type === "plain")
|
|
410
|
+
return run.value;
|
|
411
|
+
let [light, dark] = TOKEN_PALETTE[run.type];
|
|
412
|
+
return (_jsx("span", { className: `token ${run.type}`, mix: [raw({ color: `var(--highlight-${run.type}, light-dark(${light}, ${dark}))` })], children: run.value }));
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Reads children as plain text: a string, or an array made only of strings
|
|
417
|
+
* (what JSX produces for adjacent text and string expressions).
|
|
418
|
+
*
|
|
419
|
+
* @param children The stage's children.
|
|
420
|
+
* @returns The joined text, or `null` when any child is an element.
|
|
421
|
+
*/
|
|
422
|
+
function textOf(children) {
|
|
423
|
+
if (typeof children === "string")
|
|
424
|
+
return children;
|
|
425
|
+
if (Array.isArray(children) && children.every((child) => typeof child === "string")) {
|
|
426
|
+
return children.join("");
|
|
427
|
+
}
|
|
428
|
+
return null;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Alias for {@link CodeStage} with terminal chrome — same props, same host.
|
|
432
|
+
* Prefer this name when the sample is a shell session rather than a file.
|
|
433
|
+
*/
|
|
434
|
+
export const TerminalPanel = CodeStage;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small "+" mark centred on a corner of its positioned ancestor, the registration mark a
|
|
3
|
+
* ruled page draws where a rail meets a rule. Purely decorative: it is hidden from assistive
|
|
4
|
+
* technology and ignores the pointer, so it never changes what a visitor can reach.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Prop types for {@link Crosshair}.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace Crosshair {
|
|
14
|
+
/** `sm` is an 11px mark for dense grids; `md` is the 21px mark a band corner takes. */
|
|
15
|
+
type Size = "sm" | "md";
|
|
16
|
+
/**
|
|
17
|
+
* Corner of the positioned ancestor the mark centres on, as `<block>-<inline>` in
|
|
18
|
+
* logical terms, so a right-to-left page mirrors the marks with its content.
|
|
19
|
+
*/
|
|
20
|
+
type Corner = "start-start" | "start-end" | "end-start" | "end-end";
|
|
21
|
+
/**
|
|
22
|
+
* Props accepted by {@link Crosshair}.
|
|
23
|
+
*/
|
|
24
|
+
interface Props extends Omit<TagProps<"span">, "children"> {
|
|
25
|
+
/** Corner to centre on. Defaults to {@link DEFAULT_CORNER}. */
|
|
26
|
+
corner?: Corner;
|
|
27
|
+
/** Mark size. Defaults to {@link DEFAULT_SIZE}. */
|
|
28
|
+
size?: Size;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Draws a "+" in hairline ink, absolutely positioned and centred on one corner of the
|
|
33
|
+
* nearest positioned ancestor by a negative half-size margin on every side. Give the
|
|
34
|
+
* ancestor `position: relative`; logical insets put the mark on the mirrored corner in RTL.
|
|
35
|
+
*
|
|
36
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
37
|
+
* @returns The render function producing the mark.
|
|
38
|
+
* @example
|
|
39
|
+
* <div mix={[relative()]}>
|
|
40
|
+
* <Crosshair corner="start-start" />
|
|
41
|
+
* <Crosshair corner="end-end" size="sm" />
|
|
42
|
+
* </div>
|
|
43
|
+
*/
|
|
44
|
+
export declare function Crosshair(handle: Handle<Crosshair.Props>): () => import("remix/component").RemixElement;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/component/jsx-runtime";
|
|
2
|
+
import { raw, mergeMix } from "@sdxc/u/general";
|
|
3
|
+
/** Mark size {@link Crosshair} draws when `size` is omitted. */
|
|
4
|
+
const DEFAULT_SIZE = "md";
|
|
5
|
+
/** Corner {@link Crosshair} sits on when `corner` is omitted. */
|
|
6
|
+
const DEFAULT_CORNER = "start-start";
|
|
7
|
+
/**
|
|
8
|
+
* Edge length of each mark. Both are odd, so the 1px arms sit on whole pixels at the
|
|
9
|
+
* centre of the box.
|
|
10
|
+
*/
|
|
11
|
+
const SIZES = { sm: "11px", md: "21px" };
|
|
12
|
+
/** Ink the arms draw with: the landing hairline, so marks read as part of the rules. */
|
|
13
|
+
const INK = "var(--ui-landing-hairline, color-mix(in oklch, CanvasText 8%, transparent))";
|
|
14
|
+
/**
|
|
15
|
+
* Draws a "+" in hairline ink, absolutely positioned and centred on one corner of the
|
|
16
|
+
* nearest positioned ancestor by a negative half-size margin on every side. Give the
|
|
17
|
+
* ancestor `position: relative`; logical insets put the mark on the mirrored corner in RTL.
|
|
18
|
+
*
|
|
19
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
20
|
+
* @returns The render function producing the mark.
|
|
21
|
+
* @example
|
|
22
|
+
* <div mix={[relative()]}>
|
|
23
|
+
* <Crosshair corner="start-start" />
|
|
24
|
+
* <Crosshair corner="end-end" size="sm" />
|
|
25
|
+
* </div>
|
|
26
|
+
*/
|
|
27
|
+
export function Crosshair(handle) {
|
|
28
|
+
return () => {
|
|
29
|
+
let { corner, mix, size, ...rest } = handle.props;
|
|
30
|
+
let resolvedCorner = corner ?? DEFAULT_CORNER;
|
|
31
|
+
let resolvedSize = size ?? DEFAULT_SIZE;
|
|
32
|
+
let [block, inline] = resolvedCorner.split("-");
|
|
33
|
+
let edge = SIZES[resolvedSize];
|
|
34
|
+
return (_jsx("span", { "aria-hidden": "true", ...rest, "data-slot": "crosshair", "data-corner": resolvedCorner, "data-size": resolvedSize, mix: mergeMix(raw({
|
|
35
|
+
position: "absolute",
|
|
36
|
+
display: "block",
|
|
37
|
+
insetBlockStart: block === "start" ? "0" : "auto",
|
|
38
|
+
insetBlockEnd: block === "end" ? "0" : "auto",
|
|
39
|
+
insetInlineStart: inline === "start" ? "0" : "auto",
|
|
40
|
+
insetInlineEnd: inline === "end" ? "0" : "auto",
|
|
41
|
+
margin: `calc(${edge} / -2)`,
|
|
42
|
+
inlineSize: edge,
|
|
43
|
+
blockSize: edge,
|
|
44
|
+
pointerEvents: "none",
|
|
45
|
+
background: `linear-gradient(${INK}, ${INK}) center / 100% 1px no-repeat, linear-gradient(${INK}, ${INK}) center / 1px 100% no-repeat`,
|
|
46
|
+
}), mix) }));
|
|
47
|
+
};
|
|
48
|
+
}
|