create-alistt69-kit 0.1.20 → 0.1.22
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 +1 -1
- package/src/features/eslint/files/eslint.config.mjs +4 -3
- package/src/features/react-router/files/src/app/App.tsx +3 -3
- package/src/features/react-router/files/src/app/providers/error-boundary/lib/provider/index.tsx +4 -4
- package/src/features/react-router/files/src/app/providers/error-boundary/ui/error-screen/index.tsx +3 -3
- package/src/features/react-router/files/src/app/providers/index.ts +14 -4
- package/src/features/react-router/files/src/app/providers/router/lib/hooks/useGetCurrentRouteConfig.ts +13 -0
- package/src/features/react-router/files/src/app/providers/router/lib/provider/index.tsx +16 -5
- package/src/features/react-router/files/src/app/providers/router/model/config/index.ts +8 -0
- package/src/features/react-router/files/src/app/providers/router/model/router/index.tsx +21 -0
- package/src/features/react-router/files/src/app/providers/router/types/index.ts +9 -0
- package/src/features/react-router/files/src/app/providers/router/ui/app/index.tsx +36 -0
- package/src/features/react-router/files/src/index.tsx +8 -4
- package/src/templates/base/config/build/buildPlugins.ts +1 -1
- package/src/templates/base/src/styles/index.scss +1 -1
- package/src/templates/base/src/styles/normalize.scss +36 -0
- package/src/features/react-router/files/src/app/layouts/app/index.tsx +0 -39
- package/src/features/react-router/files/src/app/providers/router/lib/router/index.tsx +0 -13
- /package/src/features/react-router/files/src/app/{layouts → providers/router/ui}/app/styles.module.scss +0 -0
package/package.json
CHANGED
|
@@ -102,9 +102,10 @@ export default [
|
|
|
102
102
|
// === React ===
|
|
103
103
|
...react.configs.recommended.rules,
|
|
104
104
|
...reactHooks.configs.recommended.rules,
|
|
105
|
-
'react/react-in-jsx-scope': 'off',
|
|
106
|
-
'react/jsx-uses-react': 'off',
|
|
107
|
-
'react/prop-types': 'off',
|
|
105
|
+
'react/react-in-jsx-scope': 'off', // Not needed in React 17+
|
|
106
|
+
'react/jsx-uses-react': 'off', // Not needed in React 17+
|
|
107
|
+
'react/prop-types': 'off', // TypeScript handles this
|
|
108
|
+
'react-hooks/set-state-in-effect': 'warn',
|
|
108
109
|
|
|
109
110
|
// === JSX formatting ===
|
|
110
111
|
'react/jsx-indent': ['error', 4],
|
|
@@ -3,10 +3,10 @@ import Logo from '../../public/create-alistt69-kit-logo.svg';
|
|
|
3
3
|
import styles from './styles.module.scss';
|
|
4
4
|
|
|
5
5
|
interface AppProps {
|
|
6
|
-
|
|
6
|
+
router: ReactNode;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
function App({
|
|
9
|
+
function App({ router }: AppProps) {
|
|
10
10
|
return (
|
|
11
11
|
<div className={styles.app_wrapper}>
|
|
12
12
|
<div className={styles.created_by_section}>
|
|
@@ -15,7 +15,7 @@ function App({ children }: AppProps) {
|
|
|
15
15
|
created by create-alistt69-kit
|
|
16
16
|
</p>
|
|
17
17
|
</div>
|
|
18
|
-
{
|
|
18
|
+
{router}
|
|
19
19
|
</div>
|
|
20
20
|
);
|
|
21
21
|
}
|
package/src/features/react-router/files/src/app/providers/error-boundary/lib/provider/index.tsx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Component, ErrorInfo, ReactNode } from 'react';
|
|
2
2
|
import ErrorScreen from '../../ui/error-screen';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface ErrorBoundaryProps {
|
|
5
5
|
children: ReactNode;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
interface ErrorBoundaryState {
|
|
9
9
|
hasError: boolean;
|
|
10
10
|
error: Error | null;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
|
|
13
13
|
class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
14
14
|
constructor(props: ErrorBoundaryProps) {
|
package/src/features/react-router/files/src/app/providers/error-boundary/ui/error-screen/index.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
interface ErrorScreenProps {
|
|
2
2
|
title?: string;
|
|
3
3
|
description?: string;
|
|
4
4
|
errorMessage?: string;
|
|
5
5
|
onRetry?: () => void;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
|
|
8
8
|
function ErrorScreen({
|
|
9
9
|
title = 'Something went wrong',
|
|
@@ -148,4 +148,4 @@ const buttonSecondaryStyle: React.CSSProperties = {
|
|
|
148
148
|
border: '1px solid rgba(255,255,255,0.1)',
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
-
export default ErrorScreen;
|
|
151
|
+
export default ErrorScreen;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import ErrorBoundary from './error-boundary/lib/provider'
|
|
2
|
-
import
|
|
1
|
+
import ErrorBoundary from './error-boundary/lib/provider';
|
|
2
|
+
import { useGetCurrentRouteConfig } from './router/lib/hooks/useGetCurrentRouteConfig';
|
|
3
|
+
import RouterProvider from './router/lib/provider';
|
|
4
|
+
import { routesConfig } from './router/model/config';
|
|
5
|
+
import { ERoutePath, IRouteConfig } from './router/types';
|
|
3
6
|
|
|
4
7
|
export {
|
|
5
|
-
Router
|
|
6
|
-
|
|
8
|
+
// Router
|
|
9
|
+
ERoutePath,
|
|
10
|
+
IRouteConfig,
|
|
11
|
+
routesConfig,
|
|
12
|
+
RouterProvider,
|
|
13
|
+
useGetCurrentRouteConfig,
|
|
14
|
+
|
|
15
|
+
// Error Boundary
|
|
16
|
+
ErrorBoundary,
|
|
7
17
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useLocation } from 'react-router-dom';
|
|
2
|
+
import { routesConfig } from '../../model/config';
|
|
3
|
+
import { IRouteConfig, ERoutePath } from '../../types';
|
|
4
|
+
|
|
5
|
+
export const useGetCurrentRouteConfig = (): IRouteConfig => {
|
|
6
|
+
const location = useLocation();
|
|
7
|
+
|
|
8
|
+
const firstPathSegment = location.pathname.split('/')[1] || '';
|
|
9
|
+
|
|
10
|
+
const matchedRoute = Object.values(routesConfig).find((route) => route.path === firstPathSegment);
|
|
11
|
+
|
|
12
|
+
return matchedRoute || routesConfig[ERoutePath.MAIN];
|
|
13
|
+
};
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ComponentType, ReactNode, useMemo } from 'react';
|
|
2
|
+
import { RouterProvider as RouterDomProvider } from 'react-router-dom';
|
|
3
|
+
import { getRouter } from '../../model/router';
|
|
4
|
+
|
|
5
|
+
interface RouterProviderProps {
|
|
6
|
+
errorBoundary: ComponentType<{ children: ReactNode }>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function RouterProvider({ errorBoundary }: RouterProviderProps) {
|
|
10
|
+
const router = useMemo(() => (
|
|
11
|
+
getRouter(errorBoundary)
|
|
12
|
+
), [errorBoundary]);
|
|
3
13
|
|
|
4
|
-
function Router() {
|
|
5
14
|
return (
|
|
6
|
-
<
|
|
15
|
+
<RouterDomProvider
|
|
16
|
+
router={router}
|
|
17
|
+
/>
|
|
7
18
|
);
|
|
8
19
|
}
|
|
9
20
|
|
|
10
|
-
export default
|
|
21
|
+
export default RouterProvider;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import { createBrowserRouter, createRoutesFromElements, Route } from 'react-router-dom';
|
|
3
|
+
import { Error } from '../../../../../pages/error';
|
|
4
|
+
import { Main } from '../../../../../pages/main';
|
|
5
|
+
import AppLayout from '../../ui/app';
|
|
6
|
+
|
|
7
|
+
export const getRouter = (ErrorBoundary: ComponentType<{ children: ReactNode }>) => createBrowserRouter(
|
|
8
|
+
createRoutesFromElements(
|
|
9
|
+
<Route
|
|
10
|
+
path="/"
|
|
11
|
+
element={(
|
|
12
|
+
<ErrorBoundary>
|
|
13
|
+
<AppLayout />
|
|
14
|
+
</ErrorBoundary>
|
|
15
|
+
)}
|
|
16
|
+
>
|
|
17
|
+
<Route index element={<Main />} />
|
|
18
|
+
<Route path="*" element={<Error />} />
|
|
19
|
+
</Route>,
|
|
20
|
+
),
|
|
21
|
+
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { NavLink, Outlet } from 'react-router-dom';
|
|
3
|
+
import styles from './styles.module.scss';
|
|
4
|
+
|
|
5
|
+
export default function AppLayout() {
|
|
6
|
+
return (
|
|
7
|
+
<div className={styles.layout_wrapper}>
|
|
8
|
+
<aside className={styles.sidebar}>
|
|
9
|
+
<nav>
|
|
10
|
+
<NavLink
|
|
11
|
+
className={({ isActive }) => clsx({
|
|
12
|
+
[styles.active]: isActive,
|
|
13
|
+
})}
|
|
14
|
+
to="/"
|
|
15
|
+
>
|
|
16
|
+
Main
|
|
17
|
+
</NavLink>
|
|
18
|
+
</nav>
|
|
19
|
+
<nav>
|
|
20
|
+
<NavLink
|
|
21
|
+
className={({ isActive }) => clsx({
|
|
22
|
+
[styles.active]: isActive,
|
|
23
|
+
})}
|
|
24
|
+
to="/error-route"
|
|
25
|
+
>
|
|
26
|
+
Error
|
|
27
|
+
</NavLink>
|
|
28
|
+
</nav>
|
|
29
|
+
</aside>
|
|
30
|
+
|
|
31
|
+
<main>
|
|
32
|
+
<Outlet />
|
|
33
|
+
</main>
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StrictMode } from 'react';
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import App from '@/app/App';
|
|
4
|
-
import {
|
|
4
|
+
import { RouterProvider, ErrorBoundary } from '@/app/providers';
|
|
5
5
|
import './styles/index.scss';
|
|
6
6
|
|
|
7
7
|
const container = document.getElementById('root');
|
|
@@ -12,8 +12,12 @@ if (!container) {
|
|
|
12
12
|
|
|
13
13
|
createRoot(container).render(
|
|
14
14
|
<StrictMode>
|
|
15
|
-
<App
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
<App
|
|
16
|
+
router={(
|
|
17
|
+
<RouterProvider
|
|
18
|
+
errorBoundary={ErrorBoundary}
|
|
19
|
+
/>
|
|
20
|
+
)}
|
|
21
|
+
/>
|
|
18
22
|
</StrictMode>,
|
|
19
23
|
);
|
|
@@ -6,7 +6,7 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
|
6
6
|
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
|
|
7
7
|
|
|
8
8
|
export function buildPlugins({ paths, isDev, apiUrl }: BuildOptions): webpack.WebpackPluginInstance[] {
|
|
9
|
-
const plugins = [
|
|
9
|
+
const plugins: webpack.WebpackPluginInstance[] = [
|
|
10
10
|
new HTMLWebpackPlugin({
|
|
11
11
|
template: paths.html,
|
|
12
12
|
}),
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
*,
|
|
2
|
+
*::before,
|
|
3
|
+
*::after {
|
|
4
|
+
margin: 0;
|
|
5
|
+
padding: 0;
|
|
6
|
+
border: none;
|
|
7
|
+
list-style: none;
|
|
8
|
+
text-decoration: none;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
color: inherit;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
body {
|
|
14
|
+
-webkit-font-smoothing: antialiased;
|
|
15
|
+
text-rendering: optimizelegibility;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
input,
|
|
19
|
+
button,
|
|
20
|
+
textarea {
|
|
21
|
+
font-size: inherit;
|
|
22
|
+
font-family: inherit;
|
|
23
|
+
|
|
24
|
+
&::placeholder {
|
|
25
|
+
user-select: none;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
button {
|
|
30
|
+
user-select: none;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
img {
|
|
35
|
+
user-select: none;
|
|
36
|
+
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { NavLink, Outlet } from 'react-router-dom';
|
|
3
|
-
import { AppErrorBoundary } from '@/app/providers';
|
|
4
|
-
import styles from './styles.module.scss';
|
|
5
|
-
|
|
6
|
-
export default function AppLayout() {
|
|
7
|
-
return (
|
|
8
|
-
<AppErrorBoundary>
|
|
9
|
-
<div className={styles.layout_wrapper}>
|
|
10
|
-
<aside className={styles.sidebar}>
|
|
11
|
-
<nav>
|
|
12
|
-
<NavLink
|
|
13
|
-
className={({ isActive }) => clsx({
|
|
14
|
-
[styles.active]: isActive,
|
|
15
|
-
})}
|
|
16
|
-
to="/"
|
|
17
|
-
>
|
|
18
|
-
Main
|
|
19
|
-
</NavLink>
|
|
20
|
-
</nav>
|
|
21
|
-
<nav>
|
|
22
|
-
<NavLink
|
|
23
|
-
className={({ isActive }) => clsx({
|
|
24
|
-
[styles.active]: isActive,
|
|
25
|
-
})}
|
|
26
|
-
to="/error-route"
|
|
27
|
-
>
|
|
28
|
-
Error
|
|
29
|
-
</NavLink>
|
|
30
|
-
</nav>
|
|
31
|
-
</aside>
|
|
32
|
-
|
|
33
|
-
<main>
|
|
34
|
-
<Outlet />
|
|
35
|
-
</main>
|
|
36
|
-
</div>
|
|
37
|
-
</AppErrorBoundary>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createBrowserRouter, createRoutesFromElements, Route } from 'react-router-dom';
|
|
2
|
-
import { Error } from '../../../../../pages/error';
|
|
3
|
-
import { Main } from '../../../../../pages/main';
|
|
4
|
-
import AppLayout from '../../../../layouts/app';
|
|
5
|
-
|
|
6
|
-
export const router = createBrowserRouter(
|
|
7
|
-
createRoutesFromElements(
|
|
8
|
-
<Route path="/" element={<AppLayout />}>
|
|
9
|
-
<Route index element={<Main />} />
|
|
10
|
-
<Route path="*" element={<Error />} />
|
|
11
|
-
</Route>,
|
|
12
|
-
),
|
|
13
|
-
);
|
|
File without changes
|