-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afc421a
commit 7666f5b
Showing
43 changed files
with
4,428 additions
and
531 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,78 @@ | ||
module.exports = { | ||
root: true, | ||
env: { browser: true, es2020: true }, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:react-hooks/recommended', | ||
'plugin:@tanstack/eslint-plugin-query/recommended', | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
env: { | ||
browser: true, | ||
commonjs: true, | ||
es6: true, | ||
}, | ||
ignorePatterns: ['!**/.server', '!**/.client'], | ||
|
||
overrides: [ | ||
// React | ||
{ | ||
files: ['**/*.{js,jsx,ts,tsx}'], | ||
plugins: ['react', 'jsx-a11y'], | ||
extends: [ | ||
'plugin:react/recommended', | ||
'plugin:react/jsx-runtime', | ||
'plugin:react-hooks/recommended', | ||
'plugin:jsx-a11y/recommended', | ||
'plugin:@tanstack/eslint-plugin-query/recommended', | ||
], | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
formComponents: ['Form'], | ||
linkComponents: [ | ||
{ name: 'Link', linkAttribute: 'to' }, | ||
{ name: 'NavLink', linkAttribute: 'to' }, | ||
], | ||
'import/resolver': { | ||
typescript: {}, | ||
}, | ||
}, | ||
}, | ||
|
||
// Typescript | ||
{ | ||
files: ['**/*.{ts,tsx}'], | ||
plugins: ['@typescript-eslint', 'import'], | ||
parser: '@typescript-eslint/parser', | ||
settings: { | ||
'import/internal-regex': '^~/', | ||
'import/resolver': { | ||
node: { | ||
extensions: ['.ts', '.tsx'], | ||
}, | ||
typescript: { | ||
alwaysTryTypes: true, | ||
}, | ||
}, | ||
}, | ||
extends: [ | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:import/recommended', | ||
'plugin:import/typescript', | ||
], | ||
}, | ||
|
||
// Node | ||
{ | ||
files: ['.eslintrc.cjs'], | ||
env: { | ||
node: true, | ||
}, | ||
}, | ||
], | ||
ignorePatterns: ['dist', '.eslintrc.cjs'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['react-refresh'], | ||
rules: { | ||
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], | ||
'prefer-const': 0, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,7 @@ dist-ssr | |
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
/.cache | ||
/build | ||
/public/build |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* By default, Remix will handle hydrating your app on the client for you. | ||
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨ | ||
* For more information, see https://remix.run/file-conventions/entry.client | ||
*/ | ||
|
||
import { RemixBrowser } from '@remix-run/react'; | ||
import { startTransition, StrictMode } from 'react'; | ||
import { hydrateRoot } from 'react-dom/client'; | ||
|
||
async function enableMocking() { | ||
if (import.meta.env.VITE_NODE_ENV !== 'development') { | ||
return; | ||
} | ||
|
||
const { worker } = await import('./mocks/browser'); | ||
|
||
// `worker.start()` returns a Promise that resolves | ||
// once the Service Worker is up and ready to intercept requests. | ||
return worker.start({ | ||
onUnhandledRequest: 'bypass', | ||
}); | ||
} | ||
|
||
enableMocking().then(() => { | ||
startTransition(() => { | ||
hydrateRoot( | ||
document.querySelector('#app'), | ||
<StrictMode> | ||
<RemixBrowser /> | ||
</StrictMode>, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
|
||
import type { EntryContext } from '@remix-run/node'; | ||
import { RemixServer } from '@remix-run/react'; | ||
import { renderToString } from 'react-dom/server'; | ||
|
||
export default function handleRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext, | ||
) { | ||
const shellHtml = fs.readFileSync(path.join(process.cwd(), 'app/index.html')).toString(); | ||
|
||
const appHtml = renderToString(<RemixServer context={remixContext} url={request.url} />); | ||
|
||
const html = shellHtml.replace('<!-- Remix SPA -->', appHtml); | ||
|
||
return new Response(html, { | ||
headers: { 'Content-Type': 'text/html' }, | ||
status: responseStatusCode, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Demo</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Demo</title> | ||
</head> | ||
<body> | ||
<div id="app"><!-- Remix SPA --></div> | ||
</body> | ||
</html> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
Links, | ||
Meta, | ||
Outlet, | ||
Scripts, | ||
isRouteErrorResponse, | ||
useNavigate, | ||
useRouteError, | ||
} from '@remix-run/react'; | ||
import { Button } from './components/ui/button'; | ||
import '@/tailwind.css'; | ||
|
||
export default function Component() { | ||
return ( | ||
<> | ||
<Outlet /> | ||
<Meta /> | ||
<Links /> | ||
<Scripts /> | ||
</> | ||
); | ||
} | ||
|
||
export function HydrateFallback() { | ||
return ( | ||
<> | ||
<p>Loading...</p> | ||
<Scripts /> | ||
</> | ||
); | ||
} | ||
|
||
export function ErrorBoundary() { | ||
let error = useRouteError(); | ||
|
||
const navigate = useNavigate(); | ||
|
||
let errorMessage = ''; | ||
|
||
if (isRouteErrorResponse(error)) { | ||
errorMessage = error.statusText; | ||
} else if (error instanceof Error) { | ||
errorMessage = error.message; | ||
} | ||
|
||
return ( | ||
<html> | ||
<head> | ||
<title>Oh no!</title> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<div className='flex flex-col items-center justify-center gap-2 py-8'> | ||
<h1>Oops!</h1> | ||
|
||
<p>Sorry, an unexpected error has occurred</p> | ||
|
||
<p> | ||
<i>{errorMessage}</i> | ||
</p> | ||
|
||
<Button onClick={() => navigate('/')}>Reload page</Button> | ||
</div> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.