Skip to content

Commit

Permalink
feat: add layout and get sidebar data
Browse files Browse the repository at this point in the history
  • Loading branch information
limsohee1002 committed Nov 13, 2024
1 parent d05fa87 commit 66324b3
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 57 deletions.
31 changes: 31 additions & 0 deletions src/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { FC } from 'react'

import { useDocsData } from '@docusaurus/plugin-content-docs/client'

const Sidebar: FC = () => {
React.useEffect(() => {
const main = document.getElementById('new-main')
const sidebars = main.getElementsByTagName('aside')
Array.from(sidebars).map((sidebar) => {
if (sidebar.id !== 'new-sidebar') {
sidebar.remove()
}
})
}, [])
const visibleItems = useDocsData(undefined)
console.log('!!!', visibleItems)
return (
<aside id="new-sidebar" className="w-sidebar-w">
<div>new sidebar</div>
<div>new sidebar</div>
<div>new sidebar</div>
<div>new sidebar</div>
<div>new sidebar</div>
<div>new sidebar</div>
<div>new sidebar</div>
<div>new sidebar</div>
</aside>
)
}

export default Sidebar
29 changes: 0 additions & 29 deletions src/theme/DocSidebarItem.tsx

This file was deleted.

24 changes: 24 additions & 0 deletions src/theme/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { FC } from 'react'

import LayoutProvider from '@theme/Layout/Provider'
import { PageMetadata } from '@docusaurus/theme-common'
import Navbar from '@theme/Navbar'
import Footer from '@theme/Footer'
import type { Props } from '@theme/Layout'
import Sidebar from '../components/Sidebar'

const Layout: FC<Props> = ({ title, description, children }) => {
return (
<LayoutProvider>
<PageMetadata title={title} description={description} />
<Navbar />
<main id="new-main" className="pt-nav-h min-h-screen flex flex-row">
<Sidebar />
<div className="">{children}</div>
</main>
<Footer />
</LayoutProvider>
)
}

export default Layout
60 changes: 32 additions & 28 deletions src/theme/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,40 @@ import ThemeSwitch from '../components/ThemeSwitch'

const Navbar: FC = () => {
return (
<nav className="Navbar fixed left-0 right-0 z-nav flex w-screen justify-center bg-light-surface-1 dark:border-dark-surface-3 dark:bg-dark-surface-1">
<div className="w-full h-nav-h flex flex-row justify-between items-center px-4 py-[1.15625rem] sm:px-[0.9375rem] sm:py-3">
<a className="flex flex-row items-center" href="/" target="_self" aria-label="Uniswap Documentation Home">
<MiniUnicon className="w-8 h-8 mr-3" />
<p className="Navbar__logo-text body-1 text-light-accent-1 dark:text-dark-accent-1 mb-0">Uniswap Docs</p>
</a>
<div className="flex flex-row items-center">
<OriginalSearchbar />
<button
className="ml-3 flex items-center md:hidden"
onClick={() => {
console.log('open mobile menu')
}}
>
<Menu />
</button>
</div>
<div className="hidden md:flex flex-row items-center">
<ThemeSwitch />
<a
className="button-label-4 py-2 px-3 bg-light-accent-2 dark:bg-dark-accent-2 rounded-small ml-2"
href="https://docs.google.com/forms/d/e/1FAIpQLSdjSkZam8KiatL9XACRVxCHjDJjaPGbls77PCXDKFn4JwykXg/viewform"
target="_blank"
rel="noreferrer"
>
<span className="text-light-accent-1 dark:text-dark-accent-1">Submit Feedback</span>
<>
{/* docusaurus expects class name "navbar". adding fake div for handling error that is looking for "navbar" class */}
<div className="navbar hidden"></div>
<nav className="Navbar fixed left-0 right-0 z-nav flex w-screen justify-center bg-light-surface-1 dark:border-dark-surface-3 dark:bg-dark-surface-1">
<div className="w-full h-nav-h flex flex-row justify-between items-center px-4 py-[1.15625rem] sm:px-[0.9375rem] sm:py-3">
<a className="flex flex-row items-center" href="/" target="_self" aria-label="Uniswap Documentation Home">
<MiniUnicon className="w-8 h-8 mr-3" />
<p className="Navbar__logo-text body-1 text-light-accent-1 dark:text-dark-accent-1 mb-0">Uniswap Docs</p>
</a>
<div className="flex flex-row items-center">
<OriginalSearchbar />
<button
className="ml-3 flex items-center md:hidden"
onClick={() => {
console.log('open mobile menu')
}}
>
<Menu />
</button>
</div>
<div className="hidden md:flex flex-row items-center">
<ThemeSwitch />
<a
className="button-label-4 py-2 px-3 bg-light-accent-2 dark:bg-dark-accent-2 rounded-small ml-2"
href="https://docs.google.com/forms/d/e/1FAIpQLSdjSkZam8KiatL9XACRVxCHjDJjaPGbls77PCXDKFn4JwykXg/viewform"
target="_blank"
rel="noreferrer"
>
<span className="text-light-accent-1 dark:text-dark-accent-1">Submit Feedback</span>
</a>
</div>
</div>
</div>
</nav>
</nav>
</>
)
}

Expand Down
1 change: 1 addition & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module.exports = {
'gap-small': rem(8),
'gap-x-small': rem(4),
'nav-h': rem(72),
'sidebar-w': rem(240),
},
boxShadow: {
'light-short': '0px 1px 6px 2px rgba(0, 0, 0, 0.03), 0px 1px 2px 0px rgba(0, 0, 0, 0.02)',
Expand Down

0 comments on commit 66324b3

Please sign in to comment.