Skip to content

Commit

Permalink
fix: move nav menu component to directory and load from index
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemcdonald committed Aug 6, 2022
1 parent 19254ae commit 2cda001
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx'
import type { MenuLink } from '~/types'
import { Link } from '~/components/link'
import { Logo } from '~/components/logo'
import { Nav } from '~/components/navMenu'
import { Nav } from '~/components/nav'

const menuLinks: MenuLink[] = [
{
Expand Down
2 changes: 2 additions & 0 deletions app/components/nav/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Nav } from './nav'
export { default as NavMenu } from './nav-menu'
17 changes: 2 additions & 15 deletions app/components/navMenu.tsx → app/components/nav/nav-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ChevronDownIcon } from '@heroicons/react/solid'
import type { NavMenuProps } from '~/types'
import { Link } from '~/components/link'

export const NavMenu = ({ as = 'div', children, className, link }: NavMenuProps) => (
const NavMenu = ({ as = 'div', children, className, link }: NavMenuProps) => (
<Menu as={as} className={clsx('relative inline-block text-left', className)}>
<Menu.Button className="inline-flex justify-center rounded-md bg-black bg-opacity-0 px-3 py-2 text-base uppercase tracking-wide text-primary-900 hover:bg-opacity-5 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75">
<span>{link.name}</span>
Expand Down Expand Up @@ -49,17 +49,4 @@ export const NavMenu = ({ as = 'div', children, className, link }: NavMenuProps)
</Menu>
)

interface NavProps {
children: React.ReactNode
className?: string
}

export class Nav extends React.Component<NavProps, {}> {
static Menu = NavMenu

render() {
const { children, className } = this.props

return <nav className={className}>{children}</nav>
}
}
export default NavMenu
15 changes: 15 additions & 0 deletions app/components/nav/nav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import NavMenu from './nav-menu'

interface NavProps {
children: React.ReactNode
className?: string
}

function Nav({ children, className }: NavProps) {
return <nav className={className}>{children}</nav>
}

export default Object.assign(Nav, {
Menu: NavMenu,
})

0 comments on commit 2cda001

Please sign in to comment.