create-fate 1.4.0 → 1.5.0

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 (89) hide show
  1. package/bin/create-fate.mjs +30 -1
  2. package/package.json +1 -1
  3. package/templates/fate/cloudflare/README.md +11 -0
  4. package/templates/fate/cloudflare/client/package.json +10 -5
  5. package/templates/fate/cloudflare/client/pages/layout.tsx +2 -16
  6. package/templates/fate/cloudflare/client/src/lib/AvailableLanguages.tsx +3 -3
  7. package/templates/fate/cloudflare/client/src/lib/LocaleContext.tsx +61 -0
  8. package/templates/fate/cloudflare/client/src/ui/LocaleSwitcher.tsx +26 -44
  9. package/templates/fate/cloudflare/client/start.mjs +11 -0
  10. package/templates/fate/cloudflare/client/translations/{de_DE.json → de-DE.json} +56 -113
  11. package/templates/fate/{graphql/client/translations/ja_JP.json → cloudflare/client/translations/ja-JP.json} +56 -113
  12. package/templates/fate/cloudflare/client/vite.config.ts +1 -1
  13. package/templates/fate/cloudflare/server/src/lib/auth.ts +0 -2
  14. package/templates/fate/cloudflare/server/tsconfig.json +1 -1
  15. package/templates/fate/cloudflare/tsconfig.json +1 -1
  16. package/templates/fate/drizzle/README.md +11 -0
  17. package/templates/fate/drizzle/client/package.json +9 -5
  18. package/templates/fate/drizzle/client/pages/layout.tsx +2 -16
  19. package/templates/fate/drizzle/client/src/lib/AvailableLanguages.tsx +3 -3
  20. package/templates/fate/drizzle/client/src/lib/LocaleContext.tsx +61 -0
  21. package/templates/fate/drizzle/client/src/ui/LocaleSwitcher.tsx +26 -44
  22. package/templates/fate/drizzle/client/start.mjs +11 -0
  23. package/templates/fate/{graphql/client/translations/de_DE.json → drizzle/client/translations/de-DE.json} +56 -113
  24. package/templates/fate/{cloudflare/client/translations/ja_JP.json → drizzle/client/translations/ja-JP.json} +56 -113
  25. package/templates/fate/drizzle/client/vite.config.ts +1 -1
  26. package/templates/fate/graphql/README.md +11 -0
  27. package/templates/fate/graphql/client/package.json +9 -5
  28. package/templates/fate/graphql/client/pages/layout.tsx +2 -16
  29. package/templates/fate/graphql/client/src/lib/AvailableLanguages.tsx +3 -3
  30. package/templates/fate/graphql/client/src/lib/LocaleContext.tsx +61 -0
  31. package/templates/fate/graphql/client/src/ui/LocaleSwitcher.tsx +26 -44
  32. package/templates/fate/graphql/client/start.mjs +11 -0
  33. package/templates/fate/{drizzle/client/translations/de_DE.json → graphql/client/translations/de-DE.json} +56 -113
  34. package/templates/fate/{http/client/translations/ja_JP.json → graphql/client/translations/ja-JP.json} +56 -113
  35. package/templates/fate/graphql/client/vite.config.ts +1 -1
  36. package/templates/fate/graphql-client/README.md +9 -0
  37. package/templates/fate/graphql-client/_gitignore +3 -0
  38. package/templates/fate/graphql-client/package.json +9 -2
  39. package/templates/fate/graphql-client/pages/index.tsx +13 -5
  40. package/templates/fate/graphql-client/pages/layout.tsx +22 -15
  41. package/templates/fate/graphql-client/src/lib/AvailableLanguages.tsx +5 -0
  42. package/templates/fate/graphql-client/src/lib/LocaleContext.tsx +61 -0
  43. package/templates/fate/graphql-client/src/ui/LocaleSwitcher.tsx +34 -0
  44. package/templates/fate/graphql-client/translations/de-DE.json +225 -0
  45. package/templates/fate/graphql-client/translations/ja-JP.json +225 -0
  46. package/templates/fate/graphql-client/vite.config.ts +2 -0
  47. package/templates/fate/http/README.md +11 -0
  48. package/templates/fate/http/client/package.json +9 -5
  49. package/templates/fate/http/client/pages/layout.tsx +2 -16
  50. package/templates/fate/http/client/src/lib/AvailableLanguages.tsx +3 -3
  51. package/templates/fate/http/client/src/lib/LocaleContext.tsx +61 -0
  52. package/templates/fate/http/client/src/ui/LocaleSwitcher.tsx +26 -44
  53. package/templates/fate/http/client/start.mjs +11 -0
  54. package/templates/fate/http/client/translations/{de_DE.json → de-DE.json} +56 -113
  55. package/templates/fate/{drizzle/client/translations/ja_JP.json → http/client/translations/ja-JP.json} +56 -113
  56. package/templates/fate/http/client/vite.config.ts +1 -1
  57. package/templates/fate/prisma/README.md +11 -0
  58. package/templates/fate/prisma/client/package.json +9 -5
  59. package/templates/fate/prisma/client/pages/layout.tsx +2 -16
  60. package/templates/fate/prisma/client/src/lib/AvailableLanguages.tsx +3 -3
  61. package/templates/fate/prisma/client/src/lib/LocaleContext.tsx +61 -0
  62. package/templates/fate/prisma/client/src/ui/LocaleSwitcher.tsx +26 -44
  63. package/templates/fate/prisma/client/start.mjs +11 -0
  64. package/templates/fate/prisma/client/translations/de-DE.json +632 -0
  65. package/templates/fate/prisma/client/translations/ja-JP.json +632 -0
  66. package/templates/fate/prisma/client/vite.config.ts +1 -1
  67. package/templates/fate/void/README.md +9 -0
  68. package/templates/fate/void/_gitignore +3 -0
  69. package/templates/fate/void/middleware/01.shared.ts +3 -0
  70. package/templates/fate/void/package.json +9 -2
  71. package/templates/fate/void/pages/index.tsx +22 -10
  72. package/templates/fate/void/pages/layout.tsx +22 -19
  73. package/templates/fate/void/pages/login.tsx +22 -18
  74. package/templates/fate/void/pages/search.tsx +18 -4
  75. package/templates/fate/void/src/lib/AvailableLanguages.tsx +5 -0
  76. package/templates/fate/void/src/lib/LocaleContext.tsx +61 -0
  77. package/templates/fate/void/src/ui/CategoryCard.tsx +22 -4
  78. package/templates/fate/void/src/ui/CreatePost.tsx +12 -7
  79. package/templates/fate/void/src/ui/Error.tsx +4 -2
  80. package/templates/fate/void/src/ui/EventCard.tsx +18 -5
  81. package/templates/fate/void/src/ui/Header.tsx +10 -4
  82. package/templates/fate/void/src/ui/LocaleSwitcher.tsx +34 -0
  83. package/templates/fate/void/src/ui/PostCard.tsx +29 -14
  84. package/templates/fate/void/src/ui/UserCard.tsx +15 -8
  85. package/templates/fate/void/translations/de-DE.json +863 -0
  86. package/templates/fate/void/translations/ja-JP.json +863 -0
  87. package/templates/fate/void/vite.config.ts +2 -0
  88. package/templates/fate/prisma/client/translations/de_DE.json +0 -689
  89. package/templates/fate/prisma/client/translations/ja_JP.json +0 -689
@@ -1,52 +1,34 @@
1
- import { VStack } from '@nkzw/stack';
2
- import { cx } from 'class-variance-authority';
3
1
  import { useLocaleContext } from 'fbtee';
4
- import { Languages } from 'lucide-react';
2
+ import { startTransition } from 'react';
5
3
  import AvailableLanguages from '../lib/AvailableLanguages.tsx';
6
- import { Button } from './Button.tsx';
7
- import Card from './Card.tsx';
8
4
 
9
5
  export default function LocaleSwitcher() {
10
- const { locale: currentLocale, setLocale } = useLocaleContext();
11
-
6
+ const { locale, localeChangeIsPending, setLocale } = useLocaleContext();
12
7
  return (
13
- <>
14
- <Button asChild size="sm" variant="ghost">
15
- <button popoverTarget="locale-switcher" popoverTargetAction="show" type="button">
16
- <Languages className="h-4 w-4" />
17
- <span className="hidden sm:inline">
18
- <fbt desc="Locale switcher button">Change Language</fbt>
19
- </span>
20
- </button>
21
- </Button>
22
- <Card
23
- className="translate-y-50 justify-self-center border-slate-100 bg-white shadow transition-all dark:bg-black"
24
- id="locale-switcher"
25
- popover="auto"
8
+ <label className="inline-flex items-center gap-2 text-sm">
9
+ <span className="sr-only">
10
+ <fbt desc="Locale switcher button">Change Language</fbt>
11
+ </span>
12
+ <select
13
+ className="rounded-md border border-gray-300 bg-background px-2 py-1 text-foreground"
14
+ disabled={localeChangeIsPending}
15
+ onChange={(event) => {
16
+ const nextLocale = event.target.value;
17
+ try {
18
+ localStorage.setItem('fbtee:locale', nextLocale);
19
+ } catch {
20
+ // Changing the language still works without browser storage.
21
+ }
22
+ startTransition(() => setLocale(nextLocale));
23
+ }}
24
+ value={locale}
26
25
  >
27
- <VStack alignCenter center className="w-64" gap={12} padding={16}>
28
- {[...AvailableLanguages.entries()].map(([locale, name]) => (
29
- <Button
30
- action={() => {
31
- setLocale(locale);
32
- localStorage.setItem('fbtee:locale', locale);
33
- }}
34
- asChild
35
- className={cx(
36
- 'transition-background border-slate-200 bg-transparent duration-150 hover:border-slate-300 hover:bg-slate-200 dark:hover:bg-slate-900 dark:text-white active:py-2',
37
- {
38
- 'bg-slate-100 dark:bg-slate-900': currentLocale === locale,
39
- },
40
- )}
41
- key={locale}
42
- size="sm"
43
- variant="outline"
44
- >
45
- <a className="w-full flex-1 cursor-pointer p-2">{name}</a>
46
- </Button>
47
- ))}
48
- </VStack>
49
- </Card>
50
- </>
26
+ {[...AvailableLanguages].map(([value, name]) => (
27
+ <option key={value} value={value}>
28
+ {name}
29
+ </option>
30
+ ))}
31
+ </select>
32
+ </label>
51
33
  );
52
34
  }
@@ -0,0 +1,11 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import process from 'node:process';
3
+ import { fileURLToPath, URL } from 'node:url';
4
+
5
+ const dist = new URL('./dist/', import.meta.url);
6
+ // Void's Node renderer reads this manifest to emit client scripts and styles.
7
+ globalThis.__VITE_MANIFEST__ = JSON.parse(
8
+ readFileSync(new URL('client/.vite/manifest.json', dist), 'utf8'),
9
+ );
10
+ process.chdir(fileURLToPath(dist));
11
+ await import(new URL('ssr/index.js', dist).href);