@cloudgrid-io/ui 0.63.0 → 0.65.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/dist/blocks/add-tile.d.ts +16 -1
- package/dist/blocks/add-tile.d.ts.map +1 -1
- package/dist/blocks/add-tile.js +20 -3
- package/dist/blocks/add-tile.js.map +1 -1
- package/dist/blocks/avatar-picker.d.ts +19 -1
- package/dist/blocks/avatar-picker.d.ts.map +1 -1
- package/dist/blocks/avatar-picker.js +16 -3
- package/dist/blocks/avatar-picker.js.map +1 -1
- package/dist/blocks/bento-card-hint.d.ts +16 -0
- package/dist/blocks/bento-card-hint.d.ts.map +1 -0
- package/dist/blocks/bento-card-hint.js +23 -0
- package/dist/blocks/bento-card-hint.js.map +1 -0
- package/dist/blocks/bento-card.d.ts +59 -0
- package/dist/blocks/bento-card.d.ts.map +1 -0
- package/dist/blocks/bento-card.js +59 -0
- package/dist/blocks/bento-card.js.map +1 -0
- package/dist/blocks/coming-soon-hint.d.ts.map +1 -1
- package/dist/blocks/coming-soon-hint.js +110 -7
- package/dist/blocks/coming-soon-hint.js.map +1 -1
- package/dist/blocks/creation-search.d.ts +147 -0
- package/dist/blocks/creation-search.d.ts.map +1 -0
- package/dist/blocks/creation-search.js +239 -0
- package/dist/blocks/creation-search.js.map +1 -0
- package/dist/blocks/entity-card.d.ts +80 -2
- package/dist/blocks/entity-card.d.ts.map +1 -1
- package/dist/blocks/entity-card.js +162 -17
- package/dist/blocks/entity-card.js.map +1 -1
- package/dist/blocks/from-your-grid.d.ts +66 -0
- package/dist/blocks/from-your-grid.d.ts.map +1 -0
- package/dist/blocks/from-your-grid.js +63 -0
- package/dist/blocks/from-your-grid.js.map +1 -0
- package/dist/blocks/grid-profile.d.ts +17 -1
- package/dist/blocks/grid-profile.d.ts.map +1 -1
- package/dist/blocks/grid-profile.js +66 -5
- package/dist/blocks/grid-profile.js.map +1 -1
- package/dist/blocks/home-bento.d.ts +86 -0
- package/dist/blocks/home-bento.d.ts.map +1 -0
- package/dist/blocks/home-bento.js +87 -0
- package/dist/blocks/home-bento.js.map +1 -0
- package/dist/blocks/home-empty-illustrations.d.ts +37 -0
- package/dist/blocks/home-empty-illustrations.d.ts.map +1 -0
- package/dist/blocks/home-empty-illustrations.js +47 -0
- package/dist/blocks/home-empty-illustrations.js.map +1 -0
- package/dist/blocks/home-pinned.d.ts +120 -0
- package/dist/blocks/home-pinned.d.ts.map +1 -0
- package/dist/blocks/home-pinned.js +58 -0
- package/dist/blocks/home-pinned.js.map +1 -0
- package/dist/blocks/icons.d.ts +39 -0
- package/dist/blocks/icons.d.ts.map +1 -1
- package/dist/blocks/icons.js +39 -0
- package/dist/blocks/icons.js.map +1 -1
- package/dist/blocks/image-adjust-dialog.d.ts +171 -0
- package/dist/blocks/image-adjust-dialog.d.ts.map +1 -0
- package/dist/blocks/image-adjust-dialog.js +396 -0
- package/dist/blocks/image-adjust-dialog.js.map +1 -0
- package/dist/blocks/inspiration-cards.d.ts +241 -0
- package/dist/blocks/inspiration-cards.d.ts.map +1 -0
- package/dist/blocks/inspiration-cards.js +234 -0
- package/dist/blocks/inspiration-cards.js.map +1 -0
- package/dist/blocks/liquid-glass.d.ts +106 -0
- package/dist/blocks/liquid-glass.d.ts.map +1 -0
- package/dist/blocks/liquid-glass.js +283 -0
- package/dist/blocks/liquid-glass.js.map +1 -0
- package/dist/blocks/meter.d.ts +5 -2
- package/dist/blocks/meter.d.ts.map +1 -1
- package/dist/blocks/meter.js +4 -0
- package/dist/blocks/meter.js.map +1 -1
- package/dist/blocks/motion.d.ts +46 -0
- package/dist/blocks/motion.d.ts.map +1 -0
- package/dist/blocks/motion.js +144 -0
- package/dist/blocks/motion.js.map +1 -0
- package/dist/blocks/needs-attention.d.ts +78 -0
- package/dist/blocks/needs-attention.d.ts.map +1 -0
- package/dist/blocks/needs-attention.js +29 -0
- package/dist/blocks/needs-attention.js.map +1 -0
- package/dist/blocks/phosphor-marks.d.ts +16 -0
- package/dist/blocks/phosphor-marks.d.ts.map +1 -1
- package/dist/blocks/phosphor-marks.js +24 -0
- package/dist/blocks/phosphor-marks.js.map +1 -1
- package/dist/blocks/ranked-list.d.ts +7 -1
- package/dist/blocks/ranked-list.d.ts.map +1 -1
- package/dist/blocks/ranked-list.js +8 -6
- package/dist/blocks/ranked-list.js.map +1 -1
- package/dist/blocks/recent-plugs.d.ts +66 -0
- package/dist/blocks/recent-plugs.d.ts.map +1 -0
- package/dist/blocks/recent-plugs.js +20 -0
- package/dist/blocks/recent-plugs.js.map +1 -0
- package/dist/blocks/shared-grid-illustration.d.ts +55 -0
- package/dist/blocks/shared-grid-illustration.d.ts.map +1 -0
- package/dist/blocks/shared-grid-illustration.js +81 -0
- package/dist/blocks/shared-grid-illustration.js.map +1 -0
- package/dist/blocks/shelf-strip.d.ts +36 -0
- package/dist/blocks/shelf-strip.d.ts.map +1 -0
- package/dist/blocks/shelf-strip.js +32 -0
- package/dist/blocks/shelf-strip.js.map +1 -0
- package/dist/blocks/stat-tile.d.ts +17 -1
- package/dist/blocks/stat-tile.d.ts.map +1 -1
- package/dist/blocks/stat-tile.js +4 -1
- package/dist/blocks/stat-tile.js.map +1 -1
- package/dist/blocks/top-creations.d.ts +76 -0
- package/dist/blocks/top-creations.d.ts.map +1 -0
- package/dist/blocks/top-creations.js +54 -0
- package/dist/blocks/top-creations.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/fit.d.ts +39 -0
- package/dist/lib/fit.d.ts.map +1 -0
- package/dist/lib/fit.js +92 -0
- package/dist/lib/fit.js.map +1 -0
- package/dist/lib/motion.d.ts +126 -0
- package/dist/lib/motion.d.ts.map +1 -0
- package/dist/lib/motion.js +132 -0
- package/dist/lib/motion.js.map +1 -0
- package/dist/ui/dialog.d.ts +7 -1
- package/dist/ui/dialog.d.ts.map +1 -1
- package/dist/ui/dialog.js +2 -2
- package/dist/ui/dialog.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type LogoSet } from "./onboard-widget-content.js";
|
|
3
|
+
import { type ToolMarkName } from "./tool-marks.js";
|
|
4
|
+
/**
|
|
5
|
+
* INSPIRATION CARDS FOR HOME (ui#532), Asaf's design of 2026-11-20 for the new
|
|
6
|
+
* Console Home.
|
|
7
|
+
*
|
|
8
|
+
* <InspirationCards ideas={ideas} /> // the card on Home, pages of 3
|
|
9
|
+
* <InspirationCard {...idea} /> // one idea alone
|
|
10
|
+
*
|
|
11
|
+
* The card "Your grid starts with your creations.", its subtitle "Need
|
|
12
|
+
* inspiration? Pick an idea and make it yours.", a pager at the top right, and
|
|
13
|
+
* the ideas in pages of three. Every idea is the caller's: the picture, the
|
|
14
|
+
* category, the title, the description and the prompt. The library holds the
|
|
15
|
+
* words around them and the category tags, and no idea of its own.
|
|
16
|
+
*
|
|
17
|
+
* ## One card
|
|
18
|
+
*
|
|
19
|
+
* White, the hairline, radius 12, padding 12 (11 inside the 1px hairline, as
|
|
20
|
+
* the design's stroke sits inside its box), 10 between its parts:
|
|
21
|
+
*
|
|
22
|
+
* - the picture, 208 by 120 at the design's width (an aspect ratio of 26/15
|
|
23
|
+
* at any width), radius 8, `object-cover`, decorative (the title names it);
|
|
24
|
+
* - the category tag, the library `Badge`: 22 tall, 10 aside, a full pill, the
|
|
25
|
+
* word bold ink on the category's tint (`INSPIRATION_CATEGORIES`);
|
|
26
|
+
* - the title (an h3, bold 15) and, 4 under it, the description, given two
|
|
27
|
+
* lines of height so the buttons line up across a row;
|
|
28
|
+
* - "Copy prompt", the library's filled button (the Style Guide default, cyan
|
|
29
|
+
* with an ink label) with the copy icon after the word, 34 tall, 10 aside,
|
|
30
|
+
* radius 8. `CopyButton` copies the prompt, exactly, and for 2s the button
|
|
31
|
+
* says "Copied" with a check in the icon's place, or "Couldn't copy" when the
|
|
32
|
+
* clipboard refuses; the live region says it too. The three faces share one
|
|
33
|
+
* grid cell, so the button keeps its width whatever it says. The button is
|
|
34
|
+
* described by the card's title, so "Copy prompt" is not three identical
|
|
35
|
+
* buttons to a screen reader.
|
|
36
|
+
* - "Paste in" and one 20px agent mark, at the right of the button's row.
|
|
37
|
+
*
|
|
38
|
+
* ## The agent mark: the pill's own cycle and logos
|
|
39
|
+
*
|
|
40
|
+
* "Paste in" shows an agent that turns like the Onboard your agent pill
|
|
41
|
+
* (`OnboardWidget`), and it is the pill's cycle, not a copy of it:
|
|
42
|
+
* `createLogoCycle` over `ONBOARD_WIDGET_SLOTS`, bound by `bindLogoCycle`. The
|
|
43
|
+
* pill has three slots that each cross between two marks; this slot has one
|
|
44
|
+
* place, so it shows the mark the pill's last slot to cross turned to
|
|
45
|
+
* (`pasteInMark`). At rest that is slot 1's first mark, Claude Code; then,
|
|
46
|
+
* 2s in and every 2.6s after, Codex, Claude, Antigravity, Claude Code, Cursor,
|
|
47
|
+
* and the colour Gemini, and round again. Each turn is the pill's 600ms
|
|
48
|
+
* ease-in-out crossfade. Under reduced motion no timer starts and Claude Code
|
|
49
|
+
* stays; while the tab is hidden it pauses. The marks are `aria-hidden`;
|
|
50
|
+
* "Paste in" ends, for a screen reader only, "your AI coding tool".
|
|
51
|
+
*
|
|
52
|
+
* ## The card of cards
|
|
53
|
+
*
|
|
54
|
+
* White, radius 12, padding 24, 20 between the heading row and the cards. The
|
|
55
|
+
* heading (an h2, bold 20) over the subtitle (13), 4 apart; the pager at the
|
|
56
|
+
* right of the row: previous, "1 / 2", next, 8 apart, each arrow a 28 by 30
|
|
57
|
+
* ghost button with an 18px chevron. At either end its arrow is dimmed to 30%
|
|
58
|
+
* and does nothing, and stays focusable, as `Pager` does (`aria-disabled`).
|
|
59
|
+
* Left and Right arrows page too while focus is on either. With three ideas or
|
|
60
|
+
* fewer there is no pager.
|
|
61
|
+
*
|
|
62
|
+
* The cards sit 16 apart, three across when the card is 776 wide or more
|
|
63
|
+
* (the Home at 1440), two across below that and one under another on a phone
|
|
64
|
+
* (below), by container queries, so they follow the column, not the window,
|
|
65
|
+
* and the server's page is the one the script hydrates. The pager shares the
|
|
66
|
+
* heading's row, top right, whenever the two fit side by side (the title and
|
|
67
|
+
* the subtitle at their own width, 339, + 16 + the pager, 99: an inside of 453
|
|
68
|
+
* or more, so on the Home always from 1024 wide); under that, a phone, the
|
|
69
|
+
* row wraps and the pager goes under the heading, still at the right, so the
|
|
70
|
+
* heading is never squeezed (ui#546; it used to wrap under 640).
|
|
71
|
+
*
|
|
72
|
+
* Two across between the two-per-row minimum and the three-per-row one
|
|
73
|
+
* (ui#546, Asaf's option A: a narrow laptop, the Home from 1024 up to just
|
|
74
|
+
* under 1440 wide), where three do not fit their action rows on one line and
|
|
75
|
+
* one under another makes a very tall card; tighter there, 12 between the
|
|
76
|
+
* idea cards and 20 inside, so each idea card keeps Copy prompt and Paste in
|
|
77
|
+
* on one line (`INSPIRATION_COLUMNS`). The rows are CSS (`PAGE_COLUMNS`,
|
|
78
|
+
* `TWO_INSET`); the paging is the script's: it measures the card (`useBand`,
|
|
79
|
+
* read once in the commit that mounts it, then one ResizeObserver) and steps
|
|
80
|
+
* through the same ideas two at a time (nine ideas, "1 / 5"; the last page
|
|
81
|
+
* one card at the same width, not stretched). Before that a server's page of
|
|
82
|
+
* three shows its first two, the same two. A change of columns keeps the
|
|
83
|
+
* first idea in view: the card shows the page that holds it.
|
|
84
|
+
*
|
|
85
|
+
* The page is a list in a polite live region, a group named "Page 1 of 2", in
|
|
86
|
+
* a region named by the heading: the WAI carousel pattern, as `Pager` has it.
|
|
87
|
+
*
|
|
88
|
+
* ## Tokens
|
|
89
|
+
*
|
|
90
|
+
* Ground `--cg-surface-card`, edge `border-hairline` (#E6E8EA), ink `text-ink`. Tags:
|
|
91
|
+
* For work `lime-tint` (--cg-lime-200), Everyday `brand-100`
|
|
92
|
+
* (--cg-violet-100), Just for fun `cyan-tint` (--cg-cyan-200). "Paste in" is
|
|
93
|
+
* `text-faint-strong`. A light card on every surface (`data-theme="default"`),
|
|
94
|
+
* as the creation card is.
|
|
95
|
+
*
|
|
96
|
+
* Where the design and the library differ, the library's rung is used: the
|
|
97
|
+
* design's 11 and 12px words are the caption's 13 (the smallest reading rung;
|
|
98
|
+
* the source gate bans any other size), its 18 and 29 leadings are the body
|
|
99
|
+
* leading's, the For work tint is lime-200 (#EEF7DC; the design's #E7F4CD has
|
|
100
|
+
* no rung), and "Paste in" is the muted-strong grey rather than ink at 70%.
|
|
101
|
+
*
|
|
102
|
+
* ## Every page at once, when there is room (ui#546)
|
|
103
|
+
*
|
|
104
|
+
* `layout="fill"` is for the Home bento, where the card may be stretched to
|
|
105
|
+
* meet the other column. With room for the rest of the pages under the first,
|
|
106
|
+
* it shows every page at once, one row each, 16 apart, and the pager goes:
|
|
107
|
+
* everything is visible. With less room it is one row and the pager, as
|
|
108
|
+
* `layout="paged"` (the default) always is. The cards are the same cards in
|
|
109
|
+
* both: size, words, Copy prompt and Copied, and Paste in with its turning
|
|
110
|
+
* agent mark.
|
|
111
|
+
*
|
|
112
|
+
* The other pages wait under the first in a place that only ever has the room
|
|
113
|
+
* a stretch gives (a zero basis, no least height, the card's 20 gap taken
|
|
114
|
+
* back), so the card is exactly as tall in either layout and the room never
|
|
115
|
+
* depends on what shows in it. `useFits` measures it with one ResizeObserver.
|
|
116
|
+
* While they wait the rows are out of sight, out of the Tab order and silent
|
|
117
|
+
* to a screen reader; they fade in over 200ms, at once under reduced motion.
|
|
118
|
+
* Shown all at once the card is a plain region, not a carousel; when the
|
|
119
|
+
* room goes, it is back on page 1, the row that was at the top.
|
|
120
|
+
*
|
|
121
|
+
* ## Specimens
|
|
122
|
+
*
|
|
123
|
+
* `specimen` pins one face of Copy prompt for the gallery and for screenshots
|
|
124
|
+
* (hover, focus, copied, blocked) and holds the agent mark still. Product code
|
|
125
|
+
* leaves it out.
|
|
126
|
+
*/
|
|
127
|
+
export type InspirationCategory = "work" | "everyday" | "fun";
|
|
128
|
+
/** The tags: the word and the tint, per category. */
|
|
129
|
+
export declare const INSPIRATION_CATEGORIES: Readonly<Record<InspirationCategory, {
|
|
130
|
+
readonly label: string;
|
|
131
|
+
readonly className: string;
|
|
132
|
+
}>>;
|
|
133
|
+
/** The words around the ideas. */
|
|
134
|
+
export declare const INSPIRATION_COPY: Readonly<{
|
|
135
|
+
title: "Your grid starts with your creations.";
|
|
136
|
+
subtitle: "Need inspiration? Pick an idea and make it yours.";
|
|
137
|
+
copy: "Copy prompt";
|
|
138
|
+
copied: "Copied";
|
|
139
|
+
blocked: "Couldn't copy";
|
|
140
|
+
announceCopied: "Prompt copied. Paste it into your AI coding tool.";
|
|
141
|
+
pasteIn: "Paste in";
|
|
142
|
+
/** Read after "Paste in" by a screen reader only: the mark beside it is hidden. */
|
|
143
|
+
pasteInEnd: "your AI coding tool";
|
|
144
|
+
previous: "Previous page";
|
|
145
|
+
next: "Next page";
|
|
146
|
+
}>;
|
|
147
|
+
/** One idea, all of it the caller's. */
|
|
148
|
+
export type InspirationIdea = {
|
|
149
|
+
/** The picture's URL. Decorative: the title names the card. */
|
|
150
|
+
image: string;
|
|
151
|
+
category: InspirationCategory;
|
|
152
|
+
title: string;
|
|
153
|
+
/** One line, two at most. */
|
|
154
|
+
description: string;
|
|
155
|
+
/** What Copy prompt copies, exactly. */
|
|
156
|
+
prompt: string;
|
|
157
|
+
};
|
|
158
|
+
type Specimen = "hover" | "focus" | "copied" | "blocked";
|
|
159
|
+
/** The agent marks the Paste in slot shows: the pill's, slot by slot, A then B. */
|
|
160
|
+
export declare const PASTE_IN_MARKS: readonly ToolMarkName[];
|
|
161
|
+
/**
|
|
162
|
+
* The mark the Paste in slot shows after the pill's cycle moves from `prev` to
|
|
163
|
+
* `next`: the mark the first slot that crossed turned to. With nothing crossed,
|
|
164
|
+
* the rest mark, slot 1's A.
|
|
165
|
+
*/
|
|
166
|
+
export declare function pasteInMark(prev: readonly LogoSet[], next: readonly LogoSet[]): ToolMarkName;
|
|
167
|
+
declare function InspirationCard({ image, category, title, description, prompt, specimen, className, }: InspirationIdea & {
|
|
168
|
+
/** Pins one face of Copy prompt and holds the agent still, for the gallery. Leave it out in product code. */
|
|
169
|
+
specimen?: Specimen;
|
|
170
|
+
className?: string;
|
|
171
|
+
}): React.JSX.Element;
|
|
172
|
+
/**
|
|
173
|
+
* Where the card puts its ideas two to a row (ui#546, Asaf's option A): under
|
|
174
|
+
* 40rem inside three do not fit, and stacked one under another the card is
|
|
175
|
+
* very tall on a narrow laptop. Two to a row is tighter (Asaf, 2026-11-20):
|
|
176
|
+
* 12 between the idea cards and 20 inside the card, against 16 and 24.
|
|
177
|
+
*
|
|
178
|
+
* The widths are the card's OUTER width, so the band does not move when two
|
|
179
|
+
* to a row changes the padding. An idea card's action row is Copy prompt
|
|
180
|
+
* (126.4) + 4 + Paste in with its mark (72.5) = 202.9 here; CI's Linux
|
|
181
|
+
* Chromium sets it 3.1 wider, 206.0. An idea card adds 12 each side (11
|
|
182
|
+
* padding, the 1px edge).
|
|
183
|
+
*
|
|
184
|
+
* - `twoMin` 516: two idea cards each fit their row on one line on Linux too,
|
|
185
|
+
* with the same 2 to spare: 206.0 + 24 + 2 = 232; two, 12 apart, 20 inside
|
|
186
|
+
* each side = 516 (the bare Linux minimum is 512). The Home at 1024 is 519.
|
|
187
|
+
* Under it, a phone, one to a row as before.
|
|
188
|
+
* - `threeMin` 776: three idea cards each fit their row on one line on Linux
|
|
189
|
+
* too, with 2 to spare: 206.0 + 24 + 2 = 232, the design's own card; three,
|
|
190
|
+
* 16 apart, 24 inside each side = 776, the card on the Home at 1440. Under
|
|
191
|
+
* it a card is too narrow for three (at 40rem inside, the old rule, Paste
|
|
192
|
+
* in wrapped at 1366), so it shows two.
|
|
193
|
+
*/
|
|
194
|
+
export declare const INSPIRATION_COLUMNS: Readonly<{
|
|
195
|
+
twoMin: 516;
|
|
196
|
+
threeMin: 776;
|
|
197
|
+
padding: 24;
|
|
198
|
+
gap: 16;
|
|
199
|
+
twoPadding: 20;
|
|
200
|
+
twoGap: 12;
|
|
201
|
+
}>;
|
|
202
|
+
/** How many ideas a row holds at the card's outer width: 1, 2 from `twoMin`, 3 from `threeMin`. */
|
|
203
|
+
export declare function inspirationColumns(width: number): 1 | 2 | 3;
|
|
204
|
+
/**
|
|
205
|
+
* Ideas per page: `pageSize` (3) three to a row and on a phone; two thirds of
|
|
206
|
+
* it (2) two to a row; twice that (4) two to a row with room for a second row.
|
|
207
|
+
*/
|
|
208
|
+
export declare function inspirationPerPage({ pageSize, columns, secondRow }: {
|
|
209
|
+
pageSize: number;
|
|
210
|
+
columns: 1 | 2 | 3;
|
|
211
|
+
secondRow: boolean;
|
|
212
|
+
}): number;
|
|
213
|
+
/** The page, from 0, that holds idea `first` when pages hold `perPage`. */
|
|
214
|
+
export declare function inspirationPageOf(first: number, perPage: number): number;
|
|
215
|
+
declare function InspirationCards({ ideas, title, subtitle, pageSize, layout, page: pageProp, defaultPage, onPageChange, specimen, className, ...props }: Omit<React.ComponentProps<"section">, "children" | "title"> & {
|
|
216
|
+
/** Every idea, in order. Shown `pageSize` at a time. */
|
|
217
|
+
ideas: readonly InspirationIdea[];
|
|
218
|
+
/** The heading. Defaults to the design's words. */
|
|
219
|
+
title?: React.ReactNode;
|
|
220
|
+
/** The line under it. Defaults to the design's words. */
|
|
221
|
+
subtitle?: React.ReactNode;
|
|
222
|
+
/** Ideas per page. The design's is 3. */
|
|
223
|
+
pageSize?: number;
|
|
224
|
+
/**
|
|
225
|
+
* `paged`, the default: one page at a time behind the pager. `fill`: every
|
|
226
|
+
* page at once, one row each and no pager, when the card is given the room
|
|
227
|
+
* (the Home bento's stretch); paged otherwise (ui#546). Two across, `fill`
|
|
228
|
+
* with room for a second row shows pages of two rows of two, with the pager.
|
|
229
|
+
*/
|
|
230
|
+
layout?: "paged" | "fill";
|
|
231
|
+
/** The shown page, from 0, when the caller drives it. */
|
|
232
|
+
page?: number;
|
|
233
|
+
/** The first page shown, from 0, when the card keeps its own place. */
|
|
234
|
+
defaultPage?: number;
|
|
235
|
+
/** Called with the new page when previous or next is pressed. */
|
|
236
|
+
onPageChange?: (page: number) => void;
|
|
237
|
+
/** Passed to every card on the page: the gallery's pinned faces. */
|
|
238
|
+
specimen?: Specimen;
|
|
239
|
+
}): React.JSX.Element;
|
|
240
|
+
export { InspirationCard, InspirationCards };
|
|
241
|
+
//# sourceMappingURL=inspiration-cards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspiration-cards.d.ts","sourceRoot":"","sources":["../../src/blocks/inspiration-cards.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,OAAO,EAIL,KAAK,OAAO,EACb,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0HG;AAEH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAA;AAE7D,qDAAqD;AACrD,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAK7H,CAAA;AAEJ,kCAAkC;AAClC,eAAO,MAAM,gBAAgB;;;;;;;;IAQ3B,mFAAmF;;;;EAInF,CAAA;AAEF,wCAAwC;AACxC,MAAM,MAAM,eAAe,GAAG;IAC5B,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,6BAA6B;IAC7B,WAA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ACf,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG;IAC/D,wDAAwD;IACxD,KAAK,EAAE,SAAS,eAAe,EAAE,CAAA;IACjC,mDAAmD;IACnD,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACvB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACzB,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iEAAiE;IACjE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,oEAAoE;IACpE,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB,qBAkLA;AAED,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../lib/cloudgrid-cn.js";
|
|
5
|
+
import { useBand, useFits } from "../lib/fit.js";
|
|
6
|
+
import { Badge } from "../ui/badge.js";
|
|
7
|
+
import { Button } from "../ui/button.js";
|
|
8
|
+
import { CopyButton } from "./copy-button.js";
|
|
9
|
+
import { CheckIcon, ChevronLeftIcon, ChevronRightIcon, CopyIcon } from "./icons.js";
|
|
10
|
+
import { GeminiColorMark } from "./onboard-widget.js";
|
|
11
|
+
import { ONBOARD_WIDGET_SLOTS, bindLogoCycle, createLogoCycle, } from "./onboard-widget-content.js";
|
|
12
|
+
import { ToolLogo } from "./tool-logo.js";
|
|
13
|
+
import { TOOL_MARKS } from "./tool-marks.js";
|
|
14
|
+
/** The tags: the word and the tint, per category. */
|
|
15
|
+
export const INSPIRATION_CATEGORIES = Object.freeze({
|
|
16
|
+
work: Object.freeze({ label: "For work", className: "bg-lime-tint" }),
|
|
17
|
+
everyday: Object.freeze({ label: "Everyday", className: "bg-brand-100" }),
|
|
18
|
+
fun: Object.freeze({ label: "Just for fun", className: "bg-cyan-tint" }),
|
|
19
|
+
});
|
|
20
|
+
/** The words around the ideas. */
|
|
21
|
+
export const INSPIRATION_COPY = Object.freeze({
|
|
22
|
+
title: "Your grid starts with your creations.",
|
|
23
|
+
subtitle: "Need inspiration? Pick an idea and make it yours.",
|
|
24
|
+
copy: "Copy prompt",
|
|
25
|
+
copied: "Copied",
|
|
26
|
+
blocked: "Couldn't copy",
|
|
27
|
+
announceCopied: "Prompt copied. Paste it into your AI coding tool.",
|
|
28
|
+
pasteIn: "Paste in",
|
|
29
|
+
/** Read after "Paste in" by a screen reader only: the mark beside it is hidden. */
|
|
30
|
+
pasteInEnd: "your AI coding tool",
|
|
31
|
+
previous: "Previous page",
|
|
32
|
+
next: "Next page",
|
|
33
|
+
});
|
|
34
|
+
/** The agent marks the Paste in slot shows: the pill's, slot by slot, A then B. */
|
|
35
|
+
export const PASTE_IN_MARKS = Object.freeze(ONBOARD_WIDGET_SLOTS.flatMap((s) => [s.a, s.b]));
|
|
36
|
+
const REST_MARK = ONBOARD_WIDGET_SLOTS[0].a;
|
|
37
|
+
/**
|
|
38
|
+
* The mark the Paste in slot shows after the pill's cycle moves from `prev` to
|
|
39
|
+
* `next`: the mark the first slot that crossed turned to. With nothing crossed,
|
|
40
|
+
* the rest mark, slot 1's A.
|
|
41
|
+
*/
|
|
42
|
+
export function pasteInMark(prev, next) {
|
|
43
|
+
const i = next.findIndex((set, j) => set !== prev[j]);
|
|
44
|
+
if (i === -1)
|
|
45
|
+
return REST_MARK;
|
|
46
|
+
const slot = ONBOARD_WIDGET_SLOTS[i];
|
|
47
|
+
return next[i] === "a" ? slot.a : slot.b;
|
|
48
|
+
}
|
|
49
|
+
/** The mark shown now, turned by the pill's cycle unless held still. */
|
|
50
|
+
function useAgentMark(still) {
|
|
51
|
+
const [mark, setMark] = React.useState(REST_MARK);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (still || typeof window === "undefined" || typeof window.matchMedia !== "function")
|
|
54
|
+
return;
|
|
55
|
+
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
56
|
+
let prev = ONBOARD_WIDGET_SLOTS.map(() => "a");
|
|
57
|
+
const cycle = createLogoCycle({
|
|
58
|
+
onChange: (next) => {
|
|
59
|
+
// Reduced motion switched on mid-loop: `bindLogoCycle` stops the cycle
|
|
60
|
+
// and resets it to every slot's A, which is the rest mark, whichever
|
|
61
|
+
// slot that reset happened to move.
|
|
62
|
+
const reset = reducedMotion.matches && next.every((set) => set === "a");
|
|
63
|
+
setMark(reset ? REST_MARK : pasteInMark(prev, next));
|
|
64
|
+
prev = [...next];
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
return bindLogoCycle(cycle, { document, reducedMotion });
|
|
68
|
+
}, [still]);
|
|
69
|
+
return still ? REST_MARK : mark;
|
|
70
|
+
}
|
|
71
|
+
/** One 20px place, every mark stacked, the shown one at full opacity. */
|
|
72
|
+
function AgentMark({ still }) {
|
|
73
|
+
const shown = useAgentMark(still);
|
|
74
|
+
return (_jsx("span", { "data-slot": "inspiration-card-agent", "data-agent-shown": shown, "aria-hidden": "true", className: "relative size-5 shrink-0", children: PASTE_IN_MARKS.map((name) => {
|
|
75
|
+
const { Mark, hex } = TOOL_MARKS[name];
|
|
76
|
+
const colour = ONBOARD_WIDGET_SLOTS.some((s) => s.a === name && s.aColour);
|
|
77
|
+
return (_jsx("span", { "data-agent": name, className: cn(
|
|
78
|
+
// The pill's crossfade: CSS's own ease-in-out over 600ms.
|
|
79
|
+
"absolute inset-0 flex transition-opacity duration-600 ease-[ease-in-out] motion-reduce:transition-none", shown === name ? "opacity-100" : "opacity-0"), children: colour ? _jsx(ToolLogo, { name: name, mark: _jsx(GeminiColorMark, {}) }) : _jsx(ToolLogo, { name: name, mark: _jsx(Mark, {}), hex: hex }) }, name));
|
|
80
|
+
}) }));
|
|
81
|
+
}
|
|
82
|
+
/** The button's three faces in one cell: the shown one visible, the others keep the width. */
|
|
83
|
+
function Face({ face, shown, children }) {
|
|
84
|
+
const on = face === shown;
|
|
85
|
+
return (_jsx("span", { "data-face": face, "aria-hidden": on ? undefined : true, className: cn("col-start-1 row-start-1 inline-flex items-center justify-center gap-1.5", on ? "visible" : "invisible"), children: children }));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Paper on every surface. `data-theme="default"` puts every --cg- token back to
|
|
89
|
+
* its default inside, but the shadcn bridge's names are declared per surface and
|
|
90
|
+
* arrive already resolved, so the ground reads `--cg-surface-card` directly
|
|
91
|
+
* (not `bg-card`) and `--ring`, which `focus-line` draws in, is declared again
|
|
92
|
+
* here from the reset --cg-text-accent: Primary on this white, where the
|
|
93
|
+
* panel's white line or ink's lime would not show.
|
|
94
|
+
*/
|
|
95
|
+
const LIGHT_SCOPE = "[--ring:var(--cg-text-accent)]";
|
|
96
|
+
const COPY_BUTTON_CLASS =
|
|
97
|
+
// The design's compact filled button: 34 tall, 10 aside, 6 between the word
|
|
98
|
+
// and the 18px icon, radius 8. The family's type, at the caption's size.
|
|
99
|
+
"h-8.5 gap-1.5 rounded-xs px-2.5 text-caption font-bold";
|
|
100
|
+
const SPECIMEN_CLASS = {
|
|
101
|
+
hover: "bg-cyan-press",
|
|
102
|
+
// focus-line's look, drawn without the focus.
|
|
103
|
+
focus: "outline-1 outline-solid outline-offset-2 outline-(--ring)",
|
|
104
|
+
};
|
|
105
|
+
function InspirationCard({ image, category, title, description, prompt, specimen, className, }) {
|
|
106
|
+
const titleId = React.useId();
|
|
107
|
+
const tag = INSPIRATION_CATEGORIES[category];
|
|
108
|
+
const [state, setState] = React.useState("idle");
|
|
109
|
+
const face = specimen === "copied" ? "copied" : specimen === "blocked" ? "blocked" : state;
|
|
110
|
+
return (_jsxs("article", { "data-slot": "inspiration-card", "data-theme": "default", className: cn("flex h-full min-w-0 flex-col gap-2.5 rounded-md border border-hairline bg-(--cg-surface-card) p-2.75 font-ui text-ink", LIGHT_SCOPE, className), children: [_jsx("img", { "data-slot": "inspiration-card-picture", src: image, alt: "", loading: "lazy", decoding: "async", className: "block aspect-[26/15] w-full rounded-xs bg-page object-cover" }), _jsx(Badge, { "data-slot": "inspiration-card-tag", "data-category": category, className: cn("h-5.5 rounded-full px-2.5 py-0 text-caption font-bold leading-none text-ink", tag.className), children: tag.label }), _jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [_jsx("h3", { id: titleId, "data-slot": "inspiration-card-title", className: "m-0 text-body-sm font-bold text-ink", children: title }), _jsx("p", { "data-slot": "inspiration-card-description", className: "m-0 min-h-[2lh] text-caption text-ink", children: description })] }), _jsxs("div", { "data-slot": "inspiration-card-actions", className: "mt-auto flex flex-wrap items-center justify-between gap-x-1 gap-y-2", children: [_jsx(CopyButton, { value: prompt, copiedLabel: INSPIRATION_COPY.copied, blockedLabel: INSPIRATION_COPY.blocked, announceCopied: INSPIRATION_COPY.announceCopied, onStateChange: setState, render: _jsx(Button, { "data-slot": "inspiration-card-copy", "data-face": face, "aria-describedby": titleId, size: "sm", className: cn(COPY_BUTTON_CLASS, specimen && SPECIMEN_CLASS[specimen]) }), children: () => (_jsxs("span", { className: "inline-grid", children: [_jsxs(Face, { face: "idle", shown: face, children: [INSPIRATION_COPY.copy, _jsx("span", { "data-slot": "inspiration-card-copy-icon", className: "inline-flex size-4.5", children: _jsx(CopyIcon, { className: "size-full" }) })] }), _jsxs(Face, { face: "copied", shown: face, children: [INSPIRATION_COPY.copied, _jsx("span", { "data-slot": "inspiration-card-check", className: "inline-flex size-4.5", children: _jsx(CheckIcon, { className: "size-full" }) })] }), _jsx(Face, { face: "blocked", shown: face, children: INSPIRATION_COPY.blocked })] })) }), _jsxs("span", { "data-slot": "inspiration-card-paste-in", className: "ml-auto inline-flex shrink-0 items-center gap-1.25 text-caption text-faint-strong", children: [_jsxs("span", { children: [INSPIRATION_COPY.pasteIn, _jsxs("span", { className: "sr-only", children: [" ", INSPIRATION_COPY.pasteInEnd] })] }), _jsx(AgentMark, { still: specimen !== undefined })] })] })] }));
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The rows, in CSS, so the server's page is the hydrated one (nothing moves
|
|
114
|
+
* when the script arrives). The card's inside is its outer width less the
|
|
115
|
+
* 24 padding, so `INSPIRATION_COLUMNS`' outer 516 and 776 are 468 and 728
|
|
116
|
+
* here. One to a row, 16 apart, under 468; two, 12 apart, from 468, the
|
|
117
|
+
* third idea of a server's page of three hidden (the script then pages two
|
|
118
|
+
* at a time, so the same two are in view); three, 16 apart, from 728.
|
|
119
|
+
*/
|
|
120
|
+
const PAGE_COLUMNS = "m-0 grid list-none grid-cols-1 gap-4 p-0 @min-[468px]/inspiration-cards:grid-cols-2 @min-[468px]/inspiration-cards:gap-3 @min-[728px]/inspiration-cards:grid-cols-3 @min-[728px]/inspiration-cards:gap-4 @min-[468px]/inspiration-cards:@max-[728px]/inspiration-cards:[&>li:nth-child(n+3)]:hidden";
|
|
121
|
+
/**
|
|
122
|
+
* Two to a row is 20 inside, not 24, and a card cannot set its own padding
|
|
123
|
+
* from its own size: its rows come 4 out on every side instead.
|
|
124
|
+
*/
|
|
125
|
+
const TWO_INSET = "@min-[468px]/inspiration-cards:@max-[728px]/inspiration-cards:*:-mx-1 @min-[468px]/inspiration-cards:@max-[728px]/inspiration-cards:*:first:-mt-1 @min-[468px]/inspiration-cards:@max-[728px]/inspiration-cards:*:last:-mb-1";
|
|
126
|
+
/**
|
|
127
|
+
* Where the card puts its ideas two to a row (ui#546, Asaf's option A): under
|
|
128
|
+
* 40rem inside three do not fit, and stacked one under another the card is
|
|
129
|
+
* very tall on a narrow laptop. Two to a row is tighter (Asaf, 2026-11-20):
|
|
130
|
+
* 12 between the idea cards and 20 inside the card, against 16 and 24.
|
|
131
|
+
*
|
|
132
|
+
* The widths are the card's OUTER width, so the band does not move when two
|
|
133
|
+
* to a row changes the padding. An idea card's action row is Copy prompt
|
|
134
|
+
* (126.4) + 4 + Paste in with its mark (72.5) = 202.9 here; CI's Linux
|
|
135
|
+
* Chromium sets it 3.1 wider, 206.0. An idea card adds 12 each side (11
|
|
136
|
+
* padding, the 1px edge).
|
|
137
|
+
*
|
|
138
|
+
* - `twoMin` 516: two idea cards each fit their row on one line on Linux too,
|
|
139
|
+
* with the same 2 to spare: 206.0 + 24 + 2 = 232; two, 12 apart, 20 inside
|
|
140
|
+
* each side = 516 (the bare Linux minimum is 512). The Home at 1024 is 519.
|
|
141
|
+
* Under it, a phone, one to a row as before.
|
|
142
|
+
* - `threeMin` 776: three idea cards each fit their row on one line on Linux
|
|
143
|
+
* too, with 2 to spare: 206.0 + 24 + 2 = 232, the design's own card; three,
|
|
144
|
+
* 16 apart, 24 inside each side = 776, the card on the Home at 1440. Under
|
|
145
|
+
* it a card is too narrow for three (at 40rem inside, the old rule, Paste
|
|
146
|
+
* in wrapped at 1366), so it shows two.
|
|
147
|
+
*/
|
|
148
|
+
export const INSPIRATION_COLUMNS = Object.freeze({ twoMin: 516, threeMin: 776, padding: 24, gap: 16, twoPadding: 20, twoGap: 12 });
|
|
149
|
+
/** How many ideas a row holds at the card's outer width: 1, 2 from `twoMin`, 3 from `threeMin`. */
|
|
150
|
+
export function inspirationColumns(width) {
|
|
151
|
+
const c = INSPIRATION_COLUMNS;
|
|
152
|
+
if (width >= c.threeMin)
|
|
153
|
+
return 3;
|
|
154
|
+
if (width >= c.twoMin)
|
|
155
|
+
return 2;
|
|
156
|
+
return 1;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Ideas per page: `pageSize` (3) three to a row and on a phone; two thirds of
|
|
160
|
+
* it (2) two to a row; twice that (4) two to a row with room for a second row.
|
|
161
|
+
*/
|
|
162
|
+
export function inspirationPerPage({ pageSize, columns, secondRow }) {
|
|
163
|
+
const size = Math.max(1, Math.floor(pageSize));
|
|
164
|
+
if (columns !== 2)
|
|
165
|
+
return size;
|
|
166
|
+
const row = Math.max(1, Math.round((size * 2) / 3));
|
|
167
|
+
return secondRow ? row * 2 : row;
|
|
168
|
+
}
|
|
169
|
+
/** The page, from 0, that holds idea `first` when pages hold `perPage`. */
|
|
170
|
+
export function inspirationPageOf(first, perPage) {
|
|
171
|
+
return Math.floor(Math.max(0, first) / Math.max(1, perPage));
|
|
172
|
+
}
|
|
173
|
+
/** The pager's arrow: a 28 by 30 ghost button, an 18px chevron, dimmed at the end. */
|
|
174
|
+
const ARROW_CLASS = "h-7.5 w-7 text-ink hover:bg-(--cg-hover) hover:text-ink aria-disabled:cursor-default aria-disabled:opacity-30 aria-disabled:hover:bg-transparent [&_svg]:size-4.5";
|
|
175
|
+
function InspirationCards({ ideas, title = INSPIRATION_COPY.title, subtitle = INSPIRATION_COPY.subtitle, pageSize = 3, layout = "paged", page: pageProp, defaultPage = 0, onPageChange, specimen, className, ...props }) {
|
|
176
|
+
const headingId = React.useId();
|
|
177
|
+
const size = Math.max(1, Math.floor(pageSize));
|
|
178
|
+
// Two to a row only once measured: the server and the first render are the
|
|
179
|
+
// card as it always was, three to a row from 40rem and stacked under it.
|
|
180
|
+
const section = React.useRef(null);
|
|
181
|
+
const columns = useBand(section, inspirationColumns) ?? 3;
|
|
182
|
+
const two = columns === 2;
|
|
183
|
+
const rowSize = inspirationPerPage({ pageSize: size, columns, secondRow: false });
|
|
184
|
+
const rowPages = Math.max(1, Math.ceil(ideas.length / rowSize));
|
|
185
|
+
// Fill, three to a row: every page at once. Fill, two to a row: a second row
|
|
186
|
+
// of two on each page. Both only in the room a stretch gives.
|
|
187
|
+
const fillAll = layout === "fill" && !two && rowPages > 1;
|
|
188
|
+
const fillTwo = layout === "fill" && two && rowPages > 1;
|
|
189
|
+
const more = React.useRef(null);
|
|
190
|
+
const rows = React.useRef(null);
|
|
191
|
+
const viewport = React.useRef(null);
|
|
192
|
+
const allShown = useFits(more, rows, fillAll);
|
|
193
|
+
// The second row is as tall as the first, so the first row measures it,
|
|
194
|
+
// with the 12 above it: the room never depends on what is shown in it.
|
|
195
|
+
const secondRow = useFits(more, viewport, fillTwo, INSPIRATION_COLUMNS.twoGap);
|
|
196
|
+
const perPage = inspirationPerPage({ pageSize: size, columns, secondRow });
|
|
197
|
+
const pages = Math.max(1, Math.ceil(ideas.length / perPage));
|
|
198
|
+
// The card keeps its place as the first idea in view, so a change of
|
|
199
|
+
// columns or of rows shows the page that holds it.
|
|
200
|
+
const [anchor, setAnchor] = React.useState(Math.max(0, defaultPage) * size);
|
|
201
|
+
// Every page shown at once starts at page 1, so when the room goes the card
|
|
202
|
+
// is back on page 1, the row that was at the top (the card's own place only;
|
|
203
|
+
// a caller driving `page` keeps it).
|
|
204
|
+
const [wasAllShown, setWasAllShown] = React.useState(allShown);
|
|
205
|
+
if (wasAllShown !== allShown) {
|
|
206
|
+
setWasAllShown(allShown);
|
|
207
|
+
if (allShown)
|
|
208
|
+
setAnchor(0);
|
|
209
|
+
}
|
|
210
|
+
const page = Math.min(Math.max(0, pageProp ?? inspirationPageOf(anchor, perPage)), pages - 1);
|
|
211
|
+
const start = allShown ? 0 : page * perPage;
|
|
212
|
+
const shown = ideas.slice(start, start + rowSize);
|
|
213
|
+
const paged = pages > 1 && !allShown;
|
|
214
|
+
const go = (next) => {
|
|
215
|
+
if (next < 0 || next >= pages || next === page)
|
|
216
|
+
return;
|
|
217
|
+
if (pageProp === undefined)
|
|
218
|
+
setAnchor(next * perPage);
|
|
219
|
+
onPageChange?.(next);
|
|
220
|
+
};
|
|
221
|
+
const onKeyDown = (event) => {
|
|
222
|
+
if (event.key === "ArrowLeft") {
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
go(page - 1);
|
|
225
|
+
}
|
|
226
|
+
else if (event.key === "ArrowRight") {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
go(page + 1);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
return (_jsxs("section", { ref: section, "data-slot": "inspiration-cards", "data-theme": "default", ...(layout === "fill" ? { "data-layout": "fill", "data-all-shown": allShown } : {}), ...(two ? { "data-columns": "2" } : {}), ...(fillTwo ? { "data-second-row": secondRow } : {}), "aria-labelledby": headingId, ...(paged ? { "aria-roledescription": "carousel" } : {}), className: cn("@container/inspiration-cards flex w-full min-w-0 flex-col gap-5 rounded-md bg-(--cg-surface-card) p-6 font-ui text-ink", TWO_INSET, LIGHT_SCOPE, className), ...props, children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-3", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [_jsx("h2", { id: headingId, "data-slot": "inspiration-cards-title", className: "m-0 text-body-xl font-bold text-ink", children: title }), _jsx("p", { "data-slot": "inspiration-cards-subtitle", className: "m-0 text-caption text-ink", children: subtitle })] }), paged ? (_jsxs("div", { "data-slot": "inspiration-cards-pager", className: "ml-auto flex shrink-0 items-center gap-2", children: [_jsx(Button, { "data-slot": "inspiration-cards-previous", variant: "ghost", size: "icon-sm", "aria-label": INSPIRATION_COPY.previous, "aria-disabled": page === 0 || undefined, onClick: () => go(page - 1), onKeyDown: onKeyDown, className: ARROW_CLASS, children: _jsx(ChevronLeftIcon, {}) }), _jsxs("span", { "data-slot": "inspiration-cards-position", "aria-hidden": "true", className: "text-caption font-bold text-ink tabular-nums", children: [page + 1, " / ", pages] }), _jsx(Button, { "data-slot": "inspiration-cards-next", variant: "ghost", size: "icon-sm", "aria-label": INSPIRATION_COPY.next, "aria-disabled": page === pages - 1 || undefined, onClick: () => go(page + 1), onKeyDown: onKeyDown, className: ARROW_CLASS, children: _jsx(ChevronRightIcon, {}) })] })) : null] }), _jsx("div", { ref: viewport, "data-slot": "inspiration-cards-viewport", "aria-live": "polite", className: "min-w-0", children: _jsx("ul", { "data-slot": "inspiration-cards-page", ...(paged ? { "aria-roledescription": "slide", "aria-label": `Page ${page + 1} of ${pages}` } : {}), className: PAGE_COLUMNS, children: shown.map((idea, i) => (_jsx("li", { className: "min-w-0", children: _jsx(InspirationCard, { ...idea, specimen: specimen }) }, `${page}-${i}`))) }, page) }), fillAll || fillTwo ? (_jsx("div", { ref: more, "data-slot": "inspiration-cards-more", className: "-mt-5 min-h-0 flex-[1_1_0] overflow-hidden", children: fillTwo ? (_jsx("ul", { "data-slot": "inspiration-cards-second-row", className: cn(PAGE_COLUMNS, "pt-3 transition-[opacity,visibility] duration-200 ease-out motion-reduce:transition-none", secondRow ? "visible opacity-100" : "invisible opacity-0"), children: ideas.slice(page * perPage + rowSize, page * perPage + 2 * rowSize).map((idea, i) => (_jsx("li", { className: "min-w-0", children: _jsx(InspirationCard, { ...idea, specimen: specimen }) }, `${page}-${i}`))) })) : (_jsx("div", { ref: rows, "data-slot": "inspiration-cards-more-rows", className: cn("grid gap-4 pt-4 transition-[opacity,visibility] duration-200 ease-out motion-reduce:transition-none", allShown ? "visible opacity-100" : "invisible opacity-0"), children: Array.from({ length: pages - 1 }, (_, p) => (_jsx("ul", { "data-slot": "inspiration-cards-row", "data-page": p + 1, className: PAGE_COLUMNS, children: ideas.slice((p + 1) * size, (p + 2) * size).map((idea, i) => (_jsx("li", { className: "min-w-0", children: _jsx(InspirationCard, { ...idea, specimen: specimen }) }, i))) }, p + 1))) })) })) : null] }));
|
|
232
|
+
}
|
|
233
|
+
export { InspirationCard, InspirationCards };
|
|
234
|
+
//# sourceMappingURL=inspiration-cards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspiration-cards.js","sourceRoot":"","sources":["../../src/blocks/inspiration-cards.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,EAAE,EAAE,MAAM,oBA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MAAM,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAC3C,0BAEY,uBAAuB,eACtB,CAAC,GAAG,CAAC,EAChB,SAAS,EAAE,YAAY,YAEtB,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAC5D,aAAY,SAAS,EAAC,SAAS,YAC7B,KAAC,eAAe,OAAK,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAI,IAD1C,CAAC,CAEL,CACN,CAAC,IATG,CAAC,GAAG,CAAC,CAUP,CACN,CAAC,GACE,CACP,GACG,CACP,CAAC,CAAC,CAAC,IAAI,IACA,CACX,CAAA;AACH,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* LIQUID GLASS (ui#541), Asaf's design of 2026-11-20: the full-width band under
|
|
4
|
+
* the Console's floating header that appears once the page is scrolled.
|
|
5
|
+
*
|
|
6
|
+
* Content slides under the header's clusters (the grid menu, the centred pill,
|
|
7
|
+
* the bell and the person) as the page scrolls. The band sits UNDER those
|
|
8
|
+
* clusters and bends what passes behind it like a lens:
|
|
9
|
+
*
|
|
10
|
+
* - **Bend** (where `backdrop-filter: url()` is drawn, i.e. Chromium): an SVG
|
|
11
|
+
* displacement filter as the backdrop filter, pushing most near the top and
|
|
12
|
+
* bottom edges and not at all in the middle (scale 40), then a 6px blur and
|
|
13
|
+
* saturation 1.9, so colours glow through and the header's words read
|
|
14
|
+
* cleanly over busy content.
|
|
15
|
+
* - **Glass** (everywhere else, under reduced motion or reduced transparency,
|
|
16
|
+
* and when `fallback` is set): the clear glass, the scrim's blur token and the
|
|
17
|
+
* same saturation.
|
|
18
|
+
*
|
|
19
|
+
* Both: a sheen of the page colour, 55% at the top, held near half through the
|
|
20
|
+
* header's line and easing to 8% at the bottom, a 1px white highlight along
|
|
21
|
+
* the very top, and a mask that fades the bottom 28% into the page. No border
|
|
22
|
+
* line. Lower down the band it stays see-through and liquid.
|
|
23
|
+
*
|
|
24
|
+
* `active` fades it in (the slow duration, ease out) and out again; the fade is
|
|
25
|
+
* instant under reduced motion. Once faded out it is `visibility: hidden`, so a
|
|
26
|
+
* band at the top of the page costs nothing to draw. Pass `useScrolled()`:
|
|
27
|
+
*
|
|
28
|
+
* const scrolled = useScrolled() // the window
|
|
29
|
+
* const scrolled = useScrolled(4, mainRef) // a scrolling element
|
|
30
|
+
* <LiquidGlass active={scrolled} className="fixed inset-x-0 top-0 z-44" />
|
|
31
|
+
*
|
|
32
|
+
* The caller places it (position, inset, z-index under the clusters) and may
|
|
33
|
+
* change its height (64 by default). It is decorative: `aria-hidden`, no
|
|
34
|
+
* pointer events, never focused.
|
|
35
|
+
*
|
|
36
|
+
* The filter is defined once per page for each band height (one, in the
|
|
37
|
+
* Console: 64 on the desktop, 56 on the phone), in a hidden `<svg>` at the end
|
|
38
|
+
* of `<body>` that the first band to mount adds; the band measures itself to
|
|
39
|
+
* pick it. Until React runs, and in an engine that cannot draw it, the band is
|
|
40
|
+
* the clear glass.
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* The design's numbers, strengthened from the mockup's (scale 26, blur 2, a
|
|
44
|
+
* straight 55% to 8% white) so the header reads cleanly over busy content.
|
|
45
|
+
*/
|
|
46
|
+
declare const LIQUID_GLASS: {
|
|
47
|
+
/** The band's height, px: about the header's. */
|
|
48
|
+
readonly height: 64;
|
|
49
|
+
/** The displacement's scale, px, at the edges. */
|
|
50
|
+
readonly scale: 40;
|
|
51
|
+
/** The blur after the bending, px. */
|
|
52
|
+
readonly blur: 6;
|
|
53
|
+
/** The saturation, both modes. */
|
|
54
|
+
readonly saturate: 1.9;
|
|
55
|
+
/** The page-colour sheen, top to bottom: [alpha %, at %]. */
|
|
56
|
+
readonly sheen: readonly [readonly [55, 0], readonly [48, 50], readonly [30, 75], readonly [8, 100]];
|
|
57
|
+
/** The 1px highlight's alpha along the very top, %. */
|
|
58
|
+
readonly highlight: 80;
|
|
59
|
+
/** The share of the band at the bottom that fades into the page, %. */
|
|
60
|
+
readonly fade: 28;
|
|
61
|
+
/** `useScrolled`'s default: "a few pixels". */
|
|
62
|
+
readonly threshold: 4;
|
|
63
|
+
};
|
|
64
|
+
/** The filter for a band `height` px tall: one per height on a page, shared by every band of it. */
|
|
65
|
+
declare const liquidGlassFilterId: (height?: number) => string;
|
|
66
|
+
type LiquidGlassMode = "bend" | "glass";
|
|
67
|
+
/**
|
|
68
|
+
* Which glass an environment gets. Bend only where the bending is drawn and
|
|
69
|
+
* nothing asks for less.
|
|
70
|
+
*/
|
|
71
|
+
declare function liquidGlassMode(env: {
|
|
72
|
+
bendSupported: boolean;
|
|
73
|
+
reducedMotion: boolean;
|
|
74
|
+
reducedTransparency: boolean;
|
|
75
|
+
fallback?: boolean;
|
|
76
|
+
}): LiquidGlassMode;
|
|
77
|
+
/**
|
|
78
|
+
* The `<filter>` the bend mode's backdrop filter points at, for a band
|
|
79
|
+
* `height` px tall. sRGB, so the map's 0.5 means "no shift" (in the default
|
|
80
|
+
* linearRGB it would shift everything).
|
|
81
|
+
*
|
|
82
|
+
* The map is drawn 1px wide and exactly the band's height, in pixels, then
|
|
83
|
+
* tiled across the band, so one filter serves a band of any width. Pixels, not
|
|
84
|
+
* percentages: Chromium draws a percentage-sized `feImage` in a backdrop
|
|
85
|
+
* filter as nothing, which reads as a map of zeros (a flat 20px shift); and
|
|
86
|
+
* bounding-box units scale the shift by the band's width.
|
|
87
|
+
*/
|
|
88
|
+
declare function liquidGlassFilterMarkup(height?: number): string;
|
|
89
|
+
/** Scrolled means past the threshold, not at it; an overscroll bounce above the top is not. */
|
|
90
|
+
declare function scrolledPast(offset: number, threshold: number): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* True once `target` (or the window) has scrolled past `threshold` px, false
|
|
93
|
+
* again at the top. Passive listener; re-renders only when the answer changes.
|
|
94
|
+
* False on the server and until the first effect.
|
|
95
|
+
*/
|
|
96
|
+
declare function useScrolled(threshold?: number, target?: React.RefObject<HTMLElement | null>): boolean;
|
|
97
|
+
type LiquidGlassProps = Omit<React.ComponentProps<"div">, "children" | "ref"> & {
|
|
98
|
+
/** Shown (faded in) while true. Pass `useScrolled()`. */
|
|
99
|
+
active?: boolean;
|
|
100
|
+
/** Forces the clear glass, as an engine without the bending draws it. */
|
|
101
|
+
fallback?: boolean;
|
|
102
|
+
};
|
|
103
|
+
declare function LiquidGlass({ active, fallback, className, style, ...props }: LiquidGlassProps): React.JSX.Element;
|
|
104
|
+
export { LIQUID_GLASS, LiquidGlass, liquidGlassFilterId, liquidGlassFilterMarkup, liquidGlassMode, scrolledPast, useScrolled, };
|
|
105
|
+
export type { LiquidGlassMode, LiquidGlassProps };
|
|
106
|
+
//# sourceMappingURL=liquid-glass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liquid-glass.d.ts","sourceRoot":"","sources":["../../src/blocks/liquid-glass.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH;;;GAGG;AACH,QAAA,MAAM,YAAY;IAChB,iDAAiD;;IAEjD,kDAAkD;;IAElD,sCAAsC;;IAEtC,kCAAkC;;IAElC,6DAA6D;;IAO7D,uDAAuD;;IAEvD,uEAAuE;;IAEvE,+CAA+C;;CAEvC,CAAA;AAEV,oGAAoG;AACpG,QAAA,MAAM,mBAAmB,GAAI,SAAQ,MAA4B,WAAgC,CAAA;AAEjG,KAAK,eAAe,GAAG,MAAM,GAAG,OAAO,CAAA;AAEvC;;;GA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