diff --git a/src/handbook/.prettierrc b/src/handbook/.prettierrc new file mode 100644 index 000000000..a370e477a --- /dev/null +++ b/src/handbook/.prettierrc @@ -0,0 +1,12 @@ +{ + "arrowParens": "always", + "bracketSpacing": true, + "endOfLine": "lf", + "jsxSingleQuote": false, + "jsxBracketSameLine": false, + "semi": true, + "singleQuote": false, + "tabWidth": 4, + "trailingComma": "none", + "useTabs": false +} \ No newline at end of file diff --git a/src/handbook/cfg/postcss.config.js b/src/handbook/cfg/postcss.config.js new file mode 100644 index 000000000..1962ca60c --- /dev/null +++ b/src/handbook/cfg/postcss.config.js @@ -0,0 +1,25 @@ +import tailwind from "tailwindcss"; +import autoprefixer from "autoprefixer"; +import cssnanoPlugin from "cssnano"; + +import tailwindConfig from "./tailwind.config.js"; +const mode = process.env.NODE_ENV; +const dev = mode === "development"; + +export default { + plugins: (() => { + let plugins = [ + // Some plugins, like TailwindCSS/Nesting, need to run before Tailwind. + tailwind(tailwindConfig), + + // But others, like autoprefixer, need to run after. + autoprefixer() + ]; + + !dev && cssnanoPlugin({ + preset: "default" + }); + + return plugins; + })() +} diff --git a/src/handbook/cfg/tailwind.config.js b/src/handbook/cfg/tailwind.config.js new file mode 100644 index 000000000..6a004f99f --- /dev/null +++ b/src/handbook/cfg/tailwind.config.js @@ -0,0 +1,9 @@ +export default { + content: ["./src/**/*.{html,js,tsx,ts}"], + mode: "jit", + theme: { + extend: {} + }, + darkMode: "class", + plugins: [] +}; diff --git a/src/handbook/index.html b/src/handbook/index.html index e0d1c8408..4e84c88f2 100644 --- a/src/handbook/index.html +++ b/src/handbook/index.html @@ -2,9 +2,8 @@ - - Vite + React + TS + GM Handbook
diff --git a/src/handbook/package.json b/src/handbook/package.json index ea88d0ac2..93a199de0 100644 --- a/src/handbook/package.json +++ b/src/handbook/package.json @@ -1,22 +1,39 @@ { "name": "handbook", + "description": "The ultimate anime game handbook!", + "version": "0.1.0", "private": true, - "version": "0.0.0", + "type": "module", "scripts": { "dev": "vite", "build": "tsc && vite build", "preview": "vite preview" }, + "dependencies": { "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { + "typescript": "^4.9.3", "@types/react": "^18.0.28", "@types/react-dom": "^18.0.11", + + "vite": "^4.2.0", + "vite-tsconfig-paths": "^4.0.7", + "vite-plugin-singlefile": "^0.13.5", "@vitejs/plugin-react-swc": "^3.0.0", - "typescript": "^4.9.3", - "vite": "^4.2.0" + + "sass": "^1.58.3", + "cssnano": "^5.1.15", + "tailwindcss": "^3.2.7", + "autoprefixer": "^10.4.13", + + "postcss": "^8.4.21", + "postcss-load-config": "^4.0.1", + "postcss-font-magician": "^3.0.0", + + "prettier": "^2.8.7" } } diff --git a/src/handbook/public/vite.svg b/src/handbook/public/vite.svg deleted file mode 100644 index e7b8dfb1b..000000000 --- a/src/handbook/public/vite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/handbook/src/App.css b/src/handbook/src/App.css deleted file mode 100644 index b9d355df2..000000000 --- a/src/handbook/src/App.css +++ /dev/null @@ -1,42 +0,0 @@ -#root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - -@media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} diff --git a/src/handbook/src/App.tsx b/src/handbook/src/App.tsx deleted file mode 100644 index 776eaa027..000000000 --- a/src/handbook/src/App.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { useState } from 'react' -import reactLogo from './assets/react.svg' -import viteLogo from '/vite.svg' -import './App.css' - -function App() { - const [count, setCount] = useState(0) - - return ( -
-
- - Vite logo - - - React logo - -
-

Vite + React

-
- -

- Edit src/App.tsx and save to test HMR -

-
-

- Click on the Vite and React logos to learn more -

-
- ) -} - -export default App diff --git a/src/handbook/src/assets/react.svg b/src/handbook/src/assets/react.svg deleted file mode 100644 index 6c87de9bb..000000000 --- a/src/handbook/src/assets/react.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/handbook/src/index.css b/src/handbook/src/index.css deleted file mode 100644 index 2c3fac689..000000000 --- a/src/handbook/src/index.css +++ /dev/null @@ -1,69 +0,0 @@ -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - -webkit-text-size-adjust: 100%; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/src/handbook/src/main.tsx b/src/handbook/src/main.tsx index 791f139e2..0cb2b7b3d 100644 --- a/src/handbook/src/main.tsx +++ b/src/handbook/src/main.tsx @@ -1,10 +1,12 @@ -import React from 'react' -import ReactDOM from 'react-dom/client' -import App from './App' -import './index.css' +import React from "react"; +import { createRoot } from "react-dom/client"; -ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - - - , -) +import App from "@components/App"; + +// Render the application. +createRoot(document.getElementById( + "root") as HTMLElement).render( + + + +); diff --git a/src/handbook/src/ui/App.tsx b/src/handbook/src/ui/App.tsx new file mode 100644 index 000000000..8160b631d --- /dev/null +++ b/src/handbook/src/ui/App.tsx @@ -0,0 +1,17 @@ +import React from "react"; + +class App extends React.Component { + constructor(props: any) { + super(props); + } + + render() { + return ( +
+

Hello World!

+
+ ); + } +} + +export default App; diff --git a/src/handbook/src/vite-env.d.ts b/src/handbook/src/vite-env.d.ts deleted file mode 100644 index 11f02fe2a..000000000 --- a/src/handbook/src/vite-env.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/src/handbook/tsconfig.json b/src/handbook/tsconfig.json index bb02c4b3d..ded2a1810 100644 --- a/src/handbook/tsconfig.json +++ b/src/handbook/tsconfig.json @@ -14,10 +14,16 @@ "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react-jsx" + "jsx": "react-jsx", + + "baseUrl": ".", + "paths": { + "@app/*": ["src/*"], + "@backend/*": ["src/backend/*"], + "@css/*": ["src/css/*"], + "@components/*": ["src/ui/*"] + } }, - "include": [ - "src" - ], - "references": [{ "path": "./tsconfig.node.json"}] + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/src/handbook/vite.config.ts b/src/handbook/vite.config.ts index 861b04b35..9bd37677d 100644 --- a/src/handbook/vite.config.ts +++ b/src/handbook/vite.config.ts @@ -1,7 +1,14 @@ -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react-swc' +// noinspection JSUnusedGlobalSymbols + +import { defineConfig } from "vite"; + +import react from "@vitejs/plugin-react-swc"; +import tsconfigPaths from "vite-tsconfig-paths"; + +import postcss from "./cfg/postcss.config.js"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()], -}) + plugins: [ react(), tsconfigPaths() ], + css: { postcss } +});