Added Ts.ED

This commit is contained in:
2022-09-04 21:00:45 +02:00
parent d0b69d7ae1
commit f4162f7f06
45 changed files with 4046 additions and 0 deletions

34
frontend/README.md Normal file
View File

@@ -0,0 +1,34 @@
## Usage
Those templates dependencies are maintained via [pnpm](https://pnpm.io) via `pnpm up -Lri`.
This is the reason you see a `pnpm-lock.yaml`. That being said, any package manager will work. This file can be safely be removed once you clone a template.
```bash
$ npm install # or pnpm install or yarn install
```
### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs)
## Available Scripts
In the project directory, you can run:
### `npm dev` or `npm start`
Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br>
### `npm run build`
Builds the app for production to the `dist` folder.<br>
It correctly bundles Solid in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!
## Deployment
You can deploy the `dist` folder to any static host provider (netlify, surge, now, etc.)

16
frontend/index.html Normal file
View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="shortcut icon" type="image/ico" href="/src/assets/favicon.ico" />
<title>Solid App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="main-container"></div>
<script src="/src/index.tsx" type="module"></script>
</body>
</html>

32
frontend/package.json Normal file
View File

@@ -0,0 +1,32 @@
{
"name": "vite-template-solid",
"version": "0.0.0",
"description": "",
"scripts": {
"start": "vite",
"dev": "vite",
"build": "vite build",
"serve": "vite preview",
"codegen": "graphql-codegen --config codegen.yml",
"codegen:watch": "codegen -- --watch"
},
"license": "MIT",
"devDependencies": {
"@graphql-codegen/cli": "2.12.0",
"@graphql-codegen/introspection": "^2.2.1",
"@graphql-codegen/typescript": "2.7.3",
"@graphql-codegen/typescript-operations": "2.5.3",
"@graphql-codegen/typescript-urql": "^3.6.4",
"@graphql-codegen/urql-introspection": "2.2.1",
"typescript": "^4.8.2",
"urql": "^3.0.2",
"vite": "^3.0.9",
"vite-plugin-solid": "^2.3.0"
},
"dependencies": {
"@solidjs/router": "^0.4.3",
"@urql/core": "^3.0.3",
"graphql": "^16.6.0",
"solid-js": "^1.5.1"
}
}

8
frontend/src/App.tsx Normal file
View File

@@ -0,0 +1,8 @@
import type { Component } from "solid-js";
import AppRouter from "./routes";
const App: Component = () => {
return <AppRouter />;
};
export default App;

View File

@@ -0,0 +1,5 @@
import { createClient } from "@urql/core";
const client = createClient({
url: ''
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
# mutation {
# loginAction($arg1: LoginInput!) {
# access_token
# expires_in
# refresh_expires_in
# refresh_token
# scope
# session_state
# token_type
# }
# }
query allUsers {
user {
id
}
}
query getUserByEmail($email: String!) {
user(where: { email: { _eq: $email } }) {
id,
password
}
}
query getUserByUsername($username: String!) {
user(where: { username: { _eq: $username } }) {
id,
password
}
}

View File

@@ -0,0 +1,22 @@
import { createSignal } from "solid-js";
import { createStore } from "solid-js/store";
const useLogin = () => {
const [loading, setLoading] = createSignal(false);
const [form, setForm] = createStore({
username: "",
password: "",
});
const handleInput = (ev: any) => {
setForm([ev.currentTarget.name], ev.currentTarget.value);
};
const handleLogin = (ev: any) => {
ev.preventDefault();
setLoading(true);
};
return { handleInput, loading, handleLogin, form };
};
export default useLogin;

8
frontend/src/index.css Normal file
View File

@@ -0,0 +1,8 @@
form {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: center;
align-items: center;
align-content: center;
}

15
frontend/src/index.tsx Normal file
View File

@@ -0,0 +1,15 @@
/* @refresh reload */
import { render } from "solid-js/web";
import "./index.css";
import App from "./App";
import { Router } from "@solidjs/router";
render(
() => (
<Router>
<App />
</Router>
),
document.getElementById("main-container") as HTMLElement
);

View File

@@ -0,0 +1,21 @@
import { Route, Routes } from "@solidjs/router";
import { Component, lazy } from "solid-js";
const Home = lazy(() => import("./views/home/Home"));
const AuthLayout = lazy(() => import("./views/auth/AuthLayout"));
const Login = lazy(() => import("./views/auth/Login"));
const Register = lazy(() => import("./views/auth/Register"));
const AppRouter: Component = () => {
return (
<Routes>
<Route path="/" element={<Home />}></Route>
<Route path="/auth" element={<AuthLayout />}>
<Route path="/login" element={<Login />}></Route>
<Route path="/register" element={<Register />}></Route>
</Route>
</Routes>
);
};
export default AppRouter;

View File

@@ -0,0 +1,13 @@
interface MainViewProps {
// add props here
}
function MainView(props: MainViewProps) {
return (
<div>
<h2>MainView</h2>
</div>
)
}
export default MainView;

View File

@@ -0,0 +1,16 @@
import type { Component } from "solid-js";
import { Outlet } from "@solidjs/router";
const AuthLayout: Component = () => {
return (
<div>
<header>Head</header>
<div>
<Outlet />
</div>
<footer>Footer</footer>
</div>
);
}
export default AuthLayout;

View File

@@ -0,0 +1,39 @@
import { Component, Show } from "solid-js";
import useLogin from "../../../hooks/auth/login.hook";
const { handleLogin, handleInput, loading, form } = useLogin();
const Login: Component = () => {
return (
<div>
<form onsubmit={handleLogin}>
<div>
{/* <label for="name">Username or Email</label> */}
<input
type="text"
name="username"
placeholder="Email/Username"
value={form.username}
onInput={handleInput}
/>
</div>
<div>
{/* <label for="name">Password</label> */}
<input
type="password"
name="password"
placeholder="Password"
value={form.password}
onInput={handleInput}
/>
</div>
<button disabled={loading()} type="submit">
<Show when={!loading()} fallback="Logging in...">
Log In
</Show>
</button>
</form>
</div>
);
};
export default Login;

View File

@@ -0,0 +1,10 @@
import type { Component } from "solid-js";
const Register: Component = () => {
return (
<div>
<h2>Register</h2>
</div>
)
}
export default Register;

View File

@@ -0,0 +1,11 @@
import type { Component } from "solid-js";
const Home: Component = () => {
return (
<div>
<h2>Home</h2>
</div>
)
}
export default Home;

15
frontend/tsconfig.json Normal file
View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"strict": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"types": ["vite/client"],
"noEmit": true,
"isolatedModules": true
}
}

12
frontend/vite.config.ts Normal file
View File

@@ -0,0 +1,12 @@
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
export default defineConfig({
plugins: [solidPlugin()],
server: {
port: 3000,
},
build: {
target: 'esnext',
},
});

3483
frontend/yarn.lock Normal file

File diff suppressed because it is too large Load Diff