@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
|
@@ -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, type RootState } 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,6 +1,6 @@
|
|
|
1
1
|
# __TITLE__
|
|
2
2
|
|
|
3
|
-
A [Vike](https://vike.dev) app on
|
|
3
|
+
A [Vike](https://vike.dev) app on [Gild UI](https://gild-ui.soroush.design):
|
|
4
4
|
<!-- @if isomorphic -->
|
|
5
5
|
prerendered at build time with its styles in the HTML, then moving between pages with no reload.
|
|
6
6
|
<!-- @elif ssr -->
|
|
@@ -16,6 +16,7 @@ every page prerendered to HTML at build time, with its styles, and no JavaScript
|
|
|
16
16
|
- `src/pages/` holds the pages: a folder per route, each with its `+Page`.
|
|
17
17
|
- `src/pages/+Layout.jsx` is the frame every page renders in, inside the app's providers.
|
|
18
18
|
- `src/theme/themes.js` holds the light and the dark theme: make them your own.
|
|
19
|
+
- `src/theme/setup.js` configures the engine once, with the theme the app starts in; `src/pages/+onCreateGlobalContext.js` runs it on the server and in the browser.
|
|
19
20
|
<!-- @if isomorphic -->
|
|
20
21
|
- In `src/pages/`, `+onRenderHtml` and `+onRenderClient` render the pages, with the styles each page uses in its HTML.
|
|
21
22
|
<!-- @elif ssr -->
|
|
@@ -80,4 +81,4 @@ every page prerendered to HTML at build time, with its styles, and no JavaScript
|
|
|
80
81
|
<!-- @endif -->
|
|
81
82
|
|
|
82
83
|
Fonts: the theme names Space Grotesk and JetBrains Mono, and does not load them. See
|
|
83
|
-
https://
|
|
84
|
+
https://gild-ui.soroush.design/react/installation/#fonts
|
|
@@ -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
|
|
|
8
8
|
/**
|
|
9
9
|
* The app bar on every page: the app's title, its links, and `children` at its end. It sticks to
|
|
@@ -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 }) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useState } from 'react'
|
|
3
3
|
// @else
|
|
4
4
|
// @endif
|
|
5
|
-
import { View } from '@
|
|
5
|
+
import { View } from '@gild-ui/react/View'
|
|
6
6
|
// @if tanstack-query
|
|
7
7
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
8
8
|
// @endif
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { setup } from '../theme/setup'
|
|
2
|
+
|
|
3
|
+
// Vike runs this once when the server starts (the development server, the prerender) and once in
|
|
4
|
+
// the browser, before any page renders: the engine is configured once for the whole program.
|
|
5
|
+
export function onCreateGlobalContext() {
|
|
6
|
+
setup()
|
|
7
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import createEmotionServer from '@emotion/server/create-instance'
|
|
2
1
|
import { renderToString } from 'react-dom/server'
|
|
3
|
-
import {
|
|
2
|
+
import { styleServer } from '@gild-ui/react/server'
|
|
4
3
|
import { dangerouslySkipEscape, escapeInject } from 'vike/server'
|
|
5
4
|
import { PageShell } from './PageShell'
|
|
6
5
|
|
|
@@ -9,7 +8,7 @@ import { PageShell } from './PageShell'
|
|
|
9
8
|
* in the head, so it is drawn styled before any script runs.
|
|
10
9
|
*/
|
|
11
10
|
export const onRenderHtml = (pageContext) => {
|
|
12
|
-
const { extractCriticalToChunks, constructStyleTagsFromChunks } =
|
|
11
|
+
const { extractCriticalToChunks, constructStyleTagsFromChunks } = styleServer
|
|
13
12
|
const html = renderToString(<PageShell pageContext={pageContext} />)
|
|
14
13
|
const styles = constructStyleTagsFromChunks(extractCriticalToChunks(html))
|
|
15
14
|
return escapeInject`<!doctype html>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StrictMode } from 'react'
|
|
2
|
-
import { CacheProvider, styleCache } from '@
|
|
2
|
+
import { CacheProvider, styleCache } from '@gild-ui/react/engine'
|
|
3
3
|
// @if redux-toolkit
|
|
4
4
|
import { Provider as StoreProvider } from 'react-redux'
|
|
5
5
|
// @endif
|
|
@@ -9,7 +9,7 @@ import { store } from '../state/store'
|
|
|
9
9
|
import { PageContextProvider } from './usePageContext'
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* The page inside its +Layout. The
|
|
12
|
+
* The page inside its +Layout. The style cache is Gild UI's, so the styles the page
|
|
13
13
|
* uses are found where it is drawn, and every component of the page can read its pageContext.
|
|
14
14
|
*/
|
|
15
15
|
export function PageShell({ pageContext }) {
|
|
@@ -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
|
|
|
5
5
|
/** Shown for a page that does not exist, and when a page fails to render. */
|
|
6
6
|
export default function Page() {
|
|
@@ -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,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
|
// @if !ssg
|
|
5
5
|
import { Counter } from './Counter'
|
|
6
6
|
// @endif
|
|
@@ -13,8 +13,8 @@ export default function Page() {
|
|
|
13
13
|
<Flex gap={2} alignItems="flex-start">
|
|
14
14
|
<Typography variant="h2">__TITLE__</Typography>
|
|
15
15
|
<Typography color="secondary">
|
|
16
|
-
A Vike app on
|
|
17
|
-
|
|
16
|
+
A Vike app on Gild UI. Edit src/pages/index/+Page.jsx, and make the themes your own in
|
|
17
|
+
src/theme/themes.js.
|
|
18
18
|
</Typography>
|
|
19
19
|
{/* @if tanstack-query || swr || msw */}
|
|
20
20
|
<Greeting />
|
|
@@ -23,7 +23,7 @@ export default function Page() {
|
|
|
23
23
|
<Counter />
|
|
24
24
|
{/* @endif */}
|
|
25
25
|
<Flex flexDirection="row" gap={1}>
|
|
26
|
-
<Button href="https://
|
|
26
|
+
<Button href="https://gild-ui.soroush.design">Components</Button>
|
|
27
27
|
<Button href="https://vike.dev" variant="outlined">
|
|
28
28
|
Vike
|
|
29
29
|
</Button>
|
|
@@ -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
|
|
|
7
7
|
/** A count, held in the component's own state, and the button that adds to it. */
|
|
8
8
|
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'
|
|
@@ -9,11 +9,12 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
|
9
9
|
// @if redux-toolkit
|
|
10
10
|
import { Provider as StoreProvider } from 'react-redux'
|
|
11
11
|
// @endif
|
|
12
|
-
import { afterEach, describe, expect, it } from 'vitest'
|
|
12
|
+
import { afterEach, beforeAll, describe, expect, it } from 'vitest'
|
|
13
13
|
// @if redux-toolkit
|
|
14
14
|
import { store } from '../../state/store'
|
|
15
15
|
// @endif
|
|
16
16
|
import { Providers } from '../../theme/Providers'
|
|
17
|
+
import { setup } from '../../theme/setup'
|
|
17
18
|
import Page from './+Page'
|
|
18
19
|
|
|
19
20
|
/** The home page, inside the providers the app gives it. */
|
|
@@ -42,6 +43,9 @@ function renderPage() {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
describe('the home page', () => {
|
|
46
|
+
// The engine is configured once, as the app does it, before any page renders.
|
|
47
|
+
beforeAll(setup)
|
|
48
|
+
|
|
45
49
|
// Vitest has no globals here, so Testing Library cannot clean up on its own.
|
|
46
50
|
afterEach(cleanup)
|
|
47
51
|
|
|
@@ -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 { 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,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,6 +1,5 @@
|
|
|
1
|
-
import createEmotionServer from '@emotion/server/create-instance'
|
|
2
1
|
import { renderToString } from 'react-dom/server'
|
|
3
|
-
import {
|
|
2
|
+
import { styleServer } from '@gild-ui/react/server'
|
|
4
3
|
import { dangerouslySkipEscape, escapeInject } from 'vike/server'
|
|
5
4
|
import { PageShell } from './PageShell'
|
|
6
5
|
|
|
@@ -9,7 +8,7 @@ import { PageShell } from './PageShell'
|
|
|
9
8
|
* head, so it is drawn styled before any script runs.
|
|
10
9
|
*/
|
|
11
10
|
export const onRenderHtml = (pageContext) => {
|
|
12
|
-
const { extractCriticalToChunks, constructStyleTagsFromChunks } =
|
|
11
|
+
const { extractCriticalToChunks, constructStyleTagsFromChunks } = styleServer
|
|
13
12
|
const html = renderToString(<PageShell pageContext={pageContext} />)
|
|
14
13
|
const styles = constructStyleTagsFromChunks(extractCriticalToChunks(html))
|
|
15
14
|
return escapeInject`<!doctype html>
|
|
@@ -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,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,6 +1,6 @@
|
|
|
1
1
|
# __TITLE__
|
|
2
2
|
|
|
3
|
-
A [Vike](https://vike.dev) app on
|
|
3
|
+
A [Vike](https://vike.dev) app on [Gild UI](https://gild-ui.soroush.design):
|
|
4
4
|
<!-- @if isomorphic -->
|
|
5
5
|
prerendered at build time with its styles in the HTML, then moving between pages with no reload.
|
|
6
6
|
<!-- @elif ssr -->
|
|
@@ -16,6 +16,7 @@ every page prerendered to HTML at build time, with its styles, and no JavaScript
|
|
|
16
16
|
- `src/pages/` holds the pages: a folder per route, each with its `+Page`.
|
|
17
17
|
- `src/pages/+Layout.tsx` is the frame every page renders in, inside the app's providers.
|
|
18
18
|
- `src/theme/themes.ts` holds the light and the dark theme: make them your own.
|
|
19
|
+
- `src/theme/setup.ts` configures the engine once, with the theme the app starts in; `src/pages/+onCreateGlobalContext.ts` runs it on the server and in the browser.
|
|
19
20
|
<!-- @if isomorphic -->
|
|
20
21
|
- In `src/pages/`, `+onRenderHtml` and `+onRenderClient` render the pages, with the styles each page uses in its HTML.
|
|
21
22
|
<!-- @elif ssr -->
|
|
@@ -80,4 +81,4 @@ every page prerendered to HTML at build time, with its styles, and no JavaScript
|
|
|
80
81
|
<!-- @endif -->
|
|
81
82
|
|
|
82
83
|
Fonts: the theme names Space Grotesk and JetBrains Mono, and does not load them. See
|
|
83
|
-
https://
|
|
84
|
+
https://gild-ui.soroush.design/react/installation/#fonts
|
|
@@ -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
|
|
|
9
9
|
/**
|
|
10
10
|
* The app bar on every page: the app's title, its links, and `children` at its end. It sticks to
|
|
@@ -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
|
|
|
@@ -3,7 +3,7 @@ import { useState, type ReactNode } from 'react'
|
|
|
3
3
|
// @else
|
|
4
4
|
import type { ReactNode } from 'react'
|
|
5
5
|
// @endif
|
|
6
|
-
import { View } from '@
|
|
6
|
+
import { View } from '@gild-ui/react/View'
|
|
7
7
|
// @if tanstack-query
|
|
8
8
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
9
9
|
// @endif
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { setup } from '../theme/setup'
|
|
2
|
+
|
|
3
|
+
// Vike runs this once when the server starts (the development server, the prerender) and once in
|
|
4
|
+
// the browser, before any page renders: the engine is configured once for the whole program.
|
|
5
|
+
export function onCreateGlobalContext() {
|
|
6
|
+
setup()
|
|
7
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import createEmotionServer from '@emotion/server/create-instance'
|
|
2
1
|
import { renderToString } from 'react-dom/server'
|
|
3
|
-
import {
|
|
2
|
+
import { styleServer } from '@gild-ui/react/server'
|
|
4
3
|
import { dangerouslySkipEscape, escapeInject } from 'vike/server'
|
|
5
4
|
import type { OnRenderHtmlSync } from 'vike/types'
|
|
6
5
|
import { PageShell } from './PageShell'
|
|
@@ -10,7 +9,7 @@ import { PageShell } from './PageShell'
|
|
|
10
9
|
* in the head, so it is drawn styled before any script runs.
|
|
11
10
|
*/
|
|
12
11
|
export const onRenderHtml: OnRenderHtmlSync = (pageContext) => {
|
|
13
|
-
const { extractCriticalToChunks, constructStyleTagsFromChunks } =
|
|
12
|
+
const { extractCriticalToChunks, constructStyleTagsFromChunks } = styleServer
|
|
14
13
|
const html = renderToString(<PageShell pageContext={pageContext} />)
|
|
15
14
|
const styles = constructStyleTagsFromChunks(extractCriticalToChunks(html))
|
|
16
15
|
return escapeInject`<!doctype html>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StrictMode } from 'react'
|
|
2
|
-
import { CacheProvider, styleCache } from '@
|
|
2
|
+
import { CacheProvider, styleCache } from '@gild-ui/react/engine'
|
|
3
3
|
// @if redux-toolkit
|
|
4
4
|
import { Provider as StoreProvider } from 'react-redux'
|
|
5
5
|
// @endif
|
|
@@ -10,7 +10,7 @@ import { store } from '../state/store'
|
|
|
10
10
|
import { PageContextProvider } from './usePageContext'
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* The page inside its +Layout. The
|
|
13
|
+
* The page inside its +Layout. The style cache is Gild UI's, so the styles the page
|
|
14
14
|
* uses are found where it is drawn, and every component of the page can read its pageContext.
|
|
15
15
|
*/
|
|
16
16
|
export function PageShell({ pageContext }: { readonly pageContext: PageContext }) {
|
|
@@ -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
|
|
|
5
5
|
/** Shown for a page that does not exist, and when a page fails to render. */
|
|
6
6
|
export default function Page() {
|
|
@@ -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,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
|
// @if !ssg
|
|
5
5
|
import { Counter } from './Counter'
|
|
6
6
|
// @endif
|
|
@@ -13,8 +13,8 @@ export default function Page() {
|
|
|
13
13
|
<Flex gap={2} alignItems="flex-start">
|
|
14
14
|
<Typography variant="h2">__TITLE__</Typography>
|
|
15
15
|
<Typography color="secondary">
|
|
16
|
-
A Vike app on
|
|
17
|
-
|
|
16
|
+
A Vike app on Gild UI. Edit src/pages/index/+Page.tsx, and make the themes your own in
|
|
17
|
+
src/theme/themes.ts.
|
|
18
18
|
</Typography>
|
|
19
19
|
{/* @if tanstack-query || swr || msw */}
|
|
20
20
|
<Greeting />
|
|
@@ -23,7 +23,7 @@ export default function Page() {
|
|
|
23
23
|
<Counter />
|
|
24
24
|
{/* @endif */}
|
|
25
25
|
<Flex flexDirection="row" gap={1}>
|
|
26
|
-
<Button href="https://
|
|
26
|
+
<Button href="https://gild-ui.soroush.design">Components</Button>
|
|
27
27
|
<Button href="https://vike.dev" variant="outlined">
|
|
28
28
|
Vike
|
|
29
29
|
</Button>
|
|
@@ -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
|
|
|
7
7
|
/** A count, held in the component's own state, and the button that adds to it. */
|
|
8
8
|
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
|
|
@@ -9,11 +9,12 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
|
9
9
|
// @if redux-toolkit
|
|
10
10
|
import { Provider as StoreProvider } from 'react-redux'
|
|
11
11
|
// @endif
|
|
12
|
-
import { afterEach, describe, expect, it } from 'vitest'
|
|
12
|
+
import { afterEach, beforeAll, describe, expect, it } from 'vitest'
|
|
13
13
|
// @if redux-toolkit
|
|
14
14
|
import { store } from '../../state/store'
|
|
15
15
|
// @endif
|
|
16
16
|
import { Providers } from '../../theme/Providers'
|
|
17
|
+
import { setup } from '../../theme/setup'
|
|
17
18
|
import Page from './+Page'
|
|
18
19
|
|
|
19
20
|
/** The home page, inside the providers the app gives it. */
|
|
@@ -42,6 +43,9 @@ function renderPage() {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
describe('the home page', () => {
|
|
46
|
+
// The engine is configured once, as the app does it, before any page renders.
|
|
47
|
+
beforeAll(setup)
|
|
48
|
+
|
|
45
49
|
// Vitest has no globals here, so Testing Library cannot clean up on its own.
|
|
46
50
|
afterEach(cleanup)
|
|
47
51
|
|
|
@@ -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'
|