Skip to content

Commit 8c1f8a0

Browse files
committed
feat(web): implement main layout with navbar
1 parent 4765be9 commit 8c1f8a0

8 files changed

Lines changed: 802 additions & 6 deletions

File tree

web/package-lock.json

Lines changed: 662 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13+
"@radix-ui/react-dialog": "^1.1.2",
14+
"@radix-ui/react-separator": "^1.1.0",
1315
"@radix-ui/react-slot": "^1.1.0",
16+
"@radix-ui/react-tooltip": "^1.1.4",
1417
"@tanstack/react-query": "^5.61.5",
1518
"axios": "^1.7.8",
1619
"class-variance-authority": "^0.7.1",

web/src/App.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
import { Route, Routes, useLocation } from 'react-router';
2+
import MainLayout from '@/components/layouts/main-layout/main-layout';
3+
14
function App() {
2-
return <div className="">Test</div>;
5+
const location = useLocation();
6+
return (
7+
<div>
8+
<div className="container mx-auto border-l border-r border-gray-700 h-dvh max-w-7xl">
9+
<Routes location={location}>
10+
<Route element={<MainLayout />}>
11+
<Route path="/" />
12+
</Route>
13+
</Routes>
14+
</div>
15+
</div>
16+
);
317
}
418

519
export default App;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Navbar from '@/components/navbar/navbar';
2+
import { FC } from 'react';
3+
import { Outlet } from 'react-router';
4+
5+
const MainLayout: FC = () => {
6+
return (
7+
<>
8+
<Navbar />
9+
<Outlet />
10+
</>
11+
);
12+
};
13+
14+
export default MainLayout;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { FC } from 'react';
2+
import { NavLink } from 'react-router';
3+
4+
const navbar = [
5+
{
6+
url: '/',
7+
title: 'Basic',
8+
},
9+
{
10+
url: '/bug-fix',
11+
title: 'Bug Fix',
12+
},
13+
{
14+
url: '/terraform-template',
15+
title: 'Terraform Template',
16+
},
17+
{
18+
url: '/installation',
19+
title: 'Installation',
20+
},
21+
{
22+
url: '/helm-template',
23+
title: 'Helm Template',
24+
},
25+
];
26+
27+
const Navbar: FC = () => {
28+
return (
29+
<nav className="flex items-center p-4 border-b border-gray-500 h-14">
30+
<div className="flex items-center justify-between w-full gap-4">
31+
<img src="/images/logo-svg.svg" className="mr-8" width={60} />
32+
<div className="flex items-center gap-5">
33+
{navbar.map((link) => (
34+
<NavLink
35+
to={link.url}
36+
className={({ isActive }) =>
37+
isActive ? 'text-orange-base]' : ''
38+
}
39+
>
40+
{link.title}
41+
</NavLink>
42+
))}
43+
</div>
44+
</div>
45+
</nav>
46+
);
47+
};
48+
49+
export default Navbar;

web/src/hooks/use-mobile.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as React from "react"
2+
3+
const MOBILE_BREAKPOINT = 768
4+
5+
export function useIsMobile() {
6+
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
7+
8+
React.useEffect(() => {
9+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
10+
const onChange = () => {
11+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
12+
}
13+
mql.addEventListener("change", onChange)
14+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
15+
return () => mql.removeEventListener("change", onChange)
16+
}, [])
17+
18+
return !!isMobile
19+
}

web/src/index.css

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@
2828
--chart-4: 43 74% 66%;
2929
--chart-5: 27 87% 67%;
3030
--radius: 0.5rem
31-
}
31+
;
32+
--sidebar-background: 0 0% 98%;
33+
--sidebar-foreground: 240 5.3% 26.1%;
34+
--sidebar-primary: 240 5.9% 10%;
35+
--sidebar-primary-foreground: 0 0% 98%;
36+
--sidebar-accent: 240 4.8% 95.9%;
37+
--sidebar-accent-foreground: 240 5.9% 10%;
38+
--sidebar-border: 220 13% 91%;
39+
--sidebar-ring: 217.2 91.2% 59.8%}
3240
.dark {
3341
--background: 0 0% 3.9%;
3442
--foreground: 0 0% 98%;
@@ -54,7 +62,15 @@
5462
--chart-3: 30 80% 55%;
5563
--chart-4: 280 65% 60%;
5664
--chart-5: 340 75% 55%
57-
}
65+
;
66+
--sidebar-background: 240 5.9% 10%;
67+
--sidebar-foreground: 240 4.8% 95.9%;
68+
--sidebar-primary: 224.3 76.3% 48%;
69+
--sidebar-primary-foreground: 0 0% 100%;
70+
--sidebar-accent: 240 3.7% 15.9%;
71+
--sidebar-accent-foreground: 240 4.8% 95.9%;
72+
--sidebar-border: 240 3.7% 15.9%;
73+
--sidebar-ring: 217.2 91.2% 59.8%}
5874
}
5975
@layer base {
6076
@font-face {
@@ -71,4 +87,12 @@
7187
body {
7288
@apply bg-background text-foreground font-figtree;
7389
}
90+
}
91+
@layer base {
92+
* {
93+
@apply border-border;
94+
}
95+
body {
96+
@apply bg-background text-foreground;
97+
}
7498
}

web/tailwind.config.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
theme: {
66
extend: {
77
fontFamily: {
8-
"figtree": ['figtree', 'sans-serif']
8+
figtree: ['figtree', 'sans-serif']
99
},
1010
borderRadius: {
1111
lg: 'var(--radius)',
@@ -15,6 +15,9 @@ export default {
1515
colors: {
1616
background: 'hsl(var(--background))',
1717
foreground: 'hsl(var(--foreground))',
18+
orange: {
19+
base: "#f86609"
20+
},
1821
card: {
1922
DEFAULT: 'hsl(var(--card))',
2023
foreground: 'hsl(var(--card-foreground))'
@@ -52,6 +55,16 @@ export default {
5255
'3': 'hsl(var(--chart-3))',
5356
'4': 'hsl(var(--chart-4))',
5457
'5': 'hsl(var(--chart-5))'
58+
},
59+
sidebar: {
60+
DEFAULT: 'hsl(var(--sidebar-background))',
61+
foreground: 'hsl(var(--sidebar-foreground))',
62+
primary: 'hsl(var(--sidebar-primary))',
63+
'primary-foreground': 'hsl(var(--sidebar-primary-foreground))',
64+
accent: 'hsl(var(--sidebar-accent))',
65+
'accent-foreground': 'hsl(var(--sidebar-accent-foreground))',
66+
border: 'hsl(var(--sidebar-border))',
67+
ring: 'hsl(var(--sidebar-ring))'
5568
}
5669
}
5770
}

0 commit comments

Comments
 (0)