@lanfermann/ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +17 -2
- package/TRADEMARK.md +10 -0
- package/brand/app-icon.svg +1 -0
- package/brand/avatar.svg +1 -0
- package/brand/favicon.svg +1 -0
- package/dist/components/accordion/accordion.d.ts +26 -0
- package/dist/components/accordion/accordion.js +78 -0
- package/dist/components/alert/alert.d.ts +19 -0
- package/dist/components/alert/alert.js +68 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +20 -0
- package/dist/components/alert-dialog/alert-dialog.js +75 -0
- package/dist/components/anchor-heading/anchor-heading.d.ts +19 -0
- package/dist/components/anchor-heading/anchor-heading.js +39 -0
- package/dist/components/avatar/avatar.d.ts +14 -0
- package/dist/components/avatar/avatar.js +42 -0
- package/dist/components/badge/badge.d.ts +12 -0
- package/dist/components/badge/badge.js +27 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +23 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +63 -0
- package/dist/components/button/button-variants.d.ts +15 -0
- package/dist/components/button/button-variants.js +76 -0
- package/dist/components/button/button.d.ts +25 -0
- package/dist/components/button/button.js +50 -0
- package/dist/components/calendar/calendar-selection.js +216 -0
- package/dist/components/calendar/calendar.d.ts +44 -0
- package/dist/components/calendar/calendar.js +208 -0
- package/dist/components/callout/callout.d.ts +21 -0
- package/dist/components/callout/callout.js +75 -0
- package/dist/components/card/card.d.ts +16 -0
- package/dist/components/card/card.js +53 -0
- package/dist/components/checkbox/checkbox.d.ts +9 -0
- package/dist/components/checkbox/checkbox.js +33 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +18 -0
- package/dist/components/checkbox-group/checkbox-group.js +33 -0
- package/dist/components/code/code.d.ts +7 -0
- package/dist/components/code/code.js +16 -0
- package/dist/components/code-block/code-block-frame.js +146 -0
- package/dist/components/code-block/code-block-live.d.ts +45 -0
- package/dist/components/code-block/code-block-live.js +51 -0
- package/dist/components/code-block/code-block.d.ts +36 -0
- package/dist/components/code-block/code-block.js +51 -0
- package/dist/components/code-block/code-copy.d.ts +12 -0
- package/dist/components/code-block/code-copy.js +71 -0
- package/dist/components/code-block/code-lines-view.d.ts +16 -0
- package/dist/components/code-block/code-lines-view.js +48 -0
- package/dist/components/code-block/code-lines.js +17 -0
- package/dist/components/code-block/code-scroll.js +29 -0
- package/dist/components/code-block/code-surface.js +13 -0
- package/dist/components/code-block/code-tabs-frame.js +85 -0
- package/dist/components/code-block/code-tabs-store.js +25 -0
- package/dist/components/code-block/code-tabs.d.ts +28 -0
- package/dist/components/code-block/code-tabs.js +29 -0
- package/dist/components/code-block/highlight.d.ts +34 -0
- package/dist/components/code-block/highlight.js +258 -0
- package/dist/components/code-block/lines.d.ts +5 -0
- package/dist/components/code-block/lines.js +40 -0
- package/dist/components/collapsible/collapsible.d.ts +19 -0
- package/dist/components/collapsible/collapsible.js +54 -0
- package/dist/components/combobox/combobox.d.ts +84 -0
- package/dist/components/combobox/combobox.js +169 -0
- package/dist/components/container/container.d.ts +16 -0
- package/dist/components/container/container.js +30 -0
- package/dist/components/copy-pill/copy-pill.d.ts +52 -0
- package/dist/components/copy-pill/copy-pill.js +232 -0
- package/dist/components/cta/cta.d.ts +109 -0
- package/dist/components/cta/cta.js +375 -0
- package/dist/components/date-field/date-field.d.ts +40 -0
- package/dist/components/date-field/date-field.js +99 -0
- package/dist/components/date-range-field/date-range-field.d.ts +41 -0
- package/dist/components/date-range-field/date-range-field.js +155 -0
- package/dist/components/dialog/dialog.d.ts +29 -0
- package/dist/components/dialog/dialog.js +96 -0
- package/dist/components/docs-layout/docs-layout.d.ts +17 -0
- package/dist/components/docs-layout/docs-layout.js +46 -0
- package/dist/components/drawer/drawer.d.ts +39 -0
- package/dist/components/drawer/drawer.js +181 -0
- package/dist/components/field/field.d.ts +18 -0
- package/dist/components/field/field.js +77 -0
- package/dist/components/fieldset/fieldset.d.ts +8 -0
- package/dist/components/fieldset/fieldset.js +25 -0
- package/dist/components/figure/figure.d.ts +14 -0
- package/dist/components/figure/figure.js +35 -0
- package/dist/components/form/form.d.ts +31 -0
- package/dist/components/form/form.js +55 -0
- package/dist/components/ground/ground.d.ts +20 -0
- package/dist/components/ground/ground.js +31 -0
- package/dist/components/heading/heading.d.ts +16 -0
- package/dist/components/heading/heading.js +36 -0
- package/dist/components/icon/icon.d.ts +22 -0
- package/dist/components/icon/icon.js +24 -0
- package/dist/components/input/input.d.ts +19 -0
- package/dist/components/input/input.js +46 -0
- package/dist/components/input-group/input-group.d.ts +34 -0
- package/dist/components/input-group/input-group.js +61 -0
- package/dist/components/kbd/kbd.d.ts +6 -0
- package/dist/components/kbd/kbd.js +15 -0
- package/dist/components/link/link-variants.d.ts +13 -0
- package/dist/components/link/link-variants.js +27 -0
- package/dist/components/link/link.d.ts +9 -0
- package/dist/components/link/link.js +18 -0
- package/dist/components/logo/logo-paths.js +22 -0
- package/dist/components/logo/logomark.d.ts +19 -0
- package/dist/components/logo/logomark.js +49 -0
- package/dist/components/logo/wordmark.d.ts +35 -0
- package/dist/components/logo/wordmark.js +48 -0
- package/dist/components/menu/menu.d.ts +26 -0
- package/dist/components/menu/menu.js +132 -0
- package/dist/components/meter/meter.d.ts +29 -0
- package/dist/components/meter/meter.js +68 -0
- package/dist/components/navigation-menu/navigation-menu-variants.d.ts +12 -0
- package/dist/components/navigation-menu/navigation-menu-variants.js +18 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +42 -0
- package/dist/components/navigation-menu/navigation-menu.js +128 -0
- package/dist/components/number-field/number-field.d.ts +32 -0
- package/dist/components/number-field/number-field.js +85 -0
- package/dist/components/page-header/page-header.d.ts +27 -0
- package/dist/components/page-header/page-header.js +48 -0
- package/dist/components/pager/pager.d.ts +24 -0
- package/dist/components/pager/pager.js +51 -0
- package/dist/components/parameter-list/parameter-list.d.ts +34 -0
- package/dist/components/parameter-list/parameter-list.js +70 -0
- package/dist/components/popover/popover.d.ts +15 -0
- package/dist/components/popover/popover.js +64 -0
- package/dist/components/progress/progress.d.ts +19 -0
- package/dist/components/progress/progress.js +67 -0
- package/dist/components/prose/prose.d.ts +13 -0
- package/dist/components/prose/prose.js +22 -0
- package/dist/components/quote/quote.d.ts +21 -0
- package/dist/components/quote/quote.js +46 -0
- package/dist/components/radio/radio.d.ts +12 -0
- package/dist/components/radio/radio.js +37 -0
- package/dist/components/reference-entry/reference-entry.d.ts +25 -0
- package/dist/components/reference-entry/reference-entry.js +66 -0
- package/dist/components/section/section.d.ts +13 -0
- package/dist/components/section/section.js +30 -0
- package/dist/components/segmented-control/segmented-control.d.ts +42 -0
- package/dist/components/segmented-control/segmented-control.js +413 -0
- package/dist/components/select/select.d.ts +70 -0
- package/dist/components/select/select.js +189 -0
- package/dist/components/separator/separator.d.ts +12 -0
- package/dist/components/separator/separator.js +29 -0
- package/dist/components/side-nav/side-nav.d.ts +48 -0
- package/dist/components/side-nav/side-nav.js +89 -0
- package/dist/components/site-footer/site-footer-floor.js +48 -0
- package/dist/components/site-footer/site-footer.d.ts +38 -0
- package/dist/components/site-footer/site-footer.js +96 -0
- package/dist/components/site-header/site-header.d.ts +77 -0
- package/dist/components/site-header/site-header.js +214 -0
- package/dist/components/slider/slider.d.ts +42 -0
- package/dist/components/slider/slider.js +279 -0
- package/dist/components/spinner/spinner.d.ts +15 -0
- package/dist/components/spinner/spinner.js +34 -0
- package/dist/components/switch/switch.d.ts +8 -0
- package/dist/components/switch/switch.js +28 -0
- package/dist/components/table/table.d.ts +83 -0
- package/dist/components/table/table.js +123 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts +32 -0
- package/dist/components/table-of-contents/table-of-contents.js +187 -0
- package/dist/components/tabs/tabs.d.ts +28 -0
- package/dist/components/tabs/tabs.js +124 -0
- package/dist/components/text/text.d.ts +16 -0
- package/dist/components/text/text.js +63 -0
- package/dist/components/textarea/textarea.d.ts +19 -0
- package/dist/components/textarea/textarea.js +30 -0
- package/dist/components/time-field/time-field.d.ts +40 -0
- package/dist/components/time-field/time-field.js +123 -0
- package/dist/components/toast/toast.d.ts +55 -0
- package/dist/components/toast/toast.js +129 -0
- package/dist/components/tooltip/tooltip.d.ts +16 -0
- package/dist/components/tooltip/tooltip.js +41 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +77 -0
- package/dist/internal/arrow.js +41 -0
- package/dist/internal/disclosure.js +20 -0
- package/dist/internal/field-context.js +21 -0
- package/dist/internal/field.d.ts +23 -0
- package/dist/internal/field.js +49 -0
- package/dist/internal/glyphs.js +84 -0
- package/dist/internal/iso-date.d.ts +2 -0
- package/dist/internal/iso-date.js +268 -0
- package/dist/internal/overlay.js +40 -0
- package/dist/internal/picker-sheet.js +74 -0
- package/dist/internal/popup.js +37 -0
- package/dist/internal/range-shape.js +295 -0
- package/dist/internal/reduced-motion.js +19 -0
- package/dist/internal/scroll-edges.js +45 -0
- package/dist/internal/trough.js +39 -0
- package/dist/internal/typed-input.d.ts +16 -0
- package/dist/internal/typed-input.js +133 -0
- package/dist/lib/cn.d.ts +11 -0
- package/dist/lib/cn.js +98 -0
- package/dist/motion/inertia.js +111 -0
- package/dist/motion/spring-step.js +35 -0
- package/dist/motion/springs.d.ts +78 -0
- package/dist/motion/springs.js +81 -0
- package/package.json +107 -4
- package/src/styles/base.css +93 -0
- package/src/styles/calendar.css +117 -0
- package/src/styles/code.css +252 -0
- package/src/styles/density.css +53 -0
- package/src/styles/depth.css +501 -0
- package/src/styles/grounds.css +191 -0
- package/src/styles/marks.css +50 -0
- package/src/styles/motion.css +55 -0
- package/src/styles/motion.generated.css +101 -0
- package/src/styles/prose.css +252 -0
- package/src/styles/radius.css +20 -0
- package/src/styles/segmented.css +208 -0
- package/src/styles/slider.css +110 -0
- package/src/styles/status.css +108 -0
- package/src/styles/tabs.css +39 -0
- package/src/styles/toast.css +106 -0
- package/src/styles/touch.css +41 -0
- package/src/styles/type.css +54 -0
- package/src/styles.css +38 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { buttonVariants } from "../button/button-variants.js";
|
|
3
|
+
import { Icon } from "../icon/icon.js";
|
|
4
|
+
import { TickGlyph } from "../../internal/glyphs.js";
|
|
5
|
+
import { useReducedMotion } from "../../internal/reduced-motion.js";
|
|
6
|
+
import { cn } from "../../lib/cn.js";
|
|
7
|
+
import { restingMotion, trackMotion } from "../../motion/inertia.js";
|
|
8
|
+
import { springs } from "../../motion/springs.js";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Copy01Icon } from "@hugeicons/core-free-icons";
|
|
11
|
+
import { Children, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
12
|
+
// src/components/copy-pill/copy-pill.tsx
|
|
13
|
+
/** How long a copy stays confirmed, in ms. */
|
|
14
|
+
const CONFIRM_MS = 2e3;
|
|
15
|
+
/**
|
|
16
|
+
* How long the pointer has to rest on the pill before it opens, in ms. Long enough that a pass
|
|
17
|
+
* over it does nothing, short enough that nobody feels a wait (90 was felt).
|
|
18
|
+
*/
|
|
19
|
+
const OPEN_MS = 40;
|
|
20
|
+
/** How long after the pointer left the pill closes, in ms: leaving for a moment does nothing. */
|
|
21
|
+
const CLOSE_MS = 60;
|
|
22
|
+
/** How long after the mark before it a mark sets off when the stack moves, in ms. */
|
|
23
|
+
const FOLLOW_MS = 20;
|
|
24
|
+
/** How long the mark that goes to the back stays stretched before it is let go, in ms. */
|
|
25
|
+
const STRETCH_MS = 180;
|
|
26
|
+
/**
|
|
27
|
+
* A text to hand on (a prompt for an agent, a command, a link) as one fitting: a trough that
|
|
28
|
+
* holds the marks of where it goes, each a plug seated in it, and the key that copies it. The
|
|
29
|
+
* whole fitting is the button: a press anywhere in it copies.
|
|
30
|
+
*
|
|
31
|
+
* The marks lie on each other like a fanned stack, the first on top. They take turns: the one on
|
|
32
|
+
* top goes to the back, the others close up one after another. Under a pointer that rests on it,
|
|
33
|
+
* or with the keyboard's focus on it, the pill opens: the stack gathers to one plug, the trough
|
|
34
|
+
* shows the first line of what will be copied, and the key keeps only its symbol. A copy is
|
|
35
|
+
* confirmed in the key, by the tick drawing itself; there is no toast.
|
|
36
|
+
*
|
|
37
|
+
* Word the key as the thing, then the action ("Prompt kopieren"). Say beside the pill what the
|
|
38
|
+
* text is for; the marks alone are decoration to assistive tech.
|
|
39
|
+
*
|
|
40
|
+
* Motion. Opening waits a moment for the pointer to rest and closing for it to stay away, so a
|
|
41
|
+
* pass over the pill does not make it flicker. Everything that sets the pill's width (the room
|
|
42
|
+
* for the stack, the preview, the key) moves on one spring, `glide`, in both directions: on
|
|
43
|
+
* different curves their sum, the pill's outer edge, would shrink too far and come back. So the
|
|
44
|
+
* container never swings. What swings is inside it: let go, each mark comes back on `recoil`,
|
|
45
|
+
* one after another, past its place once into the gap before the key. The mark that goes to the
|
|
46
|
+
* back has the slider thumb's inertia: its speed stretches it along the way, and it comes to
|
|
47
|
+
* rest on `rebound`. Under reduced motion the marks stand still and nothing travels.
|
|
48
|
+
*
|
|
49
|
+
* The opening changes the pill's width, which is laid out and not a transform. That is the
|
|
50
|
+
* exception to the system's rule, and it holds because the pill only opens under a pointer or
|
|
51
|
+
* the keyboard: never on a phone, where a laid-out width stutters.
|
|
52
|
+
*/
|
|
53
|
+
function CopyPill({ text, preview, label, copied: copiedLabel, size = "md", turnEvery = 5, onCopied, className, style, children, ...props }) {
|
|
54
|
+
const id = useId();
|
|
55
|
+
const reduced = useReducedMotion();
|
|
56
|
+
const button = useRef(null);
|
|
57
|
+
const stack = useRef(null);
|
|
58
|
+
const words = useRef(null);
|
|
59
|
+
const marks = Children.toArray(children);
|
|
60
|
+
const count = marks.length;
|
|
61
|
+
const [copied, setCopied] = useState(false);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (!copied) return;
|
|
64
|
+
const timer = window.setTimeout(() => setCopied(false), CONFIRM_MS);
|
|
65
|
+
return () => window.clearTimeout(timer);
|
|
66
|
+
}, [copied]);
|
|
67
|
+
const copy = async () => {
|
|
68
|
+
try {
|
|
69
|
+
await navigator.clipboard.writeText(text);
|
|
70
|
+
setCopied(true);
|
|
71
|
+
onCopied?.();
|
|
72
|
+
} catch {}
|
|
73
|
+
};
|
|
74
|
+
const [open, setOpen] = useState(false);
|
|
75
|
+
const intent = useRef(0);
|
|
76
|
+
const want = (next, wait) => {
|
|
77
|
+
window.clearTimeout(intent.current);
|
|
78
|
+
intent.current = window.setTimeout(() => setOpen(next), wait);
|
|
79
|
+
};
|
|
80
|
+
useEffect(() => () => window.clearTimeout(intent.current), []);
|
|
81
|
+
useLayoutEffect(() => {
|
|
82
|
+
const element = words.current;
|
|
83
|
+
const target = button.current;
|
|
84
|
+
if (!element || !target) return;
|
|
85
|
+
const measure = () => target.style.setProperty("--words", `${element.offsetWidth + 1}px`);
|
|
86
|
+
measure();
|
|
87
|
+
const observer = new ResizeObserver(measure);
|
|
88
|
+
observer.observe(element);
|
|
89
|
+
return () => observer.disconnect();
|
|
90
|
+
}, [label]);
|
|
91
|
+
const turns = useRef(0);
|
|
92
|
+
const [turn, setTurn] = useState(0);
|
|
93
|
+
const [thrown, setThrown] = useState(null);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (reduced || turnEvery === false || count < 2) return;
|
|
96
|
+
let release = 0;
|
|
97
|
+
const timer = window.setInterval(() => {
|
|
98
|
+
const top = turns.current % count;
|
|
99
|
+
turns.current += 1;
|
|
100
|
+
setTurn(turns.current);
|
|
101
|
+
const row = stack.current;
|
|
102
|
+
const first = row?.firstElementChild;
|
|
103
|
+
if (!row || !(first instanceof HTMLElement)) return;
|
|
104
|
+
const length = first.offsetWidth;
|
|
105
|
+
const way = row.offsetWidth - length;
|
|
106
|
+
const { stretch } = trackMotion(restingMotion(0, 0), way, springs.recoil.visualDuration * 1e3, length);
|
|
107
|
+
setThrown({
|
|
108
|
+
index: top,
|
|
109
|
+
stretch
|
|
110
|
+
});
|
|
111
|
+
window.clearTimeout(release);
|
|
112
|
+
release = window.setTimeout(() => setThrown((was) => was ? {
|
|
113
|
+
...was,
|
|
114
|
+
stretch: 1
|
|
115
|
+
} : was), STRETCH_MS);
|
|
116
|
+
}, turnEvery * 1e3);
|
|
117
|
+
return () => {
|
|
118
|
+
window.clearInterval(timer);
|
|
119
|
+
window.clearTimeout(release);
|
|
120
|
+
};
|
|
121
|
+
}, [
|
|
122
|
+
reduced,
|
|
123
|
+
turnEvery,
|
|
124
|
+
count
|
|
125
|
+
]);
|
|
126
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
127
|
+
"data-slot": "copy-pill",
|
|
128
|
+
className: cn("inline-flex max-w-full", className),
|
|
129
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
130
|
+
ref: button,
|
|
131
|
+
type: "button",
|
|
132
|
+
"data-slot": "copy-pill-button",
|
|
133
|
+
"data-open": preview && open ? "" : void 0,
|
|
134
|
+
"aria-describedby": preview ? id : void 0,
|
|
135
|
+
onClick: () => void copy(),
|
|
136
|
+
onPointerEnter: (event) => event.pointerType !== "touch" && want(true, OPEN_MS),
|
|
137
|
+
onPointerLeave: () => want(false, CLOSE_MS),
|
|
138
|
+
onFocus: (event) => event.currentTarget.matches(":focus-visible") && want(true, 0),
|
|
139
|
+
onBlur: () => want(false, 0),
|
|
140
|
+
style: {
|
|
141
|
+
"--count": count,
|
|
142
|
+
...style
|
|
143
|
+
},
|
|
144
|
+
className: cn("group/pill relative inline-flex max-w-full cursor-pointer items-center rounded-full bg-trough p-1 text-left select-none", "after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:depth-trough", "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent", size === "lg" ? "[--pad:var(--control-pad-lg)] [--plug:var(--control-lg)]" : "[--pad:var(--control-pad-md)] [--plug:var(--control-md)]", "[--step:calc(var(--plug)*0.6)]", "sm:data-open:[--step:3px]"),
|
|
145
|
+
...props,
|
|
146
|
+
children: [
|
|
147
|
+
count > 0 ? /* @__PURE__ */ jsx("span", {
|
|
148
|
+
ref: stack,
|
|
149
|
+
"aria-hidden": true,
|
|
150
|
+
"data-slot": "copy-pill-marks",
|
|
151
|
+
className: "relative isolate mr-3 h-(--plug) w-[calc(var(--plug)+var(--step)*(var(--count)-1))] shrink-0 transition-[width] spring-glide motion-reduce:transition-none",
|
|
152
|
+
children: marks.map((mark, index) => {
|
|
153
|
+
const place = ((index - turn) % count + count) % count;
|
|
154
|
+
const stretch = thrown?.index === index ? thrown.stretch : 1;
|
|
155
|
+
return /* @__PURE__ */ jsx("span", {
|
|
156
|
+
"data-moving": stretch !== 1 ? "" : void 0,
|
|
157
|
+
className: "group/mark absolute top-0 left-0 size-(--plug) transition-[translate] spring-recoil motion-reduce:transition-none sm:group-data-open/pill:spring-glide",
|
|
158
|
+
style: {
|
|
159
|
+
translate: `calc(var(--step) * ${place}) 0`,
|
|
160
|
+
zIndex: count - place,
|
|
161
|
+
transitionDelay: stretch !== 1 ? "0ms" : `${Math.max(0, place - 1) * FOLLOW_MS}ms`,
|
|
162
|
+
"--s": stretch
|
|
163
|
+
},
|
|
164
|
+
children: mark
|
|
165
|
+
}, index);
|
|
166
|
+
})
|
|
167
|
+
}) : null,
|
|
168
|
+
preview ? /* @__PURE__ */ jsx("span", {
|
|
169
|
+
id,
|
|
170
|
+
"aria-hidden": true,
|
|
171
|
+
"data-slot": "copy-pill-preview",
|
|
172
|
+
className: "grid grid-cols-[0fr] transition-[grid-template-columns] spring-glide motion-reduce:transition-none max-sm:hidden sm:group-data-open/pill:grid-cols-[1fr]",
|
|
173
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
174
|
+
className: "min-w-0 overflow-hidden",
|
|
175
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
176
|
+
className: "block max-w-[26rem] truncate pr-3 font-mono text-sm whitespace-nowrap text-fg-body",
|
|
177
|
+
children: preview
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
}) : null,
|
|
181
|
+
/* @__PURE__ */ jsx("span", {
|
|
182
|
+
"data-slot": "copy-pill-key",
|
|
183
|
+
className: cn(buttonVariants({
|
|
184
|
+
variant: "primary",
|
|
185
|
+
size
|
|
186
|
+
}), "rounded-full px-0", "group-hover/pill:bg-key-hover group-hover/pill:depth-raised-hover", "group-active/pill:scale-(--motion-press-scale) group-active/pill:bg-key-pressed group-active/pill:depth-pressed group-active/pill:spring-snap"),
|
|
187
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
188
|
+
className: "flex items-center gap-2 px-(--pad) transition-[padding,gap] spring-glide motion-reduce:transition-none sm:group-data-open/pill:gap-0 sm:group-data-open/pill:px-[calc((var(--plug)-1rem)/2)]",
|
|
189
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
190
|
+
className: "relative flex size-4 shrink-0",
|
|
191
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
192
|
+
icon: Copy01Icon,
|
|
193
|
+
size: 16,
|
|
194
|
+
"data-off": copied ? "" : void 0,
|
|
195
|
+
className: "absolute inset-0 transition-[opacity,scale] spring-leave data-off:scale-75 data-off:opacity-0"
|
|
196
|
+
}), /* @__PURE__ */ jsx(TickGlyph, {
|
|
197
|
+
width: 22,
|
|
198
|
+
height: 22,
|
|
199
|
+
strokeWidth: 21 / 22,
|
|
200
|
+
"data-on": copied ? "" : void 0,
|
|
201
|
+
className: "absolute top-1/2 left-1/2 -translate-1/2 opacity-0 transition-[stroke-dashoffset,opacity] duration-200 ease-out [stroke-dasharray:1] [stroke-dashoffset:1] data-on:opacity-100 data-on:[stroke-dashoffset:0]"
|
|
202
|
+
})]
|
|
203
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
204
|
+
className: "w-[var(--words,auto)] overflow-hidden whitespace-nowrap transition-[width] spring-glide motion-reduce:transition-none sm:group-data-open/pill:w-0",
|
|
205
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
206
|
+
ref: words,
|
|
207
|
+
className: "inline-block",
|
|
208
|
+
children: label
|
|
209
|
+
})
|
|
210
|
+
})]
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
]
|
|
214
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
215
|
+
role: "status",
|
|
216
|
+
className: "sr-only",
|
|
217
|
+
children: copied ? copiedLabel : ""
|
|
218
|
+
})]
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* One mark in the pill: a plug seated in the trough, holding a logo or an icon at half its
|
|
223
|
+
* height. It is decoration; say in words beside the pill what the text is for.
|
|
224
|
+
*/
|
|
225
|
+
function CopyPillMark({ className, ...props }) {
|
|
226
|
+
return /* @__PURE__ */ jsx("span", {
|
|
227
|
+
"data-slot": "copy-pill-mark",
|
|
228
|
+
className: cn("flex size-full origin-right items-center justify-center rounded-full bg-raised depth-plug *:size-[calc(var(--plug)/2)]", "[scale:var(--s,1)_calc(1-(var(--s,1)-1)*0.3)] transition-[scale] spring-rebound group-data-moving/mark:spring-snap motion-reduce:transition-none", className),
|
|
229
|
+
...props
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
export { CopyPill, CopyPillMark };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The colours a Cta's block can take: a fitting's tones from depth.css, so its edge, light, shade
|
|
4
|
+
* and shadow follow the face on every ground.
|
|
5
|
+
* accent the ask: Indigo on Paper, the light violet on Ink, white on an Indigo page
|
|
6
|
+
* key the committed key: charcoal, a Paper face on Ink
|
|
7
|
+
* raised the neutral fitting: a white face (a deeper Indigo on an Indigo page)
|
|
8
|
+
*/
|
|
9
|
+
declare const tones: {
|
|
10
|
+
readonly accent: {
|
|
11
|
+
readonly knobs: "depth-tone-accent";
|
|
12
|
+
readonly fill: "bg-accent";
|
|
13
|
+
readonly text: "text-on-accent";
|
|
14
|
+
};
|
|
15
|
+
readonly key: {
|
|
16
|
+
readonly knobs: "depth-tone-key";
|
|
17
|
+
readonly fill: "bg-key";
|
|
18
|
+
readonly text: "text-on-key";
|
|
19
|
+
};
|
|
20
|
+
readonly raised: {
|
|
21
|
+
readonly knobs: "";
|
|
22
|
+
readonly fill: "bg-raised";
|
|
23
|
+
readonly text: "text-fg";
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type CtaTone = keyof typeof tones;
|
|
27
|
+
export type CtaProps = ComponentProps<"div"> & {
|
|
28
|
+
/** The block's colour: the ask (`accent`, the default), the dark key, or the white face. */
|
|
29
|
+
tone?: CtaTone;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The closing ask of a page, as a joint: a block in a button's recipe (by default the `ask`'s:
|
|
33
|
+
* Indigo on Paper, the light violet on Ink, white on an Indigo page; or `tone` `key` or
|
|
34
|
+
* `raised`) whose lower right corner is cut away, with
|
|
35
|
+
* the actions seated in the cut on the page's own ground. The cut's inner corner is concentric
|
|
36
|
+
* with the first button in it, so block and buttons read as two parts of one joint. Where the
|
|
37
|
+
* block is narrow (below 42rem, a phone) there is no cut: the buttons stand inside the block at
|
|
38
|
+
* its foot, one over the other at its full width.
|
|
39
|
+
*
|
|
40
|
+
* Put it last on a page, above the footer, once. Word the title as what to send („Erzähl mir von
|
|
41
|
+
* deinem Produkt."), the text as what happens next. One action, or two: the second is quieter.
|
|
42
|
+
*/
|
|
43
|
+
export declare function Cta({ tone, className, children, ...props }: CtaProps): import("react").JSX.Element;
|
|
44
|
+
/** The title: a sentence with a full stop that says what to send. */
|
|
45
|
+
export declare function CtaTitle({ className, ...props }: ComponentProps<"h2">): import("react").JSX.Element;
|
|
46
|
+
/** One or two sentences: that the first conversation costs nothing, that he answers. */
|
|
47
|
+
export declare function CtaText({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
|
|
48
|
+
/**
|
|
49
|
+
* The actions of a Cta, seated in its cut: the first at the outer edge, a second, quieter one
|
|
50
|
+
* beside it. Where the block is narrower than 42rem there is no cut: they stand inside the block
|
|
51
|
+
* at its foot, one over the other at its full width.
|
|
52
|
+
*/
|
|
53
|
+
export declare function CtaActions({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
54
|
+
export type CtaActionProps = ComponentProps<"a"> & {
|
|
55
|
+
/**
|
|
56
|
+
* The colour of the action. The first is `primary` (the dark key) by default, or `ask`
|
|
57
|
+
* (Indigo) where the page wants it; a second action is `secondary`, or `quiet` in a message.
|
|
58
|
+
*/
|
|
59
|
+
variant?: "primary" | "ask" | "secondary" | "quiet";
|
|
60
|
+
/**
|
|
61
|
+
* A symbol before the words that says where the action leads: the mark of the site it opens,
|
|
62
|
+
* a book for documentation. An `Icon` or a mark of your own, at 18px in a Cta.
|
|
63
|
+
*/
|
|
64
|
+
icon?: ReactNode;
|
|
65
|
+
/**
|
|
66
|
+
* The arrow after the words. The first action has one by default; `out` is for an action
|
|
67
|
+
* that leaves the site, `false` takes it away.
|
|
68
|
+
*/
|
|
69
|
+
arrow?: "right" | "out" | false;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* One action of a Cta or a CtaMessage: a link that looks like a button. The first carries the
|
|
73
|
+
* arrow, which grows from a chevron when it is pointed at. Word it as what happens
|
|
74
|
+
* („Nachricht schreiben"). Where two actions lead to different kinds of place, give each its
|
|
75
|
+
* `icon`, so they are told apart before they are read.
|
|
76
|
+
*/
|
|
77
|
+
export declare function CtaAction({ variant, icon, arrow, className, children, ...props }: CtaActionProps): import("react").JSX.Element;
|
|
78
|
+
export type CtaMessageProps = Omit<ComponentProps<"div">, "onSubmit"> & {
|
|
79
|
+
/**
|
|
80
|
+
* Sends the message: called with the form's data once every field is valid. Throw (or reject)
|
|
81
|
+
* when it was not sent; the sheet then says so and keeps what was typed.
|
|
82
|
+
*/
|
|
83
|
+
action: (data: FormData) => Promise<void> | void;
|
|
84
|
+
/** Whom the message goes to, at the foot of the sheet: „An Justin Lanfermann". */
|
|
85
|
+
recipient: ReactNode;
|
|
86
|
+
/** The recipient's initials, in the avatar beside the name. */
|
|
87
|
+
initials?: string;
|
|
88
|
+
/** The send key. */
|
|
89
|
+
sendLabel?: string;
|
|
90
|
+
/** A second, quieter way, beside the send key: a CtaAction with `variant="quiet"`. */
|
|
91
|
+
secondAction?: ReactNode;
|
|
92
|
+
/** What the sheet says once the message was sent: the title, then one sentence. */
|
|
93
|
+
sentTitle?: string;
|
|
94
|
+
sentText?: string;
|
|
95
|
+
/** What it says when the message was not sent. */
|
|
96
|
+
failedText?: string;
|
|
97
|
+
/** Shows the sent state from the start, for a page that already knows. */
|
|
98
|
+
sent?: boolean;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* The closing ask as a letter already begun: a resting sheet with the title, the first fields
|
|
102
|
+
* of a message (pass `Field`s as children, with their `name`s), whom it goes to, and the send
|
|
103
|
+
* key. Sent, the sheet says so in place, with a drawn tick, and keeps its height. Not sent, it
|
|
104
|
+
* says so above the key and keeps what was typed.
|
|
105
|
+
*
|
|
106
|
+
* For a contact page, or wherever the first step can happen on the page itself.
|
|
107
|
+
*/
|
|
108
|
+
export declare function CtaMessage({ action, recipient, initials, sendLabel, secondAction, sentTitle, sentText, failedText, sent: sentProp, className, children, ...props }: CtaMessageProps): import("react").JSX.Element;
|
|
109
|
+
export {};
|