mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-31 13:21:52 -04:00
docs: mobile nav
This commit is contained in:
@@ -6,6 +6,8 @@ import SidebarToggle from './SidebarToggle';
|
||||
// import LanguageSelect from './LanguageSelect';
|
||||
import Search from './Search';
|
||||
import CommandLineIcon from '@heroicons/react/20/solid/CommandLineIcon';
|
||||
import MobileNav from '../../docs/MobileNav';
|
||||
import { SIDEBAR } from '../../config';
|
||||
|
||||
type Props = {
|
||||
currentPage: string;
|
||||
@@ -13,9 +15,11 @@ type Props = {
|
||||
|
||||
const { currentPage } = Astro.props as Props;
|
||||
// const lang = getLanguageFromURL(currentPage);
|
||||
const langCode = 'en'; // getLanguageFromURL(currentPage);
|
||||
const sidebar = SIDEBAR[langCode];
|
||||
---
|
||||
|
||||
<nav class="flex justify-between py-2 px-4 items-center h-25 bg-[#161616]" title="Top Navigation">
|
||||
<nav class="flex justify-between py-2 px-4 items-center h-14 max-h-14 bg-[#161616]" title="Top Navigation">
|
||||
<!-- <div class="menu-toggle">
|
||||
<SidebarToggle client:idle />
|
||||
</div> -->
|
||||
@@ -34,9 +38,12 @@ const { currentPage } = Astro.props as Props;
|
||||
<div class="search-item h-10">
|
||||
<!-- <Search client:idle /> -->
|
||||
</div>
|
||||
<a href=".." class="cursor-pointer items-center flex space-x-1"
|
||||
<a href=".." class="hidden md:flex cursor-pointer items-center space-x-1"
|
||||
><CommandLineIcon className="w-5 h-5" /><span>go to REPL</span>
|
||||
</a>
|
||||
<div class="md:hidden">
|
||||
<MobileNav sidebar={sidebar} client:idle />
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Disclosure } from '@headlessui/react';
|
||||
import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline';
|
||||
|
||||
function classNames(...classes) {
|
||||
return classes.filter(Boolean).join(' ');
|
||||
}
|
||||
|
||||
export default function MobileNav({ sidebar }) {
|
||||
return (
|
||||
<Disclosure as="nav">
|
||||
{({ open }) => (
|
||||
<>
|
||||
<Disclosure.Button className="inline-flex items-center justify-center rounded-md p-2 text-gray-400 hover:bg-gray-700 hover:text-white focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white">
|
||||
<span className="sr-only">Open main menu</span>
|
||||
{open ? (
|
||||
<XMarkIcon className="block h-6 w-6" aria-hidden="true" />
|
||||
) : (
|
||||
<Bars3Icon className="block h-6 w-6" aria-hidden="true" />
|
||||
)}
|
||||
</Disclosure.Button>
|
||||
<Disclosure.Panel className="md:hidden absolute top-14 right-0 max-h-screen pb-14 overflow-auto z-[100] w-full">
|
||||
<div className="space-y-1 px-4 py-4 bg-[#161616]">
|
||||
<a
|
||||
href=".."
|
||||
className="py-2 flex cursor-pointer items-center space-x-1 hover:bg-bg hover:px-2 rounded-md"
|
||||
>
|
||||
<span>go to REPL</span>
|
||||
</a>
|
||||
{Object.entries(sidebar).map(([group, items], i) => (
|
||||
<div key={i} className="space-y-2">
|
||||
<div>{group}</div>
|
||||
{items.map((item, j) => (
|
||||
<Disclosure.Button
|
||||
key={j}
|
||||
as="a"
|
||||
href={`/${item.link}`}
|
||||
className={classNames(
|
||||
item.current ? 'bg-bg text-white' : 'text-gray-300 hover:bg-bg hover:text-white',
|
||||
'block px-3 py-2 rounded-md text-base font-medium',
|
||||
)}
|
||||
aria-current={item.current ? 'page' : undefined}
|
||||
>
|
||||
{item.text}
|
||||
</Disclosure.Button>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Disclosure.Panel>
|
||||
</>
|
||||
)}
|
||||
</Disclosure>
|
||||
);
|
||||
}
|
||||
@@ -31,8 +31,7 @@ export function Header({ context }) {
|
||||
<header
|
||||
id="header"
|
||||
className={cx(
|
||||
'flex-none w-full md:flex text-black justify-between z-[100] text-lg select-none sticky top-0',
|
||||
isEmbedded ? 'h-12 md:h-8' : 'h-25 md:h-14',
|
||||
'py-1 flex-none w-full md:flex text-black justify-between z-[100] text-lg select-none sticky top-0',
|
||||
!isZen && 'bg-header',
|
||||
)}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user