@typed-grid-areas/solid 0.1.0 → 0.1.1
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/README.md +40 -12
- package/dist/gridComponent.jsx +25 -14
- package/dist/index.js +13 -7
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -10,6 +10,9 @@ Framework-free at the core (`typed-grid-areas`); each UI framework's adapter
|
|
|
10
10
|
is a package of its own. The React adapter, `@typed-grid-areas/react`,
|
|
11
11
|
renders a definition as typed slot components (`<Card>`, `<Card.icon>`).
|
|
12
12
|
|
|
13
|
+
[Docs](https://michaelbuss.github.io/typed-grid-areas/) ·
|
|
14
|
+
[Try it in your browser](https://michaelbuss.github.io/typed-grid-areas/try-it/)
|
|
15
|
+
|
|
13
16
|
## Install
|
|
14
17
|
|
|
15
18
|
```sh
|
|
@@ -22,6 +25,20 @@ npm i typed-grid-areas @typed-grid-areas/react
|
|
|
22
25
|
Moving from `typed-grid-areas/react` (0.1)? Install `@typed-grid-areas/react`
|
|
23
26
|
and import `createGridComponent` from it instead; nothing else changes.
|
|
24
27
|
|
|
28
|
+
### Agent skill
|
|
29
|
+
|
|
30
|
+
The `typed-grid-areas` package ships an agent skill (in its
|
|
31
|
+
`skills/typed-grid-areas/`) that walks a coding agent through writing,
|
|
32
|
+
converting and debugging layouts, versioned with each release. Enable it in your project with
|
|
33
|
+
[TanStack Intent](https://tanstack.com/intent):
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npx @tanstack/intent@latest install
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The first run asks which packages' skills to enable, so it needs an
|
|
40
|
+
interactive terminal, and Intent needs Node.js 20.12 or newer.
|
|
41
|
+
|
|
25
42
|
## At a glance
|
|
26
43
|
|
|
27
44
|
```tsx
|
|
@@ -210,7 +227,7 @@ All generated CSS sits in the `typed-grid-areas` cascade layer, so your own
|
|
|
210
227
|
unlayered classes on the grid or a slot (say `justify-self`) always win. The
|
|
211
228
|
one exception is hiding: it is `!important`, so a `display` class on a slot
|
|
212
229
|
can't bring back an area the current layout leaves out
|
|
213
|
-
([ADR 0003](docs/adr/0003-hidden-areas-are-important.md)).
|
|
230
|
+
([ADR 0003](https://github.com/MichaelBuss/typed-grid-areas/blob/main/docs/adr/0003-hidden-areas-are-important.md)).
|
|
214
231
|
|
|
215
232
|
## Breakpoints
|
|
216
233
|
|
|
@@ -246,7 +263,7 @@ wherever it's placed. A container query can't measure the element it
|
|
|
246
263
|
styles, so a grid with breakpoints renders inside its own size container: a
|
|
247
264
|
wrapper `div` with `container-type: inline-size` and a container name unique
|
|
248
265
|
to the definition, which its `@container` queries target by name (see
|
|
249
|
-
[ADR 0002](docs/adr/0002-grid-owns-its-size-container.md)). Grids without
|
|
266
|
+
[ADR 0002](https://github.com/MichaelBuss/typed-grid-areas/blob/main/docs/adr/0002-grid-owns-its-size-container.md)). Grids without
|
|
250
267
|
breakpoints get no wrapper and are not size containers.
|
|
251
268
|
|
|
252
269
|
Inline-size containment has a cost: **a grid with breakpoints can't size to
|
|
@@ -403,6 +420,9 @@ Slots must be **direct children** of their grid (fragments and conditionals
|
|
|
403
420
|
are fine). Render an area's slot even while the current layout hides it;
|
|
404
421
|
leave it out only to make an optional area absent.
|
|
405
422
|
|
|
423
|
+
Grid components work with React Compiler and in Strict Mode, and the
|
|
424
|
+
adapter's tests run under both.
|
|
425
|
+
|
|
406
426
|
### Nesting: `nest`
|
|
407
427
|
|
|
408
428
|
A grid can fill another grid's area. `nest` makes the area's slot the root
|
|
@@ -1297,7 +1317,6 @@ import {
|
|
|
1297
1317
|
gridMarkup,
|
|
1298
1318
|
gridStyleTags,
|
|
1299
1319
|
insertGridStyle,
|
|
1300
|
-
isDevelopment,
|
|
1301
1320
|
} from "typed-grid-areas/adapter";
|
|
1302
1321
|
|
|
1303
1322
|
const cardGrid = defineLayout({
|
|
@@ -1323,12 +1342,19 @@ insertGridStyle(document, cardGrid);
|
|
|
1323
1342
|
const head = gridStyleTags([cardGrid]);
|
|
1324
1343
|
|
|
1325
1344
|
// In development, after each render: what to warn about the grid's slots.
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1345
|
+
try {
|
|
1346
|
+
if (process.env.NODE_ENV === "development") {
|
|
1347
|
+
const checkSlots = createSlotCheck(cardGrid, {
|
|
1348
|
+
strayChildRemedy: "make it a slot with asChild",
|
|
1349
|
+
});
|
|
1350
|
+
const gridElement = document.querySelector(`[data-grid-id="${markup.id}"]`);
|
|
1351
|
+
if (gridElement !== null) {
|
|
1352
|
+
checkSlots(gridElement).forEach(warning => console.warn(warning));
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
} catch (error) {
|
|
1356
|
+
// Without a bundler, `process` may not exist: then this isn't development.
|
|
1357
|
+
if (!(error instanceof ReferenceError)) throw error;
|
|
1332
1358
|
}
|
|
1333
1359
|
```
|
|
1334
1360
|
|
|
@@ -1345,7 +1371,9 @@ id>">` in `<head>` (ahead of the page's other styles, reusing a tag the
|
|
|
1345
1371
|
`markup.cssKey` instead.
|
|
1346
1372
|
- **Slot check.** One check per grid instance; it reports a set of problems
|
|
1347
1373
|
once. `strayChildRemedy` says how your framework makes an element a slot.
|
|
1348
|
-
Gate it on your framework's development flag, or
|
|
1374
|
+
Gate it on your framework's development flag, or read
|
|
1375
|
+
`process.env.NODE_ENV` as above: bundlers replace it, so production builds
|
|
1376
|
+
drop the check. Behind a call, such as `isDevelopment()`, they keep it.
|
|
1349
1377
|
|
|
1350
1378
|
The main entry's `createSlots`, `generateCss` and `gridId` remain for
|
|
1351
1379
|
rendering by hand.
|
|
@@ -1367,8 +1395,8 @@ just build # compile each package's src/ into its dist/, as npm pack doe
|
|
|
1367
1395
|
Each runs every package's own script of that name (or via npm directly:
|
|
1368
1396
|
`npm test`, `npm run typecheck`, `npm run build`). Each package owns its
|
|
1369
1397
|
toolchain, down to its TypeScript version; see
|
|
1370
|
-
[docs/agents/workspaces.md](docs/agents/workspaces.md) for adding an adapter
|
|
1398
|
+
[docs/agents/workspaces.md](https://github.com/MichaelBuss/typed-grid-areas/blob/main/docs/agents/workspaces.md) for adding an adapter
|
|
1371
1399
|
and pinning its own TypeScript.
|
|
1372
1400
|
|
|
1373
1401
|
A change to a package carries a changeset (`npm run changeset`); see
|
|
1374
|
-
[docs/agents/release.md](docs/agents/release.md) for how releases ship.
|
|
1402
|
+
[docs/agents/release.md](https://github.com/MichaelBuss/typed-grid-areas/blob/main/docs/agents/release.md) for how releases ship.
|
package/dist/gridComponent.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { children, createEffect, mergeProps, sharedConfig, splitProps, } from "solid-js";
|
|
2
2
|
import { Dynamic, isServer, ssr, useAssets } from "solid-js/web";
|
|
3
|
-
import { createSlotCheck, gridMarkup, gridStyleTags, insertGridStyle,
|
|
3
|
+
import { createSlotCheck, gridMarkup, gridStyleTags, insertGridStyle, } from "typed-grid-areas/adapter";
|
|
4
4
|
/**
|
|
5
5
|
* What a server render has registered with `useAssets`, by render. The
|
|
6
6
|
* render's list of assets is internal to Solid; it's only used here as a
|
|
@@ -44,20 +44,31 @@ function createRoot(definition) {
|
|
|
44
44
|
grid = element;
|
|
45
45
|
local.ref?.(element);
|
|
46
46
|
};
|
|
47
|
-
// In development, check the slots after mount and whenever they change.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
// In development, check the slots after mount and whenever they change. Written out,
|
|
48
|
+
// not `isDevelopment()`, so production builds drop the check.
|
|
49
|
+
try {
|
|
50
|
+
if (process.env.NODE_ENV === "development") {
|
|
51
|
+
if (!isServer) {
|
|
52
|
+
const checkSlots = createSlotCheck(definition, {
|
|
53
|
+
strayChildRemedy: "make it a slot with `as`",
|
|
54
|
+
});
|
|
55
|
+
createEffect(() => {
|
|
56
|
+
resolved();
|
|
57
|
+
if (grid !== undefined) {
|
|
58
|
+
for (const warning of checkSlots(grid)) {
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
console.warn(warning);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
59
64
|
}
|
|
60
|
-
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
// Without a bundler, `process` may not exist: then this isn't development.
|
|
69
|
+
if (!(error instanceof ReferenceError)) {
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
61
72
|
}
|
|
62
73
|
const element = (<Dynamic component={local.as ?? "div"} {...others} {...gridElement.attributes} ref={ref}>
|
|
63
74
|
{resolved()}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Dynamic, createComponent, insert, isServer, mergeProps, spread, ssr, template, useAssets } from "solid-js/web";
|
|
2
2
|
import { children, createEffect, mergeProps as mergeProps$1, sharedConfig, splitProps } from "solid-js";
|
|
3
|
-
import { createSlotCheck, gridMarkup, gridStyleTags, insertGridStyle
|
|
3
|
+
import { createSlotCheck, gridMarkup, gridStyleTags, insertGridStyle } from "typed-grid-areas/adapter";
|
|
4
4
|
// src/gridComponent.tsx
|
|
5
5
|
var _tmpl$ = /*#__PURE__*/ template(`<div>`);
|
|
6
6
|
/**
|
|
@@ -46,12 +46,18 @@ function createRoot(definition) {
|
|
|
46
46
|
grid = element;
|
|
47
47
|
local.ref?.(element);
|
|
48
48
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
try {
|
|
50
|
+
if (process.env.NODE_ENV === "development") {
|
|
51
|
+
if (!isServer) {
|
|
52
|
+
const checkSlots = createSlotCheck(definition, { strayChildRemedy: "make it a slot with `as`" });
|
|
53
|
+
createEffect(() => {
|
|
54
|
+
resolved();
|
|
55
|
+
if (grid !== void 0) for (const warning of checkSlots(grid)) console.warn(warning);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (!(error instanceof ReferenceError)) throw error;
|
|
55
61
|
}
|
|
56
62
|
const element = createComponent(Dynamic, mergeProps({ get component() {
|
|
57
63
|
return local.as ?? "div";
|
package/package.json
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typed-grid-areas/solid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Solid adapter for typed-grid-areas: render a grid definition as typed slot components.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"css-grid",
|
|
7
|
+
"grid-template-areas",
|
|
8
|
+
"layout",
|
|
9
|
+
"typescript",
|
|
10
|
+
"solid"
|
|
11
|
+
],
|
|
5
12
|
"type": "module",
|
|
6
13
|
"license": "MIT",
|
|
7
14
|
"repository": {
|
|
@@ -9,7 +16,7 @@
|
|
|
9
16
|
"url": "git+https://github.com/MichaelBuss/typed-grid-areas.git",
|
|
10
17
|
"directory": "packages/solid"
|
|
11
18
|
},
|
|
12
|
-
"homepage": "https://github.
|
|
19
|
+
"homepage": "https://michaelbuss.github.io/typed-grid-areas/",
|
|
13
20
|
"bugs": {
|
|
14
21
|
"url": "https://github.com/MichaelBuss/typed-grid-areas/issues"
|
|
15
22
|
},
|
|
@@ -35,7 +42,7 @@
|
|
|
35
42
|
"solid-js": "^1.9.0"
|
|
36
43
|
},
|
|
37
44
|
"dependencies": {
|
|
38
|
-
"typed-grid-areas": "^0.
|
|
45
|
+
"typed-grid-areas": "^0.3.0"
|
|
39
46
|
},
|
|
40
47
|
"devDependencies": {
|
|
41
48
|
"@typed-grid-areas/acceptance": "*",
|