meowtail 0.4.0-alpha.1 → 0.4.0-alpha.2
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/AUTHORING.md +268 -0
- package/CHANGELOG.md +14 -0
- package/README.md +49 -26
- package/dist/src/shared/page-attribute.d.ts +5 -0
- package/dist/src/shared/page-attribute.js +5 -0
- package/dist/src/theme/base.styles.js +14 -0
- package/dist/src/web/index.d.ts +1 -0
- package/dist/src/web/index.js +1 -0
- package/dist/src/web/theme-plugin.d.ts +33 -0
- package/dist/src/web/theme-plugin.js +93 -0
- package/package.json +7 -6
package/AUTHORING.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# Authoring components the Meowland way
|
|
2
|
+
|
|
3
|
+
This guide is for application authors who know shadcn/ui and Tailwind. It shows how to write a
|
|
4
|
+
component with MeowJSX, address its parts with MeowCSS, and use Meowtail's built-in theme values.
|
|
5
|
+
The worked examples have typechecked counterparts in
|
|
6
|
+
[tests/fixtures/authoring](tests/fixtures/authoring/), and
|
|
7
|
+
[authoring.test.tsx](tests/unit/theme/authoring.test.tsx) renders them and audits their styles.
|
|
8
|
+
|
|
9
|
+
Library contributors also follow [AGENTS.md](AGENTS.md).
|
|
10
|
+
|
|
11
|
+
## Step 0: use what exists
|
|
12
|
+
|
|
13
|
+
Most shadcn components already exist here with the same anatomy. Reach for these before writing
|
|
14
|
+
anything:
|
|
15
|
+
|
|
16
|
+
| shadcn/ui | Meowtail |
|
|
17
|
+
| --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| Button | `Button` (`primary`, `outline`, `quiet`, `accent`, `danger`, `stop`), `IconButton` |
|
|
19
|
+
| Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, CardAction | the same names |
|
|
20
|
+
| Badge | `Badge`, `Tag`, `Pill` |
|
|
21
|
+
| Alert | `Alert` |
|
|
22
|
+
| Dialog, AlertDialog, Sheet | `Dialog`, `Modal`, `RiskConfirmation`, `Drawer` |
|
|
23
|
+
| Tabs, ToggleGroup | `Tabs`, `SegmentedControl`, `ChoiceGroup` |
|
|
24
|
+
| Input, Textarea, Select, Checkbox, Switch, Slider, Label + FormField | `Input`, `Textarea`, `Select` / `ChoiceSelect`, `Checkbox`, `Switch`, `Slider`, `Field`, `FieldGroup` |
|
|
25
|
+
| Tooltip, Popover, HoverCard | `Tooltip`, `Popover`, `HoverCard` |
|
|
26
|
+
| DropdownMenu, ContextMenu | `MenuButton`, `Menu`, `ContextMenu` |
|
|
27
|
+
| Separator, Skeleton, Avatar, Accordion, Table, Breadcrumb, Progress | the same names |
|
|
28
|
+
| Sonner / Toast | `Toast` |
|
|
29
|
+
| Sidebar | `NavList`, `IconRail` |
|
|
30
|
+
| Kbd, Spinner, AspectRatio, Empty | `ShortcutKeys`, `Spinner`, `AspectRatio`, `EmptyState` |
|
|
31
|
+
| `flex gap-*`, `grid grid-cols-*` | `Stack`, `Inline`, `Grid` with `gap="compact" \| "normal" \| "relaxed"` |
|
|
32
|
+
| `<p className="text-muted-foreground text-sm">` | `Text variant="secondary" \| "caption" \| "eyebrow"` |
|
|
33
|
+
| `prose` (typography plugin) | `Prose` |
|
|
34
|
+
|
|
35
|
+
Write a component when the library does not have its shape. Business components such as a plan
|
|
36
|
+
badge, a stat card or a settings row belong to the host.
|
|
37
|
+
|
|
38
|
+
## The translation
|
|
39
|
+
|
|
40
|
+
| shadcn + Tailwind | Meowland |
|
|
41
|
+
| --------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
42
|
+
| A function component that re-renders | An ordinary function whose setup runs once per mount; bound Signals carry later updates |
|
|
43
|
+
| `data-slot="card-title"` | `meta.parts` and `ref={context.parts.title}` |
|
|
44
|
+
| `cva({ variants })` + `VariantProps` | `defineOptions` + `meta.style: defineStyleProps(...)`, `ThemedProps` and `options.when(...)` in CSS |
|
|
45
|
+
| Utility classes in `className` | `className={[ui.p.group, ui.bg.fill]}` or `cx(ui.p.group, ui.bg.fill)` |
|
|
46
|
+
| The Tailwind scale | Typed roles in `ui` and `uiTokens` |
|
|
47
|
+
| `dark:` variants | Color tokens carry light/dark pairs; nested scheme regions resolve their own values |
|
|
48
|
+
| `hover:`, `focus-visible:`, `disabled:` | Native CSS states and finite theme values that retain their state rules |
|
|
49
|
+
| `cn()` | Public `cx` from `meowcss`; stylesheet order and the CSS cascade decide conflicts |
|
|
50
|
+
| Radix primitives | Meowtail's behavior components; native elements first for a new primitive |
|
|
51
|
+
| Tailwind preflight | The standard theme's foundation within a Meowland region |
|
|
52
|
+
| A lint plugin for class names | `auditCSS(fragment, standardAuditRules)` checks painted values |
|
|
53
|
+
|
|
54
|
+
## Components and parts
|
|
55
|
+
|
|
56
|
+
A component is a function with static metadata. The second argument supplies that mount's lifecycle
|
|
57
|
+
and finite part bindings. Register the function itself; declaring metadata does not register it.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { h, type Context, type Props, type RefBinding } from "meowjsx";
|
|
61
|
+
import type {} from "meowjsx/web";
|
|
62
|
+
|
|
63
|
+
interface StatCardProps extends Props {
|
|
64
|
+
label: string;
|
|
65
|
+
value: string;
|
|
66
|
+
ref?: RefBinding<HTMLElement>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function StatCard(
|
|
70
|
+
{ label, value, children, ref, ...props }: StatCardProps,
|
|
71
|
+
context: Context<typeof StatCard>,
|
|
72
|
+
) {
|
|
73
|
+
return (
|
|
74
|
+
<section {...props} ref={[context.parts.root, ref]}>
|
|
75
|
+
<p ref={context.parts.label}>{label}</p>
|
|
76
|
+
<strong ref={context.parts.value}>{value}</strong>
|
|
77
|
+
<div ref={context.parts.delta}>{children}</div>
|
|
78
|
+
</section>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
StatCard.meta = {
|
|
82
|
+
name: "app-stat-card",
|
|
83
|
+
parts: ["root", "label", "value", "delta"],
|
|
84
|
+
} as const;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Part bindings preserve component identity and original props before mounting. They add no wrapper
|
|
88
|
+
or component instance. A ref array can also contain local callbacks, nested forwarded refs and
|
|
89
|
+
false/nullish omissions. Callbacks run in order, and their synchronous cleanups run in reverse order.
|
|
90
|
+
Static HTML reads part identity without invoking callbacks.
|
|
91
|
+
|
|
92
|
+
Setup still runs only once. Type a changing prop as `MaybeSignal<T>` and pass the Signal through to
|
|
93
|
+
its text, attribute or child binding. An event handler reads the live value with `unwrap` or
|
|
94
|
+
`.value`. A setup-time `unwrap` reads once and does not make a plain variable reactive.
|
|
95
|
+
|
|
96
|
+
## Wiring
|
|
97
|
+
|
|
98
|
+
Register the component families the host renders, and assemble its styles with the standard theme:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { createRuntime } from "meowjsx";
|
|
102
|
+
import { createMeowUI, meowUIComponents } from "meowtail";
|
|
103
|
+
import { extendStandardTheme } from "meowtail/theme";
|
|
104
|
+
import { mountStyles } from "meowcss/web";
|
|
105
|
+
import { PlanBadge } from "./plan-badge";
|
|
106
|
+
import { StatCard } from "./stat-card";
|
|
107
|
+
import { ListRow } from "./list-row";
|
|
108
|
+
|
|
109
|
+
const runtime = createRuntime({
|
|
110
|
+
plugins: [createMeowUI({ components: [...meowUIComponents, PlanBadge, StatCard, ListRow] })],
|
|
111
|
+
});
|
|
112
|
+
const appTheme = extendStandardTheme({
|
|
113
|
+
styles: [planBadgeStyles, statCardStyles, listRowStyles],
|
|
114
|
+
});
|
|
115
|
+
const removeStyles = mountStyles(document, appTheme.cssText);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For a small host, pass a narrow list such as `[Button, PlanBadge]` instead of the complete
|
|
119
|
+
`meowUIComponents` catalog. The selective factory does not import the complete catalog or its
|
|
120
|
+
optional engines. Register nested component families that the composition renders as well.
|
|
121
|
+
|
|
122
|
+
Prefix host metadata names (`app-badge`, for example). The registry layers by name, so registering
|
|
123
|
+
a host component as `card` replaces the library identity with that name. Install one style-props
|
|
124
|
+
adapter through `createMeowUI`; a separate runtime plugin can also list component functions.
|
|
125
|
+
|
|
126
|
+
`extendStandardTheme` keeps the foundation first, standard component rules before host fragments,
|
|
127
|
+
and the shared utility sheet last. Part descriptors use zero-specificity selectors; complete rules
|
|
128
|
+
retain their ordinary specificity. Class order in `cx` does not override stylesheet order.
|
|
129
|
+
|
|
130
|
+
## Class values and theme rules
|
|
131
|
+
|
|
132
|
+
`ui` is Meowtail's built-in catalog. A value carries both a CSS class and its declarations, so it
|
|
133
|
+
works on an instance and inside a theme rule:
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import { cx } from "meowcss";
|
|
137
|
+
import { ui } from "meowtail/theme";
|
|
138
|
+
|
|
139
|
+
const panel = cx(ui.p.panel, ui.bg.raised, ui.radius.xl);
|
|
140
|
+
<div className={["host-panel", panel]} />;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import type { StatCard } from "./stat-card";
|
|
145
|
+
import { css, parts } from "meowcss/meowjsx";
|
|
146
|
+
import { cx } from "meowcss";
|
|
147
|
+
import { ui, uiTokens } from "meowtail/theme";
|
|
148
|
+
|
|
149
|
+
const card = parts<typeof StatCard>("app-stat-card");
|
|
150
|
+
export const statCardStyles = css`
|
|
151
|
+
${card.root} {
|
|
152
|
+
${cx(ui.surface.raised, ui.p.panel)}
|
|
153
|
+
display: grid;
|
|
154
|
+
gap: ${uiTokens.space.group};
|
|
155
|
+
}
|
|
156
|
+
${card.label} {
|
|
157
|
+
${ui.text.eyebrow}
|
|
158
|
+
margin: 0;
|
|
159
|
+
}
|
|
160
|
+
${card.value} {
|
|
161
|
+
${ui.text.title}
|
|
162
|
+
font-variant-numeric: tabular-nums;
|
|
163
|
+
}
|
|
164
|
+
${card.delta} {
|
|
165
|
+
${ui.text.caption}
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The theme imports only the component's type. `parts<typeof StatCard>("app-stat-card")` checks the
|
|
171
|
+
name and available members without loading that component's implementation. Within a `cx` composite,
|
|
172
|
+
values from one catalog expand in that catalog's stylesheet order. Separate CSS interpolations keep
|
|
173
|
+
ordinary CSS order. A plain external class string has no declarations, so a composite containing one
|
|
174
|
+
cannot be expanded inside a rule.
|
|
175
|
+
|
|
176
|
+
Class lists preserve order and omit `false`, `null`, `undefined` and empty strings. Lists can be
|
|
177
|
+
nested and can contain Signals. Use `cx` when a reusable composite should also retain declarations.
|
|
178
|
+
Keep hover, focus, disabled, responsive rules and one-off geometry in CSS; no condition language or
|
|
179
|
+
source scanning is needed.
|
|
180
|
+
|
|
181
|
+
## Options with variants
|
|
182
|
+
|
|
183
|
+
Components and themes share an options object from a module that imports neither implementation nor
|
|
184
|
+
assembled theme:
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
// plan-badge.options.ts
|
|
188
|
+
import { defineOptions } from "meowcss";
|
|
189
|
+
export const planBadgeOptions = defineOptions("app-plan-badge", {
|
|
190
|
+
tone: ["free", "pro", "trial"],
|
|
191
|
+
});
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
// plan-badge.tsx
|
|
196
|
+
import { h, type Context, type Props } from "meowjsx";
|
|
197
|
+
import { defineStyleProps, type ThemedProps } from "meowcss/meowjsx";
|
|
198
|
+
import { planBadgeOptions } from "./plan-badge.options";
|
|
199
|
+
|
|
200
|
+
interface PlanBadgeProps extends Props, ThemedProps<typeof planBadgeOptions> {}
|
|
201
|
+
|
|
202
|
+
export function PlanBadge({ ref, ...props }: PlanBadgeProps, context: Context<typeof PlanBadge>) {
|
|
203
|
+
return <span {...props} ref={[context.parts.root, ref]} />;
|
|
204
|
+
}
|
|
205
|
+
PlanBadge.meta = {
|
|
206
|
+
name: "app-plan-badge",
|
|
207
|
+
parts: ["root"],
|
|
208
|
+
style: defineStyleProps(planBadgeOptions, { defaults: { tone: "free" } }),
|
|
209
|
+
} as const;
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
// plan-badge.styles.ts
|
|
214
|
+
import type { PlanBadge } from "./plan-badge";
|
|
215
|
+
import { css, parts } from "meowcss/meowjsx";
|
|
216
|
+
import { ui, uiTokens } from "meowtail/theme";
|
|
217
|
+
import { planBadgeOptions } from "./plan-badge.options";
|
|
218
|
+
|
|
219
|
+
const badge = parts<typeof PlanBadge>("app-plan-badge");
|
|
220
|
+
export const planBadgeStyles = css`
|
|
221
|
+
${badge.root} {
|
|
222
|
+
${ui.text.caption}
|
|
223
|
+
display: inline-flex;
|
|
224
|
+
padding: 2px ${uiTokens.space.group};
|
|
225
|
+
border-radius: ${uiTokens.radius.sm};
|
|
226
|
+
${planBadgeOptions.when({ tone: "pro" })} {
|
|
227
|
+
background: ${uiTokens.action.primary};
|
|
228
|
+
color: ${uiTokens.action.onPrimary};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
`;
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
`<PlanBadge tone="pro">` carries `data-option-app-plan-badge-tone="pro"`; the adapter consumes the
|
|
235
|
+
`tone` prop. `defineStyleProps` validates defaults, and registration validates that carrier parts
|
|
236
|
+
exist. Token assembly rejects conflicting definitions for the same option attribute. It does not
|
|
237
|
+
compare the component with an independently authored theme schema; share the options object.
|
|
238
|
+
|
|
239
|
+
## The floor
|
|
240
|
+
|
|
241
|
+
The foundation gives a Meowland region border-box sizing, contained media, a mono code face,
|
|
242
|
+
inherited control type and shared focus defaults. It does not reset headings, lists or margins.
|
|
243
|
+
Use `Text` for copy and `Prose` for reading content.
|
|
244
|
+
|
|
245
|
+
Theme values keep materials, typography and state behavior on the existing token roles. A part's
|
|
246
|
+
geometry stays beside that selector, where its exceptions can be reviewed. Dark colors resolve at
|
|
247
|
+
the nearest scheme region without rebuilding component instances.
|
|
248
|
+
|
|
249
|
+
Audit application fragments with the same rules as the standard theme:
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
import { auditCSS } from "meowcss";
|
|
253
|
+
import { standardAuditRules } from "meowtail/theme";
|
|
254
|
+
|
|
255
|
+
test("app styles stay on the standard scales", () => {
|
|
256
|
+
for (const fragment of appStyles) expect(auditCSS(fragment, standardAuditRules)).toEqual([]);
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
The audit reports literal colors, durations, type sizes, line heights, weights and radii with their
|
|
261
|
+
selector and line. Token references, derived lengths, masks, `0` and `50%` pass. Accept a deliberate
|
|
262
|
+
exception through `allow` and keep its reason beside it. Spacing is not audited: part geometry can
|
|
263
|
+
use off-ramp lengths.
|
|
264
|
+
|
|
265
|
+
Icons follow [Which icon where](src/icons/README.md#which-icon-where). Each intent has one icon;
|
|
266
|
+
leading icons name the type, trailing icons name an action, and state uses the shared status marker.
|
|
267
|
+
Check a new composition in the real component scene, including focus, disabled state, a narrow
|
|
268
|
+
viewport and both themes. Type and audit checks do not establish those observations.
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- `createMeowUITheme({ theme, config })` from `meowtail/web` is a runtime plugin that delivers a
|
|
6
|
+
theme to every Web mount: the stylesheet (shared per document through `meowcss/web`
|
|
7
|
+
`mountStyles`), the theme attributes on the container and the focus-modality tracker, all
|
|
8
|
+
released by `unmount()`. A browser page is now `createMeowUI` plus `createMeowUITheme` in one
|
|
9
|
+
`plugins` list and MeowJSX's `render`. It is built on MeowJSX's new `prepareContainer` plugin hook,
|
|
10
|
+
refuses a second themed mount into one container and containers inside a shadow root, and stays
|
|
11
|
+
out of bundles that only register components. By default it also owns the page: the document
|
|
12
|
+
element takes the theme's canvas and CSS `color-scheme`, so a dark scheme no longer renders light
|
|
13
|
+
text on a white page; `page: false` leaves an embedded region's ground to its host. See the
|
|
14
|
+
[design](../../docs/designs/2026-11-03-theme-delivery-plugin.md).
|
|
15
|
+
|
|
16
|
+
- The package ships `AUTHORING.md`, which the README links as the guide for host components; an
|
|
17
|
+
agent or author can read it from `node_modules/meowtail` at the installed version.
|
|
18
|
+
|
|
5
19
|
- `HoverCard` copy feedback no longer covers the card. On success the copy cue turns into a check and
|
|
6
20
|
`copiedLabel` for 1.5 seconds; on failure the message takes its own line under the content and
|
|
7
21
|
stays until the next attempt or the card closes. The `feedback` part stays the live status, and
|
package/README.md
CHANGED
|
@@ -12,35 +12,41 @@ The presentation player, Reveal, media lifecycle, presentation content layouts,
|
|
|
12
12
|
|
|
13
13
|
This package's npm name is `meowtail`; existing APIs such as `createMeowUI`, `installMeowUI`, and `createMeowUICatalog`, along with runtime style identity, stay unchanged. Use the new package import path; do not derive new function names, `data-*` markers, or CSS variables from the package name.
|
|
14
14
|
|
|
15
|
+
Agents building an application with this package start with the
|
|
16
|
+
[Meowland skill](https://github.com/lidessen/meowland/blob/main/skills/meowland/SKILL.md) (`npx skills add lidessen/meowland --skill meowland`)
|
|
17
|
+
and the Markdown component pages listed in [meowland.dev/llms.txt](https://meowland.dev/llms.txt).
|
|
18
|
+
|
|
15
19
|
Application authors writing their own components (the shadcn/ui and Tailwind equivalents, the style floor and the audit) start with [Authoring](AUTHORING.md). See [Assistant](ASSISTANT.md) for the usage contract of the complete composition and [JSON catalog](JSON.md) for the finite JSON entry point. Implementation and independent acceptance of both are still in progress; the API descriptions and early artifact verification on this page do not equal a same-source acceptance pass for all current source code.
|
|
16
20
|
|
|
17
21
|
## Runtime compatibility
|
|
18
22
|
|
|
19
|
-
The
|
|
20
|
-
`
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
The `0.4.0-alpha.2` candidate requires `meowjsx@^0.3.0-alpha.1` and `meowcss@^0.3.0-alpha.2`:
|
|
24
|
+
`createMeowUITheme` runs on MeowJSX's `prepareContainer` hook and shares stylesheets through
|
|
25
|
+
MeowCSS's counted `mountStyles`. It uses ordinary components with static `meta`, composed part/ref
|
|
26
|
+
bindings and the class-value theme API. Earlier package generations do not implement that
|
|
27
|
+
authoring contract. The published releases remain listed in the root README.
|
|
23
28
|
|
|
24
29
|
## Minimal browser integration
|
|
25
30
|
|
|
26
|
-
In a browser entry point containing `<main id="app"></main>`,
|
|
27
|
-
|
|
31
|
+
In a browser entry point containing `<main id="app"></main>`, install two plugins on the runtime that
|
|
32
|
+
renders the page: `createMeowUI` registers the components and `createMeowUITheme` delivers the theme
|
|
33
|
+
to every Web mount. Rendering is then MeowJSX's own `render`.
|
|
28
34
|
|
|
29
35
|
```tsx
|
|
30
36
|
import { createRuntime, h } from "meowjsx";
|
|
31
37
|
import { createWebRenderer } from "meowjsx/web";
|
|
32
38
|
import { Button, Inline, Stack, createMeowUI } from "meowtail";
|
|
33
|
-
import { standardTheme
|
|
34
|
-
import {
|
|
35
|
-
import { applyTheme, mountStyles } from "meowcss/web";
|
|
39
|
+
import { standardTheme } from "meowtail/theme";
|
|
40
|
+
import { createMeowUITheme } from "meowtail/web";
|
|
36
41
|
|
|
37
42
|
const root = document.querySelector<HTMLElement>("#app");
|
|
38
43
|
if (!root) throw new Error("Missing app root");
|
|
39
|
-
const runtime = createRuntime(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
const runtime = createRuntime({
|
|
45
|
+
plugins: [
|
|
46
|
+
createMeowUI({ components: [Button, Inline, Stack] }),
|
|
47
|
+
createMeowUITheme({ theme: standardTheme }),
|
|
48
|
+
],
|
|
49
|
+
});
|
|
44
50
|
const mounted = createWebRenderer(runtime).render(
|
|
45
51
|
<Stack align="start">
|
|
46
52
|
<strong>Connection settings</strong>
|
|
@@ -52,28 +58,39 @@ const mounted = createWebRenderer(runtime).render(
|
|
|
52
58
|
root,
|
|
53
59
|
);
|
|
54
60
|
|
|
55
|
-
// Dispose with the host that owns this mount.
|
|
56
|
-
const dispose = () =>
|
|
57
|
-
mounted.unmount();
|
|
58
|
-
removeFocusModality();
|
|
59
|
-
removeTheme();
|
|
60
|
-
removeStyles();
|
|
61
|
-
uninstall();
|
|
62
|
-
};
|
|
61
|
+
// Dispose with the host that owns this mount; it also releases the theme delivery.
|
|
62
|
+
const dispose = () => mounted.unmount();
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
For each mount, `createMeowUITheme` puts `theme.cssText` in the container's document (one shared
|
|
66
|
+
`<style>` per document), binds the theme attributes to the container (`config` selects the scheme
|
|
67
|
+
and other options; a Signal keeps it live) and installs the focus-modality tracker. It also owns the
|
|
68
|
+
page: the document element takes the same theme and selection and is marked `data-meowui-page`, so
|
|
69
|
+
the foundation styles paint it with `surface.canvas` and the matching CSS `color-scheme`, and a dark
|
|
70
|
+
scheme never sits on a white page. The first mount in a document sets the page's selection and the
|
|
71
|
+
last one releases it. A region embedded in a page whose ground belongs to the host passes
|
|
72
|
+
`page: false`. A second themed
|
|
73
|
+
render into the same container, or a container inside a shadow root, throws instead of leaving a
|
|
74
|
+
page half-styled. Registration alone (`createMeowUI` without the theme plugin) changes nothing in the
|
|
75
|
+
document, and a bundle that only registers components carries no theme delivery. Static output does
|
|
76
|
+
not run the theme plugin; deliver CSS at build time as described in
|
|
77
|
+
[Component installation and style delivery](#component-installation-and-style-delivery).
|
|
78
|
+
Hosts whose theme is assembled with extra CSS, or whose theme root is not the render container,
|
|
79
|
+
keep the explicit `mountStyles` and `applyTheme` steps.
|
|
80
|
+
|
|
65
81
|
`installFocusModality` from `meowtail/web` makes focus rings follow the keyboard. Browsers disagree on
|
|
66
82
|
`:focus-visible`: Safari also matches it when script moves focus after a tap, so a ring lands on
|
|
67
83
|
what the reader just touched. Like React Aria's input modality, the tracker records whether the last
|
|
68
84
|
input was a pointer or a key on the document element (`data-meowui-focus-modality`). After a pointer,
|
|
69
85
|
the theme hides every outline focus ring until the next keystroke. Text entry (text inputs, textarea,
|
|
70
86
|
select, `contenteditable`, `role="textbox"`) keeps its focus state either way, and a Menu keeps its
|
|
71
|
-
active row.
|
|
87
|
+
active row. `createMeowUITheme` installs it with each mount; a host without that plugin installs it
|
|
88
|
+
once per document, the canvas iframe of a gallery included; calls are counted.
|
|
72
89
|
A page rendered ahead of time inlines `focusModalityScript` instead. Without the tracker, rings follow
|
|
73
90
|
the browser's own `:focus-visible`. Styles inside shadow roots do not see the attribute.
|
|
74
91
|
|
|
75
92
|
The theme root provides an inheritable body font, font size, line height, and text color; local theme configuration inherits the outer typography, while components still own their own control and heading scales.
|
|
76
|
-
This does not include a global `html/body` margin reset
|
|
93
|
+
This does not include a global `html/body` margin reset or page whitespace, and does not automatically reset arbitrary `h1/h2/p`; the page background and color scheme come only from a page that `createMeowUITheme` owns.
|
|
77
94
|
Use `PageFrame` / `Container` for page space, `Stack` for related content, and `Inline` for a group of actions; the complete Assistant can use `AssistantView` directly, without rebuilding a page from bare Cards.
|
|
78
95
|
`CardHeader/Title/Content/Footer` express relationships inside a card, while native content follows document semantics; do not wrap every layer of content in its own surface.
|
|
79
96
|
Compare Meowbook's `buttons`, `card-composition`, and `workspace-composition`; they show action relationships, card structure, and a scrolling workspace respectively. A stress state does not mean the product must display all states at once.
|
|
@@ -651,7 +668,11 @@ These relationships inform composition; theme values and component behavior are
|
|
|
651
668
|
|
|
652
669
|
### Component installation and style delivery
|
|
653
670
|
|
|
654
|
-
|
|
671
|
+
A browser host normally installs both through the runtime, as in
|
|
672
|
+
[Minimal browser integration](#minimal-browser-integration). The pieces below are what those two
|
|
673
|
+
plugins do, and what a static host or a host with its own delivery uses directly.
|
|
674
|
+
|
|
675
|
+
`createMeowUI({ components })` registers
|
|
655
676
|
an explicit list of component functions and the style-props adapter. `standardTheme.cssText` provides
|
|
656
677
|
the complete CSS with variable declarations, component rules and built-in utility classes. A dynamic
|
|
657
678
|
host can assemble it like this:
|
|
@@ -696,7 +717,9 @@ A static host that bundles that `.css` file with Bun runs `removeLegacyIsFallbac
|
|
|
696
717
|
`meowcss/bundle` over the output: Bun writes legacy `:-moz-any()` copies of the theme's `:is()`
|
|
697
718
|
rules, and iOS Safari matches one of them on every container of a focused control.
|
|
698
719
|
Source code maintains no `.css` files, and generated CSS is still a browser asset. Module imports themselves do not access the DOM;
|
|
699
|
-
`mountStyles`
|
|
720
|
+
`mountStyles` shares one `<style>` per document and stylesheet text across its holders, including
|
|
721
|
+
`createMeowUITheme`, and the last cleanup removes it; a host that assembles its own CSS text still
|
|
722
|
+
assembles it once per document.
|
|
700
723
|
|
|
701
724
|
### Root configuration and local overrides
|
|
702
725
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css } from "meowcss/meowjsx";
|
|
2
2
|
import { logoTokens, uiTokens } from "./tokens.js";
|
|
3
3
|
import { ui } from "./utilities.js";
|
|
4
|
+
import { pageAttribute } from "../shared/page-attribute.js";
|
|
4
5
|
export const cornerShapeStyles = css `
|
|
5
6
|
@supports (corner-shape: superellipse(1.5)) {
|
|
6
7
|
:where([data-meowui-part]),
|
|
@@ -26,6 +27,19 @@ export const textEntry = [
|
|
|
26
27
|
'[role="textbox"]',
|
|
27
28
|
].join(", ");
|
|
28
29
|
export const foundationStyles = css `
|
|
30
|
+
/* A themed page: the document takes the canvas and tells the browser its scheme, so native
|
|
31
|
+
controls, scrollbars and the overscroll area match instead of leaving a white page around a
|
|
32
|
+
dark one. Only the theme plugin marks a page; an embedded region keeps its host's ground. */
|
|
33
|
+
:where(html[${pageAttribute}][data-meowui-scope]) {
|
|
34
|
+
background-color: ${uiTokens.surface.canvas};
|
|
35
|
+
color-scheme: light;
|
|
36
|
+
}
|
|
37
|
+
:where(html[${pageAttribute}][data-meowui-color-scheme="dark"]) {
|
|
38
|
+
color-scheme: dark;
|
|
39
|
+
}
|
|
40
|
+
:where(html[${pageAttribute}][data-meowui-color-scheme="auto"]) {
|
|
41
|
+
color-scheme: light dark;
|
|
42
|
+
}
|
|
29
43
|
:where(
|
|
30
44
|
[data-meowui-theme-root="meowui"],
|
|
31
45
|
[data-meowui-theme-root="meowui"] *,
|
package/dist/src/web/index.d.ts
CHANGED
package/dist/src/web/index.js
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RuntimePlugin } from "meowjsx";
|
|
2
|
+
import type { MaybeSignal } from "meowjsx/signal";
|
|
3
|
+
import type { Selection, ThemeDefinition } from "meowcss";
|
|
4
|
+
export interface MeowUIThemeOptions {
|
|
5
|
+
/** The theme every Web mount delivers, such as `standardTheme` from `meowtail/theme`. */
|
|
6
|
+
readonly theme: ThemeDefinition;
|
|
7
|
+
/** The root selection, such as `standardOptions.select({ scheme: "dark" })`; a Signal stays live. */
|
|
8
|
+
readonly config?: MaybeSignal<Selection>;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the mount owns the page: the document element takes the theme's canvas and color
|
|
11
|
+
* scheme, so a dark scheme does not sit on a white page. Defaults to true; pass false for a
|
|
12
|
+
* region embedded in a page whose ground belongs to someone else.
|
|
13
|
+
*/
|
|
14
|
+
readonly page?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The runtime plugin that makes each Web mount render styled: it puts the theme's stylesheet in
|
|
18
|
+
* the container's document (shared with any other holder of the same text), binds the theme
|
|
19
|
+
* attributes to the container, paints the page with the theme's canvas and color scheme (unless
|
|
20
|
+
* `page: false`) and tracks focus modality. Install it next to `createMeowUI`:
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* createRuntime({
|
|
24
|
+
* plugins: [
|
|
25
|
+
* createMeowUI({ components: meowUIComponents }),
|
|
26
|
+
* createMeowUITheme({ theme: standardTheme }),
|
|
27
|
+
* ],
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Static output does not run it; deliver CSS at build time and use `themeAttributes` there.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createMeowUITheme(options: MeowUIThemeOptions): RuntimePlugin;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { applyTheme, mountStyles } from "meowcss/web";
|
|
2
|
+
import { installFocusModality } from "./focus-modality.js";
|
|
3
|
+
import { pageAttribute } from "../shared/page-attribute.js";
|
|
4
|
+
/** The documents whose page a theme plugin paints, with the number of mounts holding it. */
|
|
5
|
+
const pages = new WeakMap();
|
|
6
|
+
/**
|
|
7
|
+
* Paints the page for one more mount. The first holder binds the document element; later holders
|
|
8
|
+
* share that binding, and its theme and selection, until the last one releases it.
|
|
9
|
+
*/
|
|
10
|
+
function holdPage(document, root, theme, config) {
|
|
11
|
+
let entry = pages.get(document);
|
|
12
|
+
if (!entry) {
|
|
13
|
+
const html = document.documentElement;
|
|
14
|
+
// A container that is the document element already carries the theme attributes.
|
|
15
|
+
const removeTheme = root === html ? undefined : applyTheme(html, theme, config);
|
|
16
|
+
html.setAttribute(pageAttribute, "");
|
|
17
|
+
const created = {
|
|
18
|
+
count: 0,
|
|
19
|
+
release: () => {
|
|
20
|
+
pages.delete(document);
|
|
21
|
+
html.removeAttribute(pageAttribute);
|
|
22
|
+
removeTheme?.();
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
pages.set(document, (entry = created));
|
|
26
|
+
}
|
|
27
|
+
entry.count++;
|
|
28
|
+
const held = entry;
|
|
29
|
+
let released = false;
|
|
30
|
+
return () => {
|
|
31
|
+
if (released)
|
|
32
|
+
return;
|
|
33
|
+
released = true;
|
|
34
|
+
if (--held.count === 0)
|
|
35
|
+
held.release();
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** The containers a theme plugin currently binds, so a second mount into one fails loudly. */
|
|
39
|
+
const bound = new WeakSet();
|
|
40
|
+
function prepare({ theme, config, page = true }, { container, target }) {
|
|
41
|
+
if (target !== "web")
|
|
42
|
+
return undefined;
|
|
43
|
+
const root = container;
|
|
44
|
+
const document = root.ownerDocument;
|
|
45
|
+
if (root.getRootNode() !== document && root.isConnected) {
|
|
46
|
+
throw new Error("meowtail theme delivery needs a container in the document, not in a shadow root; mount the stylesheet in the shadow root yourself and omit createMeowUITheme");
|
|
47
|
+
}
|
|
48
|
+
if (bound.has(root)) {
|
|
49
|
+
throw new Error("meowtail theme delivery already binds this container; unmount the earlier render or render into a child element");
|
|
50
|
+
}
|
|
51
|
+
const releases = [];
|
|
52
|
+
try {
|
|
53
|
+
releases.push(mountStyles(document, theme.cssText));
|
|
54
|
+
releases.push(applyTheme(root, theme, config));
|
|
55
|
+
releases.push(installFocusModality(document));
|
|
56
|
+
if (page)
|
|
57
|
+
releases.push(holdPage(document, root, theme, config));
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
for (const release of releases.reverse())
|
|
61
|
+
release();
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
bound.add(root);
|
|
65
|
+
return () => {
|
|
66
|
+
bound.delete(root);
|
|
67
|
+
for (const release of releases.reverse())
|
|
68
|
+
release();
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The runtime plugin that makes each Web mount render styled: it puts the theme's stylesheet in
|
|
73
|
+
* the container's document (shared with any other holder of the same text), binds the theme
|
|
74
|
+
* attributes to the container, paints the page with the theme's canvas and color scheme (unless
|
|
75
|
+
* `page: false`) and tracks focus modality. Install it next to `createMeowUI`:
|
|
76
|
+
*
|
|
77
|
+
* ```ts
|
|
78
|
+
* createRuntime({
|
|
79
|
+
* plugins: [
|
|
80
|
+
* createMeowUI({ components: meowUIComponents }),
|
|
81
|
+
* createMeowUITheme({ theme: standardTheme }),
|
|
82
|
+
* ],
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* Static output does not run it; deliver CSS at build time and use `themeAttributes` there.
|
|
87
|
+
*/
|
|
88
|
+
export function createMeowUITheme(options) {
|
|
89
|
+
return {
|
|
90
|
+
name: "meow-ui-theme",
|
|
91
|
+
prepareContainer: (context) => prepare(options, context),
|
|
92
|
+
};
|
|
93
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meowtail",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
14
14
|
"AGENT-COMPONENTS.md",
|
|
15
|
+
"AUTHORING.md",
|
|
15
16
|
"CHANGELOG.md",
|
|
16
17
|
"COMPONENTS.md",
|
|
17
18
|
"README.md",
|
|
@@ -67,16 +68,16 @@
|
|
|
67
68
|
"shiki": "4.3.1"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
|
-
"meowjsx": "^0.3.0-alpha.
|
|
71
|
-
"meowcss": "^0.3.0-alpha.
|
|
71
|
+
"meowjsx": "^0.3.0-alpha.1",
|
|
72
|
+
"meowcss": "^0.3.0-alpha.2"
|
|
72
73
|
},
|
|
73
74
|
"devDependencies": {
|
|
74
75
|
"@fontsource-variable/inter": "^5.3.0",
|
|
75
76
|
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
|
76
77
|
"@fontsource-variable/newsreader": "^5.3.0",
|
|
77
|
-
"meowbook": "0.3.0-alpha.
|
|
78
|
-
"meowcss": "0.3.0-alpha.
|
|
79
|
-
"meowjsx": "0.3.0-alpha.
|
|
78
|
+
"meowbook": "0.3.0-alpha.1",
|
|
79
|
+
"meowcss": "0.3.0-alpha.2",
|
|
80
|
+
"meowjsx": "0.3.0-alpha.1"
|
|
80
81
|
},
|
|
81
82
|
"repository": {
|
|
82
83
|
"type": "git",
|