@astryxdesign/cli 0.7.5-canary.d9b43cf → 0.7.5-canary.daab0b6

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.
@@ -0,0 +1,47 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Contract test for the Tokenizer showcase block.
5
+ * @input The shipped TokenizerShowcase block source.
6
+ * @output Guards the block's search source: typing in the showcase must list
7
+ * matching tags rather than an empty menu.
8
+ * @position CLI template regression coverage; runs in the node test project.
9
+ * The block is the hero example of the Tokenizer docs page. Like the other
10
+ * template contract tests here it reads the block's source instead of
11
+ * importing it, so it needs no built `@astryxdesign/core`.
12
+ */
13
+
14
+ import fs from 'node:fs';
15
+ import path from 'node:path';
16
+ import {fileURLToPath} from 'node:url';
17
+ import {describe, expect, it} from 'vitest';
18
+
19
+ const sourcePath = path.resolve(
20
+ path.dirname(fileURLToPath(import.meta.url)),
21
+ '../../assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx',
22
+ );
23
+ const source = fs.readFileSync(sourcePath, 'utf8');
24
+
25
+ // Evaluate the block's tag list and search source on their own, with the
26
+ // type annotations removed, so the test exercises the shipped logic.
27
+ function loadSearchSource() {
28
+ const tags = source.match(/const tags[^=]*=\s*(\[[\s\S]*?\n\]);/)?.[1];
29
+ const searchSource = source.match(
30
+ /const source[^=]*=\s*(\{[\s\S]*?\n\});/,
31
+ )?.[1];
32
+ if (tags == null || searchSource == null) {
33
+ throw new Error('TokenizerShowcase no longer declares `tags` and `source`');
34
+ }
35
+ const untyped = searchSource.replace(/\((\w+):\s*string\)/g, '($1)');
36
+ return new Function(`const tags = ${tags}; return ${untyped};`)();
37
+ }
38
+
39
+ describe('Tokenizer showcase block', () => {
40
+ it('lists the tags that match a typed query, ignoring case', async () => {
41
+ const {search, bootstrap} = loadSearchSource();
42
+ const labels = async query => (await search(query)).map(tag => tag.label);
43
+ expect(await labels('mar')).toEqual(['Marketing']);
44
+ expect(await labels('A')).toEqual(['Marketing', 'Research', 'Sales']);
45
+ expect((await bootstrap()).length).toBeGreaterThan(0);
46
+ });
47
+ });
@@ -57,7 +57,8 @@ export const docs = {
57
57
  ['icons', 'Shallow-merged: child icons override matching names from the base.'],
58
58
  ['indicators', 'Shallow-merged: child indicators override matching names from the base.'],
59
59
  ['onDark, onLight', "Deep-merged per surface: the base's resolved surface first, then the child's overrides."],
60
- ['typography, motion, radius, color', 'Child config replaces base entirely (these are scale inputs, not additive).'],
60
+ ['motion', "Field by field: the child's `fast`, `medium` and `ratio` regenerate the fast and medium duration tokens; `slow` and `easing` left unset keep the base theme's tokens, so an inherited slow band stays at the base's ratio."],
61
+ ['typography, radius, color', 'Child config replaces base entirely (these are scale inputs, not additive).'],
61
62
  ['adaptations', 'Width-breakpoint overrides merge by fixed name. Inherited ordered rules keep their relative order; child rules append and re-resolve against the child root axes.'],
62
63
  ]},
63
64
  {type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `{@command theme build}` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it. A base that is not a theme (most often an import that missed) throws when `defineTheme` runs, rather than producing a theme that silently inherits nothing."},
@@ -101,11 +101,34 @@ export const brandTheme = defineTheme({
101
101
  },
102
102
  });`,
103
103
  },
104
+ {
105
+ type: 'prose',
106
+ text: "An entry can also be a function of the request, so the theme maps Icon's size to its icon library's own props or artwork. `Icon` calls it with `{size, variant}`, where `size` is the size it renders at (`xsm`, `sm`, `md`, or `lg`: an explicit `size`, else the owning component's default, else `md`). Reads that return one node — `getIcon()`, `useIcon()`, `getIconRegistry()`, and the theme's `icons` field — call it with `{size: 'md'}`. The same entry shape works in `registerIcons()`.",
107
+ },
108
+ {
109
+ type: 'code',
110
+ lang: 'tsx',
111
+ label: 'A size-aware icon entry',
112
+ code: `import {defineTheme} from '@astryxdesign/core/theme';
113
+ import {Info} from 'lucide-react';
114
+
115
+ export const brandTheme = defineTheme({
116
+ name: 'brand',
117
+ icons: {
118
+ // A heavier stroke keeps the small size legible.
119
+ info: ({size}) => <Info strokeWidth={size === 'sm' || size === 'xsm' ? 2.5 : 2} />,
120
+ },
121
+ });`,
122
+ },
123
+ {
124
+ type: 'prose',
125
+ text: 'Keep the function pure and synchronous: it computes its result from the request only, with no hooks, DOM or SVG measurement, browser globals, network access, mutable module state, or side effects. Its result is final. Returning `null` draws no glyph instead of falling back to a registered or built-in icon, while a `null` or `undefined` node entry still falls back. A child theme that sets an entry for a key replaces the inherited entry for that key.',
126
+ },
104
127
  ],
105
128
  },
106
129
  {
107
130
  title: 'Component and Library Icons',
108
- category: 'foundations',
131
+ category: 'foundations',
109
132
  content: [
110
133
  {
111
134
  type: 'prose',
@@ -6,16 +6,23 @@ import {useState} from 'react';
6
6
  import {Tokenizer} from '@astryxdesign/core/Tokenizer';
7
7
  import type {SearchableItem, SearchSource} from '@astryxdesign/core/Typeahead';
8
8
 
9
+ const tags: SearchableItem[] = [
10
+ {id: '1', label: 'Design'},
11
+ {id: '2', label: 'Engineering'},
12
+ {id: '3', label: 'Marketing'},
13
+ {id: '4', label: 'Product'},
14
+ {id: '5', label: 'Research'},
15
+ {id: '6', label: 'Sales'},
16
+ ];
17
+
9
18
  const source: SearchSource = {
10
- search: () => [],
11
- bootstrap: () => [],
19
+ search: (query: string) =>
20
+ tags.filter(tag => tag.label.toLowerCase().includes(query.toLowerCase())),
21
+ bootstrap: () => tags,
12
22
  };
13
23
 
14
24
  export default function TokenizerShowcase() {
15
- const [value, setValue] = useState<SearchableItem[]>([
16
- {id: '1', label: 'Design'},
17
- {id: '2', label: 'Engineering'},
18
- ]);
25
+ const [value, setValue] = useState<SearchableItem[]>([tags[0], tags[1]]);
19
26
  return (
20
27
  <div style={{display: 'grid', gridTemplateColumns: 'minmax(0, 400px)'}}>
21
28
  <Tokenizer
@@ -91,9 +91,11 @@ export const myTheme = defineTheme({
91
91
 
92
92
  /**
93
93
  * Start from another theme instead of the defaults. Tokens are copied then
94
- * overridden, `components` deep-merge, `icons` shallow-merge — but the scale
95
- * configs below REPLACE the base's rather than merging, because they are
96
- * inputs to a generator, not values.
94
+ * overridden, `components` deep-merge, `icons` shallow-merge — but the
95
+ * typography, radius and color scale configs below REPLACE the base's rather
96
+ * than merging, because they are inputs to a generator, not values. `motion`
97
+ * inherits field by field: `fast`, `medium` and `ratio` regenerate the fast
98
+ * and medium durations, and a `slow` or `easing` left unset keeps the base's.
97
99
  *
98
100
  * Reference: `astryx theme list` (themes you can install and extend).
99
101
  */
@@ -312,10 +314,12 @@ export const myTheme = defineTheme({
312
314
 
313
315
  /**
314
316
  * Swap the artwork behind semantic icon names — every component that asks
315
- * for `check`, `close`, `chevron-down` gets yours.
317
+ * for `check`, `close`, `chevron-down` gets yours. An entry may also be a
318
+ * pure function of `{size, variant}` that picks artwork for the size Icon
319
+ * renders at.
316
320
  * Reference: `astryx docs icons` lists the names.
317
321
  */
318
- // icons: {check: <MyCheck />, close: <MyClose />},
322
+ // icons: {check: <MyCheck />, info: ({size}) => <MyInfo bold={size === 'sm'} />},
319
323
 
320
324
  /**
321
325
  * Replace the small components that DRAW control state — the checkbox box,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.7.5-canary.d9b43cf",
3
+ "version": "0.7.5-canary.daab0b6",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -111,10 +111,10 @@
111
111
  "zod": "^4.4.3"
112
112
  },
113
113
  "peerDependencies": {
114
- "@astryxdesign/charts": "0.7.5-canary.d9b43cf",
115
- "@astryxdesign/core": "0.7.5-canary.d9b43cf",
116
- "@astryxdesign/lab": "0.7.5-canary.d9b43cf",
117
- "@astryxdesign/theme-neutral": "0.7.5-canary.d9b43cf"
114
+ "@astryxdesign/charts": "0.7.5-canary.daab0b6",
115
+ "@astryxdesign/core": "0.7.5-canary.daab0b6",
116
+ "@astryxdesign/lab": "0.7.5-canary.daab0b6",
117
+ "@astryxdesign/theme-neutral": "0.7.5-canary.daab0b6"
118
118
  },
119
119
  "peerDependenciesMeta": {
120
120
  "@astryxdesign/charts": {
@@ -131,10 +131,10 @@
131
131
  }
132
132
  },
133
133
  "devDependencies": {
134
- "@astryxdesign/charts": "0.7.5-canary.d9b43cf",
135
- "@astryxdesign/core": "0.7.5-canary.d9b43cf",
136
- "@astryxdesign/lab": "0.7.5-canary.d9b43cf",
137
- "@astryxdesign/theme-neutral": "0.7.5-canary.d9b43cf",
134
+ "@astryxdesign/charts": "0.7.5-canary.daab0b6",
135
+ "@astryxdesign/core": "0.7.5-canary.daab0b6",
136
+ "@astryxdesign/lab": "0.7.5-canary.daab0b6",
137
+ "@astryxdesign/theme-neutral": "0.7.5-canary.daab0b6",
138
138
  "@heroicons/react": "^2.2.0",
139
139
  "@stylexjs/stylex": "^0.19.0",
140
140
  "@types/babel__core": "^7.20.5",