create-waku 0.7.0 → 0.7.2
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/cli.js +4 -0
- package/dist/index.js +1 -2
- package/package.json +2 -2
- package/template/01_template/package.json +6 -6
- package/template/01_template/src/components/counter.tsx +7 -2
- package/template/01_template/src/components/footer.tsx +6 -1
- package/template/01_template/src/components/header.tsx +1 -1
- package/template/01_template/src/styles.css +1 -13
- package/template/01_template/src/templates/about-page.tsx +6 -3
- package/template/01_template/src/templates/home-page.tsx +5 -2
- package/template/01_template/src/templates/root-layout.tsx +1 -1
- package/template/{04_callserver → 02_demo}/package.json +8 -6
- package/template/02_demo/postcss.config.js +7 -0
- package/template/02_demo/public/images/favicon.png +0 -0
- package/template/02_demo/src/components/error-boundary.tsx +28 -0
- package/template/02_demo/src/components/footer.tsx +18 -0
- package/template/02_demo/src/components/header.tsx +11 -0
- package/template/02_demo/src/entries.tsx +29 -0
- package/template/02_demo/src/lib/index.ts +26 -0
- package/template/02_demo/src/lib/pokemon.ts +2586 -0
- package/template/{05_mutation → 02_demo}/src/main.tsx +6 -4
- package/template/02_demo/src/styles.css +5 -0
- package/template/02_demo/src/templates/home-page.tsx +35 -0
- package/template/02_demo/src/templates/pokemon-page.tsx +69 -0
- package/template/02_demo/src/templates/root-layout.tsx +33 -0
- package/template/02_demo/tailwind.config.js +10 -0
- package/template/{05_mutation → 02_demo}/tsconfig.json +4 -1
- package/template/{02_minimal → 03_minimal}/package.json +5 -5
- package/template/{03_promise → 04_promise}/package.json +5 -5
- package/template/{05_mutation → 05_actions}/package.json +5 -5
- package/template/{05_mutation → 05_actions}/src/components/App.tsx +3 -2
- package/template/{04_callserver → 05_actions}/src/components/Counter.tsx +15 -9
- package/template/{05_mutation → 05_actions}/src/components/funcs.ts +2 -0
- package/template/05_actions/vite.config.ts +6 -0
- package/template/06_nesting/package.json +5 -5
- package/template/07_router/package.json +5 -5
- package/template/08_cookies/dev.js +1 -1
- package/template/08_cookies/package.json +6 -6
- package/template/08_cookies/start.js +3 -4
- package/template/09_cssmodules/package.json +5 -5
- package/template/09_cssmodules/src/components/Layout.tsx +22 -0
- package/template/09_cssmodules/src/components/styles.css +3 -0
- package/template/09_cssmodules/src/entries.tsx +6 -1
- package/template/10_dynamicroute/package.json +5 -5
- package/template/10_dynamicroute/src/entries.tsx +17 -16
- package/template/10_dynamicroute/vite.config.ts +0 -3
- package/template/11_form/package.json +5 -5
- package/template/12_css/package.json +10 -10
- package/template/12_css/vite.config.ts +3 -8
- package/template/13_path-alias/package.json +7 -7
- package/template/13_path-alias/vite.config.ts +9 -4
- package/template/04_callserver/src/components/App.tsx +0 -20
- package/template/04_callserver/src/components/funcs.ts +0 -3
- package/template/04_callserver/src/entries.tsx +0 -31
- package/template/05_mutation/src/components/Counter.tsx +0 -24
- /package/template/{02_minimal → 03_minimal}/src/components/App.tsx +0 -0
- /package/template/{02_minimal → 03_minimal}/src/components/Counter.tsx +0 -0
- /package/template/{02_minimal → 03_minimal}/src/entries.tsx +0 -0
- /package/template/{02_minimal → 03_minimal}/src/main.tsx +0 -0
- /package/template/{02_minimal → 03_minimal}/tsconfig.json +0 -0
- /package/template/{03_promise → 04_promise}/src/components/App.tsx +0 -0
- /package/template/{03_promise → 04_promise}/src/components/Counter.tsx +0 -0
- /package/template/{03_promise → 04_promise}/src/entries.tsx +0 -0
- /package/template/{03_promise → 04_promise}/src/main.tsx +0 -0
- /package/template/{03_promise → 04_promise}/tsconfig.json +0 -0
- /package/template/{04_callserver → 05_actions}/src/components/TextBox.tsx +0 -0
- /package/template/{05_mutation → 05_actions}/src/entries.tsx +0 -0
- /package/template/{04_callserver → 05_actions}/src/main.tsx +0 -0
- /package/template/{04_callserver → 05_actions}/tsconfig.json +0 -0
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import type { ReactNode, FunctionComponent } from 'react';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
fallback: (error: unknown) => ReactNode;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class ErrorBoundaryClass extends Component<Props, { error?: unknown }> {
|
|
10
|
+
constructor(props: Props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.state = {};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static getDerivedStateFromError(error: unknown) {
|
|
16
|
+
return { error };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
render() {
|
|
20
|
+
if ('error' in this.state) {
|
|
21
|
+
return this.props.fallback(this.state.error);
|
|
22
|
+
}
|
|
23
|
+
return this.props.children;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const ErrorBoundary =
|
|
28
|
+
ErrorBoundaryClass as unknown as FunctionComponent<Props>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const Footer = () => {
|
|
2
|
+
return (
|
|
3
|
+
<footer className="fixed bottom-0 left-0 p-6">
|
|
4
|
+
<div>
|
|
5
|
+
visit{' '}
|
|
6
|
+
<a
|
|
7
|
+
href="https://waku.gg/"
|
|
8
|
+
target="_blank"
|
|
9
|
+
rel="noreferrer"
|
|
10
|
+
className="mt-4 inline-block underline"
|
|
11
|
+
>
|
|
12
|
+
waku.gg
|
|
13
|
+
</a>{' '}
|
|
14
|
+
to learn more
|
|
15
|
+
</div>
|
|
16
|
+
</footer>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createPages } from 'waku';
|
|
2
|
+
|
|
3
|
+
import { getPokemonPaths } from './lib/index.js';
|
|
4
|
+
import { RootLayout } from './templates/root-layout.js';
|
|
5
|
+
import { HomePage } from './templates/home-page.js';
|
|
6
|
+
import { PokemonPage } from './templates/pokemon-page.js';
|
|
7
|
+
|
|
8
|
+
export default createPages(async ({ createPage, createLayout }) => {
|
|
9
|
+
createLayout({
|
|
10
|
+
render: 'static',
|
|
11
|
+
path: '/',
|
|
12
|
+
component: RootLayout,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
createPage({
|
|
16
|
+
render: 'dynamic',
|
|
17
|
+
path: '/',
|
|
18
|
+
component: HomePage,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const pokemonPaths = await getPokemonPaths();
|
|
22
|
+
|
|
23
|
+
createPage({
|
|
24
|
+
render: 'static',
|
|
25
|
+
path: '/[slug]',
|
|
26
|
+
component: PokemonPage,
|
|
27
|
+
staticPaths: pokemonPaths,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { pokemon } from './pokemon.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mock database
|
|
6
|
+
* @param {TemplateStringsArray} query: mock query string
|
|
7
|
+
*/
|
|
8
|
+
export const sql = async (query: TemplateStringsArray) => {
|
|
9
|
+
const shuffledPokemon = shuffle(pokemon).slice(0, 9);
|
|
10
|
+
|
|
11
|
+
return { rows: shuffledPokemon };
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const shuffle = (array: Array<any>) => {
|
|
15
|
+
return array
|
|
16
|
+
.map((value: any) => ({ value, sort: Math.random() }))
|
|
17
|
+
.sort((a: any, b: any) => a.sort - b.sort)
|
|
18
|
+
.map(({ value }: any) => value);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Mock static paths
|
|
23
|
+
*/
|
|
24
|
+
export const getPokemonPaths = async () => {
|
|
25
|
+
return pokemon.map((row) => row.slug);
|
|
26
|
+
};
|