add: boilerplate w/ navbar, tailwindcss

This commit is contained in:
Jordan Edgington
2024-05-17 21:58:07 -04:00
parent 2fd5a4583c
commit efce89bd16
13 changed files with 1224 additions and 141 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -11,16 +11,20 @@
}, },
"dependencies": { "dependencies": {
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0" "react-dom": "^18.2.0",
"react-router-dom": "^6.23.1"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^18.2.66", "@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22", "@types/react-dom": "^18.2.22",
"@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.1", "eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6", "eslint-plugin-react-refresh": "^0.4.6",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"vite": "^5.2.0" "vite": "^5.2.0"
} }
} }

View File

@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

View File

@@ -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;
}

View File

@@ -1,33 +1,15 @@
import { useState } from 'react' import { Outlet } from 'react-router-dom'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css' import './App.css'
import NavBar from './components/navbar'
function App() { function App() {
const [count, setCount] = useState(0)
return ( return (
<> <>
<div> <div className='flex flex-col items-center bg-gray-600 min-h-screen'>
<a href="https://vitejs.dev" target="_blank"> <NavBar />
<img src={viteLogo} className="logo" alt="Vite logo" /> <Outlet />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div> </div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.jsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</> </>
) )
} }

View File

@@ -0,0 +1,18 @@
import { Link } from "react-router-dom"
function NavBar() {
return (
<>
<div className='flex items-center w-full h-20 justify-center bg-gray-800 border-b border-2 border-black'>
<ul className='flex gap-16 items-center justify-center'>
<li><Link to='/'><p className='text-2xl text-white hover:text-red-900'>Main</p></Link></li>
<li><Link to='scenario/'><p className='text-2xl text-white hover:text-red-900'>Scenario</p></Link></li>
<li><Link to='about/'><p className='text-2xl text-white hover:text-red-900'>About</p></Link></li>
</ul>
</div>
</>
)
}
export default NavBar

View File

@@ -1,68 +1,3 @@
:root { @tailwind base;
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; @tailwind components;
line-height: 1.5; @tailwind utilities;
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;
}
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;
}
}

View File

@@ -1,10 +1,8 @@
import React from 'react'
import ReactDOM from 'react-dom/client' import ReactDOM from 'react-dom/client'
import App from './App.jsx' import { RouterProvider } from 'react-router-dom'
import router from './router'
import './index.css' import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render( ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode> <RouterProvider router={router} />
<App /> )
</React.StrictMode>,
)

View File

@@ -0,0 +1,13 @@
function About() {
return (
<>
<div>
<p>About</p>
</div>
</>
)
}
export default About

View File

@@ -0,0 +1,13 @@
function Main() {
return (
<>
<div>
<p>Main</p>
</div>
</>
)
}
export default Main

View File

@@ -0,0 +1,13 @@
function Scenario() {
return (
<>
<div>
<p>Scenario</p>
</div>
</>
)
}
export default Scenario

29
frontend/src/router.jsx Normal file
View File

@@ -0,0 +1,29 @@
// router.jsx
import { createBrowserRouter } from "react-router-dom";
import App from "./App";
import Main from "./pages/main";
import Scenario from "./pages/scenario";
import About from "./pages/about";
const router = createBrowserRouter([
{
path: "/",
element: <App />,
children: [
{
index: true,
element: <Main />,
},
{
path: 'scenario/',
element: <Scenario />
},
{
path: 'about/',
element: <About />
}
],
},
]);
export default router;

View File

@@ -0,0 +1,10 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ["./index.html",
"./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
}