Skip to content

Commit ddcaf5e

Browse files
feat(react): add shield-react, shield-react-router and shield-react-shadcn-ui (#192)
1 parent 4a0c8ed commit ddcaf5e

63 files changed

Lines changed: 11312 additions & 1854 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,5 +162,12 @@ target/
162162
# mdBook
163163
book/book/
164164

165+
# React Router
166+
.react-router/
167+
build/
168+
165169
# SeaORM
166170
packages/storage/shield-sea-orm/src/entities_template/
171+
172+
# Turborepo
173+
.turbo/

.prettierignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierrc.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
2-
"bracketSpacing": false,
2+
"importOrder": ["^~", "^[.]"],
3+
"importOrderSeparation": true,
4+
"importOrderSortSpecifiers": true,
5+
"jsonRecursiveSort": true,
6+
"plugins": ["@trivago/prettier-plugin-sort-imports", "prettier-plugin-sort-json", "prettier-plugin-tailwindcss"],
37
"printWidth": 120,
48
"singleQuote": true,
59
"tabWidth": 4,
6-
"trailingComma": "none"
10+
"tailwindStylesheet": "./examples/react-router/assets/css/index.css"
711
}

book/theme/tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ document.addEventListener('DOMContentLoaded', () => {
5454
localStorage.setItem(`mdbook-tabs-${global}`, name);
5555

5656
const globalContainers = document.querySelectorAll(
57-
`.mdbook-tabs-container[data-tabglobal="${global}"]`
57+
`.mdbook-tabs-container[data-tabglobal="${global}"]`,
5858
);
5959
for (const globalContainer of globalContainers) {
6060
changeTab(globalContainer, name);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { type ClassValue, clsx } from 'clsx';
2+
import { twMerge } from 'tailwind-merge';
3+
4+
export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));

examples/react-router/app/root.tsx

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
2+
import { Links, Meta, Outlet, Scripts, ScrollRestoration, isRouteErrorResponse } from 'react-router';
3+
4+
import '~assets/css/index.css';
5+
6+
import type { Route } from './+types/root';
7+
8+
export const Layout = ({ children }: React.PropsWithChildren) => {
9+
return (
10+
<html lang="en">
11+
<head>
12+
<meta charSet="utf-8" />
13+
<meta name="viewport" content="width=device-width, initial-scale=1" />
14+
15+
<title>Shield React Router Example</title>
16+
17+
<Meta />
18+
<Links />
19+
</head>
20+
<body>
21+
{children}
22+
23+
<ScrollRestoration />
24+
<Scripts />
25+
</body>
26+
</html>
27+
);
28+
};
29+
30+
const queryClient = new QueryClient();
31+
32+
const App = () => (
33+
<QueryClientProvider client={queryClient}>
34+
<Outlet />
35+
</QueryClientProvider>
36+
);
37+
38+
export default App;
39+
40+
export const ErrorBoundary = ({ error }: Route.ErrorBoundaryProps) => {
41+
let message = 'Oops!';
42+
let details = 'An unexpected error occurred.';
43+
let stack: string | undefined;
44+
45+
if (isRouteErrorResponse(error)) {
46+
message = error.status === 404 ? '404' : 'Error';
47+
details = error.status === 404 ? 'The requested page could not be found.' : error.statusText || details;
48+
} else if (import.meta.env.DEV && error && error instanceof Error) {
49+
details = error.message;
50+
stack = error.stack;
51+
}
52+
53+
return (
54+
<main className="container mx-auto p-4 pt-16">
55+
<h1>{message}</h1>
56+
<p>{details}</p>
57+
{stack && (
58+
<pre className="w-full overflow-x-auto p-4">
59+
<code>{stack}</code>
60+
</pre>
61+
)}
62+
</main>
63+
);
64+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { type RouteConfig, index, prefix, route } from '@react-router/dev/routes';
2+
3+
export default [
4+
index('routes/home.tsx'),
5+
6+
...prefix('auth', [
7+
index('routes/auth/action.tsx', {
8+
id: 'routes/auth/action-index',
9+
}),
10+
route(':actionId', 'routes/auth/action.tsx'),
11+
]),
12+
] satisfies RouteConfig;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Action } from '@rustforweb/shield-react-router';
2+
import { ShadcnUiStyle } from '@rustforweb/shield-react-shadcn-ui';
3+
4+
import type { Route } from './+types/action';
5+
6+
const ActionRoute = (props: Route.ComponentProps) => {
7+
return <Action style={ShadcnUiStyle} {...props} />;
8+
};
9+
10+
export default ActionRoute;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const HomeRoute = () => <h1>Shield React Router Example</h1>;
2+
3+
export default HomeRoute;
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
@import 'tailwindcss';
2+
@import 'tw-animate-css';
3+
4+
@source "../../../../node_modules/@rustforweb/shield-react-shadcn-ui";
5+
6+
@custom-variant dark (&:is(.dark *));
7+
8+
:root {
9+
--radius: 0.65rem;
10+
--background: oklch(1 0 0);
11+
--foreground: oklch(0.145 0 0);
12+
--card: oklch(1 0 0);
13+
--card-foreground: oklch(0.145 0 0);
14+
--popover: oklch(1 0 0);
15+
--popover-foreground: oklch(0.145 0 0);
16+
--primary: oklch(0.205 0 0);
17+
--primary-foreground: oklch(0.985 0 0);
18+
--secondary: oklch(0.97 0 0);
19+
--secondary-foreground: oklch(0.205 0 0);
20+
--muted: oklch(0.97 0 0);
21+
--muted-foreground: oklch(0.556 0 0);
22+
--accent: oklch(0.97 0 0);
23+
--accent-foreground: oklch(0.205 0 0);
24+
--destructive: oklch(0.577 0.245 27.325);
25+
--border: oklch(0.922 0 0);
26+
--input: oklch(0.922 0 0);
27+
--ring: oklch(0.708 0 0);
28+
--chart-1: oklch(0.646 0.222 41.116);
29+
--chart-2: oklch(0.6 0.118 184.704);
30+
--chart-3: oklch(0.398 0.07 227.392);
31+
--chart-4: oklch(0.828 0.189 84.429);
32+
--chart-5: oklch(0.769 0.188 70.08);
33+
--radius: 0.625rem;
34+
--sidebar: oklch(0.985 0 0);
35+
--sidebar-foreground: oklch(0.145 0 0);
36+
--sidebar-primary: oklch(0.205 0 0);
37+
--sidebar-primary-foreground: oklch(0.985 0 0);
38+
--sidebar-accent: oklch(0.97 0 0);
39+
--sidebar-accent-foreground: oklch(0.205 0 0);
40+
--sidebar-border: oklch(0.922 0 0);
41+
--sidebar-ring: oklch(0.708 0 0);
42+
}
43+
44+
.dark {
45+
--background: oklch(0.145 0 0);
46+
--foreground: oklch(0.985 0 0);
47+
--card: oklch(0.205 0 0);
48+
--card-foreground: oklch(0.985 0 0);
49+
--popover: oklch(0.205 0 0);
50+
--popover-foreground: oklch(0.985 0 0);
51+
--primary: oklch(0.922 0 0);
52+
--primary-foreground: oklch(0.205 0 0);
53+
--secondary: oklch(0.269 0 0);
54+
--secondary-foreground: oklch(0.985 0 0);
55+
--muted: oklch(0.269 0 0);
56+
--muted-foreground: oklch(0.708 0 0);
57+
--accent: oklch(0.269 0 0);
58+
--accent-foreground: oklch(0.985 0 0);
59+
--destructive: oklch(0.704 0.191 22.216);
60+
--border: oklch(1 0 0 / 10%);
61+
--input: oklch(1 0 0 / 15%);
62+
--ring: oklch(0.556 0 0);
63+
--chart-1: oklch(0.488 0.243 264.376);
64+
--chart-2: oklch(0.696 0.17 162.48);
65+
--chart-3: oklch(0.769 0.188 70.08);
66+
--chart-4: oklch(0.627 0.265 303.9);
67+
--chart-5: oklch(0.645 0.246 16.439);
68+
--sidebar: oklch(0.205 0 0);
69+
--sidebar-foreground: oklch(0.985 0 0);
70+
--sidebar-primary: oklch(0.488 0.243 264.376);
71+
--sidebar-primary-foreground: oklch(0.985 0 0);
72+
--sidebar-accent: oklch(0.269 0 0);
73+
--sidebar-accent-foreground: oklch(0.985 0 0);
74+
--sidebar-border: oklch(1 0 0 / 10%);
75+
--sidebar-ring: oklch(0.556 0 0);
76+
}
77+
78+
@theme inline {
79+
--color-background: var(--background);
80+
--color-foreground: var(--foreground);
81+
--color-card: var(--card);
82+
--color-card-foreground: var(--card-foreground);
83+
--color-popover: var(--popover);
84+
--color-popover-foreground: var(--popover-foreground);
85+
--color-primary: var(--primary);
86+
--color-primary-foreground: var(--primary-foreground);
87+
--color-secondary: var(--secondary);
88+
--color-secondary-foreground: var(--secondary-foreground);
89+
--color-muted: var(--muted);
90+
--color-muted-foreground: var(--muted-foreground);
91+
--color-accent: var(--accent);
92+
--color-accent-foreground: var(--accent-foreground);
93+
--color-destructive: var(--destructive);
94+
--color-destructive-foreground: var(--destructive-foreground);
95+
--color-border: var(--border);
96+
--color-input: var(--input);
97+
--color-ring: var(--ring);
98+
--color-chart-1: var(--chart-1);
99+
--color-chart-2: var(--chart-2);
100+
--color-chart-3: var(--chart-3);
101+
--color-chart-4: var(--chart-4);
102+
--color-chart-5: var(--chart-5);
103+
--radius-sm: calc(var(--radius) - 4px);
104+
--radius-md: calc(var(--radius) - 2px);
105+
--radius-lg: var(--radius);
106+
--radius-xl: calc(var(--radius) + 4px);
107+
--color-sidebar: var(--sidebar);
108+
--color-sidebar-foreground: var(--sidebar-foreground);
109+
--color-sidebar-primary: var(--sidebar-primary);
110+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
111+
--color-sidebar-accent: var(--sidebar-accent);
112+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
113+
--color-sidebar-border: var(--sidebar-border);
114+
--color-sidebar-ring: var(--sidebar-ring);
115+
}
116+
117+
@layer base {
118+
* {
119+
@apply border-border outline-ring/50;
120+
}
121+
body {
122+
@apply bg-background text-foreground;
123+
}
124+
}

0 commit comments

Comments
 (0)