@soroush.design/cli 0.2.0 → 0.3.0-alpha.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 +6 -4
- package/dist/bin.mjs +2 -9
- package/dist/index.d.mts +19 -27
- package/dist/index.mjs +1 -1
- package/dist/init-D8jcA_md.mjs +1279 -0
- package/dist/{io-dfx17dYF.mjs → io-CcfotW1X.mjs} +105 -883
- package/dist/migrate-jUWXX1hA.mjs +22239 -0
- package/package.json +23 -22
- package/templates/astro/js/base/README.md +4 -3
- package/templates/astro/js/base/astro.config.mjs +16 -1
- package/templates/astro/js/base/src/components/About.jsx +2 -2
- package/templates/astro/js/base/src/components/Counter.jsx +3 -3
- package/templates/astro/js/base/src/components/Greeting.jsx +1 -1
- package/templates/astro/js/base/src/components/Header.jsx +6 -6
- package/templates/astro/js/base/src/components/Home.jsx +6 -6
- package/templates/astro/js/base/src/components/Home.test.jsx +5 -1
- package/templates/astro/js/base/src/components/NotFound.jsx +3 -3
- package/templates/astro/js/base/src/components/SchemeSwitch.jsx +4 -4
- package/templates/astro/js/base/src/layouts/Layout.astro +24 -13
- package/templates/astro/js/base/src/theme/Island.jsx +1 -1
- package/templates/astro/js/sample-data/src/components/ItemDetails.jsx +3 -3
- package/templates/astro/js/sample-data/src/components/ItemList.jsx +3 -3
- package/templates/astro/js/sample-data/src/components/StatusChip.jsx +1 -1
- package/templates/astro/js/with/jotai/src/components/Counter.jsx +3 -3
- package/templates/astro/js/with/react-hook-form/src/components/Form.jsx +4 -4
- package/templates/astro/js/with/redux-toolkit/src/components/Counter.jsx +3 -3
- package/templates/astro/js/with/zustand/src/components/Counter.jsx +3 -3
- package/templates/astro/ts/base/README.md +4 -3
- package/templates/astro/ts/base/astro.config.mjs +16 -1
- package/templates/astro/ts/base/src/components/About.tsx +2 -2
- package/templates/astro/ts/base/src/components/Counter.tsx +3 -3
- package/templates/astro/ts/base/src/components/Greeting.tsx +1 -1
- package/templates/astro/ts/base/src/components/Header.tsx +6 -6
- package/templates/astro/ts/base/src/components/Home.test.tsx +5 -1
- package/templates/astro/ts/base/src/components/Home.tsx +6 -6
- package/templates/astro/ts/base/src/components/NotFound.tsx +3 -3
- package/templates/astro/ts/base/src/components/SchemeSwitch.tsx +4 -4
- package/templates/astro/ts/base/src/layouts/Layout.astro +24 -13
- package/templates/astro/ts/base/src/theme/Island.tsx +1 -1
- package/templates/astro/ts/sample-data/src/components/ItemDetails.tsx +3 -3
- package/templates/astro/ts/sample-data/src/components/ItemList.tsx +3 -3
- package/templates/astro/ts/sample-data/src/components/StatusChip.tsx +1 -1
- package/templates/astro/ts/with/jotai/src/components/Counter.tsx +3 -3
- package/templates/astro/ts/with/react-hook-form/src/components/Form.tsx +4 -4
- package/templates/astro/ts/with/redux-toolkit/src/components/Counter.tsx +3 -3
- package/templates/astro/ts/with/zustand/src/components/Counter.tsx +3 -3
- package/templates/react-router/js/base/README.md +4 -3
- package/templates/react-router/js/base/src/components/Header.jsx +5 -5
- package/templates/react-router/js/base/src/components/RouterLink.jsx +2 -2
- package/templates/react-router/js/base/src/components/SchemeSwitch.jsx +4 -4
- package/templates/react-router/js/base/src/main.jsx +5 -0
- package/templates/react-router/js/base/src/pages/ErrorPage.jsx +2 -2
- package/templates/react-router/js/base/src/pages/Layout.jsx +1 -1
- package/templates/react-router/js/base/src/pages/about/Page.jsx +2 -2
- package/templates/react-router/js/base/src/pages/index/Counter.jsx +3 -3
- package/templates/react-router/js/base/src/pages/index/Greeting.jsx +1 -1
- package/templates/react-router/js/base/src/pages/index/Page.jsx +6 -6
- package/templates/react-router/js/base/src/pages/index/Page.test.jsx +5 -1
- package/templates/react-router/js/sample-data/src/pages/item/Page.jsx +2 -2
- package/templates/react-router/js/sample-data/src/pages/items/Page.jsx +2 -2
- package/templates/react-router/js/sample-data/src/pages/items/StatusChip.jsx +1 -1
- package/templates/react-router/js/with/jotai/src/pages/index/Counter.jsx +3 -3
- package/templates/react-router/js/with/react-hook-form/src/pages/form/Page.jsx +4 -4
- package/templates/react-router/js/with/redux-toolkit/src/pages/index/Counter.jsx +3 -3
- package/templates/react-router/js/with/zustand/src/pages/index/Counter.jsx +3 -3
- package/templates/react-router/ts/base/README.md +4 -3
- package/templates/react-router/ts/base/src/components/Header.tsx +5 -5
- package/templates/react-router/ts/base/src/components/RouterLink.tsx +2 -2
- package/templates/react-router/ts/base/src/components/SchemeSwitch.tsx +4 -4
- package/templates/react-router/ts/base/src/main.tsx +5 -0
- package/templates/react-router/ts/base/src/pages/ErrorPage.tsx +2 -2
- package/templates/react-router/ts/base/src/pages/Layout.tsx +1 -1
- package/templates/react-router/ts/base/src/pages/about/Page.tsx +2 -2
- package/templates/react-router/ts/base/src/pages/index/Counter.tsx +3 -3
- package/templates/react-router/ts/base/src/pages/index/Greeting.tsx +1 -1
- package/templates/react-router/ts/base/src/pages/index/Page.test.tsx +5 -1
- package/templates/react-router/ts/base/src/pages/index/Page.tsx +6 -6
- package/templates/react-router/ts/sample-data/src/pages/item/Page.tsx +2 -2
- package/templates/react-router/ts/sample-data/src/pages/items/Page.tsx +2 -2
- package/templates/react-router/ts/sample-data/src/pages/items/StatusChip.tsx +1 -1
- package/templates/react-router/ts/with/jotai/src/pages/index/Counter.tsx +3 -3
- package/templates/react-router/ts/with/react-hook-form/src/pages/form/Page.tsx +4 -4
- package/templates/react-router/ts/with/redux-toolkit/src/pages/index/Counter.tsx +3 -3
- package/templates/react-router/ts/with/zustand/src/pages/index/Counter.tsx +3 -3
- package/templates/vike/js/base/README.md +3 -2
- package/templates/vike/js/base/src/components/Header.jsx +6 -6
- package/templates/vike/js/base/src/components/SchemeSwitch.jsx +4 -4
- package/templates/vike/js/base/src/pages/+Layout.jsx +1 -1
- package/templates/vike/js/base/src/pages/+onCreateGlobalContext.js +7 -0
- package/templates/vike/js/base/src/pages/+onRenderHtml.jsx +2 -3
- package/templates/vike/js/base/src/pages/PageShell.jsx +2 -2
- package/templates/vike/js/base/src/pages/_error/+Page.jsx +3 -3
- package/templates/vike/js/base/src/pages/about/+Page.jsx +2 -2
- package/templates/vike/js/base/src/pages/index/+Page.jsx +6 -6
- package/templates/vike/js/base/src/pages/index/Counter.jsx +3 -3
- package/templates/vike/js/base/src/pages/index/Greeting.jsx +1 -1
- package/templates/vike/js/base/src/pages/index/Page.test.jsx +5 -1
- package/templates/vike/js/sample-data/src/pages/items/+Page.jsx +3 -3
- package/templates/vike/js/sample-data/src/pages/items/@id/+Page.jsx +3 -3
- package/templates/vike/js/sample-data/src/pages/items/StatusChip.jsx +1 -1
- package/templates/vike/js/ssg/src/pages/about/+Page.jsx +2 -2
- package/templates/vike/js/ssr/src/pages/+onRenderHtml.jsx +2 -3
- package/templates/vike/js/ssr/src/pages/about/+Page.jsx +2 -2
- package/templates/vike/js/with/jotai/src/pages/index/Counter.jsx +3 -3
- package/templates/vike/js/with/react-hook-form/src/pages/form/+Page.jsx +4 -4
- package/templates/vike/js/with/redux-toolkit/src/pages/index/Counter.jsx +3 -3
- package/templates/vike/js/with/zustand/src/pages/index/Counter.jsx +3 -3
- package/templates/vike/ts/base/README.md +3 -2
- package/templates/vike/ts/base/src/components/Header.tsx +6 -6
- package/templates/vike/ts/base/src/components/SchemeSwitch.tsx +4 -4
- package/templates/vike/ts/base/src/pages/+Layout.tsx +1 -1
- package/templates/vike/ts/base/src/pages/+onCreateGlobalContext.ts +7 -0
- package/templates/vike/ts/base/src/pages/+onRenderHtml.tsx +2 -3
- package/templates/vike/ts/base/src/pages/PageShell.tsx +2 -2
- package/templates/vike/ts/base/src/pages/_error/+Page.tsx +3 -3
- package/templates/vike/ts/base/src/pages/about/+Page.tsx +2 -2
- package/templates/vike/ts/base/src/pages/index/+Page.tsx +6 -6
- package/templates/vike/ts/base/src/pages/index/Counter.tsx +3 -3
- package/templates/vike/ts/base/src/pages/index/Greeting.tsx +1 -1
- package/templates/vike/ts/base/src/pages/index/Page.test.tsx +5 -1
- package/templates/vike/ts/sample-data/src/pages/items/+Page.tsx +3 -3
- package/templates/vike/ts/sample-data/src/pages/items/@id/+Page.tsx +3 -3
- package/templates/vike/ts/sample-data/src/pages/items/StatusChip.tsx +1 -1
- package/templates/vike/ts/ssg/src/pages/about/+Page.tsx +2 -2
- package/templates/vike/ts/ssr/src/pages/+onRenderHtml.tsx +2 -3
- package/templates/vike/ts/ssr/src/pages/about/+Page.tsx +2 -2
- package/templates/vike/ts/with/jotai/src/pages/index/Counter.tsx +3 -3
- package/templates/vike/ts/with/react-hook-form/src/pages/form/+Page.tsx +4 -4
- package/templates/vike/ts/with/redux-toolkit/src/pages/index/Counter.tsx +3 -3
- package/templates/vike/ts/with/zustand/src/pages/index/Counter.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soroush.design/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The command line of
|
|
3
|
+
"version": "0.3.0-alpha.1",
|
|
4
|
+
"description": "The command line of Gild UI: init sets it up in an existing React app, and create starts a new one, each showing every change first.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
7
7
|
"init",
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
],
|
|
12
12
|
"author": "Masoud Soroush <masoud@soroush.tech>",
|
|
13
13
|
"license": "MIT",
|
|
14
|
-
"homepage": "https://
|
|
14
|
+
"homepage": "https://gild-ui.soroush.design/cli/",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/soroush-tech/
|
|
17
|
+
"url": "git+https://github.com/soroush-tech/gild-ui.git",
|
|
18
18
|
"directory": "packages/cli"
|
|
19
19
|
},
|
|
20
20
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/soroush-tech/
|
|
21
|
+
"url": "https://github.com/soroush-tech/gild-ui/issues"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"sideEffects": false,
|
|
@@ -41,37 +41,38 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@astrojs/check": "^0.9.12",
|
|
44
|
-
"@astrojs/node": "^11.1.
|
|
44
|
+
"@astrojs/node": "^11.1.14",
|
|
45
45
|
"@astrojs/react": "^7.1.9",
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
46
|
+
"@babel/parser": "^8.1.3",
|
|
47
|
+
"@babel/types": "^8.1.3",
|
|
48
|
+
"@hookform/resolvers": "^7.0.10",
|
|
49
|
+
"@reduxjs/toolkit": "^2.16.0",
|
|
50
|
+
"@tanstack/react-query": "^5.108.4",
|
|
50
51
|
"@testing-library/dom": "^10.4.2",
|
|
51
52
|
"@testing-library/react": "^16.3.3",
|
|
52
|
-
"@types/node": "^26.6.
|
|
53
|
-
"@types/react": "^19.3.
|
|
53
|
+
"@types/node": "^26.6.11",
|
|
54
|
+
"@types/react": "^19.3.3",
|
|
54
55
|
"@types/react-dom": "^19.3.0",
|
|
55
56
|
"@vitejs/plugin-react": "^6.3.0",
|
|
56
|
-
"@vitest/coverage-v8": "^5.1.
|
|
57
|
-
"astro": "^7.4.
|
|
58
|
-
"jotai": "^3.0
|
|
57
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
58
|
+
"astro": "^7.4.13",
|
|
59
|
+
"jotai": "^3.1.0",
|
|
59
60
|
"jsdom": "^31.0.1",
|
|
60
|
-
"msw": "^3.0.
|
|
61
|
-
"oxlint": "^1.
|
|
61
|
+
"msw": "^3.0.8",
|
|
62
|
+
"oxlint": "^1.96.0",
|
|
62
63
|
"react": "^19.3.1",
|
|
63
64
|
"react-dom": "^19.3.1",
|
|
64
65
|
"react-hook-form": "^7.92.0",
|
|
65
66
|
"react-redux": "^9.3.1",
|
|
66
|
-
"react-router": "^8.5.
|
|
67
|
+
"react-router": "^8.5.3",
|
|
67
68
|
"swr": "^2.5.1",
|
|
68
|
-
"ts-blank-space": "^0.
|
|
69
|
+
"ts-blank-space": "^0.10.1",
|
|
69
70
|
"tsdown": "^0.23.7",
|
|
70
71
|
"typescript": "~7.0.2",
|
|
71
72
|
"typescript-astro": "npm:typescript@^6.0.3",
|
|
72
73
|
"vike": "0.4.270",
|
|
73
|
-
"vite": "~8.
|
|
74
|
-
"vitest": "^5.1.
|
|
74
|
+
"vite": "~8.4.0",
|
|
75
|
+
"vitest": "^5.1.2",
|
|
75
76
|
"zod": "^4.6.7",
|
|
76
77
|
"zustand": "^5.1.0",
|
|
77
78
|
"@soroush.tech/eslint-config": "0.0.0"
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
"typecheck": "tsc --noEmit",
|
|
83
84
|
"test": "vitest run",
|
|
84
85
|
"test:coverage": "vitest run --coverage",
|
|
85
|
-
"test:types": "pnpm --filter @
|
|
86
|
+
"test:types": "pnpm --filter @gild-ui/core build && pnpm --filter @gild-ui/hooks build && pnpm --filter @gild-ui/react build && tsc -p type-tests/init/tsconfig.json && tsc -p src/migrate/steps/gild-ui-0.1.0/fixtures/init-templates/tsconfig.after.json && tsc -p src/migrate/steps/gild-ui-0.1.0/fixtures/docs-app/tsconfig.after.json && tsc -p type-tests/tsconfig.create-vike.json && tsc -p type-tests/tsconfig.create-vike-ssg.json && tsc -p type-tests/tsconfig.create-vike-ssr.json && tsc -p type-tests/tsconfig.create-vike-libraries.json && tsc -p type-tests/tsconfig.create-vike-jotai.json && tsc -p type-tests/tsconfig.create-vike-more.json && tsc -p type-tests/tsconfig.create-astro-ssg.json && tsc -p type-tests/tsconfig.create-astro-ssr.json && tsc -p type-tests/tsconfig.create-astro-libraries.json && tsc -p type-tests/tsconfig.create-astro-more.json && tsc -p type-tests/tsconfig.create-react-router.json && tsc -p type-tests/tsconfig.create-react-router-libraries.json && tsc -p type-tests/tsconfig.create-react-router-more.json && tsc -p type-tests/tsconfig.create-react-router-jotai.json",
|
|
86
87
|
"gen:templates": "node scripts/gen-templates.mjs"
|
|
87
88
|
},
|
|
88
89
|
"module": "./dist/index.mjs"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# __TITLE__
|
|
2
2
|
|
|
3
|
-
An [Astro](https://astro.build) app on
|
|
3
|
+
An [Astro](https://astro.build) app on [Gild UI](https://gild-ui.soroush.design):
|
|
4
4
|
<!-- @if ssr -->
|
|
5
5
|
every page is rendered on the server, on each request, with its styles, and its parts are
|
|
6
6
|
React islands that hydrate in the browser. Astro's client router moves between pages with no
|
|
@@ -27,10 +27,11 @@ React parts render at build time only.
|
|
|
27
27
|
`src/theme/scheme.js`, not context.
|
|
28
28
|
- The home page's counter is an island of its own, which renders in the browser only
|
|
29
29
|
(`client:only`), so the count it shows is the one in memory, not the build's.
|
|
30
|
-
- `src/layouts/Layout.astro` keeps
|
|
30
|
+
- `src/layouts/Layout.astro` keeps Gild UI's styles as the client router moves
|
|
31
31
|
between pages.
|
|
32
32
|
<!-- @endif -->
|
|
33
33
|
- `src/theme/themes.js` holds the light and the dark theme: make them your own.
|
|
34
|
+
- `src/theme/setup.js` configures the engine once, with the theme the app starts in; the integration in `astro.config.mjs` runs it in the browser, before the islands hydrate, and on the server.
|
|
34
35
|
<!-- @if sample-data && ssr -->
|
|
35
36
|
- `src/pages/items/` lists the sample items of `src/data/items.js`, with a page for each,
|
|
36
37
|
read on each request: make them fetch your own.
|
|
@@ -87,4 +88,4 @@ React parts render at build time only.
|
|
|
87
88
|
<!-- @endif -->
|
|
88
89
|
|
|
89
90
|
Fonts: the theme names Space Grotesk and JetBrains Mono, and does not load them. See
|
|
90
|
-
https://
|
|
91
|
+
https://gild-ui.soroush.design/react/installation/#fonts
|
|
@@ -7,6 +7,21 @@ import { msw } from 'msw/vite'
|
|
|
7
7
|
// @endif
|
|
8
8
|
import { defineConfig } from 'astro/config'
|
|
9
9
|
|
|
10
|
+
// Configures the engine once for the whole program (src/theme/setup.js): in the browser before the
|
|
11
|
+
// islands hydrate, and on the server before a page is rendered.
|
|
12
|
+
function setupEngine() {
|
|
13
|
+
const run = "import { setup } from '/src/theme/setup.js'; setup()"
|
|
14
|
+
return {
|
|
15
|
+
name: 'setup-engine',
|
|
16
|
+
hooks: {
|
|
17
|
+
'astro:config:setup': ({ injectScript }) => {
|
|
18
|
+
injectScript('before-hydration', run)
|
|
19
|
+
injectScript('page-ssr', run)
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
10
25
|
// The settings of the app: https://docs.astro.build/en/reference/configuration-reference/
|
|
11
26
|
export default defineConfig({
|
|
12
27
|
// @if ssr
|
|
@@ -15,7 +30,7 @@ export default defineConfig({
|
|
|
15
30
|
output: 'server',
|
|
16
31
|
adapter: node({ mode: 'standalone' }),
|
|
17
32
|
// @endif
|
|
18
|
-
integrations: [react()],
|
|
33
|
+
integrations: [setupEngine(), react()],
|
|
19
34
|
// @if msw
|
|
20
35
|
// msw's plugin serves the mock API's worker, in development and in the build.
|
|
21
36
|
vite: { plugins: [msw({ mode: 'worker-only' })] },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Flex } from '@
|
|
2
|
-
import { Typography } from '@
|
|
1
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
2
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
3
3
|
import { withIsland } from '../theme/Island'
|
|
4
4
|
|
|
5
5
|
function About() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @if !ssg
|
|
2
2
|
import { useState } from 'react'
|
|
3
|
-
import { Button } from '@
|
|
4
|
-
import { Flex } from '@
|
|
5
|
-
import { Typography } from '@
|
|
3
|
+
import { Button } from '@gild-ui/react/Button'
|
|
4
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
5
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
6
6
|
import { withIsland } from '../theme/Island'
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -6,7 +6,7 @@ import useSWR from 'swr'
|
|
|
6
6
|
// @else
|
|
7
7
|
import { useEffect, useState } from 'react'
|
|
8
8
|
// @endif
|
|
9
|
-
import { Typography } from '@
|
|
9
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
10
10
|
// @if !tanstack-query && !swr
|
|
11
11
|
// @endif
|
|
12
12
|
import { fetchGreeting } from '../data/api'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AppBar } from '@
|
|
2
|
-
import { Flex } from '@
|
|
3
|
-
import { Link } from '@
|
|
4
|
-
import { useTheme } from '@
|
|
5
|
-
import { Typography } from '@
|
|
6
|
-
import { alpha } from '@
|
|
1
|
+
import { AppBar } from '@gild-ui/react/AppBar'
|
|
2
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
3
|
+
import { Link } from '@gild-ui/react/Link'
|
|
4
|
+
import { useTheme } from '@gild-ui/react'
|
|
5
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
6
|
+
import { alpha } from '@gild-ui/core/utils'
|
|
7
7
|
import { Providers } from '../theme/Providers'
|
|
8
8
|
// @if !ssg
|
|
9
9
|
import { setScheme, useScheme } from '../theme/scheme'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Button } from '@
|
|
2
|
-
import { Flex } from '@
|
|
3
|
-
import { Typography } from '@
|
|
1
|
+
import { Button } from '@gild-ui/react/Button'
|
|
2
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
3
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
4
4
|
import { withIsland } from '../theme/Island'
|
|
5
5
|
|
|
6
6
|
// @if ssg
|
|
@@ -15,12 +15,12 @@ function Home({ children }) {
|
|
|
15
15
|
<Flex gap={2} alignItems="flex-start" px={3} py={4}>
|
|
16
16
|
<Typography variant="h2">__TITLE__</Typography>
|
|
17
17
|
<Typography color="secondary">
|
|
18
|
-
An Astro app on
|
|
19
|
-
|
|
18
|
+
An Astro app on Gild UI. Edit src/components/Home.jsx, and make the themes your own in
|
|
19
|
+
src/theme/themes.js.
|
|
20
20
|
</Typography>
|
|
21
21
|
{children}
|
|
22
22
|
<Flex flexDirection="row" gap={1}>
|
|
23
|
-
<Button href="https://
|
|
23
|
+
<Button href="https://gild-ui.soroush.design">Components</Button>
|
|
24
24
|
<Button href="https://astro.build" variant="outlined">
|
|
25
25
|
Astro
|
|
26
26
|
</Button>
|
|
@@ -3,7 +3,7 @@ import { cleanup, render, screen } from '@testing-library/react'
|
|
|
3
3
|
// @else
|
|
4
4
|
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
|
5
5
|
// @endif
|
|
6
|
-
import { afterEach, describe, expect, it } from 'vitest'
|
|
6
|
+
import { afterEach, beforeAll, describe, expect, it } from 'vitest'
|
|
7
7
|
// @if !ssg
|
|
8
8
|
import Counter from './Counter'
|
|
9
9
|
// @endif
|
|
@@ -11,9 +11,13 @@ import Counter from './Counter'
|
|
|
11
11
|
import Greeting from './Greeting'
|
|
12
12
|
// @endif
|
|
13
13
|
import Home from './Home'
|
|
14
|
+
import { setup } from '../theme/setup'
|
|
14
15
|
|
|
15
16
|
// Each island renders inside its own providers, so a test renders it as it is.
|
|
16
17
|
describe('the home page', () => {
|
|
18
|
+
// The engine is configured once, as the app does it, before any island renders.
|
|
19
|
+
beforeAll(setup)
|
|
20
|
+
|
|
17
21
|
// Vitest has no globals here, so Testing Library cannot clean up on its own.
|
|
18
22
|
afterEach(cleanup)
|
|
19
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Flex } from '@
|
|
2
|
-
import { Link } from '@
|
|
3
|
-
import { Typography } from '@
|
|
1
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
2
|
+
import { Link } from '@gild-ui/react/Link'
|
|
3
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
4
4
|
import { withIsland } from '../theme/Island'
|
|
5
5
|
|
|
6
6
|
/** Shown for a page that does not exist. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @if !ssg
|
|
2
|
-
import { Flex } from '@
|
|
3
|
-
import { Icon } from '@
|
|
4
|
-
import { Switch } from '@
|
|
5
|
-
import { Typography } from '@
|
|
2
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
3
|
+
import { Icon } from '@gild-ui/react/Icon'
|
|
4
|
+
import { Switch } from '@gild-ui/react/Switch'
|
|
5
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
6
6
|
|
|
7
7
|
/** The switch between the light and the dark theme, on when dark, with the scheme's icon. */
|
|
8
8
|
export function SchemeSwitch({ scheme, onSchemeChange }) {
|
|
@@ -25,25 +25,36 @@ import Header from '../components/Header'
|
|
|
25
25
|
</main>
|
|
26
26
|
{/* @if !ssg */}
|
|
27
27
|
<script>
|
|
28
|
-
// Astro's client router replaces the head on each move between pages, and with it the
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
// the
|
|
28
|
+
// Astro's client router replaces the head on each move between pages, and with it the style
|
|
29
|
+
// elements of the styling engine: the one its cache writes its rules into (`data-style`),
|
|
30
|
+
// the ones it adopted from the server (`data-umber`, and React's own, `data-precedence`),
|
|
31
|
+
// and its two markers (a `<meta>` named `...-options` and one named `...-global`). They must
|
|
32
|
+
// stay the very elements the cache holds, or it writes into one the page no longer has, so
|
|
33
|
+
// each gets an id the router keeps. The next page's own styles, which its HTML holds next to
|
|
34
|
+
// each island, move into its head, where the cache reads each element as it arrives and the
|
|
35
|
+
// islands expect them as they hydrate - but not its base styles (the global rules and the
|
|
36
|
+
// root theme): the header, which the router keeps, draws those in the scheme picked.
|
|
37
|
+
const engineElements =
|
|
38
|
+
'style[data-style], style[data-umber], style[data-precedence], meta[name$="-global"], meta[name$="-options"]'
|
|
39
|
+
const nameAttributes = ['data-umber', 'data-href', 'data-style', 'name']
|
|
33
40
|
document.addEventListener('astro:before-swap', ({ newDocument }) => {
|
|
34
41
|
const kept = new Set()
|
|
35
|
-
document.head.querySelectorAll(
|
|
42
|
+
document.head.querySelectorAll(engineElements).forEach((element, index) => {
|
|
36
43
|
const id = `soroush-styles-${index}`
|
|
37
|
-
|
|
38
|
-
const placeholder = newDocument.createElement(
|
|
44
|
+
element.setAttribute('data-astro-transition-persist', id)
|
|
45
|
+
const placeholder = newDocument.createElement(element.localName)
|
|
39
46
|
placeholder.setAttribute('data-astro-transition-persist', id)
|
|
40
47
|
newDocument.head.append(placeholder)
|
|
41
|
-
|
|
48
|
+
const name =
|
|
49
|
+
nameAttributes.map((attribute) => element.getAttribute(attribute)).find(Boolean) ?? ''
|
|
50
|
+
kept.add(name)
|
|
42
51
|
})
|
|
43
|
-
newDocument.body.querySelectorAll(
|
|
44
|
-
const name =
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
newDocument.body.querySelectorAll(engineElements).forEach((element) => {
|
|
53
|
+
const name =
|
|
54
|
+
nameAttributes.map((attribute) => element.getAttribute(attribute)).find(Boolean) ?? ''
|
|
55
|
+
const isBase = name.split(' ').some((part) => part.includes('-global'))
|
|
56
|
+
if (kept.has(name) || isBase) element.remove()
|
|
57
|
+
else newDocument.head.append(element)
|
|
47
58
|
})
|
|
48
59
|
})
|
|
49
60
|
</script>
|
|
@@ -6,7 +6,7 @@ import { QueryClientProvider } from '@tanstack/react-query'
|
|
|
6
6
|
// @if redux-toolkit
|
|
7
7
|
import { Provider as StoreProvider } from 'react-redux'
|
|
8
8
|
// @endif
|
|
9
|
-
import { ThemeProvider } from '@
|
|
9
|
+
import { ThemeProvider } from '@gild-ui/react'
|
|
10
10
|
// @if tanstack-query
|
|
11
11
|
import { getQueryClient } from '../data/queryClient'
|
|
12
12
|
// @endif
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Flex } from '@
|
|
2
|
-
import { Link } from '@
|
|
3
|
-
import { Typography } from '@
|
|
1
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
2
|
+
import { Link } from '@gild-ui/react/Link'
|
|
3
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
4
4
|
// @if tanstack-query
|
|
5
5
|
import { useQuery } from '@tanstack/react-query'
|
|
6
6
|
import { fetchItem } from '../data/api'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Flex } from '@
|
|
2
|
-
import { Link } from '@
|
|
3
|
-
import { Typography } from '@
|
|
1
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
2
|
+
import { Link } from '@gild-ui/react/Link'
|
|
3
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
4
4
|
// @if tanstack-query
|
|
5
5
|
import { useQuery } from '@tanstack/react-query'
|
|
6
6
|
import { fetchItems } from '../data/api'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Button } from '@
|
|
2
|
-
import { Flex } from '@
|
|
3
|
-
import { Typography } from '@
|
|
1
|
+
import { Button } from '@gild-ui/react/Button'
|
|
2
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
3
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
4
4
|
import { withIsland } from '../theme/Island'
|
|
5
5
|
import { useAtom } from 'jotai'
|
|
6
6
|
import { countAtom } from '../state/counter'
|
|
@@ -10,10 +10,10 @@ import { Controller, useForm } from 'react-hook-form'
|
|
|
10
10
|
import useSWRMutation from 'swr/mutation'
|
|
11
11
|
// @endif
|
|
12
12
|
import { z } from 'zod'
|
|
13
|
-
import { Button } from '@
|
|
14
|
-
import { Flex } from '@
|
|
15
|
-
import { TextInput } from '@
|
|
16
|
-
import { Typography } from '@
|
|
13
|
+
import { Button } from '@gild-ui/react/Button'
|
|
14
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
15
|
+
import { TextInput } from '@gild-ui/react/TextInput'
|
|
16
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
17
17
|
import { withIsland } from '../theme/Island'
|
|
18
18
|
// @if tanstack-query || swr || msw
|
|
19
19
|
import { sendMessage } from '../data/api'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Button } from '@
|
|
2
|
-
import { Flex } from '@
|
|
3
|
-
import { Typography } from '@
|
|
1
|
+
import { Button } from '@gild-ui/react/Button'
|
|
2
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
3
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
4
4
|
import { withIsland } from '../theme/Island'
|
|
5
5
|
import { useDispatch, useSelector } from 'react-redux'
|
|
6
6
|
import { incremented } from '../state/store'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Button } from '@
|
|
2
|
-
import { Flex } from '@
|
|
3
|
-
import { Typography } from '@
|
|
1
|
+
import { Button } from '@gild-ui/react/Button'
|
|
2
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
3
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
4
4
|
import { withIsland } from '../theme/Island'
|
|
5
5
|
import { useCounter } from '../state/counter'
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# __TITLE__
|
|
2
2
|
|
|
3
|
-
An [Astro](https://astro.build) app on
|
|
3
|
+
An [Astro](https://astro.build) app on [Gild UI](https://gild-ui.soroush.design):
|
|
4
4
|
<!-- @if ssr -->
|
|
5
5
|
every page is rendered on the server, on each request, with its styles, and its parts are
|
|
6
6
|
React islands that hydrate in the browser. Astro's client router moves between pages with no
|
|
@@ -27,10 +27,11 @@ React parts render at build time only.
|
|
|
27
27
|
`src/theme/scheme.ts`, not context.
|
|
28
28
|
- The home page's counter is an island of its own, which renders in the browser only
|
|
29
29
|
(`client:only`), so the count it shows is the one in memory, not the build's.
|
|
30
|
-
- `src/layouts/Layout.astro` keeps
|
|
30
|
+
- `src/layouts/Layout.astro` keeps Gild UI's styles as the client router moves
|
|
31
31
|
between pages.
|
|
32
32
|
<!-- @endif -->
|
|
33
33
|
- `src/theme/themes.ts` holds the light and the dark theme: make them your own.
|
|
34
|
+
- `src/theme/setup.ts` configures the engine once, with the theme the app starts in; the integration in `astro.config.mjs` runs it in the browser, before the islands hydrate, and on the server.
|
|
34
35
|
<!-- @if sample-data && ssr -->
|
|
35
36
|
- `src/pages/items/` lists the sample items of `src/data/items.ts`, with a page for each,
|
|
36
37
|
read on each request: make them fetch your own.
|
|
@@ -87,4 +88,4 @@ React parts render at build time only.
|
|
|
87
88
|
<!-- @endif -->
|
|
88
89
|
|
|
89
90
|
Fonts: the theme names Space Grotesk and JetBrains Mono, and does not load them. See
|
|
90
|
-
https://
|
|
91
|
+
https://gild-ui.soroush.design/react/installation/#fonts
|
|
@@ -7,6 +7,21 @@ import { msw } from 'msw/vite'
|
|
|
7
7
|
// @endif
|
|
8
8
|
import { defineConfig } from 'astro/config'
|
|
9
9
|
|
|
10
|
+
// Configures the engine once for the whole program (src/theme/setup.ts): in the browser before the
|
|
11
|
+
// islands hydrate, and on the server before a page is rendered.
|
|
12
|
+
function setupEngine() {
|
|
13
|
+
const run = "import { setup } from '/src/theme/setup.ts'; setup()"
|
|
14
|
+
return {
|
|
15
|
+
name: 'setup-engine',
|
|
16
|
+
hooks: {
|
|
17
|
+
'astro:config:setup': ({ injectScript }) => {
|
|
18
|
+
injectScript('before-hydration', run)
|
|
19
|
+
injectScript('page-ssr', run)
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
10
25
|
// The settings of the app: https://docs.astro.build/en/reference/configuration-reference/
|
|
11
26
|
export default defineConfig({
|
|
12
27
|
// @if ssr
|
|
@@ -15,7 +30,7 @@ export default defineConfig({
|
|
|
15
30
|
output: 'server',
|
|
16
31
|
adapter: node({ mode: 'standalone' }),
|
|
17
32
|
// @endif
|
|
18
|
-
integrations: [react()],
|
|
33
|
+
integrations: [setupEngine(), react()],
|
|
19
34
|
// @if msw
|
|
20
35
|
// msw's plugin serves the mock API's worker, in development and in the build.
|
|
21
36
|
vite: { plugins: [msw({ mode: 'worker-only' })] },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Flex } from '@
|
|
2
|
-
import { Typography } from '@
|
|
1
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
2
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
3
3
|
import { withIsland } from '../theme/Island'
|
|
4
4
|
|
|
5
5
|
function About() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @if !ssg
|
|
2
2
|
import { useState } from 'react'
|
|
3
|
-
import { Button } from '@
|
|
4
|
-
import { Flex } from '@
|
|
5
|
-
import { Typography } from '@
|
|
3
|
+
import { Button } from '@gild-ui/react/Button'
|
|
4
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
5
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
6
6
|
import { withIsland } from '../theme/Island'
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -6,7 +6,7 @@ import useSWR from 'swr'
|
|
|
6
6
|
// @else
|
|
7
7
|
import { useEffect, useState } from 'react'
|
|
8
8
|
// @endif
|
|
9
|
-
import { Typography } from '@
|
|
9
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
10
10
|
// @if !tanstack-query && !swr
|
|
11
11
|
import type { Greeting as Reply } from '../data/api'
|
|
12
12
|
// @endif
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
-
import { AppBar } from '@
|
|
3
|
-
import { Flex } from '@
|
|
4
|
-
import { Link } from '@
|
|
5
|
-
import { useTheme } from '@
|
|
6
|
-
import { Typography } from '@
|
|
7
|
-
import { alpha } from '@
|
|
2
|
+
import { AppBar } from '@gild-ui/react/AppBar'
|
|
3
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
4
|
+
import { Link } from '@gild-ui/react/Link'
|
|
5
|
+
import { useTheme } from '@gild-ui/react'
|
|
6
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
7
|
+
import { alpha } from '@gild-ui/core/utils'
|
|
8
8
|
import { Providers } from '../theme/Providers'
|
|
9
9
|
// @if !ssg
|
|
10
10
|
import { setScheme, useScheme } from '../theme/scheme'
|
|
@@ -3,7 +3,7 @@ import { cleanup, render, screen } from '@testing-library/react'
|
|
|
3
3
|
// @else
|
|
4
4
|
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
|
5
5
|
// @endif
|
|
6
|
-
import { afterEach, describe, expect, it } from 'vitest'
|
|
6
|
+
import { afterEach, beforeAll, describe, expect, it } from 'vitest'
|
|
7
7
|
// @if !ssg
|
|
8
8
|
import Counter from './Counter'
|
|
9
9
|
// @endif
|
|
@@ -11,9 +11,13 @@ import Counter from './Counter'
|
|
|
11
11
|
import Greeting from './Greeting'
|
|
12
12
|
// @endif
|
|
13
13
|
import Home from './Home'
|
|
14
|
+
import { setup } from '../theme/setup'
|
|
14
15
|
|
|
15
16
|
// Each island renders inside its own providers, so a test renders it as it is.
|
|
16
17
|
describe('the home page', () => {
|
|
18
|
+
// The engine is configured once, as the app does it, before any island renders.
|
|
19
|
+
beforeAll(setup)
|
|
20
|
+
|
|
17
21
|
// Vitest has no globals here, so Testing Library cannot clean up on its own.
|
|
18
22
|
afterEach(cleanup)
|
|
19
23
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
-
import { Button } from '@
|
|
3
|
-
import { Flex } from '@
|
|
4
|
-
import { Typography } from '@
|
|
2
|
+
import { Button } from '@gild-ui/react/Button'
|
|
3
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
4
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
5
5
|
import { withIsland } from '../theme/Island'
|
|
6
6
|
|
|
7
7
|
// @if ssg
|
|
@@ -16,12 +16,12 @@ function Home({ children }: { readonly children?: ReactNode }) {
|
|
|
16
16
|
<Flex gap={2} alignItems="flex-start" px={3} py={4}>
|
|
17
17
|
<Typography variant="h2">__TITLE__</Typography>
|
|
18
18
|
<Typography color="secondary">
|
|
19
|
-
An Astro app on
|
|
20
|
-
|
|
19
|
+
An Astro app on Gild UI. Edit src/components/Home.tsx, and make the themes your own in
|
|
20
|
+
src/theme/themes.ts.
|
|
21
21
|
</Typography>
|
|
22
22
|
{children}
|
|
23
23
|
<Flex flexDirection="row" gap={1}>
|
|
24
|
-
<Button href="https://
|
|
24
|
+
<Button href="https://gild-ui.soroush.design">Components</Button>
|
|
25
25
|
<Button href="https://astro.build" variant="outlined">
|
|
26
26
|
Astro
|
|
27
27
|
</Button>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Flex } from '@
|
|
2
|
-
import { Link } from '@
|
|
3
|
-
import { Typography } from '@
|
|
1
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
2
|
+
import { Link } from '@gild-ui/react/Link'
|
|
3
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
4
4
|
import { withIsland } from '../theme/Island'
|
|
5
5
|
|
|
6
6
|
/** Shown for a page that does not exist. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @if !ssg
|
|
2
|
-
import { Flex } from '@
|
|
3
|
-
import { Icon } from '@
|
|
4
|
-
import { Switch } from '@
|
|
5
|
-
import { Typography } from '@
|
|
2
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
3
|
+
import { Icon } from '@gild-ui/react/Icon'
|
|
4
|
+
import { Switch } from '@gild-ui/react/Switch'
|
|
5
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
6
6
|
|
|
7
7
|
type Scheme = 'light' | 'dark'
|
|
8
8
|
|