Skip to content

Commit 30a86d1

Browse files
authored
feat: create side navigation component (#102)
1 parent 50843aa commit 30a86d1

20 files changed

Lines changed: 532 additions & 26 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"react": "19.0.0",
2222
"react-aria-components": "1.8.0",
2323
"react-dom": "19.0.0",
24-
"remark-gfm": "4.0.0",
24+
"remark-gfm": "4.0.1",
2525
"tuono": "0.19.6"
2626
},
2727
"devDependencies": {

pnpm-lock.yaml

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

src/components/App/App.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
.container {
44
padding-inline: 20px;
5+
height: fit-content;
56

67
@include up-to-xs {
78
padding-inline: 8px;

src/components/App/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { JSX } from 'react'
22
import type { TuonoLayoutProps } from 'tuono'
33

4-
import { ThemeSwitch } from '@/components/ThemeSwitch'
4+
import { Navbar } from '@/components/Navbar'
55

66
import MdxProvider from '@/components/MdxProvider'
77

@@ -10,7 +10,7 @@ import styles from './App.module.scss'
1010
export default function App({ children }: TuonoLayoutProps): JSX.Element {
1111
return (
1212
<div className={styles.container}>
13-
<ThemeSwitch />
13+
<Navbar />
1414
<MdxProvider>{children}</MdxProvider>
1515
</div>
1616
)

src/components/MdxProvider/MdxProvider.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ interface MdxProviderProps {
55
children: ReactNode
66
}
77

8-
export default function MdxProvider({
9-
children,
10-
}: MdxProviderProps): JSX.Element {
8+
export function MdxProvider({ children }: MdxProviderProps): JSX.Element {
119
return (
1210
<MDXProvider
1311
components={{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import MdxProvider from './MdxProvider'
1+
import { MdxProvider } from './MdxProvider'
22

33
export default MdxProvider
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@use '@/styles/variables' as *;
2+
3+
.navbar {
4+
width: 100%;
5+
position: fixed;
6+
height: $navbar-height;
7+
backdrop-filter: blur(15px);
8+
left: 0;
9+
top: 0;
10+
z-index: 10;
11+
12+
.background {
13+
background-color: var(--background-primary);
14+
position: relative;
15+
width: 100%;
16+
height: 100%;
17+
opacity: 0.2;
18+
z-index: 2;
19+
}
20+
21+
.content {
22+
position: absolute;
23+
width: 100%;
24+
height: 100%;
25+
z-index: 3;
26+
margin-top: -$navbar-height;
27+
}
28+
}
29+
30+
.navbar-spacing {
31+
position: relative;
32+
width: 100%;
33+
height: $navbar-height;
34+
}

src/components/Navbar/Navbar.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { JSX } from 'react'
2+
3+
import { ThemeSwitch } from '@/components/ThemeSwitch'
4+
5+
import styles from './Navbar.module.scss'
6+
7+
export function Navbar(): JSX.Element {
8+
return (
9+
<>
10+
<nav className={styles.navbar}>
11+
<div className={styles.background} />
12+
<div className={styles.content}>
13+
<ThemeSwitch />
14+
</div>
15+
</nav>
16+
<div className={styles['navbar-spacing']} />
17+
</>
18+
)
19+
}

src/components/Navbar/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Navbar } from './Navbar'

src/components/ResponsiveLayout/ResponsiveLayout.module.scss

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
@use '@/styles/media-queries' as *;
2+
@use '@/styles/variables' as *;
23

34
.layout {
45
display: flex;
56
width: 100%;
67
justify-content: space-between;
7-
height: 100vh;
8+
height: fit-content;
89
max-width: 1180px;
10+
position: relative;
911
margin: 0 auto;
1012
gap: 20px;
13+
bottom: 100px;
1114

1215
@include up-to-xl {
1316
justify-content: left;
1417
}
18+
19+
.body {
20+
position: relative;
21+
top: 0;
22+
margin-top: calc($navbar-height * 2);
23+
}
1524
}
1625

1726
@mixin sidecontent {
27+
position: sticky;
1828
min-width: 220px;
19-
background-color: lightgray;
2029
height: 100%;
30+
min-height: 200px;
31+
top: calc($navbar-height + 16px);
2132

2233
@include up-to-xs {
2334
display: none;
@@ -31,6 +42,10 @@
3142
.tableOfContents {
3243
@include sidecontent;
3344

45+
& {
46+
background-color: lightgray;
47+
}
48+
3449
@include up-to-xl {
3550
display: none;
3651
}

0 commit comments

Comments
 (0)