create-nevela 0.1.4 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nevela",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Create a new Nevela app: a Laravel API and a Next.js dashboard from one resource description.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,7 @@ use Nevela\Laravel\Support\Naming;
17
17
  final class Nevela
18
18
  {
19
19
  /** Written by `pnpm release`; the same number as the repository's git tag. */
20
- public const VERSION = '0.1.4';
20
+ public const VERSION = '0.1.5';
21
21
 
22
22
  /** @var array<string, Descriptor> */
23
23
  private static array $descriptors = [];
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { useState } from "react";
3
+ import { useState, useSyncExternalStore } from "react";
4
4
  import Link from "next/link";
5
5
  import { BellIcon, MoonIcon, SunIcon } from "lucide-react";
6
6
  import { Button } from "@/components/ui/button";
@@ -30,9 +30,31 @@ function applyTheme(theme: Theme) {
30
30
  if (theme !== "system") root.classList.add(theme);
31
31
  }
32
32
 
33
+ const DARK_QUERY = "(prefers-color-scheme: dark)";
34
+
35
+ function watchSystemTheme(onChange: () => void) {
36
+ const query = window.matchMedia(DARK_QUERY);
37
+ query.addEventListener("change", onChange);
38
+ return () => query.removeEventListener("change", onChange);
39
+ }
40
+
41
+ /**
42
+ * Whether the device prefers dark. The server can't know, so it and the first render in
43
+ * the browser both say no, and the real answer follows straight after: reading it during
44
+ * that first render would give the browser a different page from the one the server sent.
45
+ */
46
+ function useSystemDark() {
47
+ return useSyncExternalStore(
48
+ watchSystemTheme,
49
+ () => window.matchMedia(DARK_QUERY).matches,
50
+ () => false,
51
+ );
52
+ }
53
+
33
54
  export function DashboardHeader({ user, initialTheme, notices = [] }: { user: DashboardUser; initialTheme: Theme; notices?: Notice[] }) {
34
55
  const [theme, setTheme] = useState<Theme>(initialTheme);
35
- const dark = theme === "dark" || (theme === "system" && typeof window !== "undefined" && window.matchMedia("(prefers-color-scheme: dark)").matches);
56
+ const systemDark = useSystemDark();
57
+ const dark = theme === "dark" || (theme === "system" && systemDark);
36
58
  const needsAttention = notices.some((notice) => notice.tone === "warning");
37
59
 
38
60
  return (
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nevela-web",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -22,7 +22,7 @@
22
22
  "cmdk": "^1.1.1",
23
23
  "date-fns": "^4.4.0",
24
24
  "lucide-react": "^1.46.0",
25
- "next": "16.0.4",
25
+ "next": "16.3.8",
26
26
  "radix-ui": "^1.6.7",
27
27
  "react": "19.3.0",
28
28
  "react-day-picker": "^10.0.1",