@signal9/era-ui 3.0.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,12 @@
1
1
  export interface CssUtility {
2
- /** Class name, e.g. `era-link`. */
2
+ /** Class name, e.g. `era-link` — the first of `names` for a ladder. */
3
3
  name: string;
4
+ /**
5
+ * Every class the doc comment governs. Usually one; a scale documented as a
6
+ * run of consecutive `@utility` blocks under a single comment (h-xs … h-lg)
7
+ * lists the whole ladder.
8
+ */
9
+ names: string[];
4
10
  /** Stylesheet the utility is declared in, relative to src/lib/styles. */
5
11
  file: string;
6
12
  /** One-line use case from the comment's `@use` line, if present. */
@@ -17,5 +23,5 @@ export interface CssUtility {
17
23
  export declare function parseUtilities(sources: Record<string, string>): CssUtility[];
18
24
  /** Renders the utilities reference — the generated `utilities.md` body. */
19
25
  export declare function buildUtilitiesDoc(utilities: CssUtility[]): string;
20
- /** One line per utility for llms.txt — name plus its searchable use case. */
26
+ /** One line per utility (or ladder) for llms.txt — plus its searchable use case. */
21
27
  export declare function buildUtilitiesIndex(utilities: CssUtility[]): string[];
@@ -62,11 +62,22 @@ function parseFile(file, source) {
62
62
  // between there and the @utility.
63
63
  const pattern = /\/\*((?:(?!\*\/)[\s\S])*)\*\/\s*@utility\s+([\w-]+)\s*\{/g;
64
64
  for (const match of source.matchAll(pattern)) {
65
- const openBrace = match.index + match[0].length - 1;
66
- const end = blockEnd(source, openBrace);
65
+ const names = [match[2]];
66
+ let end = blockEnd(source, match.index + match[0].length - 1);
67
+ // One doc comment may govern a RUN of consecutive @utility blocks — a
68
+ // ladder like h-xs…h-lg shares one story, and repeating it five times
69
+ // would drown the docs. Attach every block that follows the previous one
70
+ // with nothing but whitespace in between; the next commented block never
71
+ // matches here because the outer pattern requires the comment.
72
+ const next = /^\s*@utility\s+([\w-]+)\s*\{/;
73
+ for (let m; (m = next.exec(source.slice(end + 1)));) {
74
+ names.push(m[1]);
75
+ end = blockEnd(source, end + 1 + m[0].length - 1);
76
+ }
67
77
  const { useCase, description } = splitUseCase(cleanComment(match[1]));
68
78
  out.push({
69
- name: match[2],
79
+ name: names[0],
80
+ names,
70
81
  file,
71
82
  useCase,
72
83
  description,
@@ -89,27 +100,49 @@ export function parseUtilities(sources) {
89
100
  .flatMap(([file, source]) => parseFile(file, source));
90
101
  }
91
102
  const INTRO = [
92
- 'era ships a handful of Tailwind v4 `@utility` classes for the patterns that are',
93
- 'styling, not components an inline link, ink-centred control text, a hidden',
94
- 'scrollbar. They need no import: they ride along with the stylesheet.',
103
+ "era's styling API is pure class names write `h-md rounded-md px-md shadow`,",
104
+ 'never the `h-(--era-h-md)` var-class spelling. Everything below rides along',
105
+ 'with the stylesheet and needs no import:',
95
106
  '',
96
107
  '```ts',
97
108
  'import "@sig-nine/era-ui/css";',
98
109
  '```',
99
110
  '',
100
111
  '```svelte',
101
- '<a class="era-link" href="/spacing">the spacing ladder</a>',
102
- '```'
112
+ '<button class="h-md rounded-md px-inset-md shadow text-body">era styled</button>',
113
+ '```',
114
+ '',
115
+ 'Alongside the `@utility` classes referenced below, era registers named theme',
116
+ 'scales that OVERLOAD the stock Tailwind names, so ordinary-looking markup',
117
+ 'renders on-design and responds to every axis (density, surface, corners,',
118
+ 'motion):',
119
+ '',
120
+ '| Stock-looking class | What it resolves to |',
121
+ '|---|---|',
122
+ '| `rounded-xs/xxs/sm/md/lg` | the concentric radius ladder (collapses on `data-corners="square"`) |',
123
+ '| `rounded-item` | menu-row radius, concentric inside a `rounded-md` panel |',
124
+ '| `shadow` / `shadow-lg` | resting control edge / floating panel chrome, per surface |',
125
+ '| `shadow-well` / `shadow-pressed` / `shadow-highlight` | recessed, pressed/latched, hover-material chrome |',
126
+ '| `bg-well` / `bg-elevated` / `bg-highlight` / `bg-overlay` | surface fills: resting, raised, transient feedback, modal scrim |',
127
+ '| `transition-*` (bare) | duration + easing default to the motion axis |',
128
+ '| `ease-base` / `duration-base` | the motion axis, named explicitly |',
129
+ '| `text-body` | density-derived body/control text size |',
130
+ '',
131
+ "Deliberate gaps: `w-*`/`min-w-*` tier names would shadow Tailwind's container",
132
+ 'scale (`min-w-md` stays 28rem), and the concentric-inset tokens are advanced',
133
+ 'enough to stay var-form — `min-w-(--era-h-md)` etc. remain the escape hatch.'
103
134
  ].join('\n');
135
+ /** `h-xs` for a single class, `h-xs · h-xxs · … · h-lg` for a ladder. */
136
+ const label = (u) => u.names.join(' · ');
104
137
  /** Renders the utilities reference — the generated `utilities.md` body. */
105
138
  export function buildUtilitiesDoc(utilities) {
106
139
  const lines = ['## Overview', '', INTRO, '', '| Utility | Use it for |', '|---|---|'];
107
140
  for (const u of utilities) {
108
- lines.push(`| \`${u.name}\` | ${u.useCase ?? '—'} |`);
141
+ lines.push(`| ${u.names.map((n) => `\`${n}\``).join(' ')} | ${u.useCase ?? '—'} |`);
109
142
  }
110
143
  lines.push('');
111
144
  for (const u of utilities) {
112
- lines.push(`## ${u.name}`, '');
145
+ lines.push(`## ${label(u)}`, '');
113
146
  if (u.useCase)
114
147
  lines.push(`**Use it for:** ${u.useCase}`, '');
115
148
  if (u.description)
@@ -118,7 +151,7 @@ export function buildUtilitiesDoc(utilities) {
118
151
  }
119
152
  return lines.join('\n');
120
153
  }
121
- /** One line per utility for llms.txt — name plus its searchable use case. */
154
+ /** One line per utility (or ladder) for llms.txt — plus its searchable use case. */
122
155
  export function buildUtilitiesIndex(utilities) {
123
- return utilities.map((u) => `- \`${u.name}\` — ${u.useCase ?? u.description.split('\n')[0]}`);
156
+ return utilities.map((u) => `- \`${label(u)}\` — ${u.useCase ?? u.description.split('\n')[0]}`);
124
157
  }