@vyriy/create 0.5.4 → 0.5.6
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/package.json +2 -16
- package/plan/plan.d.ts +0 -1
- package/plan/plan.js +1 -3
- package/plan/types.d.ts +0 -1
- package/preset/api.js +118 -5
- package/preset/fullstack.js +393 -12
- package/preset/gql.js +198 -34
- package/preset/library.js +346 -180
- package/preset/mfe.js +546 -16
- package/preset/rest.js +182 -6
- package/preset/spa.js +236 -7
- package/preset/ssg.js +266 -13
- package/preset/ssr.js +256 -10
- package/prompt/index.d.ts +0 -1
- package/prompt/index.js +0 -1
- package/prompt/scope.d.ts +0 -2
- package/prompt/scope.js +0 -2
package/preset/library.js
CHANGED
|
@@ -8,20 +8,83 @@ const agentsPath = [
|
|
|
8
8
|
resolve(presetDir, '../../../../AGENTS.md'),
|
|
9
9
|
].find(existsSync) ?? '';
|
|
10
10
|
const agentsContent = agentsPath ? readFileSync(agentsPath, 'utf8') : '';
|
|
11
|
-
export const library = (options) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
export const library = (options) => ({
|
|
12
|
+
'README.md': `# Library
|
|
13
|
+
|
|
14
|
+
Reusable React component library for library applications.
|
|
15
|
+
|
|
16
|
+
This repository is a Yarn workspace with shared package tooling, Storybook documentation, and Jest tests.
|
|
17
|
+
|
|
18
|
+
## Packages
|
|
19
|
+
|
|
20
|
+
### \`@library/components\`
|
|
21
|
+
|
|
22
|
+
React components exported from \`packages/components\`.
|
|
23
|
+
|
|
24
|
+
\`\`\`tsx
|
|
25
|
+
import { Button } from '@library/components';
|
|
26
|
+
\`\`\`
|
|
27
|
+
|
|
28
|
+
The package currently includes:
|
|
29
|
+
|
|
30
|
+
| Component | Description |
|
|
31
|
+
| --------- | ------------------------------------------------------- |
|
|
32
|
+
| \`Button\` | Styled HTML button with primary and secondary variants. |
|
|
33
|
+
|
|
34
|
+
## Development
|
|
35
|
+
|
|
36
|
+
Install dependencies:
|
|
37
|
+
|
|
38
|
+
\`\`\`bash
|
|
39
|
+
yarn install
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
Run Storybook:
|
|
43
|
+
|
|
44
|
+
\`\`\`bash
|
|
45
|
+
yarn storybook
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
Run the full validation suite:
|
|
49
|
+
|
|
50
|
+
\`\`\`bash
|
|
51
|
+
yarn check
|
|
52
|
+
\`\`\`
|
|
53
|
+
|
|
54
|
+
Focused commands are also available:
|
|
55
|
+
|
|
56
|
+
\`\`\`bash
|
|
57
|
+
yarn lint
|
|
58
|
+
yarn build
|
|
59
|
+
yarn test
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
Storybook renders the package documentation from the repository README files:
|
|
65
|
+
|
|
66
|
+
- \`README.md\` for the library overview.
|
|
67
|
+
- \`packages/components/README.md\` for the components package.
|
|
68
|
+
- \`packages/components/button/README.md\` for Button usage and props.
|
|
69
|
+
|
|
70
|
+
## Project Guidance
|
|
71
|
+
|
|
72
|
+
These articles describe the development approach behind this preset and provide practical guidance for evolving a project on top of it:
|
|
73
|
+
|
|
74
|
+
- [Calm Development Environment: Node.js, Corepack, Yarn and Static Preview](https://vyriy.dev/blog/calm-development-setup/) - how to keep the local development environment predictable and easy to reproduce.
|
|
75
|
+
- [Calm App Structure for the Vyriy Ecosystem](https://vyriy.dev/blog/vyriy-calm-app-structure/) - a practical project structure for Vyriy applications: shared configs, small packages, thin workspaces, Storybook docs, tests, and deployable entry points.
|
|
76
|
+
- [Calm Component Structure](https://vyriy.dev/blog/calm-component-structure/) - how to organize component code, tests, stories, and public exports.
|
|
77
|
+
- [Storybook as Project Documentation](https://vyriy.dev/blog/storybook-as-project-documentation/) - how to use Storybook as living project documentation and a component playground.
|
|
78
|
+
`,
|
|
79
|
+
'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
17
80
|
import ReadMe from './README.md?raw';
|
|
18
81
|
|
|
19
|
-
<Meta title="
|
|
82
|
+
<Meta title="Library" />
|
|
20
83
|
|
|
21
84
|
<Markdown>{ReadMe}</Markdown>
|
|
22
85
|
`,
|
|
23
|
-
|
|
24
|
-
|
|
86
|
+
'AGENTS.md': agentsContent,
|
|
87
|
+
'.editorconfig': `# https://editorconfig.org
|
|
25
88
|
root = true
|
|
26
89
|
|
|
27
90
|
[*]
|
|
@@ -56,7 +119,7 @@ indent_size = 2
|
|
|
56
119
|
[*.sh]
|
|
57
120
|
indent_size = 2
|
|
58
121
|
`,
|
|
59
|
-
|
|
122
|
+
'.gitignore': `.yarn/*
|
|
60
123
|
!.yarn/cache
|
|
61
124
|
!.yarn/patches
|
|
62
125
|
!.yarn/plugins
|
|
@@ -78,15 +141,15 @@ cdk.context.json
|
|
|
78
141
|
|
|
79
142
|
!/**/.gitkeep
|
|
80
143
|
`,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
144
|
+
'.npmrc': 'engine-strict=true\n',
|
|
145
|
+
'.nvmrc': 'lts/krypton\n',
|
|
146
|
+
'.yarnrc.yml': 'nodeLinker: node-modules\nnpmMinimalAgeGate: 0\n',
|
|
147
|
+
'.husky/commit-msg': '#!/bin/sh\n',
|
|
148
|
+
'.husky/post-checkout': '#!/bin/sh\n\nyarn\n',
|
|
149
|
+
'.husky/post-merge': '#!/bin/sh\n\nyarn\n',
|
|
150
|
+
'.husky/pre-commit': '#!/bin/sh\n\nyarn check\n',
|
|
151
|
+
'.husky/pre-push': '#!/bin/sh\n\nyarn check\n',
|
|
152
|
+
'.storybook/main.ts': `import config from '@vyriy/storybook-config';
|
|
90
153
|
import { path } from '@vyriy/path';
|
|
91
154
|
|
|
92
155
|
export default {
|
|
@@ -97,162 +160,110 @@ export default {
|
|
|
97
160
|
],
|
|
98
161
|
};
|
|
99
162
|
`,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
name: packageName,
|
|
205
|
-
version: '0.0.0',
|
|
206
|
-
description: options.description,
|
|
207
|
-
private: true,
|
|
208
|
-
type: 'module',
|
|
209
|
-
main: 'index.js',
|
|
210
|
-
dependencies: {
|
|
211
|
-
'@vyriy/cn': `^${packageJson.version}`,
|
|
212
|
-
},
|
|
213
|
-
peerDependencies: {
|
|
214
|
-
react: packageJson.peerDependencies.react,
|
|
215
|
-
},
|
|
216
|
-
}, null, 2) + '\n',
|
|
217
|
-
[`packages/${options.name}/README.md`]: `# ${packageName}\n\n${options.description}\n`,
|
|
218
|
-
[`packages/${options.name}/doc.mdx`]: `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
219
|
-
import ReadMe from './README.md?raw';
|
|
220
|
-
|
|
221
|
-
<Meta title="UI/Button" />
|
|
222
|
-
|
|
223
|
-
<Markdown>{ReadMe}</Markdown>
|
|
224
|
-
`,
|
|
225
|
-
[`packages/${options.name}/index.ts`]: "export * from './button.js';\nexport type * from './types.js';\n",
|
|
226
|
-
[`packages/${options.name}/types.ts`]: `import type { ComponentProps, FC } from 'react';
|
|
227
|
-
|
|
228
|
-
export type ButtonProps = ComponentProps<'button'> & {
|
|
229
|
-
readonly variant?: 'primary' | 'secondary';
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
export type ButtonType = FC<ButtonProps>;
|
|
233
|
-
`,
|
|
234
|
-
[`packages/${options.name}/button.tsx`]: `import { cn } from '@vyriy/cn';
|
|
235
|
-
|
|
236
|
-
import type { ButtonType } from './types.js';
|
|
237
|
-
|
|
238
|
-
import './button.scss';
|
|
239
|
-
|
|
240
|
-
export const Button: ButtonType = ({ className, variant = 'primary', ...props }) => (
|
|
241
|
-
<button type="button" className={cn('button', \`button--\${variant}\`, className)} {...props} />
|
|
242
|
-
);
|
|
243
|
-
`,
|
|
244
|
-
[`packages/${options.name}/index.test.ts`]: `import { describe, expect, it } from '@jest/globals';
|
|
245
|
-
|
|
246
|
-
import { Button } from './button.js';
|
|
247
|
-
import { Button as PublicButton } from './index.js';
|
|
248
|
-
|
|
249
|
-
describe('ui entry point', () => {
|
|
250
|
-
it('exports Button', () => {
|
|
251
|
-
expect(PublicButton).toBe(Button);
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
`,
|
|
255
|
-
[`packages/${options.name}/button.scss`]: `.button {
|
|
163
|
+
'.storybook/preview.tsx': "export { default } from '@vyriy/storybook-config/preview';\n",
|
|
164
|
+
'yarn.lock': '',
|
|
165
|
+
'tsconfig.json': JSON.stringify({
|
|
166
|
+
extends: '@vyriy/typescript-config/index.json',
|
|
167
|
+
include: [
|
|
168
|
+
'.storybook/**/*.ts',
|
|
169
|
+
'.storybook/**/*.tsx',
|
|
170
|
+
'packages/**/*.ts',
|
|
171
|
+
'packages/**/*.tsx',
|
|
172
|
+
'workspaces/**/*.ts',
|
|
173
|
+
'workspaces/**/*.tsx',
|
|
174
|
+
'*.ts',
|
|
175
|
+
],
|
|
176
|
+
}, null, 2) + '\n',
|
|
177
|
+
'prettier.config.ts': "export { default } from '@vyriy/prettier-config';\n",
|
|
178
|
+
'.prettierignore': 'node_modules\ndist\ncoverage\nstorybook-static\nconsumer\n',
|
|
179
|
+
'eslint.config.ts': "export { default } from '@vyriy/eslint-config';\n",
|
|
180
|
+
'jest.config.ts': "export { default } from '@vyriy/jest-config';\n",
|
|
181
|
+
'package.json': JSON.stringify({
|
|
182
|
+
name: options.name,
|
|
183
|
+
version: '0.0.0',
|
|
184
|
+
description: options.description,
|
|
185
|
+
private: true,
|
|
186
|
+
type: 'module',
|
|
187
|
+
agents: './AGENTS.md',
|
|
188
|
+
packageManager: packageJson.packageManager,
|
|
189
|
+
engines: {
|
|
190
|
+
node: packageJson.engines.node,
|
|
191
|
+
},
|
|
192
|
+
workspaces: [
|
|
193
|
+
'packages/*',
|
|
194
|
+
],
|
|
195
|
+
license: 'MIT',
|
|
196
|
+
repository: {
|
|
197
|
+
type: 'git',
|
|
198
|
+
url: `https://github.com/${options.name}/${options.name}`,
|
|
199
|
+
},
|
|
200
|
+
scripts: {
|
|
201
|
+
storybook: 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook dev -p 6006 --disable-telemetry',
|
|
202
|
+
check: 'run-s lint build test',
|
|
203
|
+
fix: "run-s 'fix:*'",
|
|
204
|
+
lint: "run-s 'lint:*'",
|
|
205
|
+
build: "run-s 'build:*'",
|
|
206
|
+
test: "run-s 'test:*'",
|
|
207
|
+
'fix:prettier': 'prettier . --write',
|
|
208
|
+
'fix:eslint': 'eslint . --fix',
|
|
209
|
+
'fix:stylelint': 'stylelint "**/*.{css,scss}" --fix',
|
|
210
|
+
'lint:ts': 'tsc',
|
|
211
|
+
'lint:prettier': 'prettier . --check',
|
|
212
|
+
'lint:eslint': 'eslint .',
|
|
213
|
+
'lint:stylelint': 'stylelint "**/*.{css,scss}"',
|
|
214
|
+
'build:dist': 'rimraf dist && tsc -p tsconfig.build.json && vd',
|
|
215
|
+
'build:storybook': 'cross-env STORYBOOK_DISABLE_TELEMETRY=1 storybook build --quiet --disable-telemetry',
|
|
216
|
+
'test:jest': 'jest',
|
|
217
|
+
postinstall: 'husky',
|
|
218
|
+
},
|
|
219
|
+
dependencies: {
|
|
220
|
+
'@vyriy/typescript-config': `^${packageJson.version}`,
|
|
221
|
+
typescript: packageJson.peerDependencies.typescript,
|
|
222
|
+
'@vyriy/prettier-config': `^${packageJson.version}`,
|
|
223
|
+
prettier: packageJson.peerDependencies.prettier,
|
|
224
|
+
'@vyriy/eslint-config': `^${packageJson.version}`,
|
|
225
|
+
eslint: packageJson.peerDependencies.eslint,
|
|
226
|
+
'@vyriy/jest-config': `^${packageJson.version}`,
|
|
227
|
+
jest: packageJson.peerDependencies.jest,
|
|
228
|
+
'@vyriy/storybook-config': `^${packageJson.version}`,
|
|
229
|
+
storybook: packageJson.peerDependencies.storybook,
|
|
230
|
+
'@vyriy/path': `^${packageJson.version}`,
|
|
231
|
+
husky: packageJson.peerDependencies.husky,
|
|
232
|
+
'npm-run-all2': packageJson.peerDependencies['npm-run-all2'],
|
|
233
|
+
'cross-env': packageJson.peerDependencies['cross-env'],
|
|
234
|
+
react: packageJson.peerDependencies.react,
|
|
235
|
+
'react-dom': packageJson.peerDependencies['react-dom'],
|
|
236
|
+
'@types/react': packageJson.peerDependencies['@types/react'],
|
|
237
|
+
'@types/react-dom': packageJson.peerDependencies['@types/react-dom'],
|
|
238
|
+
'@vyriy/stylelint-config': `^${packageJson.version}`,
|
|
239
|
+
stylelint: packageJson.peerDependencies.stylelint,
|
|
240
|
+
rimraf: packageJson.peerDependencies.rimraf,
|
|
241
|
+
'@vyriy/dist': `^${packageJson.version}`,
|
|
242
|
+
},
|
|
243
|
+
}, null, 2) + '\n',
|
|
244
|
+
'tsconfig.build.json': JSON.stringify({
|
|
245
|
+
extends: './tsconfig.json',
|
|
246
|
+
include: [
|
|
247
|
+
'packages/**/*.ts',
|
|
248
|
+
'packages/**/*.tsx',
|
|
249
|
+
'packages/**/*.json',
|
|
250
|
+
],
|
|
251
|
+
exclude: [
|
|
252
|
+
'**/*.test.ts',
|
|
253
|
+
'**/*.test.tsx',
|
|
254
|
+
'**/*.stories.ts',
|
|
255
|
+
'**/*.stories.tsx',
|
|
256
|
+
],
|
|
257
|
+
compilerOptions: {
|
|
258
|
+
rootDir: './packages',
|
|
259
|
+
outDir: './dist',
|
|
260
|
+
noEmit: false,
|
|
261
|
+
declaration: true,
|
|
262
|
+
allowImportingTsExtensions: false,
|
|
263
|
+
},
|
|
264
|
+
}, null, 2) + '\n',
|
|
265
|
+
'stylelint.config.ts': "export { default } from '@vyriy/stylelint-config';\n",
|
|
266
|
+
'packages/components/button/button.scss': `.button {
|
|
256
267
|
border: 1px solid transparent;
|
|
257
268
|
border-radius: 6px;
|
|
258
269
|
cursor: pointer;
|
|
@@ -271,13 +282,12 @@ describe('ui entry point', () => {
|
|
|
271
282
|
color: #24292f;
|
|
272
283
|
}
|
|
273
284
|
`,
|
|
274
|
-
|
|
275
|
-
[`packages/${options.name}/button.stories.tsx`]: `import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
285
|
+
'packages/components/button/button.stories.tsx': `import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
276
286
|
|
|
277
287
|
import { Button } from './button.js';
|
|
278
288
|
|
|
279
289
|
const meta = {
|
|
280
|
-
title: '
|
|
290
|
+
title: 'Components/Button',
|
|
281
291
|
component: Button,
|
|
282
292
|
args: {
|
|
283
293
|
children: 'Button',
|
|
@@ -321,7 +331,7 @@ export const Secondary: Story = {
|
|
|
321
331
|
},
|
|
322
332
|
};
|
|
323
333
|
`,
|
|
324
|
-
|
|
334
|
+
'packages/components/button/button.test.tsx': `import type { ReactElement } from 'react';
|
|
325
335
|
import { describe, expect, it } from '@jest/globals';
|
|
326
336
|
|
|
327
337
|
import { Button } from './button.js';
|
|
@@ -352,5 +362,161 @@ describe('Button', () => {
|
|
|
352
362
|
});
|
|
353
363
|
});
|
|
354
364
|
`,
|
|
355
|
-
};
|
|
365
|
+
'packages/components/button/button.tsx': `import { cn } from '@vyriy/cn';
|
|
366
|
+
|
|
367
|
+
import type { ButtonType } from './types.js';
|
|
368
|
+
|
|
369
|
+
import './button.scss';
|
|
370
|
+
|
|
371
|
+
export const Button: ButtonType = ({ className, variant = 'primary', ...props }) => (
|
|
372
|
+
<button type="button" className={cn('button', \`button--\${variant}\`, className)} {...props} />
|
|
373
|
+
);
|
|
374
|
+
`,
|
|
375
|
+
'packages/components/button/doc.mdx': `import { Canvas, Controls, Meta, Markdown, Stories } from '@storybook/addon-docs/blocks';
|
|
376
|
+
import ReadMe from './README.md?raw';
|
|
377
|
+
import * as ButtonStories from './button.stories';
|
|
378
|
+
|
|
379
|
+
<Meta of={ButtonStories} />
|
|
380
|
+
|
|
381
|
+
<Markdown>{ReadMe}</Markdown>
|
|
382
|
+
|
|
383
|
+
<Canvas of={ButtonStories.Primary} />
|
|
384
|
+
|
|
385
|
+
<Controls of={ButtonStories.Primary} />
|
|
386
|
+
|
|
387
|
+
<Stories />
|
|
388
|
+
`,
|
|
389
|
+
'packages/components/button/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
390
|
+
|
|
391
|
+
import { Button } from './button.js';
|
|
392
|
+
import { Button as PublicButton } from './index.js';
|
|
393
|
+
|
|
394
|
+
describe('ui entry point', () => {
|
|
395
|
+
it('exports Button', () => {
|
|
396
|
+
expect(PublicButton).toBe(Button);
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
`,
|
|
400
|
+
'packages/components/button/index.ts': `export * from './button.js';
|
|
401
|
+
export type * from './types.js';
|
|
402
|
+
`,
|
|
403
|
+
'packages/components/button/README.md': `# Button
|
|
404
|
+
|
|
405
|
+
\`Button\` is a lightweight React button component with library styling and native button props.
|
|
406
|
+
|
|
407
|
+
## Import
|
|
408
|
+
|
|
409
|
+
\`\`\`tsx
|
|
410
|
+
import { Button } from '@library/components';
|
|
411
|
+
import type { ButtonProps } from '@library/components';
|
|
412
|
+
\`\`\`
|
|
413
|
+
|
|
414
|
+
## Usage
|
|
415
|
+
|
|
416
|
+
\`\`\`tsx
|
|
417
|
+
<Button>Save</Button>
|
|
418
|
+
\`\`\`
|
|
419
|
+
|
|
420
|
+
The primary variant is used by default. Use the secondary variant for lower-emphasis actions.
|
|
421
|
+
|
|
422
|
+
\`\`\`tsx
|
|
423
|
+
<Button variant="secondary">Cancel</Button>
|
|
424
|
+
\`\`\`
|
|
425
|
+
|
|
426
|
+
Native button props are supported and forwarded to the rendered \`<button>\`.
|
|
427
|
+
|
|
428
|
+
\`\`\`tsx
|
|
429
|
+
<Button type="submit" disabled>
|
|
430
|
+
Submit
|
|
431
|
+
</Button>
|
|
432
|
+
\`\`\`
|
|
433
|
+
|
|
434
|
+
Custom classes are composed with the component classes.
|
|
435
|
+
|
|
436
|
+
\`\`\`tsx
|
|
437
|
+
<Button className="settings-action">Open settings</Button>
|
|
438
|
+
\`\`\`
|
|
439
|
+
|
|
440
|
+
## Props
|
|
441
|
+
|
|
442
|
+
\`ButtonProps\` extends \`ComponentProps<'button'>\`.
|
|
443
|
+
|
|
444
|
+
| Prop | Type | Default | Description |
|
|
445
|
+
| ----------- | ----------- | ------------ | -------------------------------------------------- | -------------------------- |
|
|
446
|
+
| \`variant\` | \`'primary' | 'secondary'\` | \`'primary'\` | Controls the visual style. |
|
|
447
|
+
| \`className\` | \`string\` | - | Adds custom classes alongside the library classes. |
|
|
448
|
+
| \`children\` | \`ReactNode\` | - | Button content. |
|
|
449
|
+
`,
|
|
450
|
+
'packages/components/button/types.ts': `import type { ComponentProps, FC } from 'react';
|
|
451
|
+
|
|
452
|
+
export type ButtonProps = ComponentProps<'button'> & {
|
|
453
|
+
readonly variant?: 'primary' | 'secondary';
|
|
356
454
|
};
|
|
455
|
+
|
|
456
|
+
export type ButtonType = FC<ButtonProps>;
|
|
457
|
+
`,
|
|
458
|
+
'packages/components/doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
|
|
459
|
+
import ReadMe from './README.md?raw';
|
|
460
|
+
|
|
461
|
+
<Meta title="Components" />
|
|
462
|
+
|
|
463
|
+
<Markdown>{ReadMe}</Markdown>
|
|
464
|
+
`,
|
|
465
|
+
'packages/components/index.test.ts': `import { describe, expect, it } from '@jest/globals';
|
|
466
|
+
|
|
467
|
+
import { Button } from './button/index.js';
|
|
468
|
+
import { Button as PublicButton } from './index.js';
|
|
469
|
+
|
|
470
|
+
describe('components entry point', () => {
|
|
471
|
+
it('exports Button', () => {
|
|
472
|
+
expect(PublicButton).toBe(Button);
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
`,
|
|
476
|
+
'packages/components/index.ts': `export * from './button/index.js';
|
|
477
|
+
`,
|
|
478
|
+
'packages/components/package.json': `{
|
|
479
|
+
"name": "@${options.name}/components",
|
|
480
|
+
"version": "0.0.0",
|
|
481
|
+
"description": "Calm cloud-ready application",
|
|
482
|
+
"private": true,
|
|
483
|
+
"type": "module",
|
|
484
|
+
"dependencies": {
|
|
485
|
+
"@vyriy/cn": "^${packageJson.version}"
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
`,
|
|
489
|
+
'packages/components/README.md': `# Components
|
|
490
|
+
|
|
491
|
+
Reusable React components for library applications.
|
|
492
|
+
|
|
493
|
+
## Exports
|
|
494
|
+
|
|
495
|
+
\`\`\`tsx
|
|
496
|
+
import { Button } from '@library/components';
|
|
497
|
+
import type { ButtonProps } from '@library/components';
|
|
498
|
+
\`\`\`
|
|
499
|
+
|
|
500
|
+
## Components
|
|
501
|
+
|
|
502
|
+
### Button
|
|
503
|
+
|
|
504
|
+
\`Button\` renders an SSR-friendly HTML \`button\` with library styles and two visual variants.
|
|
505
|
+
|
|
506
|
+
\`\`\`tsx
|
|
507
|
+
import { Button } from '@library/components';
|
|
508
|
+
|
|
509
|
+
export const SaveAction = () => <Button onClick={() => undefined}>Save</Button>;
|
|
510
|
+
\`\`\`
|
|
511
|
+
|
|
512
|
+
Use \`variant="secondary"\` for lower-emphasis actions:
|
|
513
|
+
|
|
514
|
+
\`\`\`tsx
|
|
515
|
+
<Button variant="secondary">Cancel</Button>
|
|
516
|
+
\`\`\`
|
|
517
|
+
|
|
518
|
+
See the Button documentation for the full component API.
|
|
519
|
+
`,
|
|
520
|
+
'packages/components/styles.d.ts': `declare module '*.scss';
|
|
521
|
+
`,
|
|
522
|
+
});
|