Skip to content

Commit

Permalink
ui basics
Browse files Browse the repository at this point in the history
  • Loading branch information
hckrg committed Jul 13, 2023
1 parent 4621109 commit 2f48962
Show file tree
Hide file tree
Showing 11 changed files with 1,039 additions and 153 deletions.
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,27 @@
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/material": "^5.14.0",
"classnames": "^2.3.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"react-router-dom": "^6.14.1",
"recoil": "^0.7.7"
},
"devDependencies": {
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"@vitejs/plugin-react-swc": "^3.3.2",
"autoprefixer": "^10.4.14",
"eslint": "^8.44.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.1",
"postcss": "^8.4.25",
"tailwindcss": "^3.3.3",
"typescript": "^5.0.2",
"vite": "^4.4.0"
}
Expand Down
6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
42 changes: 0 additions & 42 deletions src/App.css

This file was deleted.

36 changes: 7 additions & 29 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,13 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { RecoilRoot } from 'recoil'
import AppRoutes from './Routes'

function App() {
const [count, setCount] = useState(0)

// for any wrappers required on the entire app
return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
<RecoilRoot>
<AppRoutes />
</RecoilRoot>
)
}

export default App
export default App
25 changes: 25 additions & 0 deletions src/Routes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { BrowserRouter, Route, Routes } from 'react-router-dom'
import ExploreDashboard from './pages/ExploreDashboard'

function AppRoutes() {
return (
<BrowserRouter>
<Routes>
<Route
path='/'
Component={ExploreDashboard}
/>
{/* <Route
path='/token/:tokenId'
Component={TokenDetails}
/>
<Route
path='create'
Component={CreateToken}
/> */}
</Routes>
</BrowserRouter>
)
}

export default AppRoutes
61 changes: 61 additions & 0 deletions src/components/Dashboard_Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {useEffect, useState, useRef } from 'react';

const Dashboard_Navbar = ({ navbarShadow }: { navbarShadow: boolean }) => {
const [showLogout, setShowLogout] = useState(false);
const logoutRef = useRef<HTMLDivElement>(null);

useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (logoutRef.current && !logoutRef.current.contains(event.target as Node)) {
setShowLogout(false);
}
};
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, []);

const handleImageClick = () => {
setShowLogout(!showLogout);
};

const handleLogout = () => {
console.log("Logging Out...");
};

const handleShowPrice = () => {
console.log("Showing Prices...");
};

return (
<div className={`flex flex-row fixed top-0 ${navbarShadow ? 'shadow-md shadow-gray-200' : ''} z-10 bg-white w-full py-7 p-5 sm:px-9 justify-between items-center`}>
<div className="flex font-bold text-[22px] space-x-2 justify-center items-center">
<img src={""} alt="logo" className="w-7 h-7" />
<div>Basket Protocol</div>
</div>
<div className="flex space-x-5">

<div className="flex justify-center items-center space-x-2 hover:opacity-80 cursor-pointer transition duration-200" onClick={handleImageClick}>
<div>
<img src={""} alt="profile" className="w-11 h-11" />
{showLogout && (
<div className="absolute right-6 sm:right-56 rounded-lg shadow-lg my-1 border" ref={logoutRef}>
<div className="flex space-x-2 px-2 sm:px-5 py-2 rounded-lg bg-white hover:bg-red-200 justify-center items-center">
{/* <HiOutlineLogout size={18} /> */}
logout
<div className='opacity-0 left-0 top-0 absolute sm:static sm:opacity-100' onClick={handleLogout}>Logout</div>
</div>
</div>
)}
</div>
<div className="text-gray-500 text-sm opacity-0 left-0 top-0 sm:pr-8 absolute sm:opacity-100 sm:static">
[email protected]
</div>
</div>
</div>
</div>
);
};

export default Dashboard_Navbar;
72 changes: 3 additions & 69 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,69 +1,3 @@
: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;
}
}
@tailwind base;
@tailwind components;
@tailwind utilities;
25 changes: 25 additions & 0 deletions src/pages/ExploreDashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Dashboard_Navbar from "../components/Dashboard_Navbar"

const ExploreDashboard = () => {
return (
<div className="flex flex-col items-center bg-green-50 h-screen">
<Dashboard_Navbar navbarShadow />
<div className="flex flex-col items-center w-2/3 mt-40">
<div className="flex w-full text-sm gap-8 m-auto">

</div>
</div>
</div>
)
}

const ThemeCard = () => {
return <div className="border-[1px] flex-grow border-gray-400 rounded-xl p-6 flex gap-3">
<div className="h-8 w-8 border-[1px] border-gray-700 rounded-md">D</div>
<div className="flex flex-col">
<p className="font-medium">Thematic Exposure</p>
<p>Built around a single theme</p>
</div>
</div>
}
export default ExploreDashboard
11 changes: 11 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Bundler mode */
"moduleResolution": "Node",
"allowImportingTsExtensions": true,
"allowSyntheticDefaultImports":true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
Expand Down
Loading

0 comments on commit 2f48962

Please sign in to comment.