@dataimago/ui 0.1.0-alpha.3 → 0.1.0-alpha.34

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/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { LogoId, LogoVariant, AnimationId, NavbarLogoId } from '@dataimago/brand';
3
4
 
4
5
  type ButtonVariant = 'primary' | 'secondary' | 'ghost';
5
6
  type ButtonSize = 'sm' | 'md' | 'lg';
@@ -49,8 +50,8 @@ declare function LogoMonogram({ size, title, ...rest }: LogoMonogramProps): reac
49
50
 
50
51
  /**
51
52
  * <LogoMonogramBg /> — the dataimago 'a + i' monogram with a rounded accent
52
- * backplate. White letters on the historical brand-red role
53
- * (var(--color-interactive-accent), the emancipation copper-red).
53
+ * backplate. White letters on the brand-accent role
54
+ * (var(--color-interactive-accent), iteration-2 sky-blue).
54
55
  *
55
56
  * Use this variant on neutral surfaces where the no-background monogram
56
57
  * would lack presence — favicons, app icons, social-media avatars, or any
@@ -60,10 +61,16 @@ declare function LogoMonogram({ size, title, ...rest }: LogoMonogramProps): reac
60
61
  * FOUNDATIONS/background/04_dataimago_Content/Design_Assets/logos/
61
62
  * ai_monogram_supreme_bg_1_PATH.svg
62
63
  *
63
- * Theming: the background uses var(--color-interactive-accent), so the mark
64
- * picks up the canonical accent color in both light and dark modes. The
65
- * letter fill is hard-set to white because the accent backplate is dark
66
- * enough that white letters always have AAA contrast (verified in iteration-1).
64
+ * Theming: the background uses var(--color-interactive-accent), which
65
+ * resolves via theme-colors.json's mode-aware role mapping — accent-500
66
+ * (#1f618d) on light surfaces, accent-300 (#3498DB) on dark. The letter
67
+ * fill is hard-set to white; both accent stops have AA-or-better contrast
68
+ * with white letters (light-mode 6.66:1 AA, dark-mode 3.15:1 AA-large for
69
+ * the dot-and-stem heading-size letters used in the monogram). The
70
+ * literal-fallback in this component is light-mode (#1f618d, sky-blue
71
+ * iteration-2) for rare non-CSS-aware contexts. Iteration-1's copper-red
72
+ * fallback (#b54a27) was retired in iteration-2-B.2; see
73
+ * wiki/decisions/iteration-2-blue-accent.md for the rationale.
67
74
  *
68
75
  * Usage:
69
76
  * <LogoMonogramBg size={64} aria-label="dataimago" />
@@ -78,8 +85,8 @@ declare function LogoMonogramBg({ size, title, ...rest }: LogoMonogramBgProps):
78
85
 
79
86
  /**
80
87
  * <LogoWordmark /> — the full "dataimago" wordmark with the 'ai' overlap.
81
- * White letters on a rounded accent backplate (the historical brand-red role,
82
- * var(--color-interactive-accent)).
88
+ * White letters on a rounded accent backplate, themed via
89
+ * var(--color-interactive-accent).
83
90
  *
84
91
  * Use this variant for primary brand surfaces: site headers, document
85
92
  * letterheads, large-format presentations, business materials. For compact
@@ -95,6 +102,15 @@ declare function LogoMonogramBg({ size, title, ...rest }: LogoMonogramBgProps):
95
102
  * FOUNDATIONS/background/04_dataimago_Content/Design_Assets/logos/
96
103
  * dataimago_supreme_1_PATH.svg
97
104
  *
105
+ * Theming: the backplate uses var(--color-interactive-accent), which resolves
106
+ * via theme-colors.json's mode-aware role mapping — accent-500 (#1f618d) on
107
+ * light surfaces, accent-300 (#3498DB) on dark. The literal-fallback in this
108
+ * component is light-mode (#1f618d, sky-blue iteration-2) for the rare cases
109
+ * where the SVG is consumed without CSS-variable resolution (printed PDFs from
110
+ * raw SVG, third-party platforms that strip CSS). Iteration-1's copper-red
111
+ * fallback (#b54a27) was retired in iteration-2-B.2; see
112
+ * wiki/decisions/iteration-2-blue-accent.md for the rationale.
113
+ *
98
114
  * Usage:
99
115
  * <LogoWordmark width={240} aria-label="dataimago" />
100
116
  *
@@ -109,4 +125,222 @@ interface LogoWordmarkProps extends React.SVGAttributes<SVGSVGElement> {
109
125
  }
110
126
  declare function LogoWordmark({ width, title, ...rest }: LogoWordmarkProps): react_jsx_runtime.JSX.Element;
111
127
 
112
- export { Button, type ButtonProps, type ButtonSize, type ButtonVariant, LogoMonogram, LogoMonogramBg, type LogoMonogramBgProps, type LogoMonogramProps, LogoWordmark, type LogoWordmarkProps };
128
+ interface LogoProps extends React.HTMLAttributes<HTMLSpanElement> {
129
+ /** Mark id, e.g. `dissertation_ai_OVERLAP`. */
130
+ name: LogoId;
131
+ /** PATH (default), CUTOUT, BG, or LETTERS. See @dataimago/brand. */
132
+ variant?: LogoVariant;
133
+ /**
134
+ * Render width (px number or any CSS length). Height scales proportionally
135
+ * via the SVG viewBox. Omit to use the mark's intrinsic size.
136
+ */
137
+ width?: number | string;
138
+ }
139
+ /**
140
+ * Manifest-driven brand mark from `@dataimago/brand`. Inlines the SVG string so
141
+ * `currentColor` (PATH/LETTERS), the `--color-interactive-accent` badge fill
142
+ * (CUTOUT/BG), and the per-letter interaction classes (`.glyph`, `.logo-*`) all
143
+ * work — an `<img src>` can't receive those interior styles.
144
+ *
145
+ * Color flows from CSS: set `color` (PATH/LETTERS) on this element or an
146
+ * ancestor. Size via `width` (or CSS on the wrapper).
147
+ */
148
+ declare function Logo({ name, variant, width, style, ...rest }: LogoProps): react_jsx_runtime.JSX.Element | null;
149
+
150
+ /** A link the lockup renders; pass one to route through a framework link (e.g. next/link). */
151
+ interface CopulaLinkProps {
152
+ href: string;
153
+ 'aria-label': string;
154
+ className?: string;
155
+ style?: React.CSSProperties;
156
+ children: React.ReactNode;
157
+ }
158
+ interface CopulaLockupProps extends React.HTMLAttributes<HTMLSpanElement> {
159
+ /** The property's wordmark id, e.g. `dissertation_ai`. Its PATH variant is drawn. */
160
+ property: LogoId;
161
+ /** Accessible name of the property link, e.g. `dissertation-ai`. */
162
+ propertyLabel: string;
163
+ /** Where the property mark links. Defaults to `/`. */
164
+ propertyHref?: string;
165
+ /**
166
+ * `shown` (default): "<property> is dataimago". `hidden`: the property mark
167
+ * alone, with no badge, no dataimago wordmark and no link to dataimago, for
168
+ * apps that keep dataimago out of view while it is in stealth.
169
+ */
170
+ dataimago?: 'shown' | 'hidden';
171
+ /** Where the dataimago wordmark links. Defaults to https://dataimago.ai. */
172
+ brandHref?: string;
173
+ /** Wordmark height in px. Defaults to 32; the badge and spacing scale with it. */
174
+ height?: number;
175
+ /** Class for each link (colour and hover); both links share one treatment. */
176
+ linkClassName?: string;
177
+ /** Render the links with a framework component. Defaults to a plain `<a>`. */
178
+ renderLink?: (props: CopulaLinkProps) => React.ReactNode;
179
+ }
180
+ /**
181
+ * The copula lockup, "dissertation-ai **is** dataimago": the property wordmark,
182
+ * the `is_badge` disc and the dataimago wordmark, each wordmark its own link
183
+ * (wiki/connections/is-copula-coupling.md). The badge is a mark, not a link: at
184
+ * 16px it is below the 24px pointer-target floor (WCAG 2.5.8), so it is read as
185
+ * "is" and the philosophy page stays reachable from the nav.
186
+ *
187
+ * Spacing is ink-symmetric about the badge centre, computed from each mark's
188
+ * `ink` box in the @dataimago/brand manifest, so any property mark lines up
189
+ * without hand-tuned margins. Geometry is inline style (no Tailwind), so a
190
+ * consumer on plain CSS can use it too. Colour is `currentColor`: set `color`.
191
+ */
192
+ declare function CopulaLockup({ property, propertyLabel, propertyHref, dataimago, brandHref, height, linkClassName, renderLink, style, ...rest }: CopulaLockupProps): react_jsx_runtime.JSX.Element | null;
193
+
194
+ interface BrandAnimationProps extends React.HTMLAttributes<HTMLSpanElement> {
195
+ /** Animation id, e.g. `dissertation-ai`. See @dataimago/brand animations.json. */
196
+ name: AnimationId;
197
+ /**
198
+ * Render width (px number or any CSS length). Height scales via the SVG
199
+ * viewBox. Omit to use the animation's intrinsic size.
200
+ */
201
+ width?: number | string;
202
+ }
203
+ /**
204
+ * Decorative brand animation from `@dataimago/brand` (the animation-foundry).
205
+ * Inlines the pure-SMIL SVG string so its interior `<style>` works — an
206
+ * `<img src>` can't receive those styles (same rationale as `<Logo>`).
207
+ *
208
+ * Motion-dignity: decorative brand animation is a distinct category from the
209
+ * 300ms UI-transition ceiling, but it is contractually gated on
210
+ * `prefers-reduced-motion`. When the user prefers reduced motion this renders
211
+ * the static brand mark the animation settles to (its `poster`) via `<Logo>`,
212
+ * so no consumer can ship the motion without the fallback.
213
+ */
214
+ declare function BrandAnimation({ name, width, style, ...rest }: BrandAnimationProps): react_jsx_runtime.JSX.Element | null;
215
+
216
+ interface NavbarLogoProps extends React.HTMLAttributes<HTMLSpanElement> {
217
+ /** Navbar mark id, e.g. `dissertation-ai`. See @dataimago/brand navbar.json. */
218
+ name: NavbarLogoId;
219
+ /**
220
+ * Render width (px number or any CSS length). Height scales via the SVG
221
+ * viewBox. Omit to use the mark's intrinsic size.
222
+ */
223
+ width?: number | string;
224
+ }
225
+ /**
226
+ * Animated brand mark for an app navbar, from `@dataimago/brand` (the
227
+ * animation-foundry's navbar set). Inlines the self-contained CSS-animated SVG
228
+ * so its interior `<style>` works — an `<img src>` can't receive those styles.
229
+ *
230
+ * Behaviour by mark kind (from the navbar manifest):
231
+ * - `assemble` (L2: dissertation-ai, rpkg-ai, SGPc-ai): the trailing `a`/`i`
232
+ * start apart and the `i` slides onto the `a`. Plays once on mount; replays
233
+ * on pointer-enter via a remount (`replayKey`).
234
+ * - `shimmer` (L1: dataimago-ai): the monogram is always superimposed; an
235
+ * accent shimmer sweeps on `:hover` from the SVG's own CSS (no JS trigger).
236
+ * - `dream` (promoted dream marks, `tools/dream-foundry/drop.mjs promote`):
237
+ * a self-contained CSS hover gesture like liftwash; the poster is the mark's
238
+ * own static form (`dream_<slug>` / `DREAM`). Ink is `currentColor`.
239
+ *
240
+ * Motion-dignity: the embedded CSS animation is <= 300ms and gated on
241
+ * `@media (prefers-reduced-motion: no-preference)`. When the user prefers
242
+ * reduced motion this renders the static settled mark (the manifest `poster`,
243
+ * the superimposed monogram) via `<Logo>` — so no consumer can ship the motion
244
+ * without the fallback.
245
+ */
246
+ declare function NavbarLogo({ name, width, style, ...rest }: NavbarLogoProps): react_jsx_runtime.JSX.Element | null;
247
+
248
+ /**
249
+ * Light/dark theme preference for dataimago apps.
250
+ *
251
+ * The house tokens (`@dataimago/tokens`) follow the operating system through
252
+ * `prefers-color-scheme` and yield to an explicit `data-bs-theme` on the root:
253
+ * `light` or `dark` forces that theme, no attribute means "follow the system".
254
+ * This module owns that attribute: it reads and stores the reader's choice,
255
+ * applies it, and reports the theme actually in effect (for canvas and WebGL
256
+ * surfaces that cannot read CSS variables).
257
+ *
258
+ * The choice is a per-browser convenience in localStorage. Every read and write
259
+ * is guarded: in a private window or with storage blocked the page simply
260
+ * follows the system.
261
+ */
262
+ type ThemePreference = 'system' | 'light' | 'dark';
263
+ type ResolvedTheme = 'light' | 'dark';
264
+ declare const THEME_STORAGE_KEY = "dataimago-theme";
265
+ declare const THEME_ATTRIBUTE = "data-bs-theme";
266
+ /**
267
+ * Inline this in `<head>` before any stylesheet paints, so a stored choice is
268
+ * on the root before first paint (no flash of the other theme). The server
269
+ * markup cannot know the choice, so the consumer also puts
270
+ * `suppressHydrationWarning` on `<html>`. From a React server layout, render
271
+ * `<ThemeScript />` instead: this package is a client bundle, so a server
272
+ * component cannot import the string itself.
273
+ *
274
+ * ```tsx
275
+ * <html lang="en" suppressHydrationWarning>
276
+ * <head><ThemeScript /></head>
277
+ * ```
278
+ */
279
+ declare const themeInitScript: string;
280
+ /** The stored choice, or `'system'` when there is none (or storage is unavailable). */
281
+ declare function readThemePreference(): ThemePreference;
282
+ /** Store, apply and announce a choice. `'system'` clears the stored choice. */
283
+ declare function setThemePreference(preference: ThemePreference): void;
284
+ /** The theme in effect: the root attribute when set, otherwise the system's. */
285
+ declare function resolveTheme(): ResolvedTheme;
286
+ /**
287
+ * The reader's choice and a setter. Server render and hydration see
288
+ * `'system'`; the stored choice arrives right after.
289
+ */
290
+ declare function useThemePreference(): [ThemePreference, (p: ThemePreference) => void];
291
+ /**
292
+ * The theme in effect, for surfaces that cannot read CSS variables (canvas,
293
+ * WebGL maps). Follows the toggle and, under "system", the operating system.
294
+ * Server render and hydration see `'light'`.
295
+ */
296
+ declare function useResolvedTheme(): ResolvedTheme;
297
+
298
+ interface ThemeToggleLabels {
299
+ /** What the control sets, read before the theme in effect ("Theme: Light"). */
300
+ name: string;
301
+ /** Added when the theme follows the operating system ("Theme: Light (System)"). */
302
+ system: string;
303
+ light: string;
304
+ dark: string;
305
+ }
306
+ interface ThemeToggleProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'children' | 'type'> {
307
+ /** Accessible and tooltip text; pass the property's own wording. */
308
+ labels?: Partial<ThemeToggleLabels>;
309
+ }
310
+ /**
311
+ * The choice one click makes: the other theme, stored as "system" when that is
312
+ * the operating system's own, so the page goes back to following it.
313
+ */
314
+ declare function nextThemePreference(shown: ResolvedTheme, system: ResolvedTheme): ThemePreference;
315
+ /**
316
+ * Light/dark toggle for an app navbar: one button, and one click always flips
317
+ * the theme on screen. The page follows the operating system until the first
318
+ * click; a click that lands on the system's own theme goes back to following
319
+ * it (no stored choice), and the other theme is stored and set as
320
+ * `data-bs-theme` on the root, which the house tokens obey. The icon shows the
321
+ * theme in effect: a sun in light, a moon in dark.
322
+ *
323
+ * A 48px target (the dataimago touch floor). The icon is `currentColor`.
324
+ * Inline styles would beat a consumer's `:hover` rule, so the two colours a
325
+ * navbar restyles read custom properties instead: set `--di-theme-toggle-fg`
326
+ * and `--di-theme-toggle-bg` on `.di-ui-theme-toggle` (and its `:hover`).
327
+ * Pair it with `<ThemeScript />` in `<head>` so a stored choice applies before
328
+ * first paint.
329
+ */
330
+ declare function ThemeToggle({ labels, className, style, ...rest }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
331
+
332
+ interface ThemeScriptProps {
333
+ /** Content-Security-Policy nonce, when the app sets one. */
334
+ nonce?: string;
335
+ }
336
+ /**
337
+ * Renders `themeInitScript` as an inline `<script>`, so a stored choice is on
338
+ * the root before first paint. Use this from a server layout: this package is
339
+ * a client bundle, so a server component cannot import the plain string, but
340
+ * it can render this component. Put it in `<head>` and add
341
+ * `suppressHydrationWarning` to `<html>` (the script changes its attributes
342
+ * before React hydrates).
343
+ */
344
+ declare function ThemeScript({ nonce }: ThemeScriptProps): react_jsx_runtime.JSX.Element;
345
+
346
+ export { BrandAnimation, type BrandAnimationProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CopulaLinkProps, CopulaLockup, type CopulaLockupProps, Logo, LogoMonogram, LogoMonogramBg, type LogoMonogramBgProps, type LogoMonogramProps, type LogoProps, LogoWordmark, type LogoWordmarkProps, NavbarLogo, type NavbarLogoProps, type ResolvedTheme, THEME_ATTRIBUTE, THEME_STORAGE_KEY, type ThemePreference, ThemeScript, type ThemeScriptProps, ThemeToggle, type ThemeToggleLabels, type ThemeToggleProps, nextThemePreference, readThemePreference, resolveTheme, setThemePreference, themeInitScript, useResolvedTheme, useThemePreference };