-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sidebar padding fix, bumped to next 13 (#44)
- Loading branch information
Showing
3 changed files
with
7,745 additions
and
7,630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,88 @@ | ||
import { Disclosure, Transition } from '@headlessui/react' | ||
import { useRouter } from 'next/router' | ||
import { Disclosure, Transition } from '@headlessui/react'; | ||
import { useRouter } from 'next/router'; | ||
|
||
function classNames(...classes) { | ||
return classes.filter(Boolean).join(' ') | ||
return classes.filter(Boolean).join(' '); | ||
} | ||
|
||
export default function Sidebar({ contentList, viewType }) { | ||
const router = useRouter(); | ||
const {asPath: url, query: { path }} = router; | ||
const sortedContent = contentList?.filter(page => !page.hide).sort((a,b) => a.order - b.order); | ||
return ( | ||
<div className={`${viewType === "nav" ? 'pl-0' : 'pl-20'} pr-6 py-6`}> | ||
{ | ||
sortedContent?.map(page => | ||
( | ||
<Disclosure as="div" defaultOpen={path === page.url} key={page.name} className="space-y-1"> | ||
{({ open }) => ( | ||
<> | ||
<Disclosure.Button className={classNames( | ||
open | ||
? 'text-secondary' | ||
: 'text-white', | ||
'hover:text-secondary cursor-pointer w-full flex items-center justify-between pt-8 text-2xl font-medium font-heading' | ||
)}> | ||
<div> | ||
<span className="mr-2">{page.logo}</span>{page.name} | ||
</div> | ||
<div> | ||
<svg xmlns="http://www.w3.org/2000/svg" className={classNames( | ||
open | ||
? 'rotate-90' | ||
: 'rotate-0', | ||
'h-5 w-5 transition-transform ease-in duration-150' | ||
)} fill="none" viewBox="0 0 24 24" stroke="currentColor"> | ||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M9 5l7 7-7 7" /> | ||
</svg> | ||
</div> | ||
</Disclosure.Button> | ||
<Transition | ||
enter="transition duration-100 ease-out" | ||
enterFrom="transform scale-95 opacity-0" | ||
enterTo="transform scale-100 opacity-100" | ||
leave="transition duration-75 ease-out" | ||
leaveFrom="transform scale-100 opacity-100" | ||
leaveTo="transform scale-95 opacity-0" | ||
> | ||
<Disclosure.Panel className="pl-6 border-l border-accent mb-6"> | ||
{page?.pages?.map(subPage => { | ||
const subPath = `/${subPage?.path?.replace(".md", "")}`; | ||
return ( | ||
<a | ||
key={subPage?.name} | ||
href={subPath} | ||
className={classNames( | ||
subPath === url | ||
? 'text-secondary' | ||
: 'text-white', | ||
'hover:text-secondary cursor-pointer w-full flex items-center justify-start pt-6 text-sm font-light font-heading' | ||
)} | ||
> | ||
<span className="mr-2">{subPage?.logo}</span>{subPage?.name} | ||
</a> | ||
) | ||
})} | ||
</Disclosure.Panel> | ||
</Transition> | ||
</> | ||
)} | ||
</Disclosure> | ||
) | ||
) | ||
} | ||
</div> | ||
) | ||
const router = useRouter(); | ||
const { | ||
asPath: url, | ||
query: { path }, | ||
} = router; | ||
const sortedContent = contentList | ||
?.filter((page) => !page.hide) | ||
.sort((a, b) => a.order - b.order); | ||
return ( | ||
<div className={`${viewType === 'nav' ? 'pl-0' : 'pl-[min(20%,4rem)]'} pr-6 py-6`}> | ||
{sortedContent?.map((page) => ( | ||
<Disclosure | ||
as='div' | ||
defaultOpen={path === page.url} | ||
key={page.name} | ||
className='space-y-1'> | ||
{({ open }) => ( | ||
<> | ||
<Disclosure.Button | ||
className={classNames( | ||
open ? 'text-secondary' : 'text-white', | ||
'hover:text-secondary cursor-pointer w-full flex items-center justify-between pt-8 text-2xl font-medium font-heading' | ||
)}> | ||
<div> | ||
<span className='mr-2'>{page.logo}</span> | ||
{page.name} | ||
</div> | ||
<div> | ||
<svg | ||
xmlns='http://www.w3.org/2000/svg' | ||
className={classNames( | ||
open ? 'rotate-90' : 'rotate-0', | ||
'h-5 w-5 transition-transform ease-in duration-150' | ||
)} | ||
fill='none' | ||
viewBox='0 0 24 24' | ||
stroke='currentColor'> | ||
<path | ||
strokeLinecap='round' | ||
strokeLinejoin='round' | ||
strokeWidth='2' | ||
d='M9 5l7 7-7 7' | ||
/> | ||
</svg> | ||
</div> | ||
</Disclosure.Button> | ||
<Transition | ||
enter='transition duration-100 ease-out' | ||
enterFrom='transform scale-95 opacity-0' | ||
enterTo='transform scale-100 opacity-100' | ||
leave='transition duration-75 ease-out' | ||
leaveFrom='transform scale-100 opacity-100' | ||
leaveTo='transform scale-95 opacity-0'> | ||
<Disclosure.Panel className='pl-6 border-l border-accent mb-6'> | ||
{page?.pages?.map((subPage) => { | ||
const subPath = `/${subPage?.path?.replace('.md', '')}`; | ||
return ( | ||
<a | ||
key={subPage?.name} | ||
href={subPath} | ||
className={classNames( | ||
subPath === url | ||
? 'text-secondary' | ||
: 'text-white', | ||
'hover:text-secondary cursor-pointer w-full flex items-center justify-start pt-6 text-sm font-light font-heading' | ||
)}> | ||
<span className='mr-2'>{subPage?.logo}</span> | ||
{subPage?.name} | ||
</a> | ||
); | ||
})} | ||
</Disclosure.Panel> | ||
</Transition> | ||
</> | ||
)} | ||
</Disclosure> | ||
))} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.
d7598ed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ground-zero – ./
ground-zero-superteamdao.vercel.app
ground-zero-git-master-superteamdao.vercel.app
ground-zero-opal.vercel.app