@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
|
@@ -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>
|
|
@@ -7,7 +7,7 @@ import type { ComponentType, ReactNode } from 'react'
|
|
|
7
7
|
// @if redux-toolkit
|
|
8
8
|
import { Provider as StoreProvider } from 'react-redux'
|
|
9
9
|
// @endif
|
|
10
|
-
import { ThemeProvider } from '@
|
|
10
|
+
import { ThemeProvider } from '@gild-ui/react'
|
|
11
11
|
// @if tanstack-query
|
|
12
12
|
import { getQueryClient } from '../data/queryClient'
|
|
13
13
|
// @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, type RootState } 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,7 +1,7 @@
|
|
|
1
1
|
# __TITLE__
|
|
2
2
|
|
|
3
3
|
A single-page app on [React Router](https://reactrouter.com) and the
|
|
4
|
-
[
|
|
4
|
+
[Gild UI](https://gild-ui.soroush.design): the browser renders each page, and moves
|
|
5
5
|
between them with no reload.
|
|
6
6
|
|
|
7
7
|
- `npm run dev` starts it, `npm run build` builds it, and `npm run preview` serves the build.
|
|
@@ -9,9 +9,10 @@ between them with no reload.
|
|
|
9
9
|
router shows the page a URL names.
|
|
10
10
|
- `src/routes.jsx` lists the pages by path, and `src/main.jsx` renders the router in `index.html`.
|
|
11
11
|
- `src/pages/` holds the pages, and `src/pages/Layout.jsx` is the frame every page renders in,
|
|
12
|
-
inside the app's providers. `src/components/RouterLink.jsx` is
|
|
12
|
+
inside the app's providers. `src/components/RouterLink.jsx` is Gild UI's `Link`, moving
|
|
13
13
|
to a page with no reload.
|
|
14
14
|
- `src/theme/themes.js` holds the light and the dark theme: make them your own.
|
|
15
|
+
- `src/theme/setup.js` configures the engine once, with the theme the app starts in; `src/main.jsx` runs it first.
|
|
15
16
|
<!-- @if sample-data && (tanstack-query || swr) -->
|
|
16
17
|
- `src/pages/items/` lists the sample items of `src/data/items.js`, and `src/pages/item/` shows one: both read them through `src/data/api.js`.
|
|
17
18
|
<!-- @elif sample-data -->
|
|
@@ -64,4 +65,4 @@ between them with no reload.
|
|
|
64
65
|
<!-- @endif -->
|
|
65
66
|
|
|
66
67
|
Fonts: the theme names Space Grotesk and JetBrains Mono, and does not load them. See
|
|
67
|
-
https://
|
|
68
|
+
https://gild-ui.soroush.design/react/installation/#fonts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AppBar } from '@
|
|
2
|
-
import { Flex } from '@
|
|
3
|
-
import { useTheme } from '@
|
|
4
|
-
import { Typography } from '@
|
|
5
|
-
import { alpha } from '@
|
|
1
|
+
import { AppBar } from '@gild-ui/react/AppBar'
|
|
2
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
3
|
+
import { useTheme } from '@gild-ui/react'
|
|
4
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
5
|
+
import { alpha } from '@gild-ui/core/utils'
|
|
6
6
|
import { RouterLink } from './RouterLink'
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Link } from '@
|
|
1
|
+
import { Link } from '@gild-ui/react/Link'
|
|
2
2
|
import { useHref, useLinkClickHandler } from 'react-router'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Gild UI's Link to a page of the app: a click moves to it with no reload, as the
|
|
6
6
|
* router's own Link does, and a click that opens a new tab still does.
|
|
7
7
|
*/
|
|
8
8
|
export function RouterLink({ to, ...props }) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Flex } from '@
|
|
2
|
-
import { Icon } from '@
|
|
3
|
-
import { Switch } from '@
|
|
4
|
-
import { Typography } from '@
|
|
1
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
2
|
+
import { Icon } from '@gild-ui/react/Icon'
|
|
3
|
+
import { Switch } from '@gild-ui/react/Switch'
|
|
4
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
5
5
|
|
|
6
6
|
/** The switch between the light and the dark theme, on when dark, with the scheme's icon. */
|
|
7
7
|
export function SchemeSwitch({ scheme, onSchemeChange }) {
|
|
@@ -12,6 +12,11 @@ import { routes } from './routes'
|
|
|
12
12
|
// @if redux-toolkit
|
|
13
13
|
import { store } from './state/store'
|
|
14
14
|
// @endif
|
|
15
|
+
import { setup } from './theme/setup'
|
|
16
|
+
|
|
17
|
+
// The engine is configured first, once for the whole program: what a component reads with no provider
|
|
18
|
+
// above it is the theme the app starts in.
|
|
19
|
+
setup()
|
|
15
20
|
|
|
16
21
|
// @if msw
|
|
17
22
|
// The mock API starts first, so it answers the app's first request.
|
|
@@ -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 { RouterLink } from '../components/RouterLink'
|
|
4
4
|
|
|
5
5
|
/** Shown for a path with no page, and when a page fails to load or to render. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @if tanstack-query || (!zustand && !jotai && !redux-toolkit)
|
|
2
2
|
import { useState } from 'react'
|
|
3
3
|
// @endif
|
|
4
|
-
import { View } from '@
|
|
4
|
+
import { View } from '@gild-ui/react/View'
|
|
5
5
|
// @if tanstack-query
|
|
6
6
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
7
7
|
// @endif
|
|
@@ -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
|
|
|
4
4
|
export default function Page() {
|
|
5
5
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } 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
|
|
|
6
6
|
/** A count, held in the component's own state, and the button that adds to it. */
|
|
7
7
|
export function Counter() {
|
|
@@ -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,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 { Counter } from './Counter'
|
|
5
5
|
// @if tanstack-query || swr || msw
|
|
6
6
|
import { Greeting } from './Greeting'
|
|
@@ -11,15 +11,15 @@ export default function Page() {
|
|
|
11
11
|
<Flex gap={2} alignItems="flex-start">
|
|
12
12
|
<Typography variant="h2">__TITLE__</Typography>
|
|
13
13
|
<Typography color="secondary">
|
|
14
|
-
A React Router app on
|
|
15
|
-
|
|
14
|
+
A React Router app on Gild UI. Edit src/pages/index/Page.jsx, and make the themes your own
|
|
15
|
+
in src/theme/themes.js.
|
|
16
16
|
</Typography>
|
|
17
17
|
{/* @if tanstack-query || swr || msw */}
|
|
18
18
|
<Greeting />
|
|
19
19
|
{/* @endif */}
|
|
20
20
|
<Counter />
|
|
21
21
|
<Flex flexDirection="row" gap={1}>
|
|
22
|
-
<Button href="https://
|
|
22
|
+
<Button href="https://gild-ui.soroush.design">Components</Button>
|
|
23
23
|
<Button href="https://reactrouter.com" variant="outlined">
|
|
24
24
|
React Router
|
|
25
25
|
</Button>
|
|
@@ -5,11 +5,12 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
|
5
5
|
// @if redux-toolkit
|
|
6
6
|
import { Provider as StoreProvider } from 'react-redux'
|
|
7
7
|
// @endif
|
|
8
|
-
import { afterEach, describe, expect, it } from 'vitest'
|
|
8
|
+
import { afterEach, beforeAll, describe, expect, it } from 'vitest'
|
|
9
9
|
// @if redux-toolkit
|
|
10
10
|
import { store } from '../../state/store'
|
|
11
11
|
// @endif
|
|
12
12
|
import { Providers } from '../../theme/Providers'
|
|
13
|
+
import { setup } from '../../theme/setup'
|
|
13
14
|
import Page from './Page'
|
|
14
15
|
|
|
15
16
|
/** The home page, inside the providers the app gives it. */
|
|
@@ -38,6 +39,9 @@ function renderPage() {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
describe('the home page', () => {
|
|
42
|
+
// The engine is configured once, as the app does it, before any page renders.
|
|
43
|
+
beforeAll(setup)
|
|
44
|
+
|
|
41
45
|
// Vitest has no globals here, so Testing Library cannot clean up on its own.
|
|
42
46
|
afterEach(cleanup)
|
|
43
47
|
|
|
@@ -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
|
// @if tanstack-query
|
|
4
4
|
import { useQuery } from '@tanstack/react-query'
|
|
5
5
|
import { useParams } from 'react-router'
|
|
@@ -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
|
// @if tanstack-query
|
|
4
4
|
import { useQuery } from '@tanstack/react-query'
|
|
5
5
|
// @elif swr
|
|
@@ -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 { useAtom } from 'jotai'
|
|
5
5
|
import { countAtom } from '../../state/counter'
|
|
6
6
|
|
|
@@ -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
|
// @if tanstack-query || swr || msw
|
|
18
18
|
import { sendMessage } from '../../data/api'
|
|
19
19
|
// @endif
|
|
@@ -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 { useDispatch, useSelector } from 'react-redux'
|
|
5
5
|
import { incremented } from '../../state/store'
|
|
6
6
|
|
|
@@ -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 { useCounter } from '../../state/counter'
|
|
5
5
|
|
|
6
6
|
/** A count, held in a zustand store, src/state/counter, and the button that adds to it. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# __TITLE__
|
|
2
2
|
|
|
3
3
|
A single-page app on [React Router](https://reactrouter.com) and the
|
|
4
|
-
[
|
|
4
|
+
[Gild UI](https://gild-ui.soroush.design): the browser renders each page, and moves
|
|
5
5
|
between them with no reload.
|
|
6
6
|
|
|
7
7
|
- `npm run dev` starts it, `npm run build` builds it, and `npm run preview` serves the build.
|
|
@@ -9,9 +9,10 @@ between them with no reload.
|
|
|
9
9
|
router shows the page a URL names.
|
|
10
10
|
- `src/routes.tsx` lists the pages by path, and `src/main.tsx` renders the router in `index.html`.
|
|
11
11
|
- `src/pages/` holds the pages, and `src/pages/Layout.tsx` is the frame every page renders in,
|
|
12
|
-
inside the app's providers. `src/components/RouterLink.tsx` is
|
|
12
|
+
inside the app's providers. `src/components/RouterLink.tsx` is Gild UI's `Link`, moving
|
|
13
13
|
to a page with no reload.
|
|
14
14
|
- `src/theme/themes.ts` holds the light and the dark theme: make them your own.
|
|
15
|
+
- `src/theme/setup.ts` configures the engine once, with the theme the app starts in; `src/main.tsx` runs it first.
|
|
15
16
|
<!-- @if sample-data && (tanstack-query || swr) -->
|
|
16
17
|
- `src/pages/items/` lists the sample items of `src/data/items.ts`, and `src/pages/item/` shows one: both read them through `src/data/api.ts`.
|
|
17
18
|
<!-- @elif sample-data -->
|
|
@@ -64,4 +65,4 @@ between them with no reload.
|
|
|
64
65
|
<!-- @endif -->
|
|
65
66
|
|
|
66
67
|
Fonts: the theme names Space Grotesk and JetBrains Mono, and does not load them. See
|
|
67
|
-
https://
|
|
68
|
+
https://gild-ui.soroush.design/react/installation/#fonts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react'
|
|
2
|
-
import { AppBar } from '@
|
|
3
|
-
import { Flex } from '@
|
|
4
|
-
import { useTheme } from '@
|
|
5
|
-
import { Typography } from '@
|
|
6
|
-
import { alpha } from '@
|
|
2
|
+
import { AppBar } from '@gild-ui/react/AppBar'
|
|
3
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
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 { RouterLink } from './RouterLink'
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Link, type LinkProps } from '@
|
|
1
|
+
import { Link, type LinkProps } from '@gild-ui/react/Link'
|
|
2
2
|
import { useHref, useLinkClickHandler } from 'react-router'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Gild UI's Link to a page of the app: a click moves to it with no reload, as the
|
|
6
6
|
* router's own Link does, and a click that opens a new tab still does.
|
|
7
7
|
*/
|
|
8
8
|
export function RouterLink({ to, ...props }: Omit<LinkProps, 'href' | 'onClick'> & { to: string }) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Flex } from '@
|
|
2
|
-
import { Icon } from '@
|
|
3
|
-
import { Switch } from '@
|
|
4
|
-
import { Typography } from '@
|
|
1
|
+
import { Flex } from '@gild-ui/react/Flex'
|
|
2
|
+
import { Icon } from '@gild-ui/react/Icon'
|
|
3
|
+
import { Switch } from '@gild-ui/react/Switch'
|
|
4
|
+
import { Typography } from '@gild-ui/react/Typography'
|
|
5
5
|
|
|
6
6
|
type Scheme = 'light' | 'dark'
|
|
7
7
|
|
|
@@ -12,6 +12,11 @@ import { routes } from './routes'
|
|
|
12
12
|
// @if redux-toolkit
|
|
13
13
|
import { store } from './state/store'
|
|
14
14
|
// @endif
|
|
15
|
+
import { setup } from './theme/setup'
|
|
16
|
+
|
|
17
|
+
// The engine is configured first, once for the whole program: what a component reads with no provider
|
|
18
|
+
// above it is the theme the app starts in.
|
|
19
|
+
setup()
|
|
15
20
|
|
|
16
21
|
// @if msw
|
|
17
22
|
// The mock API starts first, so it answers the app's first request.
|
|
@@ -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 { RouterLink } from '../components/RouterLink'
|
|
4
4
|
|
|
5
5
|
/** Shown for a path with no page, and when a page fails to load or to render. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @if tanstack-query || (!zustand && !jotai && !redux-toolkit)
|
|
2
2
|
import { useState } from 'react'
|
|
3
3
|
// @endif
|
|
4
|
-
import { View } from '@
|
|
4
|
+
import { View } from '@gild-ui/react/View'
|
|
5
5
|
// @if tanstack-query
|
|
6
6
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
7
7
|
// @endif
|
|
@@ -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
|
|
|
4
4
|
export default function Page() {
|
|
5
5
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState } 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
|
|
|
6
6
|
/** A count, held in the component's own state, and the button that adds to it. */
|
|
7
7
|
export function Counter() {
|
|
@@ -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
|
|
@@ -5,11 +5,12 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
|
5
5
|
// @if redux-toolkit
|
|
6
6
|
import { Provider as StoreProvider } from 'react-redux'
|
|
7
7
|
// @endif
|
|
8
|
-
import { afterEach, describe, expect, it } from 'vitest'
|
|
8
|
+
import { afterEach, beforeAll, describe, expect, it } from 'vitest'
|
|
9
9
|
// @if redux-toolkit
|
|
10
10
|
import { store } from '../../state/store'
|
|
11
11
|
// @endif
|
|
12
12
|
import { Providers } from '../../theme/Providers'
|
|
13
|
+
import { setup } from '../../theme/setup'
|
|
13
14
|
import Page from './Page'
|
|
14
15
|
|
|
15
16
|
/** The home page, inside the providers the app gives it. */
|
|
@@ -38,6 +39,9 @@ function renderPage() {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
describe('the home page', () => {
|
|
42
|
+
// The engine is configured once, as the app does it, before any page renders.
|
|
43
|
+
beforeAll(setup)
|
|
44
|
+
|
|
41
45
|
// Vitest has no globals here, so Testing Library cannot clean up on its own.
|
|
42
46
|
afterEach(cleanup)
|
|
43
47
|
|
|
@@ -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 { Counter } from './Counter'
|
|
5
5
|
// @if tanstack-query || swr || msw
|
|
6
6
|
import { Greeting } from './Greeting'
|
|
@@ -11,15 +11,15 @@ export default function Page() {
|
|
|
11
11
|
<Flex gap={2} alignItems="flex-start">
|
|
12
12
|
<Typography variant="h2">__TITLE__</Typography>
|
|
13
13
|
<Typography color="secondary">
|
|
14
|
-
A React Router app on
|
|
15
|
-
|
|
14
|
+
A React Router app on Gild UI. Edit src/pages/index/Page.tsx, and make the themes your own
|
|
15
|
+
in src/theme/themes.ts.
|
|
16
16
|
</Typography>
|
|
17
17
|
{/* @if tanstack-query || swr || msw */}
|
|
18
18
|
<Greeting />
|
|
19
19
|
{/* @endif */}
|
|
20
20
|
<Counter />
|
|
21
21
|
<Flex flexDirection="row" gap={1}>
|
|
22
|
-
<Button href="https://
|
|
22
|
+
<Button href="https://gild-ui.soroush.design">Components</Button>
|
|
23
23
|
<Button href="https://reactrouter.com" variant="outlined">
|
|
24
24
|
React Router
|
|
25
25
|
</Button>
|
|
@@ -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
|
// @if tanstack-query
|
|
4
4
|
import { useQuery } from '@tanstack/react-query'
|
|
5
5
|
import { useParams } from 'react-router'
|