🌈 Migrated to Remix v2 with Vite and removed LiveReload πŸ¦„ main

This commit is contained in:
Nikolaj Frey 2024-03-24 20:53:30 +11:00
parent cf67d463b3
commit 08927e2be9
10 changed files with 1578 additions and 2289 deletions

View File

@ -2,8 +2,8 @@
"private": true, "private": true,
"sideEffects": false, "sideEffects": false,
"scripts": { "scripts": {
"build": "remix build", "build": "remix vite:build",
"dev": "remix dev --port 9999", "dev": "remix vite:dev",
"lint": "eslint --ext .js,.ts,.jsx,.tsx .", "lint": "eslint --ext .js,.ts,.jsx,.tsx .",
"lint-fix": "eslint --ext .js,.ts,.jsx,.tsx . --fix", "lint-fix": "eslint --ext .js,.ts,.jsx,.tsx . --fix",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\"" "format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\""
@ -15,13 +15,14 @@
"@fortawesome/free-regular-svg-icons": "^6.4.0", "@fortawesome/free-regular-svg-icons": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0", "@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/react-fontawesome": "^0.2.0", "@fortawesome/react-fontawesome": "^0.2.0",
"@remix-run/node": "^1.15.0", "@remix-run/node": "^2.8.1",
"@remix-run/react": "^1.15.0", "@remix-run/react": "^2.8.1",
"@remix-run/serve": "^1.15.0", "@remix-run/serve": "^2.8.1",
"@vercel/analytics": "^0.1.11", "@vercel/analytics": "^0.1.11",
"@vercel/remix": "^1.15.0", "@vercel/remix": "^1.15.0",
"draft-js": "^0.11.7", "draft-js": "^0.11.7",
"emojis-list": "^3.0.0", "emojis-list": "^3.0.0",
"emotion": "^11.0.0",
"flatted": "^3.2.7", "flatted": "^3.2.7",
"fuse.js": "^6.6.2", "fuse.js": "^6.6.2",
"gradient-path": "^2.3.0", "gradient-path": "^2.3.0",
@ -40,8 +41,8 @@
"uuid": "^9.0.0" "uuid": "^9.0.0"
}, },
"devDependencies": { "devDependencies": {
"@remix-run/dev": "^1.15.0", "@remix-run/dev": "^2.8.1",
"@remix-run/eslint-config": "^1.15.0", "@remix-run/eslint-config": "^2.8.1",
"@shopify/eslint-plugin": "^42.1.0", "@shopify/eslint-plugin": "^42.1.0",
"@types/eslint": "^8.40.2", "@types/eslint": "^8.40.2",
"@types/react": "^18.0.25", "@types/react": "^18.0.25",
@ -57,7 +58,9 @@
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0", "eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unused-imports": "^2.0.0", "eslint-plugin-unused-imports": "^2.0.0",
"typescript": "^4.9.3" "typescript": "^4.9.3",
"vite": "^5.1.0",
"vite-tsconfig-paths": "^4.3.2"
}, },
"resolutions": { "resolutions": {
"@types/react": "^17.0.2" "@types/react": "^17.0.2"

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,56 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Flex, Button, FormControl, Input } from '@chakra-ui/react'; import { Flex, Button, FormControl, Input, Spinner } from '@chakra-ui/react';
import { useFetcher } from '@remix-run/react';
export const Login = (props) => { export const Login = (props) => {
const [email, setEmail] = useState(''); const [username, setUsername] = useState('');
const [password, setPassword] = useState(''); const [password, setPassword] = useState('');
const handleLogin = (props) => { const [loading, setLoading] = useState(false);
// handle login
const { username, password } = props; const api = useFetcher();
const handleLogin = (e) => {
e?.preventDefault();
setLoading(true);
api.load('/api/$');
// handle login
console.log('nik username', username); console.log('nik username', username);
console.log('nik password', password); console.log('nik password', password);
}; };
if (loading) {
return (
<Flex alignItems="center" justifyContent="center" height="100vh" width="100%">
<Spinner
sx={{
'@keyframes moving-rainbow': {
'0%': { backgroundPosition: '0 0' },
'100%': { backgroundPosition: 'calc(100px + 400%) 0' }
},
'@keyframes rotate': {
'0%': { transform: 'rotate(0deg)' },
'100%': { transform: 'rotate(360deg)' }
},
animation: 'rotate 2s linear infinite, moving-rainbow 40s infinite linear'
}}
bgGradient="linear-gradient(to right, #47b5e6, #a555e8, #f34a4a, #ffbc48, #58ca70, #47b5e6)"
// rainbow gradient border
backgroundSize="calc(100px + 400%)"
color="transparent"
size="xl"
/>
</Flex>
);
}
return ( return (
<> <>
<form> <form onSubmit={handleLogin}>
<Flex flexDirection="column" gap={4} width="255px" maxWidth="100%"> <Flex flexDirection="column" gap={4} width="255px" maxWidth="100%">
<FormControl> <FormControl>
<Input <Input
@ -30,10 +64,10 @@ export const Login = (props) => {
border="none" border="none"
borderRadius="5px" borderRadius="5px"
outline="none" outline="none"
onChange={(e) => setEmail(e.target.value)} onChange={(e) => setUsername(e?.target?.value)}
placeholder="Email" placeholder="πŸ’Œ Email"
type="username" type="email"
value={email} value={username}
/> />
</FormControl> </FormControl>
@ -49,8 +83,8 @@ export const Login = (props) => {
border="none" border="none"
borderRadius="5px" borderRadius="5px"
outline="none" outline="none"
onChange={(e) => setPassword(e.target.value)} onChange={(e) => setPassword(e?.target?.value)}
placeholder="Password" placeholder="πŸ”‘ Password"
type="password" type="password"
value={password} value={password}
/> />
@ -83,7 +117,7 @@ export const Login = (props) => {
paddingX={4} paddingX={4}
paddingY={2} paddingY={2}
> >
Login Login ✨
</Button> </Button>
</Flex> </Flex>
</form> </form>

View File

@ -0,0 +1,15 @@
import { Global } from '@emotion/react';
export const Globals = () => {
return (
<Global
styles={{
body: {},
'input[data-com-onepassword-filled="light"]': {
// Doesn't seem to work..?
background: 'pink !important'
}
}}
/>
);
};

View File

@ -1,26 +1,15 @@
// import type { MetaFunction } from "@vercel/remix" // import type { MetaFunction } from "@vercel/remix"
import { import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react';
Links, import { Analytics } from '@vercel/analytics/react';
LiveReload,
Meta,
Outlet,
Scripts,
ScrollRestoration,
} from "@remix-run/react"
import { Analytics } from "@vercel/analytics/react"
import { Main } from "./components/Layout/Main" import { Globals } from './globals/GlobalStyles';
import { useIcons } from "./hooks/useIcons"
import { ChakraWrapper } from "./Providers/Chakra/ChakraWrapper"
import { ThingtimeProvider } from "./Providers/ThingtimeProvider"
function Document({ import { Main } from './components/Layout/Main';
children, import { useIcons } from './hooks/useIcons';
title = "Thingtime", import { ChakraWrapper } from './Providers/Chakra/ChakraWrapper';
}: { import { ThingtimeProvider } from './Providers/ThingtimeProvider';
children: React.ReactNode
title?: string function Document({ children, title = 'Thingtime' }: { children: React.ReactNode; title?: string }) {
}) {
return ( return (
<html lang="en"> <html lang="en">
<head> <head>
@ -32,17 +21,18 @@ function Document({
</head> </head>
<body> <body>
{children} {children}
<Globals />
<ScrollRestoration /> <ScrollRestoration />
<Scripts /> <Scripts />
<LiveReload /> {/* <LiveReload /> */}
<Analytics /> <Analytics />
</body> </body>
</html> </html>
) );
} }
export default function App() { export default function App() {
useIcons() useIcons();
return ( return (
<Document> <Document>
@ -54,7 +44,7 @@ export default function App() {
</ThingtimeProvider> </ThingtimeProvider>
</ChakraWrapper> </ChakraWrapper>
</Document> </Document>
) );
} }
// limiter // limiter
@ -69,17 +59,17 @@ const setThingtime = (glob) => {
db: {}, db: {},
limit: 9999, limit: 9999,
maxDepth: 99, maxDepth: 99,
count: 0, count: 0
}, },
things: {}, things: {}
} };
} catch (err) { } catch (err) {
// will error on server // will error on server
} }
} };
try { try {
setThingtime(window) setThingtime(window);
} catch { } catch {
setThingtime(globalThis) setThingtime(globalThis);
} }

7
app/src/routes/$.tsx Normal file
View File

@ -0,0 +1,7 @@
import React from 'react';
import { ThingtimeURL } from '~/components/Thingtime/ThingtimeURL';
export default function Index() {
return <ThingtimeURL></ThingtimeURL>;
}

View File

@ -1,7 +0,0 @@
import React from "react"
import { ThingtimeURL } from "~/components/Thingtime/ThingtimeURL"
export default function Index() {
return <ThingtimeURL></ThingtimeURL>
}

3
app/src/routes/api/$.tsx Normal file
View File

@ -0,0 +1,3 @@
export async function loader({ request }) {
return { message: 'Hello, World!' };
}

27
app/vite.config.ts Normal file
View File

@ -0,0 +1,27 @@
import { vitePlugin as remix } from '@remix-run/dev';
import { installGlobals } from '@remix-run/node';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
installGlobals();
// set app path to src/
export default defineConfig({
// define web socket port
server: {
port: 9999,
hmr: {
port: 9998
}
},
plugins: [
remix({
// app path
appDirectory: 'src'
}),
tsconfigPaths()
]
// plugins: [remix(), tsconfigPaths()],
});