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.
- package/README.md +273 -176
- package/dist/index.mjs +4763 -1284
- package/package.json +71 -64
- package/templates/monorepo/components.json +23 -23
- package/templates/monorepo/packages/ui/package.json +37 -32
- package/templates/monorepo/packages/ui/src/components/ui/welcome.tsx +52 -52
- package/templates/monorepo/packages/ui/src/index.css +738 -89
- package/templates/monorepo/packages/ui/src/styles/kira-utilities.css +649 -0
- package/templates/monorepo/packages/ui/tsconfig.json +8 -7
- package/templates/next/app/globals.css +731 -83
- package/templates/next/app/kira-utilities.css +649 -0
- package/templates/next/components/ui/welcome.tsx +62 -62
- package/templates/next/components.json +23 -23
- package/templates/next/package.json +31 -28
- package/templates/next/types/import-meta.d.ts +11 -0
- package/templates/tanstack-start/README.md +16 -16
- package/templates/tanstack-start/components.json +23 -23
- package/templates/tanstack-start/package.json +33 -30
- package/templates/tanstack-start/src/components/ui/route-transition.tsx +116 -0
- package/templates/tanstack-start/src/components/ui/welcome.tsx +52 -52
- package/templates/tanstack-start/src/index.css +738 -89
- package/templates/tanstack-start/src/lib/view-transition.ts +35 -0
- package/templates/tanstack-start/src/router.tsx +23 -15
- package/templates/tanstack-start/src/routes/__root.tsx +70 -41
- package/templates/tanstack-start/src/styles/kira-utilities.css +649 -0
- package/templates/tanstack-start/tsconfig.json +22 -21
- package/templates/vite/components.json +23 -23
- package/templates/vite/package.json +31 -28
- package/templates/vite/src/components/ui/welcome.tsx +60 -60
- package/templates/vite/src/index.css +731 -83
- package/templates/vite/src/styles/kira-utilities.css +649 -0
- 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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
</
|
|
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
|
+
}
|