kira-kit 0.4.0 → 0.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 (32) hide show
  1. package/README.md +273 -176
  2. package/dist/index.mjs +4763 -1284
  3. package/package.json +71 -64
  4. package/templates/monorepo/components.json +23 -23
  5. package/templates/monorepo/packages/ui/package.json +37 -32
  6. package/templates/monorepo/packages/ui/src/components/ui/welcome.tsx +52 -52
  7. package/templates/monorepo/packages/ui/src/index.css +738 -89
  8. package/templates/monorepo/packages/ui/src/styles/kira-utilities.css +649 -0
  9. package/templates/monorepo/packages/ui/tsconfig.json +8 -7
  10. package/templates/next/app/globals.css +731 -83
  11. package/templates/next/app/kira-utilities.css +649 -0
  12. package/templates/next/components/ui/welcome.tsx +62 -62
  13. package/templates/next/components.json +23 -23
  14. package/templates/next/package.json +31 -28
  15. package/templates/next/types/import-meta.d.ts +11 -0
  16. package/templates/tanstack-start/README.md +16 -16
  17. package/templates/tanstack-start/components.json +23 -23
  18. package/templates/tanstack-start/package.json +33 -30
  19. package/templates/tanstack-start/src/components/ui/route-transition.tsx +116 -0
  20. package/templates/tanstack-start/src/components/ui/welcome.tsx +52 -52
  21. package/templates/tanstack-start/src/index.css +738 -89
  22. package/templates/tanstack-start/src/lib/view-transition.ts +35 -0
  23. package/templates/tanstack-start/src/router.tsx +23 -15
  24. package/templates/tanstack-start/src/routes/__root.tsx +70 -41
  25. package/templates/tanstack-start/src/styles/kira-utilities.css +649 -0
  26. package/templates/tanstack-start/tsconfig.json +22 -21
  27. package/templates/vite/components.json +23 -23
  28. package/templates/vite/package.json +31 -28
  29. package/templates/vite/src/components/ui/welcome.tsx +60 -60
  30. package/templates/vite/src/index.css +731 -83
  31. package/templates/vite/src/styles/kira-utilities.css +649 -0
  32. package/templates/vite/tsconfig.node.json +25 -22
@@ -0,0 +1,35 @@
1
+ type ViewTransitionUpdate = () => void | Promise<void>;
2
+
3
+ function supportsViewTransitions(): boolean {
4
+ return (
5
+ typeof document !== "undefined" &&
6
+ // oxlint-disable-next-line anti-slop/no-runtime-typeof -- feature detection at the browser API boundary.
7
+ typeof document.startViewTransition === "function"
8
+ );
9
+ }
10
+
11
+ /**
12
+ * Runs a DOM update inside a native view transition when the browser supports
13
+ * it and the user has not asked for reduced motion; otherwise runs it directly.
14
+ */
15
+ function startViewTransition(
16
+ update: ViewTransitionUpdate,
17
+ ): ViewTransition | undefined {
18
+ const reducedMotion =
19
+ typeof window !== "undefined" &&
20
+ window.matchMedia("(prefers-reduced-motion: reduce)").matches;
21
+
22
+ if (!supportsViewTransitions() || reducedMotion) {
23
+ void update();
24
+
25
+ return undefined;
26
+ }
27
+
28
+ return document.startViewTransition(update);
29
+ }
30
+
31
+ export {
32
+ startViewTransition,
33
+ supportsViewTransitions,
34
+ type ViewTransitionUpdate,
35
+ };
@@ -1,15 +1,23 @@
1
- import { createRouter } from "@tanstack/react-router";
2
- import { routeTree } from "./routeTree.gen";
3
-
4
- export function getRouter() {
5
- return createRouter({
6
- routeTree,
7
- scrollRestoration: true,
8
- });
9
- }
10
-
11
- declare module "@tanstack/react-router" {
12
- interface Register {
13
- router: ReturnType<typeof getRouter>;
14
- }
15
- }
1
+ import { createRouter } from "@tanstack/react-router";
2
+ import { routeTree } from "./routeTree.gen";
3
+
4
+ export function getRouter() {
5
+ return createRouter({
6
+ routeTree,
7
+ scrollRestoration: true,
8
+ // Preload lazy route chunks on hover/touch intent so most navigations
9
+ // commit before the progress bar's grace period ends.
10
+ defaultPreload: "intent",
11
+ // Native crossfade for real path changes only; search/hash updates stay
12
+ // instant. Browsers without the View Transitions API navigate normally.
13
+ defaultViewTransition: {
14
+ types: ({ pathChanged }) => (pathChanged ? ["route-change"] : false),
15
+ },
16
+ });
17
+ }
18
+
19
+ declare module "@tanstack/react-router" {
20
+ interface Register {
21
+ router: ReturnType<typeof getRouter>;
22
+ }
23
+ }
@@ -1,41 +1,70 @@
1
- import type { ReactNode } from "react";
2
- import {
3
- createRootRoute,
4
- HeadContent,
5
- Outlet,
6
- Scripts,
7
- } from "@tanstack/react-router";
8
- import "@/index.css";
9
-
10
- export const Route = createRootRoute({
11
- head: () => ({
12
- meta: [
13
- { charSet: "utf-8" },
14
- { name: "viewport", content: "width=device-width, initial-scale=1" },
15
- { title: "Kira Kit + TanStack Start" },
16
- ],
17
- }),
18
- component: RootComponent,
19
- });
20
-
21
- function RootComponent() {
22
- return (
23
- <RootDocument>
24
- <Outlet />
25
- </RootDocument>
26
- );
27
- }
28
-
29
- function RootDocument({ children }: Readonly<{ children: ReactNode }>) {
30
- return (
31
- <html lang="en">
32
- <head>
33
- <HeadContent />
34
- </head>
35
- <body className="bg-background text-foreground antialiased">
36
- {children}
37
- <Scripts />
38
- </body>
39
- </html>
40
- );
41
- }
1
+ import type { ReactNode } from "react";
2
+ import {
3
+ createRootRoute,
4
+ HeadContent,
5
+ Outlet,
6
+ Scripts,
7
+ useLocation,
8
+ useRouterState,
9
+ } from "@tanstack/react-router";
10
+ import {
11
+ NavigationProgress,
12
+ RouteTransition,
13
+ } from "@/components/ui/route-transition";
14
+ import { supportsViewTransitions } from "@/lib/view-transition";
15
+ import "@/index.css";
16
+
17
+ export const Route = createRootRoute({
18
+ head: () => ({
19
+ meta: [
20
+ { charSet: "utf-8" },
21
+ { name: "viewport", content: "width=device-width, initial-scale=1" },
22
+ { title: "Kira Kit + TanStack Start" },
23
+ ],
24
+ }),
25
+ component: RootComponent,
26
+ });
27
+
28
+ function RouteOutlet() {
29
+ const pathname = useLocation({ select: (location) => location.pathname });
30
+
31
+ return (
32
+ <RouteTransition
33
+ transitionKey={pathname}
34
+ // One entrance mechanism per browser: the native crossfade where the
35
+ // View Transitions API exists, the CSS fade everywhere else.
36
+ variant={supportsViewTransitions() ? "none" : "fade"}
37
+ >
38
+ <Outlet />
39
+ </RouteTransition>
40
+ );
41
+ }
42
+
43
+ function RouteProgress() {
44
+ const isLoading = useRouterState({ select: (state) => state.isLoading });
45
+
46
+ return <NavigationProgress active={isLoading} />;
47
+ }
48
+
49
+ function RootComponent() {
50
+ return (
51
+ <RootDocument>
52
+ <RouteOutlet />
53
+ <RouteProgress />
54
+ </RootDocument>
55
+ );
56
+ }
57
+
58
+ function RootDocument({ children }: Readonly<{ children: ReactNode }>) {
59
+ return (
60
+ <html lang="en">
61
+ <head>
62
+ <HeadContent />
63
+ </head>
64
+ <body className="bg-background text-foreground antialiased">
65
+ {children}
66
+ <Scripts />
67
+ </body>
68
+ </html>
69
+ );
70
+ }