@zonsh/ui 0.0.0 → 0.2.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 +21 -0
- package/README.md +75 -1
- package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
- package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction.svg +77 -0
- package/assets/illustrations/drawing/crescent-dark.svg +28 -0
- package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
- package/assets/illustrations/drawing/crescent-guides.svg +33 -0
- package/assets/illustrations/drawing/crescent.svg +28 -0
- package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
- package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
- package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
- package/assets/illustrations/drawing/eclipse.svg +187 -0
- package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
- package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides.svg +31 -0
- package/assets/illustrations/drawing/horizon-dark.svg +30 -0
- package/assets/illustrations/drawing/horizon.svg +30 -0
- package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
- package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
- package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
- package/assets/illustrations/drawing/nib-study.svg +107 -0
- package/assets/illustrations/editorial/assistant-640.webp +0 -0
- package/assets/illustrations/editorial/assistant.webp +0 -0
- package/assets/illustrations/editorial/automation-640.webp +0 -0
- package/assets/illustrations/editorial/automation.webp +0 -0
- package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-left.webp +0 -0
- package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-right.webp +0 -0
- package/assets/illustrations/editorial/custom-software-640.webp +0 -0
- package/assets/illustrations/editorial/custom-software.webp +0 -0
- package/assets/illustrations/editorial/digitalization-640.webp +0 -0
- package/assets/illustrations/editorial/digitalization.webp +0 -0
- package/assets/illustrations/editorial/integration-640.webp +0 -0
- package/assets/illustrations/editorial/integration.webp +0 -0
- package/assets/illustrations/editorial/problem-640.webp +0 -0
- package/assets/illustrations/editorial/problem.webp +0 -0
- package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
- package/assets/illustrations/editorial/process-analysis.webp +0 -0
- package/assets/illustrations/editorial/process-concept-640.webp +0 -0
- package/assets/illustrations/editorial/process-concept.webp +0 -0
- package/assets/illustrations/editorial/process-development-640.webp +0 -0
- package/assets/illustrations/editorial/process-development.webp +0 -0
- package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
- package/assets/illustrations/editorial/process-discovery.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance.webp +0 -0
- package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
- package/assets/illustrations/editorial/process-prototype.webp +0 -0
- package/assets/illustrations/editorial/process-testing-640.webp +0 -0
- package/assets/illustrations/editorial/process-testing.webp +0 -0
- package/assets/illustrations/iso/automation-dark.svg +6 -0
- package/assets/illustrations/iso/automation.svg +6 -0
- package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
- package/assets/illustrations/iso/bar-chart.svg +6 -0
- package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
- package/assets/illustrations/iso/brackets-classic.svg +6 -0
- package/assets/illustrations/iso/brackets-dark.svg +6 -0
- package/assets/illustrations/iso/brackets.svg +6 -0
- package/assets/illustrations/iso/city-dark.svg +6 -0
- package/assets/illustrations/iso/city.svg +6 -0
- package/assets/illustrations/iso/conveyor-dark.svg +6 -0
- package/assets/illustrations/iso/conveyor.svg +6 -0
- package/assets/illustrations/iso/database-dark.svg +6 -0
- package/assets/illustrations/iso/database.svg +6 -0
- package/assets/illustrations/iso/documents-dark.svg +6 -0
- package/assets/illustrations/iso/documents.svg +6 -0
- package/assets/illustrations/iso/inbox-dark.svg +6 -0
- package/assets/illustrations/iso/inbox.svg +6 -0
- package/assets/illustrations/iso/laptop-dark.svg +6 -0
- package/assets/illustrations/iso/laptop.svg +6 -0
- package/assets/illustrations/iso/monitor-dark.svg +6 -0
- package/assets/illustrations/iso/monitor.svg +6 -0
- package/assets/illustrations/iso/pipeline-dark.svg +6 -0
- package/assets/illustrations/iso/pipeline.svg +6 -0
- package/assets/illustrations/iso/platform-dark.svg +6 -0
- package/assets/illustrations/iso/platform.svg +6 -0
- package/assets/illustrations/iso/server-dark.svg +6 -0
- package/assets/illustrations/iso/server.svg +6 -0
- package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
- package/assets/illustrations/iso/spreadsheet.svg +6 -0
- package/assets/illustrations/iso/timeline-dark.svg +6 -0
- package/assets/illustrations/iso/timeline.svg +6 -0
- package/assets/illustrations/sheet/construction.svg +115 -0
- package/assets/illustrations/sheet/crescent.svg +40 -0
- package/assets/illustrations/sheet/limb.svg +42 -0
- package/assets/illustrations/sheet/stress-axis.svg +119 -0
- package/assets/illustrations/sheet/totality.svg +215 -0
- package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
- package/assets/logo-left.svg +1 -0
- package/assets/logo-right.svg +1 -0
- package/assets/logo.svg +1 -0
- package/dist/components/_overlay.d.ts +47 -0
- package/dist/components/_overlay.js +59 -0
- package/dist/components/accordion.d.ts +32 -0
- package/dist/components/accordion.js +39 -0
- package/dist/components/alert-dialog.d.ts +45 -0
- package/dist/components/alert-dialog.js +56 -0
- package/dist/components/alert.d.ts +35 -0
- package/dist/components/alert.js +42 -0
- package/dist/components/ascii-field.d.ts +34 -0
- package/dist/components/ascii-field.js +410 -0
- package/dist/components/aspect-ratio.d.ts +14 -0
- package/dist/components/aspect-ratio.js +17 -0
- package/dist/components/avatar.d.ts +42 -0
- package/dist/components/avatar.js +55 -0
- package/dist/components/badge.d.ts +70 -0
- package/dist/components/badge.js +62 -0
- package/dist/components/breadcrumb.d.ts +22 -0
- package/dist/components/breadcrumb.js +32 -0
- package/dist/components/button-group.d.ts +30 -0
- package/dist/components/button-group.js +47 -0
- package/dist/components/button.d.ts +53 -0
- package/dist/components/button.js +130 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +164 -0
- package/dist/components/card.d.ts +42 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +90 -0
- package/dist/components/carousel.js +213 -0
- package/dist/components/chart.d.ts +180 -0
- package/dist/components/chart.js +286 -0
- package/dist/components/checkbox.d.ts +23 -0
- package/dist/components/checkbox.js +43 -0
- package/dist/components/code-block.d.ts +45 -0
- package/dist/components/code-block.js +58 -0
- package/dist/components/code-highlight.d.ts +13 -0
- package/dist/components/code-highlight.js +107 -0
- package/dist/components/collapsible.d.ts +20 -0
- package/dist/components/collapsible.js +32 -0
- package/dist/components/color-picker.d.ts +85 -0
- package/dist/components/color-picker.js +407 -0
- package/dist/components/combobox.d.ts +81 -0
- package/dist/components/combobox.js +100 -0
- package/dist/components/command.d.ts +112 -0
- package/dist/components/command.js +212 -0
- package/dist/components/context-menu.d.ts +29 -0
- package/dist/components/context-menu.js +35 -0
- package/dist/components/conversation.d.ts +27 -0
- package/dist/components/conversation.js +293 -0
- package/dist/components/copy-button.d.ts +46 -0
- package/dist/components/copy-button.js +118 -0
- package/dist/components/data-table.d.ts +175 -0
- package/dist/components/data-table.js +302 -0
- package/dist/components/date-picker.d.ts +91 -0
- package/dist/components/date-picker.js +207 -0
- package/dist/components/dialog.d.ts +48 -0
- package/dist/components/dialog.js +92 -0
- package/dist/components/direction.d.ts +16 -0
- package/dist/components/direction.js +18 -0
- package/dist/components/drawer.d.ts +60 -0
- package/dist/components/drawer.js +76 -0
- package/dist/components/empty.d.ts +31 -0
- package/dist/components/empty.js +50 -0
- package/dist/components/feature-list.d.ts +54 -0
- package/dist/components/feature-list.js +43 -0
- package/dist/components/field.d.ts +15 -0
- package/dist/components/field.js +36 -0
- package/dist/components/file-drop.d.ts +55 -0
- package/dist/components/file-drop.js +197 -0
- package/dist/components/filter-bar.d.ts +106 -0
- package/dist/components/filter-bar.js +296 -0
- package/dist/components/form.d.ts +33 -0
- package/dist/components/form.js +34 -0
- package/dist/components/graph.d.ts +105 -0
- package/dist/components/graph.js +786 -0
- package/dist/components/illustration.d.ts +85 -0
- package/dist/components/illustration.js +165 -0
- package/dist/components/input-group.d.ts +127 -0
- package/dist/components/input-group.js +292 -0
- package/dist/components/input.d.ts +16 -0
- package/dist/components/input.js +25 -0
- package/dist/components/item.d.ts +64 -0
- package/dist/components/item.js +116 -0
- package/dist/components/kbd.d.ts +33 -0
- package/dist/components/kbd.js +38 -0
- package/dist/components/label.d.ts +12 -0
- package/dist/components/label.js +24 -0
- package/dist/components/layout.d.ts +136 -0
- package/dist/components/layout.js +162 -0
- package/dist/components/logo.d.ts +54 -0
- package/dist/components/logo.js +96 -0
- package/dist/components/menu.d.ts +60 -0
- package/dist/components/menu.js +138 -0
- package/dist/components/menubar.d.ts +62 -0
- package/dist/components/menubar.js +223 -0
- package/dist/components/message.d.ts +42 -0
- package/dist/components/message.js +56 -0
- package/dist/components/meter.d.ts +31 -0
- package/dist/components/meter.js +25 -0
- package/dist/components/native-select.d.ts +26 -0
- package/dist/components/native-select.js +35 -0
- package/dist/components/navigation-menu.d.ts +42 -0
- package/dist/components/navigation-menu.js +97 -0
- package/dist/components/number-field.d.ts +36 -0
- package/dist/components/number-field.js +153 -0
- package/dist/components/otp-field.d.ts +35 -0
- package/dist/components/otp-field.js +94 -0
- package/dist/components/pagination.d.ts +31 -0
- package/dist/components/pagination.js +70 -0
- package/dist/components/pdf-viewer.d.ts +69 -0
- package/dist/components/pdf-viewer.js +929 -0
- package/dist/components/popover.d.ts +33 -0
- package/dist/components/popover.js +48 -0
- package/dist/components/preview-card.d.ts +25 -0
- package/dist/components/preview-card.js +22 -0
- package/dist/components/progress.d.ts +27 -0
- package/dist/components/progress.js +23 -0
- package/dist/components/prompt-input.d.ts +131 -0
- package/dist/components/prompt-input.js +403 -0
- package/dist/components/quote.d.ts +22 -0
- package/dist/components/quote.js +15 -0
- package/dist/components/radio-group.d.ts +18 -0
- package/dist/components/radio-group.js +34 -0
- package/dist/components/reasoning.d.ts +31 -0
- package/dist/components/reasoning.js +70 -0
- package/dist/components/resizable.d.ts +38 -0
- package/dist/components/resizable.js +41 -0
- package/dist/components/response.d.ts +30 -0
- package/dist/components/response.js +538 -0
- package/dist/components/scroll-area.d.ts +33 -0
- package/dist/components/scroll-area.js +31 -0
- package/dist/components/select.d.ts +35 -0
- package/dist/components/select.js +60 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +17 -0
- package/dist/components/sidebar.d.ts +147 -0
- package/dist/components/sidebar.js +489 -0
- package/dist/components/site-header.d.ts +59 -0
- package/dist/components/site-header.js +67 -0
- package/dist/components/skeleton.d.ts +31 -0
- package/dist/components/skeleton.js +29 -0
- package/dist/components/slider.d.ts +24 -0
- package/dist/components/slider.js +129 -0
- package/dist/components/sources.d.ts +25 -0
- package/dist/components/sources.js +35 -0
- package/dist/components/spinner.d.ts +36 -0
- package/dist/components/spinner.js +72 -0
- package/dist/components/suggestions.d.ts +20 -0
- package/dist/components/suggestions.js +18 -0
- package/dist/components/switch.d.ts +14 -0
- package/dist/components/switch.js +26 -0
- package/dist/components/table.d.ts +162 -0
- package/dist/components/table.js +758 -0
- package/dist/components/tabs.d.ts +25 -0
- package/dist/components/tabs.js +162 -0
- package/dist/components/tag.d.ts +41 -0
- package/dist/components/tag.js +88 -0
- package/dist/components/tags-input.d.ts +40 -0
- package/dist/components/tags-input.js +239 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +16 -0
- package/dist/components/theme.d.ts +41 -0
- package/dist/components/theme.js +112 -0
- package/dist/components/time-field.d.ts +51 -0
- package/dist/components/time-field.js +437 -0
- package/dist/components/timeline.d.ts +76 -0
- package/dist/components/timeline.js +99 -0
- package/dist/components/toast.d.ts +72 -0
- package/dist/components/toast.js +196 -0
- package/dist/components/toggle-group.d.ts +41 -0
- package/dist/components/toggle-group.js +140 -0
- package/dist/components/toggle.d.ts +23 -0
- package/dist/components/toggle.js +35 -0
- package/dist/components/tool-call.d.ts +52 -0
- package/dist/components/tool-call.js +57 -0
- package/dist/components/toolbar.d.ts +17 -0
- package/dist/components/toolbar.js +34 -0
- package/dist/components/tooltip.d.ts +42 -0
- package/dist/components/tooltip.js +47 -0
- package/dist/components/tree.d.ts +75 -0
- package/dist/components/tree.js +636 -0
- package/dist/components/typography.d.ts +134 -0
- package/dist/components/typography.js +176 -0
- package/dist/components/video-player.d.ts +276 -0
- package/dist/components/video-player.js +1352 -0
- package/dist/components/whiteboard.d.ts +80 -0
- package/dist/components/whiteboard.js +389 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +86 -0
- package/dist/lib/cn.d.ts +20 -0
- package/dist/lib/cn.js +38 -0
- package/dist/lib/code-highlight.d.ts +31 -0
- package/dist/lib/code-highlight.js +24 -0
- package/dist/lib/code-theme.d.ts +19 -0
- package/dist/lib/code-theme.js +140 -0
- package/dist/lib/collapse-row.d.ts +9 -0
- package/dist/lib/collapse-row.js +129 -0
- package/dist/lib/digit-roll.d.ts +21 -0
- package/dist/lib/digit-roll.js +31 -0
- package/dist/lib/editorial-assets.d.ts +16 -0
- package/dist/lib/editorial-assets.js +56 -0
- package/dist/lib/figure/catalog.d.ts +127 -0
- package/dist/lib/figure/catalog.js +130 -0
- package/dist/lib/figure/figures/automation.d.ts +7 -0
- package/dist/lib/figure/figures/automation.js +143 -0
- package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
- package/dist/lib/figure/figures/bar-chart.js +99 -0
- package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
- package/dist/lib/figure/figures/brackets-classic.js +170 -0
- package/dist/lib/figure/figures/brackets.d.ts +8 -0
- package/dist/lib/figure/figures/brackets.js +84 -0
- package/dist/lib/figure/figures/city.d.ts +7 -0
- package/dist/lib/figure/figures/city.js +93 -0
- package/dist/lib/figure/figures/conveyor.d.ts +7 -0
- package/dist/lib/figure/figures/conveyor.js +97 -0
- package/dist/lib/figure/figures/database.d.ts +7 -0
- package/dist/lib/figure/figures/database.js +65 -0
- package/dist/lib/figure/figures/documents.d.ts +7 -0
- package/dist/lib/figure/figures/documents.js +83 -0
- package/dist/lib/figure/figures/inbox.d.ts +7 -0
- package/dist/lib/figure/figures/inbox.js +92 -0
- package/dist/lib/figure/figures/laptop.d.ts +7 -0
- package/dist/lib/figure/figures/laptop.js +67 -0
- package/dist/lib/figure/figures/monitor.d.ts +7 -0
- package/dist/lib/figure/figures/monitor.js +59 -0
- package/dist/lib/figure/figures/pipeline.d.ts +8 -0
- package/dist/lib/figure/figures/pipeline.js +117 -0
- package/dist/lib/figure/figures/platform.d.ts +7 -0
- package/dist/lib/figure/figures/platform.js +117 -0
- package/dist/lib/figure/figures/server.d.ts +7 -0
- package/dist/lib/figure/figures/server.js +115 -0
- package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
- package/dist/lib/figure/figures/spreadsheet.js +87 -0
- package/dist/lib/figure/figures/timeline.d.ts +7 -0
- package/dist/lib/figure/figures/timeline.js +65 -0
- package/dist/lib/figure/kernel.d.ts +152 -0
- package/dist/lib/figure/kernel.js +576 -0
- package/dist/lib/figure/parts.d.ts +42 -0
- package/dist/lib/figure/parts.js +126 -0
- package/dist/lib/form-reset.d.ts +11 -0
- package/dist/lib/form-reset.js +22 -0
- package/dist/lib/glide.d.ts +53 -0
- package/dist/lib/glide.js +138 -0
- package/dist/lib/graph-layout.d.ts +58 -0
- package/dist/lib/graph-layout.js +200 -0
- package/dist/lib/illustration-drawings.d.ts +89 -0
- package/dist/lib/illustration-drawings.js +539 -0
- package/dist/lib/illustration-info.d.ts +37 -0
- package/dist/lib/illustration-info.js +22 -0
- package/dist/lib/illustration-library.d.ts +87 -0
- package/dist/lib/illustration-library.js +352 -0
- package/dist/lib/logo-geometry.d.ts +29 -0
- package/dist/lib/logo-geometry.js +67 -0
- package/dist/lib/markdown-guard.d.ts +16 -0
- package/dist/lib/markdown-guard.js +123 -0
- package/dist/lib/merge-refs.d.ts +10 -0
- package/dist/lib/merge-refs.js +26 -0
- package/dist/lib/motion.d.ts +6 -0
- package/dist/lib/motion.js +12 -0
- package/dist/lib/pdf-worker.d.ts +1 -0
- package/dist/lib/pdf-worker.js +6 -0
- package/dist/lib/pdf.d.ts +19 -0
- package/dist/lib/pdf.js +58 -0
- package/dist/lib/platform.d.ts +33 -0
- package/dist/lib/platform.js +68 -0
- package/dist/lib/room.d.ts +25 -0
- package/dist/lib/room.js +46 -0
- package/dist/lib/table-fit.d.ts +143 -0
- package/dist/lib/table-fit.js +577 -0
- package/dist/lib/theme-script.d.ts +18 -0
- package/dist/lib/theme-script.js +29 -0
- package/dist/styles/expressive.css +188 -0
- package/dist/styles/fonts.css +145 -0
- package/dist/styles/index.css +206 -0
- package/dist/styles/material.css +313 -0
- package/dist/styles/parts/ai.css +360 -0
- package/dist/styles/parts/brand.css +75 -0
- package/dist/styles/parts/controls.css +725 -0
- package/dist/styles/parts/data.css +222 -0
- package/dist/styles/parts/editorial.css +120 -0
- package/dist/styles/parts/feedback.css +273 -0
- package/dist/styles/parts/foundations.css +166 -0
- package/dist/styles/parts/graph.css +214 -0
- package/dist/styles/parts/inputs.css +261 -0
- package/dist/styles/parts/isometric.css +124 -0
- package/dist/styles/parts/navigation.css +232 -0
- package/dist/styles/parts/overlays.css +250 -0
- package/dist/styles/parts/pdf.css +154 -0
- package/dist/styles/parts/react-flow.css +519 -0
- package/dist/styles/parts/whiteboard.css +855 -0
- package/dist/styles/tokens.css +290 -0
- package/dist/vite.d.ts +116 -0
- package/dist/vite.js +129 -0
- package/package.json +188 -5
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
/* The bracket geometry from assets/logo.svg, in its 375-unit artboard. Axis-aligned rectangles. */
|
|
6
|
+
const LEFT_BRACKET = [
|
|
7
|
+
[112.7, 55.23, 149.48, 319.76], // stem
|
|
8
|
+
[56.27, 111.59, 149.49, 148.36], // arm
|
|
9
|
+
];
|
|
10
|
+
const RIGHT_BRACKET = [
|
|
11
|
+
[225.6, 55.23, 262.38, 317.61], // stem
|
|
12
|
+
[225.52, 168.04, 318.75, 204.81], // arm
|
|
13
|
+
];
|
|
14
|
+
const ART_CX = 187.5;
|
|
15
|
+
const ART_CY = 187.5;
|
|
16
|
+
const ART_H = 264.53; // visible artwork height
|
|
17
|
+
const ART_W = 262.48; // visible artwork width
|
|
18
|
+
const ART_GAP = 76.12; // between the two stems
|
|
19
|
+
/*
|
|
20
|
+
* The zon crescent from zon.sh/logo.svg, in its 32-unit canvas: the moon, radius 12, less a circle
|
|
21
|
+
* of radius 9.312 moved 2.812 toward the opening, tilted 14°.
|
|
22
|
+
*/
|
|
23
|
+
const MOON_R = 12;
|
|
24
|
+
const CUT_R = 9.312;
|
|
25
|
+
const CUT_SHIFT = 2.812;
|
|
26
|
+
const TILT = (14 * Math.PI) / 180;
|
|
27
|
+
/* Index 0 is a blank cell. Ramp runs light → dense; "0"/"1" are binary flecks in the silhouette. */
|
|
28
|
+
const RAMP = " .:-=+*#%@";
|
|
29
|
+
const GLYPHS = RAMP + "01";
|
|
30
|
+
const RAMP_MAX = RAMP.length - 1;
|
|
31
|
+
const BIT = RAMP.length;
|
|
32
|
+
const TAU = Math.PI * 2;
|
|
33
|
+
const FRAME_MS = 33; // ~30fps is plenty for a backdrop
|
|
34
|
+
const ROLL_MS = 90; // re-roll cadence
|
|
35
|
+
const ROLL_SHARE = 0.012; // share of cells re-rolled per tick
|
|
36
|
+
const POINTER_R = 180;
|
|
37
|
+
const clamp = (v, a, b) => (v < a ? a : v > b ? b : v);
|
|
38
|
+
const smoothstep = (e0, e1, x) => {
|
|
39
|
+
const t = clamp((x - e0) / (e1 - e0), 0, 1);
|
|
40
|
+
return t * t * (3 - 2 * t);
|
|
41
|
+
};
|
|
42
|
+
function mulberry32(seed) {
|
|
43
|
+
let a = seed >>> 0;
|
|
44
|
+
return () => {
|
|
45
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
46
|
+
let t = a;
|
|
47
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
48
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
49
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function lattice(ix, iy, seed) {
|
|
53
|
+
const s = Math.sin(ix * 127.1 + iy * 311.7 + seed * 74.7) * 43758.5453;
|
|
54
|
+
return s - Math.floor(s);
|
|
55
|
+
}
|
|
56
|
+
function valueNoise(x, y, seed) {
|
|
57
|
+
const ix = Math.floor(x);
|
|
58
|
+
const iy = Math.floor(y);
|
|
59
|
+
const fx = x - ix;
|
|
60
|
+
const fy = y - iy;
|
|
61
|
+
const ux = fx * fx * (3 - 2 * fx);
|
|
62
|
+
const uy = fy * fy * (3 - 2 * fy);
|
|
63
|
+
const a = lattice(ix, iy, seed);
|
|
64
|
+
const b = lattice(ix + 1, iy, seed);
|
|
65
|
+
const c = lattice(ix, iy + 1, seed);
|
|
66
|
+
const d = lattice(ix + 1, iy + 1, seed);
|
|
67
|
+
return a + (b - a) * ux + (c - a) * uy + (a - b - c + d) * ux * uy;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Signed distances (negative inside, in canvas units) to the moon and to its light, the crescent,
|
|
71
|
+
* for a point relative to the moon's centre on screen: turned back by the tilt first.
|
|
72
|
+
*/
|
|
73
|
+
function crescent(sx, sy) {
|
|
74
|
+
const x = sx * Math.cos(TILT) - sy * Math.sin(TILT);
|
|
75
|
+
const y = sx * Math.sin(TILT) + sy * Math.cos(TILT);
|
|
76
|
+
const moon = Math.hypot(x, y) - MOON_R;
|
|
77
|
+
// The cut sits up the mark's axis, toward the opening.
|
|
78
|
+
const cut = Math.hypot(x, y + CUT_SHIFT) - CUT_R;
|
|
79
|
+
return { moon, light: Math.max(moon, -cut) };
|
|
80
|
+
}
|
|
81
|
+
/** Signed distance to an axis-aligned rectangle (negative inside). */
|
|
82
|
+
function sdRect(px, py, r) {
|
|
83
|
+
const dx = Math.abs(px - (r[0] + r[2]) / 2) - (r[2] - r[0]) / 2;
|
|
84
|
+
const dy = Math.abs(py - (r[1] + r[3]) / 2) - (r[3] - r[1]) / 2;
|
|
85
|
+
return Math.hypot(Math.max(dx, 0), Math.max(dy, 0)) + Math.min(Math.max(dx, dy), 0);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* AsciiField — a hero backdrop: a canvas of Licht Mono characters that forms the two brackets
|
|
89
|
+
* or the zon crescent, large and soft, with faint characters everywhere else.
|
|
90
|
+
* Characters re-roll and flicker slowly and brighten near the pointer.
|
|
91
|
+
*
|
|
92
|
+
* It fills its nearest positioned ancestor (`absolute inset-0`), inks with `currentColor`
|
|
93
|
+
* (`text-foreground` by default, so it follows the theme) and is always `aria-hidden`.
|
|
94
|
+
* Static under `prefers-reduced-motion`, on coarse pointers and below 768px; it pauses
|
|
95
|
+
* offscreen and in hidden tabs.
|
|
96
|
+
*
|
|
97
|
+
* The rule people break: turning `intensity` up until the field competes with the
|
|
98
|
+
* headline. It is atmosphere, not content — and never a substitute for the logo itself.
|
|
99
|
+
*/
|
|
100
|
+
export function AsciiField({ density = 1, intensity = 1, mask = "brackets", spread = 1, seed = 7, className, ...props }) {
|
|
101
|
+
const rootRef = useRef(null);
|
|
102
|
+
const canvasRef = useRef(null);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
const root = rootRef.current;
|
|
105
|
+
const canvas = canvasRef.current;
|
|
106
|
+
const ctx = canvas?.getContext("2d");
|
|
107
|
+
const atlas = document.createElement("canvas");
|
|
108
|
+
const actx = atlas.getContext("2d");
|
|
109
|
+
if (!root || !canvas || !ctx || !actx)
|
|
110
|
+
return;
|
|
111
|
+
const reduceQuery = matchMedia("(prefers-reduced-motion: reduce)");
|
|
112
|
+
const stillQuery = matchMedia("(pointer: coarse), (max-width: 767px)");
|
|
113
|
+
const ink = clamp(intensity, 0, 1.5);
|
|
114
|
+
const fontSize = clamp(13 / clamp(density, 0.25, 4), 8, 28);
|
|
115
|
+
const cw = Math.max(5, Math.round(fontSize * 0.66));
|
|
116
|
+
const ch = Math.round(fontSize * 1.32);
|
|
117
|
+
let disposed = false;
|
|
118
|
+
let W = 0;
|
|
119
|
+
let H = 0;
|
|
120
|
+
let dpr = 1;
|
|
121
|
+
let acw = 1;
|
|
122
|
+
let ach = 1;
|
|
123
|
+
let cols = 0;
|
|
124
|
+
let rows = 0;
|
|
125
|
+
let ox = 0;
|
|
126
|
+
let oy = 0;
|
|
127
|
+
let count = 0;
|
|
128
|
+
let level = new Float32Array(0);
|
|
129
|
+
let fade = new Float32Array(0);
|
|
130
|
+
let jitter = new Float32Array(0);
|
|
131
|
+
let phase = new Float32Array(0);
|
|
132
|
+
let speed = new Float32Array(0);
|
|
133
|
+
let flash = new Float32Array(0);
|
|
134
|
+
let glyph = new Uint8Array(0);
|
|
135
|
+
/** Cells on the moon's dark side, inside the cut: always empty, as the mark is there. */
|
|
136
|
+
let dark = new Uint8Array(0);
|
|
137
|
+
let raf = 0;
|
|
138
|
+
let last = 0;
|
|
139
|
+
let lastRoll = 0;
|
|
140
|
+
let onScreen = true;
|
|
141
|
+
const pointer = { x: 0, y: 0, tx: 0, ty: 0, on: 0, target: 0 };
|
|
142
|
+
const isStill = () => reduceQuery.matches || stillQuery.matches;
|
|
143
|
+
function pick(i) {
|
|
144
|
+
if (dark[i])
|
|
145
|
+
return 0;
|
|
146
|
+
const l = level[i];
|
|
147
|
+
const j = jitter[i];
|
|
148
|
+
if (l < 0.22 && j < 0.52 - l)
|
|
149
|
+
return 0; // sparse background
|
|
150
|
+
const k = (j * 7.31) % 1;
|
|
151
|
+
if (mask !== "none" && l > 0.55 && k > 0.86)
|
|
152
|
+
return k > 0.93 ? BIT + 1 : BIT;
|
|
153
|
+
return clamp(Math.round(l * RAMP_MAX + (j - 0.5) * 2.4), 0, RAMP_MAX);
|
|
154
|
+
}
|
|
155
|
+
function buildAtlas() {
|
|
156
|
+
const style = getComputedStyle(root);
|
|
157
|
+
acw = Math.ceil(cw * dpr);
|
|
158
|
+
ach = Math.ceil(ch * dpr);
|
|
159
|
+
atlas.width = acw * GLYPHS.length;
|
|
160
|
+
atlas.height = ach;
|
|
161
|
+
actx.clearRect(0, 0, atlas.width, atlas.height);
|
|
162
|
+
actx.fillStyle = style.color;
|
|
163
|
+
actx.font = `400 ${fontSize * dpr}px ${style.fontFamily}`;
|
|
164
|
+
actx.textAlign = "center";
|
|
165
|
+
actx.textBaseline = "middle";
|
|
166
|
+
for (let g = 1; g < GLYPHS.length; g++) {
|
|
167
|
+
actx.fillText(GLYPHS[g], g * acw + acw / 2, ach / 2 + dpr * 0.5);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function layout() {
|
|
171
|
+
W = root.clientWidth;
|
|
172
|
+
H = root.clientHeight;
|
|
173
|
+
dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
174
|
+
canvas.width = Math.max(1, Math.round(W * dpr));
|
|
175
|
+
canvas.height = Math.max(1, Math.round(H * dpr));
|
|
176
|
+
cols = Math.ceil(W / cw) + 1;
|
|
177
|
+
rows = Math.ceil(H / ch) + 1;
|
|
178
|
+
ox = (W - cols * cw) / 2;
|
|
179
|
+
oy = (H - rows * ch) / 2;
|
|
180
|
+
count = cols * rows;
|
|
181
|
+
level = new Float32Array(count);
|
|
182
|
+
fade = new Float32Array(count);
|
|
183
|
+
jitter = new Float32Array(count);
|
|
184
|
+
phase = new Float32Array(count);
|
|
185
|
+
speed = new Float32Array(count);
|
|
186
|
+
flash = new Float32Array(count);
|
|
187
|
+
glyph = new Uint8Array(count);
|
|
188
|
+
dark = new Uint8Array(count);
|
|
189
|
+
// Fit the brackets: tall and soft, opened apart on wide containers.
|
|
190
|
+
const aspect = W / Math.max(H, 1);
|
|
191
|
+
const open = mask === "brackets" ? clamp(spread, 0, 1) * smoothstep(0.9, 1.5, aspect) : 0;
|
|
192
|
+
let s = (H * 0.84) / ART_H;
|
|
193
|
+
const shift = open * Math.max(0, (W * 0.58 - ART_GAP * s) / 2);
|
|
194
|
+
if (ART_W * s + 2 * shift > W * 0.96)
|
|
195
|
+
s = Math.max(0.05, (W * 0.96 - 2 * shift) / ART_W);
|
|
196
|
+
const soft = 9;
|
|
197
|
+
// The crescent: its moon 64% of the height, or of the width when that is narrower.
|
|
198
|
+
const es = Math.min(H * 0.64, W * 0.8) / (2 * MOON_R);
|
|
199
|
+
const rand = mulberry32(seed);
|
|
200
|
+
for (let r = 0; r < rows; r++) {
|
|
201
|
+
for (let c = 0; c < cols; c++) {
|
|
202
|
+
const i = r * cols + c;
|
|
203
|
+
const px = ox + c * cw + cw / 2;
|
|
204
|
+
const py = oy + r * ch + ch / 2;
|
|
205
|
+
const n = 0.65 * valueNoise(c * 0.09, r * 0.16, seed) + 0.35 * valueNoise(c * 0.23, r * 0.41, seed + 1);
|
|
206
|
+
let l;
|
|
207
|
+
if (mask === "brackets") {
|
|
208
|
+
const uy = (py - H / 2) / s + ART_CY;
|
|
209
|
+
const uxL = (px - W / 2 + shift) / s + ART_CX;
|
|
210
|
+
const uxR = (px - W / 2 - shift) / s + ART_CX;
|
|
211
|
+
let d = Infinity;
|
|
212
|
+
for (const rect of LEFT_BRACKET)
|
|
213
|
+
d = Math.min(d, sdRect(uxL, uy, rect));
|
|
214
|
+
for (const rect of RIGHT_BRACKET)
|
|
215
|
+
d = Math.min(d, sdRect(uxR, uy, rect));
|
|
216
|
+
const inside = smoothstep(soft, -soft * 0.6, d);
|
|
217
|
+
const halo = Math.exp(-Math.max(d, 0) / 38);
|
|
218
|
+
l = inside * (0.66 + 0.34 * n) + halo * 0.2 * (0.5 + n) + 0.1 * n;
|
|
219
|
+
}
|
|
220
|
+
else if (mask === "crescent") {
|
|
221
|
+
const { moon, light } = crescent((px - W / 2) / es, (py - H / 2) / es);
|
|
222
|
+
const lit = smoothstep(0.5, -0.4, light);
|
|
223
|
+
const glow = Math.exp(-Math.max(light, 0) / 2.4);
|
|
224
|
+
// The dark side stays empty against the texture; the crescent is dense, with a glow
|
|
225
|
+
// around it. A faint limb traces the rest of the circle, so the moon reads as a body.
|
|
226
|
+
const limb = Math.exp(-Math.abs(moon) / 0.45);
|
|
227
|
+
dark[i] = moon < -0.5 && light > 0.4 ? 1 : 0;
|
|
228
|
+
l = lit * (0.7 + 0.3 * n) + glow * 0.3 * (0.5 + n) + limb * 0.22 * (0.6 + 0.4 * n) + 0.1 * n;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
l = 0.06 + 0.34 * n * n;
|
|
232
|
+
}
|
|
233
|
+
const ex = Math.min(px, W - px) / Math.max(W * 0.08, 1);
|
|
234
|
+
const ey = Math.min(py, H - py) / Math.max(H * 0.14, 1);
|
|
235
|
+
level[i] = clamp(l, 0, 1);
|
|
236
|
+
fade[i] = smoothstep(0, 1, Math.min(ex, ey));
|
|
237
|
+
jitter[i] = rand();
|
|
238
|
+
phase[i] = rand() * TAU;
|
|
239
|
+
speed[i] = 0.5 + rand() * 1.8;
|
|
240
|
+
glyph[i] = pick(i);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function draw(t, live) {
|
|
245
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
246
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
247
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
248
|
+
const dw = acw / dpr;
|
|
249
|
+
const dh = ach / dpr;
|
|
250
|
+
const lit = live && pointer.on > 0.01;
|
|
251
|
+
const r2 = POINTER_R * POINTER_R;
|
|
252
|
+
for (let r = 0; r < rows; r++) {
|
|
253
|
+
const py = oy + r * ch + ch / 2;
|
|
254
|
+
for (let c = 0; c < cols; c++) {
|
|
255
|
+
const i = r * cols + c;
|
|
256
|
+
if (dark[i])
|
|
257
|
+
continue;
|
|
258
|
+
const px = ox + c * cw + cw / 2;
|
|
259
|
+
let g = glyph[i];
|
|
260
|
+
let a = ink * (0.03 + level[i] * 0.3) * fade[i];
|
|
261
|
+
if (live) {
|
|
262
|
+
a *= 0.78 + 0.22 * Math.sin(t * speed[i] + phase[i]);
|
|
263
|
+
const f = flash[i];
|
|
264
|
+
if (f > 0.01) {
|
|
265
|
+
a += f * 0.14 * ink * fade[i];
|
|
266
|
+
flash[i] = f * 0.86;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (lit) {
|
|
270
|
+
const dx = px - pointer.x;
|
|
271
|
+
const dy = py - pointer.y;
|
|
272
|
+
const d2 = dx * dx + dy * dy;
|
|
273
|
+
if (d2 < r2) {
|
|
274
|
+
let b = 1 - Math.sqrt(d2) / POINTER_R;
|
|
275
|
+
b = b * b * pointer.on;
|
|
276
|
+
a += b * 0.34 * ink * fade[i];
|
|
277
|
+
if (g < BIT)
|
|
278
|
+
g =
|
|
279
|
+
g === 0
|
|
280
|
+
? b > 0.12
|
|
281
|
+
? 1 + Math.floor(b * 3)
|
|
282
|
+
: 0
|
|
283
|
+
: Math.min(RAMP_MAX, g + Math.round(b * 3));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (g === 0 || a < 0.004)
|
|
287
|
+
continue;
|
|
288
|
+
ctx.globalAlpha = a > 1 ? 1 : a;
|
|
289
|
+
ctx.drawImage(atlas, g * acw, 0, acw, ach, px - dw / 2, py - dh / 2, dw, dh);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
ctx.globalAlpha = 1;
|
|
293
|
+
}
|
|
294
|
+
function frame(now) {
|
|
295
|
+
raf = requestAnimationFrame(frame);
|
|
296
|
+
if (now - last < FRAME_MS)
|
|
297
|
+
return;
|
|
298
|
+
const dt = Math.min(0.1, (now - last) / 1000);
|
|
299
|
+
last = now;
|
|
300
|
+
pointer.on += (pointer.target - pointer.on) * Math.min(1, dt * 5);
|
|
301
|
+
const follow = Math.min(1, dt * 9);
|
|
302
|
+
pointer.x += (pointer.tx - pointer.x) * follow;
|
|
303
|
+
pointer.y += (pointer.ty - pointer.y) * follow;
|
|
304
|
+
if (now - lastRoll > ROLL_MS && count > 0) {
|
|
305
|
+
lastRoll = now;
|
|
306
|
+
const n = Math.ceil(count * ROLL_SHARE);
|
|
307
|
+
for (let k = 0; k < n; k++) {
|
|
308
|
+
const i = (Math.random() * count) | 0;
|
|
309
|
+
jitter[i] = Math.random();
|
|
310
|
+
const g = pick(i);
|
|
311
|
+
if (g !== glyph[i]) {
|
|
312
|
+
glyph[i] = g;
|
|
313
|
+
flash[i] = 1;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
draw(now / 1000, true);
|
|
318
|
+
}
|
|
319
|
+
function sync() {
|
|
320
|
+
if (disposed)
|
|
321
|
+
return;
|
|
322
|
+
const run = !isStill() && onScreen && !document.hidden && W > 0 && H > 0;
|
|
323
|
+
if (run && !raf) {
|
|
324
|
+
last = performance.now() - FRAME_MS;
|
|
325
|
+
raf = requestAnimationFrame(frame);
|
|
326
|
+
}
|
|
327
|
+
else if (!run && raf) {
|
|
328
|
+
cancelAnimationFrame(raf);
|
|
329
|
+
raf = 0;
|
|
330
|
+
}
|
|
331
|
+
if (isStill())
|
|
332
|
+
draw(0, false);
|
|
333
|
+
}
|
|
334
|
+
function refresh() {
|
|
335
|
+
if (disposed)
|
|
336
|
+
return;
|
|
337
|
+
layout();
|
|
338
|
+
buildAtlas();
|
|
339
|
+
draw(0, false);
|
|
340
|
+
sync();
|
|
341
|
+
}
|
|
342
|
+
function recolor() {
|
|
343
|
+
if (disposed)
|
|
344
|
+
return;
|
|
345
|
+
buildAtlas();
|
|
346
|
+
if (!raf)
|
|
347
|
+
draw(0, false);
|
|
348
|
+
}
|
|
349
|
+
function onPointerMove(e) {
|
|
350
|
+
if (isStill() || e.pointerType === "touch")
|
|
351
|
+
return;
|
|
352
|
+
const rect = root.getBoundingClientRect();
|
|
353
|
+
const x = e.clientX - rect.left;
|
|
354
|
+
const y = e.clientY - rect.top;
|
|
355
|
+
const near = x > -POINTER_R && y > -POINTER_R && x < W + POINTER_R && y < H + POINTER_R;
|
|
356
|
+
pointer.tx = x;
|
|
357
|
+
pointer.ty = y;
|
|
358
|
+
if (pointer.on < 0.02) {
|
|
359
|
+
pointer.x = x;
|
|
360
|
+
pointer.y = y;
|
|
361
|
+
}
|
|
362
|
+
pointer.target = near ? 1 : 0;
|
|
363
|
+
}
|
|
364
|
+
const onPointerLeave = () => {
|
|
365
|
+
pointer.target = 0;
|
|
366
|
+
};
|
|
367
|
+
const ro = new ResizeObserver(refresh);
|
|
368
|
+
ro.observe(root);
|
|
369
|
+
const io = new IntersectionObserver((entries) => {
|
|
370
|
+
onScreen = entries[entries.length - 1]?.isIntersecting ?? true;
|
|
371
|
+
sync();
|
|
372
|
+
});
|
|
373
|
+
io.observe(root);
|
|
374
|
+
// Re-ink when the theme changes anywhere above us.
|
|
375
|
+
const mo = new MutationObserver(recolor);
|
|
376
|
+
mo.observe(document.documentElement, {
|
|
377
|
+
attributes: true,
|
|
378
|
+
attributeFilter: ["class", "data-theme", "style"],
|
|
379
|
+
});
|
|
380
|
+
if (document.body)
|
|
381
|
+
mo.observe(document.body, { attributes: true, attributeFilter: ["class", "data-theme"] });
|
|
382
|
+
const schemeQuery = matchMedia("(prefers-color-scheme: dark)");
|
|
383
|
+
schemeQuery.addEventListener("change", recolor);
|
|
384
|
+
reduceQuery.addEventListener("change", sync);
|
|
385
|
+
stillQuery.addEventListener("change", sync);
|
|
386
|
+
document.addEventListener("visibilitychange", sync);
|
|
387
|
+
window.addEventListener("pointermove", onPointerMove, { passive: true });
|
|
388
|
+
document.documentElement.addEventListener("pointerleave", onPointerLeave);
|
|
389
|
+
window.addEventListener("blur", onPointerLeave);
|
|
390
|
+
// Licht Mono may not be on the page yet; ink again once it is.
|
|
391
|
+
const style = getComputedStyle(root);
|
|
392
|
+
document.fonts?.load(`400 ${fontSize}px ${style.fontFamily}`).then(recolor, () => { });
|
|
393
|
+
refresh();
|
|
394
|
+
return () => {
|
|
395
|
+
disposed = true;
|
|
396
|
+
cancelAnimationFrame(raf);
|
|
397
|
+
ro.disconnect();
|
|
398
|
+
io.disconnect();
|
|
399
|
+
mo.disconnect();
|
|
400
|
+
schemeQuery.removeEventListener("change", recolor);
|
|
401
|
+
reduceQuery.removeEventListener("change", sync);
|
|
402
|
+
stillQuery.removeEventListener("change", sync);
|
|
403
|
+
document.removeEventListener("visibilitychange", sync);
|
|
404
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
405
|
+
document.documentElement.removeEventListener("pointerleave", onPointerLeave);
|
|
406
|
+
window.removeEventListener("blur", onPointerLeave);
|
|
407
|
+
};
|
|
408
|
+
}, [density, intensity, mask, spread, seed]);
|
|
409
|
+
return (_jsx("div", { ref: rootRef, "data-slot": "ascii-field", "data-mask": mask, "aria-hidden": true, className: cn("pointer-events-none absolute inset-0 overflow-hidden font-mono text-foreground select-none", className), ...props, children: _jsx("canvas", { ref: canvasRef, className: "absolute inset-0 block size-full" }) }));
|
|
410
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
export interface AspectRatioProps extends React.ComponentProps<"div"> {
|
|
3
|
+
/** Width divided by height: `16 / 9`, `4 / 3`, `1`. Defaults to `1`. */
|
|
4
|
+
ratio?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* AspectRatio — a box that keeps a width-to-height ratio (CSS `aspect-ratio`) and makes its
|
|
8
|
+
* child fill it. Overflow is hidden; add `object-cover` to a photo that should fill the box.
|
|
9
|
+
*
|
|
10
|
+
* It has no surface and no radius of its own: round it to the thing it is (`rounded-card` for
|
|
11
|
+
* a cover in a card, none for a region). The rule people break: fixing a height on the child,
|
|
12
|
+
* which defeats the ratio — let the box size it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function AspectRatio({ ratio, className, style, ...props }: AspectRatioProps): React.JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
/**
|
|
5
|
+
* AspectRatio — a box that keeps a width-to-height ratio (CSS `aspect-ratio`) and makes its
|
|
6
|
+
* child fill it. Overflow is hidden; add `object-cover` to a photo that should fill the box.
|
|
7
|
+
*
|
|
8
|
+
* It has no surface and no radius of its own: round it to the thing it is (`rounded-card` for
|
|
9
|
+
* a cover in a card, none for a region). The rule people break: fixing a height on the child,
|
|
10
|
+
* which defeats the ratio — let the box size it.
|
|
11
|
+
*/
|
|
12
|
+
export function AspectRatio({ ratio = 1, className, style, ...props }) {
|
|
13
|
+
// A ratio CSS cannot use (0, negative, NaN or Infinity — an image's width over a height that is
|
|
14
|
+
// not there yet) would leave a box with no height: the content would vanish. It is square instead.
|
|
15
|
+
const valid = Number.isFinite(ratio) && ratio > 0 ? ratio : 1;
|
|
16
|
+
return (_jsx("div", { "data-slot": "aspect-ratio", className: cn("relative w-full overflow-hidden", "*:absolute *:inset-0 *:size-full", className), style: { aspectRatio: String(valid), ...style }, ...props }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Avatar as BaseAvatar } from "@base-ui/react/avatar";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
declare const avatarSizes: {
|
|
4
|
+
readonly sm: "size-6 text-[9px]";
|
|
5
|
+
readonly default: "size-8 text-[11px]";
|
|
6
|
+
readonly lg: "size-10 text-[13px]";
|
|
7
|
+
/** A profile page's own picture. */
|
|
8
|
+
readonly xl: "size-20 text-[22px]";
|
|
9
|
+
/** A profile picker ("Who's watching?"), where the picture is the button. */
|
|
10
|
+
readonly "2xl": "size-32 text-[34px]";
|
|
11
|
+
};
|
|
12
|
+
export type AvatarSize = keyof typeof avatarSizes;
|
|
13
|
+
export interface AvatarProps extends BaseAvatar.Root.Props {
|
|
14
|
+
/** Image URL. While it loads, or if it fails, the initials show. */
|
|
15
|
+
src?: string;
|
|
16
|
+
/** The person's name. Used for the image `alt` and to derive initials. */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** Overrides the derived initials. */
|
|
19
|
+
fallback?: React.ReactNode;
|
|
20
|
+
/** `sm` 24px · `default` 32px · `lg` 40px · `xl` 80px for a profile's own page · `2xl` 128px for a profile picker. */
|
|
21
|
+
size?: AvatarSize;
|
|
22
|
+
/** Props forwarded to the `<img>`. */
|
|
23
|
+
imageProps?: Omit<BaseAvatar.Image.Props, "src">;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Avatar — a person, as a round image with a `--field-edge` ring and mono initials as the
|
|
27
|
+
* fallback. No generated background colours per person: colour carries meaning, and a person is
|
|
28
|
+
* not a category.
|
|
29
|
+
*
|
|
30
|
+
* The rule people break: decorative avatars of people who are not real. Show a person only
|
|
31
|
+
* when they are a real member of the team or the signed-in user.
|
|
32
|
+
*/
|
|
33
|
+
export declare function Avatar({ src, name, fallback, size, imageProps, className, children, ...props }: AvatarProps): React.JSX.Element;
|
|
34
|
+
export interface AvatarGroupProps extends React.ComponentProps<"div"> {
|
|
35
|
+
/** Show at most this many avatars, then a `+N` count. */
|
|
36
|
+
max?: number;
|
|
37
|
+
/** Size of the `+N` count bubble; match the avatars. */
|
|
38
|
+
size?: AvatarSize;
|
|
39
|
+
}
|
|
40
|
+
/** Overlapping avatars, each cut out of the page with a background-coloured outline. */
|
|
41
|
+
export declare function AvatarGroup({ max, size, className, children, ...props }: AvatarGroupProps): React.JSX.Element;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Avatar as BaseAvatar } from "@base-ui/react/avatar";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn, sx } from "../lib/cn.js";
|
|
6
|
+
const avatarSizes = {
|
|
7
|
+
sm: "size-6 text-[9px]",
|
|
8
|
+
default: "size-8 text-[11px]",
|
|
9
|
+
lg: "size-10 text-[13px]",
|
|
10
|
+
/** A profile page's own picture. */
|
|
11
|
+
xl: "size-20 text-[22px]",
|
|
12
|
+
/** A profile picker ("Who's watching?"), where the picture is the button. */
|
|
13
|
+
"2xl": "size-32 text-[34px]",
|
|
14
|
+
};
|
|
15
|
+
/** AvatarGroup's `+N`: as tall as the avatars, and as wide as a long count needs ("+1204"). */
|
|
16
|
+
const countSizes = {
|
|
17
|
+
sm: "h-6 min-w-6 px-1 text-[9px]",
|
|
18
|
+
default: "h-8 min-w-8 px-1.5 text-[11px]",
|
|
19
|
+
lg: "h-10 min-w-10 px-2 text-[13px]",
|
|
20
|
+
xl: "h-20 min-w-20 px-4 text-[22px]",
|
|
21
|
+
"2xl": "h-32 min-w-32 px-6 text-[34px]",
|
|
22
|
+
};
|
|
23
|
+
function initials(name) {
|
|
24
|
+
if (!name)
|
|
25
|
+
return "";
|
|
26
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
27
|
+
// By code point, not UTF-16 unit: a name that starts with an emoji or another astral
|
|
28
|
+
// character would otherwise show half a surrogate pair (�).
|
|
29
|
+
const initial = (part) => (part ? ([...part][0] ?? "") : "");
|
|
30
|
+
const first = initial(parts[0]);
|
|
31
|
+
const last = parts.length > 1 ? initial(parts[parts.length - 1]) : "";
|
|
32
|
+
return (first + last).toUpperCase();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Avatar — a person, as a round image with a `--field-edge` ring and mono initials as the
|
|
36
|
+
* fallback. No generated background colours per person: colour carries meaning, and a person is
|
|
37
|
+
* not a category.
|
|
38
|
+
*
|
|
39
|
+
* The rule people break: decorative avatars of people who are not real. Show a person only
|
|
40
|
+
* when they are a real member of the team or the signed-in user.
|
|
41
|
+
*/
|
|
42
|
+
export function Avatar({ src, name, fallback, size = "default", imageProps, className, children, ...props }) {
|
|
43
|
+
return (_jsxs(BaseAvatar.Root, { "data-slot": "avatar", "data-size": size, className: sx([
|
|
44
|
+
"relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full align-middle select-none",
|
|
45
|
+
"bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent ring-1 ring-field-edge",
|
|
46
|
+
avatarSizes[size],
|
|
47
|
+
], className), ...props, children: [src && (_jsx(BaseAvatar.Image, { "data-slot": "avatar-image", src: src, alt: name ?? "", ...imageProps, className: sx("size-full object-cover", imageProps?.className) })), _jsxs(BaseAvatar.Fallback, { "data-slot": "avatar-fallback", delay: src ? 400 : 0, className: "font-mono leading-none tracking-[0.02em] text-foreground-soft", children: [_jsx("span", { "aria-hidden": name ? true : undefined, children: fallback ?? initials(name) }), name && _jsx("span", { className: "sr-only", children: name })] }), children] }));
|
|
48
|
+
}
|
|
49
|
+
/** Overlapping avatars, each cut out of the page with a background-coloured outline. */
|
|
50
|
+
export function AvatarGroup({ max, size = "default", className, children, ...props }) {
|
|
51
|
+
const items = React.Children.toArray(children);
|
|
52
|
+
const shown = max != null ? items.slice(0, max) : items;
|
|
53
|
+
const rest = items.length - shown.length;
|
|
54
|
+
return (_jsxs("div", { "data-slot": "avatar-group", className: cn("flex items-center -space-x-2 *:outline-2 *:outline-background", size === "lg" && "-space-x-2.5", className), ...props, children: [shown, rest > 0 && (_jsxs("span", { "data-slot": "avatar-group-count", className: cn("relative inline-flex shrink-0 items-center justify-center rounded-full font-mono leading-none text-foreground-soft tabular-nums", "bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent ring-1 ring-field-edge", countSizes[size]), children: ["+", rest] }))] }));
|
|
55
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
declare const badgeVariants: {
|
|
3
|
+
/** The primary fill: dark in light mode, light in dark mode. Counts that need attention. */
|
|
4
|
+
readonly default: "bg-(--primary-fill) text-(--primary-text) shadow-checked";
|
|
5
|
+
/** The raised key surface with foreground ink. Quiet counts and "New" markers. */
|
|
6
|
+
readonly secondary: "bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent text-foreground shadow-key";
|
|
7
|
+
/** Status only: done, connected, online. Never decoration. */
|
|
8
|
+
readonly success: "bg-success text-background shadow-checked";
|
|
9
|
+
/** Status only: away, expiring, a count of things that need attention soon. Never decoration. */
|
|
10
|
+
readonly warning: "bg-warning text-background shadow-checked";
|
|
11
|
+
/** Status only: new, syncing, an unread count of neutral news. Never decoration. */
|
|
12
|
+
readonly info: "bg-info text-background shadow-checked";
|
|
13
|
+
/** Status only: failed, offline, an error count. Never decoration. */
|
|
14
|
+
readonly destructive: "bg-destructive text-background shadow-checked";
|
|
15
|
+
};
|
|
16
|
+
declare const badgeSizes: {
|
|
17
|
+
/** 16px — on 30px controls, 24px avatars and inline in dense rows. */
|
|
18
|
+
readonly sm: "h-4 min-w-4 px-1 text-[10px]";
|
|
19
|
+
/** 20px — on 36–46px controls and 32–40px avatars. */
|
|
20
|
+
readonly default: "h-5 min-w-5 px-1.5 text-[11px]";
|
|
21
|
+
};
|
|
22
|
+
export type BadgeVariant = keyof typeof badgeVariants;
|
|
23
|
+
export type BadgeSize = keyof typeof badgeSizes;
|
|
24
|
+
export interface BadgeProps extends React.ComponentProps<"span"> {
|
|
25
|
+
variant?: BadgeVariant;
|
|
26
|
+
/** `sm` 16px (dot 8px) · `default` 20px (dot 10px). */
|
|
27
|
+
size?: BadgeSize;
|
|
28
|
+
/**
|
|
29
|
+
* A number to show. Above `max` it reads "99+"; zero or less (or `NaN`) renders nothing, so an
|
|
30
|
+
* empty inbox shows no badge. Use `children` instead for a word ("New").
|
|
31
|
+
*/
|
|
32
|
+
count?: number;
|
|
33
|
+
/** The largest count shown in full. Default 99. */
|
|
34
|
+
max?: number;
|
|
35
|
+
/** Render a status dot with no text. Give it a `label`. */
|
|
36
|
+
dot?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Text for screen readers. Required for a `dot` ("Online"). For a count on an icon button,
|
|
39
|
+
* put the count in the button's `aria-label` instead and leave this out.
|
|
40
|
+
*/
|
|
41
|
+
label?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Badge — a small count or status mark: a notification count on an icon button or avatar,
|
|
45
|
+
* a "New" marker beside a nav item, or a status dot. Mono, tabular numerals; 16 or 20px tall,
|
|
46
|
+
* fully round. Monochrome by default; `success`, `warning`, `info` and `destructive` are status only.
|
|
47
|
+
*
|
|
48
|
+
* Wrap the thing it marks in `BadgeAnchor` to pin it to the corner. Not the same as `Tag`:
|
|
49
|
+
* a tag is metadata that names something ("TypeScript", "Draft"); a badge counts or flags
|
|
50
|
+
* something about the object it sits on. The rule people break: colour as decoration — a
|
|
51
|
+
* green "New" or a red count that is not an error.
|
|
52
|
+
*/
|
|
53
|
+
export declare function Badge({ variant, size, count, max, dot, label, className, children, ...props }: BadgeProps): React.JSX.Element | null;
|
|
54
|
+
export interface BadgeAnchorProps extends React.ComponentProps<"span"> {
|
|
55
|
+
/**
|
|
56
|
+
* The outline of what is marked. `circle` (default) for avatars and icon buttons: the badge
|
|
57
|
+
* sits on the circle's 45° point. `rect` for buttons and cards: it sits on the corner.
|
|
58
|
+
*/
|
|
59
|
+
shape?: "circle" | "rect";
|
|
60
|
+
/** `top-end` (default) for counts and markers; `bottom-end` for a presence dot on an avatar. */
|
|
61
|
+
placement?: "top-end" | "bottom-end";
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* BadgeAnchor — wraps an icon button, avatar or other object and pins a direct child `Badge`
|
|
65
|
+
* to its corner, with a 2px cut-out in the page colour (`--badge-cutout`, default
|
|
66
|
+
* `--background`; set it on a card). The badge ignores the pointer, so the control underneath
|
|
67
|
+
* still receives every click.
|
|
68
|
+
*/
|
|
69
|
+
export declare function BadgeAnchor({ shape, placement, className, ...props }: BadgeAnchorProps): React.JSX.Element;
|
|
70
|
+
export {};
|