Skip to content

Commit

Permalink
Merge pull request #40 from ekmas/docs
Browse files Browse the repository at this point in the history
Docs
  • Loading branch information
ekmas authored Oct 20, 2024
2 parents 1cebbb5 + 42db1ee commit 4e68566
Show file tree
Hide file tree
Showing 16 changed files with 329 additions and 145 deletions.
4 changes: 2 additions & 2 deletions src/components/app/EditThisPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ export default function EditThisPage({

return (
<Button
className="bg-white not-prose font-base dark:text-darkText gap-2 mt-12 dark:bg-secondaryBlack"
className="bg-white not-prose px-5 py-2 m400:px-3.5 h-[unset] m400:text-xs font-base dark:text-darkText gap-2 mt-12 dark:bg-secondaryBlack"
variant="noShadow"
asChild
>
<a target="_blank" href={repoDocsUrl}>
<SquarePenIcon className="w-5 h-5" />
<SquarePenIcon className="w-4 h-4" />
Edit this page
</a>
</Button>
Expand Down
8 changes: 4 additions & 4 deletions src/components/app/MobileDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useState } from 'react'
import { usePathname, useRouter } from 'next/navigation'

import {
MAIN_SIDEBAR,
MOBILE_MAIN_SIDEBAR,
MOBILE_REACT_SIDEBAR,
MOBILE_SHADCN_SIDEBAR,
} from '@/data/sidebar-links'
Expand All @@ -20,12 +20,12 @@ export default function MobileDrawer() {
const pathname = usePathname()

const ACTIVE_SIDEBAR = pathname.includes('/docs')
? MAIN_SIDEBAR
? MOBILE_MAIN_SIDEBAR
: pathname.includes('/react')
? MOBILE_REACT_SIDEBAR
: pathname.includes('/shadcn')
? MOBILE_SHADCN_SIDEBAR
: MAIN_SIDEBAR
: MOBILE_MAIN_SIDEBAR

const [isDrawerActive, setIsDrawerActive] = useState(false)

Expand All @@ -36,7 +36,7 @@ export default function MobileDrawer() {

return (
<>
<div className="hidden w-[172px] m900:block m800:w-[44px] m400:w-9">
<div className="hidden w-[236px] m900:block m800:w-[108px] m400:w-9">
<button
onClick={() => setIsDrawerActive(true)}
className="flex items-center justify-center rounded-base border-2 border-border dark:border-darkBorder p-2 shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] transition-all hover:translate-x-[3px] hover:translate-y-[3px] hover:shadow-none"
Expand Down
2 changes: 1 addition & 1 deletion src/components/app/NavDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function NavDropdown() {
onClick={() => {
setIsOpen(!isOpen)
}}
className="flex items-center gap-2 text-xl font-base"
className="flex items-center gap-2 text-xl m1000:text-lg font-base"
>
Components
<ChevronDown
Expand Down
89 changes: 47 additions & 42 deletions src/components/app/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Link from 'next/link'

import MobileDrawer from '@/components/app/MobileDrawer'
import NavDropdown from '@/components/app/NavDropdown'
import Search from '@/components/app/Search'
import { ThemeSwitcher } from '@/components/app/ThemeSwitcher'

function Navbar() {
Expand All @@ -12,60 +13,64 @@ function Navbar() {

<div className="flex items-center gap-10">
<Link
className="text-4xl w-[172px] m900:w-[unset] font-heading m500:text-xl"
className="text-4xl m900:w-[unset] font-heading m500:text-xl"
href={'/'}
>
NBRTLSM
</Link>
</div>

<div className="flex items-center gap-10 m900:hidden">
<Link className="text-xl font-base" href="/docs">
Docs
</Link>
<div className="flex items-center gap-10 m1000:gap-8 m900:hidden">
<Link className="text-xl m1000:text-lg font-base" href="/docs">
Docs
</Link>

<NavDropdown />
<NavDropdown />

<Link className="text-xl font-base" href="/templates">
Templates
</Link>
<Link className="text-xl m1000:text-lg font-base" href="/templates">
Templates
</Link>
</div>
</div>

<div className="flex w-[172px] items-center justify-end gap-5 m800:w-[unset] m400:gap-3">
<a
target="_blank"
href="https://github.com/ekmas/neobrutalism-components"
className="m800:hidden flex items-center justify-center rounded-base border-2 border-border shadow-nav dark:shadow-navDark dark:border-darkBorder p-2 transition-all hover:translate-x-[3px] hover:translate-y-[3px] hover:shadow-none dark:hover:shadow-none"
>
<svg
className="h-6 w-6 m500:h-4 m500:w-4"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 496 512"
<div className="flex items-center gap-10 m1000:gap-5">
<Search />

<div className="flex items-center justify-end gap-5 m800:w-[unset] m400:gap-3">
<a
target="_blank"
href="https://github.com/ekmas/neobrutalism-components"
className="m800:hidden flex items-center justify-center rounded-base border-2 border-border shadow-nav dark:shadow-navDark dark:border-darkBorder p-2 transition-all hover:translate-x-[4px] hover:translate-y-[4px] hover:shadow-none dark:hover:shadow-none"
>
<path
className="fill-text dark:fill-darkText"
d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"
/>
</svg>
</a>
<a
target="_blank"
href="https://twitter.com/samuelbreznjak"
className="m800:hidden flex items-center justify-center rounded-base border-2 border-border shadow-nav dark:shadow-navDark dark:border-darkBorder p-2 transition-all hover:translate-x-[3px] hover:translate-y-[3px] hover:shadow-none dark:hover:shadow-none"
>
<svg
className="h-6 w-6 m500:h-4 m500:w-4"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
<svg
className="h-6 w-6 m500:h-4 m500:w-4"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 496 512"
>
<path
className="fill-text dark:fill-darkText"
d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3 .3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5 .3-6.2 2.3zm44.2-1.7c-2.9 .7-4.9 2.6-4.6 4.9 .3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3 .7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3 .3 2.9 2.3 3.9 1.6 1 3.6 .7 4.3-.7 .7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3 .7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3 .7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"
/>
</svg>
</a>
<a
target="_blank"
href="https://twitter.com/samuelbreznjak"
className="m800:hidden flex items-center justify-center rounded-base border-2 border-border shadow-nav dark:shadow-navDark dark:border-darkBorder p-2 transition-all hover:translate-x-[4px] hover:translate-y-[4px] hover:shadow-none dark:hover:shadow-none"
>
<path
className="fill-text dark:fill-darkText"
d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"
/>
</svg>
</a>
<svg
className="h-6 w-6 m500:h-4 m500:w-4"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 512 512"
>
<path
className="fill-text dark:fill-darkText"
d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"
/>
</svg>
</a>

<ThemeSwitcher />
<ThemeSwitcher />
</div>
</div>
</div>
</nav>
Expand Down
132 changes: 132 additions & 0 deletions src/components/app/Search.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
'use client'

import { Search as SearchIcon } from 'lucide-react'

import { useCallback, useEffect, useState } from 'react'
import { useRouter } from 'next/navigation'

import {
GETTING_STARTED_LINKS,
REACT_LINKS,
SHADCN_LINKS,
} from '@/data/sidebar-links'

import { Button } from '@/components/ui/button'
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from '@/components/ui/command'
import { Dialog, DialogContent } from '@/components/ui/dialog'

export default function Search() {
const DOCS_LINKS = [
{
heading: 'Getting started',
links: [...GETTING_STARTED_LINKS],
},
{
heading: 'Shadcn',
links: [
{
href: '/shadcn/installation',
text: 'Installation',
},
...SHADCN_LINKS,
],
},
{
heading: 'React',
links: [
{
href: '/react/installation',
text: 'Installation',
},
...REACT_LINKS,
],
},
]

const router = useRouter()

const [open, setOpen] = useState(false)

useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {
e.preventDefault()
setOpen((open) => !open)
}
}
document.addEventListener('keydown', down)
return () => document.removeEventListener('keydown', down)
}, [])

const runCommand = useCallback((command: () => unknown) => {
setOpen(false)
command()
}, [])

return (
<>
<Button
onClick={() => setOpen(true)}
className="relative bg-white dark:text-white dark:bg-secondaryBlack shadow-nav dark:shadow-navDark hover:!translate-x-[4px] hover:!translate-y-[4px] hover:shadow-none dark:hover:shadow-none px-5 m1100:pr-14 m900:p-2 pr-20 m500:h-9 shrink-0 m500:w-9 m500:p-0 h-[44px] text-lg"
>
<span className="m1100:hidden">Search docs...</span>
<span className="hidden m1100:inline">
<SearchIcon className="h-4 w-4 m900:w-6 m900:h-6 m500:h-4 m500:w-4 shrink-0" />
</span>

<span className="absolute m900:hidden text-black border text-base px-1 py-0.5 border-black rounded-base bg-main h-[28px] right-2 top-1.5">
⌘K
</span>
</Button>
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent className="overflow-hidden border-0 p-0">
<Command>
<CommandInput placeholder="Search documentation..." />
<CommandList className="command-scrollbar">
<CommandEmpty>No results found.</CommandEmpty>
{DOCS_LINKS.map(({ heading, links }) => {
const isReact = heading === 'React'
const isShadcn = heading === 'Shadcn'

return (
<CommandGroup
className="[&_[cmdk-group-heading]]:text-base"
key={heading}
heading={heading}
>
{links.map(({ text, href }) => {
const formattedText = isShadcn
? `Shadcn ${text}`
: isReact
? `React ${text}`
: text

return (
<CommandItem
value={formattedText}
onSelect={() => {
runCommand(() => router.push(href))
}}
key={href}
>
{formattedText}
</CommandItem>
)
})}
</CommandGroup>
)
})}
</CommandList>
</Command>
</DialogContent>
</Dialog>
</>
)
}
2 changes: 1 addition & 1 deletion src/components/app/ThemeSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function ThemeSwitcher() {
return (
<>
<Button
className="h-11 w-11 m500:h-9 m500:w-9 p-0 shadow-nav dark:shadow-navDark hover:!translate-x-[3px] hover:!translate-y-[3px] hover:!shadow-none dark:hover:shadow-none !bg-white dark:!bg-secondaryBlack"
className="h-11 w-11 m500:h-9 m500:w-9 p-0 shadow-nav dark:shadow-navDark hover:!translate-x-[4px] hover:!translate-y-[4px] hover:!shadow-none dark:hover:shadow-none !bg-white dark:!bg-secondaryBlack"
onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}
>
<Sun className="h-6 w-6 m500:h-4 m500:w-4 hidden dark:inline stroke-darkText" />
Expand Down
Loading

0 comments on commit 4e68566

Please sign in to comment.