{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "navbar",
  "title": "Navbar",
  "description": "The bar across the top. When it gets narrow, the links move into a menu.",
  "registryDependencies": [
    "https://creance.pages.dev/r/creance-base.json"
  ],
  "files": [
    {
      "path": "navbar/Navbar.css",
      "content": "/* The nav is the container, so the bar responds to its own width, not the window's. */\n.cr-navbar {\n  container-type: inline-size;\n  color: var(--cr-color-text-default);\n  font-family: var(--cr-font-family-sans);\n}\n\n.cr-navbar__inner {\n  display: flex;\n  align-items: center;\n  gap: var(--cr-space-2);\n  box-sizing: border-box;\n  min-height: 56px;\n  padding: var(--cr-space-2) var(--cr-space-3) var(--cr-space-2) var(--cr-space-4);\n  border-radius: var(--cr-radius-full);\n}\n\n.cr-navbar[data-variant='flush'] .cr-navbar__inner {\n  padding-inline: var(--cr-space-2);\n  border-bottom: 1px solid var(--cr-color-border-default);\n  border-radius: 0;\n}\n\n.cr-navbar__brand {\n  display: flex;\n  align-items: center;\n  margin-inline-end: var(--cr-space-2);\n  font-size: var(--cr-font-size-lg);\n  font-weight: var(--cr-font-weight-bold);\n  letter-spacing: var(--cr-font-tracking-tight);\n}\n\n.cr-navbar__brand a {\n  display: inline-flex;\n  align-items: center;\n  gap: var(--cr-space-2);\n  border-radius: var(--cr-radius-sm);\n  color: inherit;\n  text-decoration: none;\n}\n\n.cr-navbar__links {\n  display: flex;\n  align-items: center;\n  gap: 2px;\n  margin: 0;\n  padding: 0;\n  list-style: none;\n}\n\n.cr-navbar__link {\n  display: inline-flex;\n  align-items: center;\n  gap: var(--cr-space-2);\n  box-sizing: border-box;\n  min-height: var(--cr-control-height-sm);\n  padding: 0 var(--cr-space-3);\n  border-radius: var(--cr-radius-full);\n  color: var(--cr-color-text-secondary);\n  font-size: var(--cr-font-size-md);\n  font-weight: var(--cr-font-weight-semibold);\n  text-decoration: none;\n  white-space: nowrap;\n}\n\n.cr-navbar__link:hover {\n  background: var(--cr-color-bg-subtle);\n  color: var(--cr-color-text-default);\n}\n\n.cr-navbar__link[aria-current='page'] {\n  background: var(--cr-color-ink-bg);\n  color: var(--cr-color-ink-fg);\n}\n\n/* Flush: the current page is underlined instead of filled. */\n.cr-navbar[data-variant='flush'] .cr-navbar__link[aria-current='page'] {\n  border-radius: 0;\n  background: none;\n  box-shadow: inset 0 -2px 0 var(--cr-color-ink-bg);\n  color: var(--cr-color-text-default);\n}\n\n.cr-navbar__count {\n  min-width: 18px;\n  padding: 0 5px;\n  border-radius: var(--cr-radius-full);\n  background: var(--cr-color-bg-subtle);\n  font-size: 11px;\n  font-weight: var(--cr-font-weight-bold);\n  line-height: 18px;\n  text-align: center;\n}\n\n.cr-navbar__link[aria-current='page'] .cr-navbar__count {\n  background: color-mix(in srgb, currentColor 22%, transparent);\n}\n\n.cr-navbar__actions {\n  display: flex;\n  align-items: center;\n  gap: var(--cr-space-2);\n  margin-inline-start: auto;\n}\n\n.cr-navbar__toggle {\n  display: none;\n  place-items: center;\n  flex: none;\n  width: var(--cr-control-height-sm);\n  height: var(--cr-control-height-sm);\n  margin-inline-start: auto;\n  padding: 0;\n  border: 0;\n  border-radius: var(--cr-radius-full);\n  background: none;\n  color: var(--cr-color-text-secondary);\n  font-size: var(--cr-font-size-lg);\n  cursor: pointer;\n}\n\n.cr-navbar__actions + .cr-navbar__toggle {\n  margin-inline-start: 0;\n}\n\n.cr-navbar__toggle:hover,\n.cr-navbar__toggle[aria-expanded='true'] {\n  background: var(--cr-color-bg-subtle);\n  color: var(--cr-color-text-default);\n}\n\n.cr-navbar__link:focus-visible,\n.cr-navbar__brand a:focus-visible,\n.cr-navbar__toggle:focus-visible {\n  outline: var(--cr-focus-width) solid var(--cr-color-focus);\n  outline-offset: var(--cr-focus-offset);\n}\n\n/* Narrow: the links leave the row and open below it from the menu button. */\n@container (max-width: 640px) {\n  .cr-navbar__inner {\n    flex-wrap: wrap;\n    border-radius: var(--cr-radius-xl);\n  }\n\n  .cr-navbar__toggle {\n    display: grid;\n  }\n\n  .cr-navbar__links {\n    display: none;\n    flex-direction: column;\n    align-items: stretch;\n    order: 1;\n    width: 100%;\n    padding-bottom: var(--cr-space-1);\n  }\n\n  .cr-navbar[data-open] .cr-navbar__links {\n    display: flex;\n  }\n\n  .cr-navbar__link {\n    display: flex;\n    min-height: var(--cr-control-height-md);\n    border-radius: var(--cr-radius-md);\n  }\n\n  .cr-navbar__link .cr-navbar__count {\n    margin-inline-start: auto;\n  }\n\n  .cr-navbar[data-variant='flush'] .cr-navbar__link[aria-current='page'] {\n    border-radius: var(--cr-radius-md);\n    background: var(--cr-color-bg-subtle);\n    box-shadow: none;\n  }\n}\n",
      "type": "registry:file",
      "target": "@components/creance/navbar/Navbar.css"
    },
    {
      "path": "navbar/Navbar.tsx",
      "content": "'use client';\n\nimport { useId, useRef, useState, type KeyboardEvent, type MouseEventHandler, type ReactNode } from 'react';\nimport { cx } from '@/lib/creance/cx';\nimport { CrossIcon, MenuIcon } from '@/lib/creance/icons';\nimport './Navbar.css';\n\nexport interface NavbarItem {\n  label: ReactNode;\n  href?: string;\n  onClick?: MouseEventHandler<HTMLAnchorElement>;\n  /** The page the person is on. */\n  current?: boolean;\n  /** A count shown after the label, such as items waiting. */\n  count?: number;\n}\n\nexport interface NavbarProps {\n  items: NavbarItem[];\n  /** Logo and name, usually a link home. */\n  brand?: ReactNode;\n  /** The end of the bar: search, buttons, the account. Use one primary button at most. */\n  actions?: ReactNode;\n  /** `bar` is a floating glass pill. `flush` sits on the page with a line under it. */\n  variant?: 'bar' | 'flush';\n  /** Accessible name of the nav. Default \"Main\". */\n  label?: string;\n  /** Accessible name of the button that opens the links on a narrow bar. Default \"Menu\". */\n  menuLabel?: string;\n  className?: string;\n}\n\n/** The bar across the top of an app or site. When it gets narrow, the links move into a menu. */\nexport function Navbar({ items, brand, actions, variant = 'bar', label = 'Main', menuLabel = 'Menu', className }: NavbarProps) {\n  const [open, setOpen] = useState(false);\n  const listId = useId();\n  const toggle = useRef<HTMLButtonElement>(null);\n\n  function onKeyDown(e: KeyboardEvent) {\n    if (e.key !== 'Escape' || !open) return;\n    setOpen(false);\n    toggle.current?.focus();\n  }\n\n  return (\n    // The key handler closes the open menu from anywhere inside it; the controls themselves are the button and links.\n    // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n    <nav aria-label={label} className={cx('cr-navbar', className)} data-variant={variant} data-open={open || undefined} onKeyDown={onKeyDown}>\n      <div className={cx('cr-navbar__inner', variant === 'bar' && 'cr-glass')}>\n        {brand && <div className=\"cr-navbar__brand\">{brand}</div>}\n        <ul id={listId} className=\"cr-navbar__links\">\n          {items.map((item, i) => (\n            <li key={i}>\n              <a\n                className=\"cr-navbar__link\"\n                href={item.href}\n                aria-current={item.current ? 'page' : undefined}\n                onClick={(e) => {\n                  item.onClick?.(e);\n                  setOpen(false);\n                }}\n              >\n                {item.label}\n                {/* The space keeps the count a separate word in the link's accessible name. */}\n                {item.count !== undefined && ' '}\n                {item.count !== undefined && <span className=\"cr-navbar__count\">{item.count}</span>}\n              </a>\n            </li>\n          ))}\n        </ul>\n        {actions && <div className=\"cr-navbar__actions\">{actions}</div>}\n        <button\n          ref={toggle}\n          type=\"button\"\n          className=\"cr-navbar__toggle\"\n          aria-label={menuLabel}\n          aria-expanded={open}\n          aria-controls={listId}\n          onClick={() => setOpen(!open)}\n        >\n          {open ? <CrossIcon /> : <MenuIcon />}\n        </button>\n      </div>\n    </nav>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/creance/navbar/Navbar.tsx"
    }
  ],
  "categories": [
    "molecule",
    "navigation"
  ],
  "type": "registry:ui"
}