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.
Files changed (69) hide show
  1. package/cli.js +4 -0
  2. package/dist/index.js +1 -2
  3. package/package.json +2 -2
  4. package/template/01_template/package.json +6 -6
  5. package/template/01_template/src/components/counter.tsx +7 -2
  6. package/template/01_template/src/components/footer.tsx +6 -1
  7. package/template/01_template/src/components/header.tsx +1 -1
  8. package/template/01_template/src/styles.css +1 -13
  9. package/template/01_template/src/templates/about-page.tsx +6 -3
  10. package/template/01_template/src/templates/home-page.tsx +5 -2
  11. package/template/01_template/src/templates/root-layout.tsx +1 -1
  12. package/template/{04_callserver → 02_demo}/package.json +8 -6
  13. package/template/02_demo/postcss.config.js +7 -0
  14. package/template/02_demo/public/images/favicon.png +0 -0
  15. package/template/02_demo/src/components/error-boundary.tsx +28 -0
  16. package/template/02_demo/src/components/footer.tsx +18 -0
  17. package/template/02_demo/src/components/header.tsx +11 -0
  18. package/template/02_demo/src/entries.tsx +29 -0
  19. package/template/02_demo/src/lib/index.ts +26 -0
  20. package/template/02_demo/src/lib/pokemon.ts +2586 -0
  21. package/template/{05_mutation → 02_demo}/src/main.tsx +6 -4
  22. package/template/02_demo/src/styles.css +5 -0
  23. package/template/02_demo/src/templates/home-page.tsx +35 -0
  24. package/template/02_demo/src/templates/pokemon-page.tsx +69 -0
  25. package/template/02_demo/src/templates/root-layout.tsx +33 -0
  26. package/template/02_demo/tailwind.config.js +10 -0
  27. package/template/{05_mutation → 02_demo}/tsconfig.json +4 -1
  28. package/template/{02_minimal → 03_minimal}/package.json +5 -5
  29. package/template/{03_promise → 04_promise}/package.json +5 -5
  30. package/template/{05_mutation → 05_actions}/package.json +5 -5
  31. package/template/{05_mutation → 05_actions}/src/components/App.tsx +3 -2
  32. package/template/{04_callserver → 05_actions}/src/components/Counter.tsx +15 -9
  33. package/template/{05_mutation → 05_actions}/src/components/funcs.ts +2 -0
  34. package/template/05_actions/vite.config.ts +6 -0
  35. package/template/06_nesting/package.json +5 -5
  36. package/template/07_router/package.json +5 -5
  37. package/template/08_cookies/dev.js +1 -1
  38. package/template/08_cookies/package.json +6 -6
  39. package/template/08_cookies/start.js +3 -4
  40. package/template/09_cssmodules/package.json +5 -5
  41. package/template/09_cssmodules/src/components/Layout.tsx +22 -0
  42. package/template/09_cssmodules/src/components/styles.css +3 -0
  43. package/template/09_cssmodules/src/entries.tsx +6 -1
  44. package/template/10_dynamicroute/package.json +5 -5
  45. package/template/10_dynamicroute/src/entries.tsx +17 -16
  46. package/template/10_dynamicroute/vite.config.ts +0 -3
  47. package/template/11_form/package.json +5 -5
  48. package/template/12_css/package.json +10 -10
  49. package/template/12_css/vite.config.ts +3 -8
  50. package/template/13_path-alias/package.json +7 -7
  51. package/template/13_path-alias/vite.config.ts +9 -4
  52. package/template/04_callserver/src/components/App.tsx +0 -20
  53. package/template/04_callserver/src/components/funcs.ts +0 -3
  54. package/template/04_callserver/src/entries.tsx +0 -31
  55. package/template/05_mutation/src/components/Counter.tsx +0 -24
  56. /package/template/{02_minimal → 03_minimal}/src/components/App.tsx +0 -0
  57. /package/template/{02_minimal → 03_minimal}/src/components/Counter.tsx +0 -0
  58. /package/template/{02_minimal → 03_minimal}/src/entries.tsx +0 -0
  59. /package/template/{02_minimal → 03_minimal}/src/main.tsx +0 -0
  60. /package/template/{02_minimal → 03_minimal}/tsconfig.json +0 -0
  61. /package/template/{03_promise → 04_promise}/src/components/App.tsx +0 -0
  62. /package/template/{03_promise → 04_promise}/src/components/Counter.tsx +0 -0
  63. /package/template/{03_promise → 04_promise}/src/entries.tsx +0 -0
  64. /package/template/{03_promise → 04_promise}/src/main.tsx +0 -0
  65. /package/template/{03_promise → 04_promise}/tsconfig.json +0 -0
  66. /package/template/{04_callserver → 05_actions}/src/components/TextBox.tsx +0 -0
  67. /package/template/{05_mutation → 05_actions}/src/entries.tsx +0 -0
  68. /package/template/{04_callserver → 05_actions}/src/main.tsx +0 -0
  69. /package/template/{04_callserver → 05_actions}/tsconfig.json +0 -0
@@ -0,0 +1,7 @@
1
+ /** @type {import('postcss-load-config').Config} */
2
+ export default {
3
+ plugins: {
4
+ tailwindcss: {},
5
+ autoprefixer: {},
6
+ },
7
+ };
@@ -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,11 @@
1
+ import { Link } from 'waku';
2
+
3
+ export const Header = () => {
4
+ return (
5
+ <header className="fixed left-0 top-0 p-6">
6
+ <h2 className="text-lg font-bold tracking-tight">
7
+ <Link to="/">Waku pokemon</Link>
8
+ </h2>
9
+ </header>
10
+ );
11
+ };
@@ -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
+ };