Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Home #16

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
"@types/react-dom": "^18.0.9",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.4.3",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"devDependencies": {
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
"autoprefixer": "^10.4.13",
Expand Down
35 changes: 17 additions & 18 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
// import React from "react"
import logo from "./common/assets/logo.svg"
import { Routes, Route } from "react-router-dom"

import { TopBar } from "common/components/ui/TopBar"
import { NotFound404 } from "common/pages/404NotFound"
import { Home } from "features/home"

import "./common/assets/styles/App.css"

export function App(): JSX.Element {
return (
<div className="App bg-green-500">
<header className="App-header">
<h1 className="text-amber-300">Hiiiii</h1>
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
<div className="app">
{/* Any Pop-up modals */}
<div className="viewport">
<TopBar />
<div className="canvas">
<Routes>
<Route path="/" element={<Home />}></Route>
<Route path="*" element={<NotFound404 />}></Route>
</Routes>
</div>
</div>
</div>
)
}
22 changes: 22 additions & 0 deletions src/common/components/ui/TopBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NavLink } from "react-router-dom"

import { FEATURES } from "common/constants/features"

const NAV_FEATURES = [FEATURES.home, FEATURES.feedback]

export function TopBar(): JSX.Element {
return (
<div className="w-full p-6 sticky top-0 z-50 bg-amber-300">
<nav className="flex gap-8">
<img src="" alt="Logo" />
<ul className="flex gap-8">
{NAV_FEATURES.map(({ title, url }) => (
<li>
<NavLink to={url}>{title}</NavLink>
</li>
))}
</ul>
</nav>
</div>
)
}
4 changes: 4 additions & 0 deletions src/common/constants/features.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const FEATURES = {
home: { title: "Home", url: "/" },
feedback: { title: "Feedback", url: "feedback" },
}
11 changes: 11 additions & 0 deletions src/common/pages/404NotFound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Link } from "react-router-dom"

export function NotFound404(): JSX.Element {
return (
<main>
<h1>Sorry, this page could not be found!</h1>
<Link to={"/"}>Return Home</Link>
{/* Report a bug */}
</main>
)
}
7 changes: 7 additions & 0 deletions src/features/home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function Home(): JSX.Element {
return (
<main>
<h1>Welcome</h1>
</main>
)
}
16 changes: 16 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}


@layer base {
.app {@apply relative min-h-screen h-full flex flex-col ;}
.viewport {@apply min-h-screen flex flex-col items-center bg-amber-200;}
.canvas {@apply w-full grow flex flex-col items-center justify-center bg-slate-400;}

/* nav {@apply bg-slate-500} */
main, .main { @apply flex flex-col items-center; }

a, .a { @apply text-blue-900 underline;}
}



@layer components {}
6 changes: 5 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import ReactDOM from "react-dom/client"
import { BrowserRouter } from "react-router-dom"

import { App } from "./App"
import { reportWebVitals } from "./reportWebVitals"
Expand All @@ -8,7 +9,10 @@ import "./index.css"
const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement)
root.render(
<React.StrictMode>
<App />
<BrowserRouter>
{/* BrowserRouter keeps UI in sync with the URL */}
<App />
</BrowserRouter>
</React.StrictMode>
)

Expand Down