{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "navbar-utility",
  "type": "registry:block",
  "title": "Navbar, utility bar",
  "description": "Two rows: a slim tinted utility bar (a note on the left, phone, language or sign-in links on the right) above the main row with brand, up to six links and one call to action. The main row collapses to a menu in narrow containers; the utility bar stays.",
  "categories": [
    "navbar"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/kit-d-chrome.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/navbar-utility/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/navbar-utility/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, link, t, wordmark } from '../_shared/schema';\n\nconst schema = z.object({\n  brand: t(40),\n  /** Their logo in place of the brand name; the name stays for screen readers. Not drawn without a src. */\n  wordmark,\n  /** Brand link target; default \"/\". */\n  brandHref: t(300).optional(),\n  /** One line on the left of the utility bar (opening hours, delivery terms). Empty or left out hides it, so a swap from another navbar needs none (KB-266). */\n  note: t(80).default(''),\n  /** Quiet links on the right of the utility bar: phone, language, sign in. Up to three. */\n  utility: z.array(link).max(3).default([]),\n  links: z.array(link).max(10) // KB-178: raised from 6 for sites with ten menu links\n,\n  /** The href of the current page's link, in the main row or the utility bar: that link gets aria-current=\"page\". */\n  current: t(300).optional(),\n  cta: link,\n  /** Where the call to action sits on a phone with a menu: unset moves it into the menu when brand and button run past about 22 characters, false keeps it in the bar (a site that measured its header fits), true always moves it. */\n  ctaInMenu: z.boolean().optional(),\n});\n\nexport const spec = defineSpec({\n  type: 'navbar-utility',\n  aliases: ['navigation/utility', 'header/utility'],\n  name: 'Navbar, utility bar',\n  category: 'navbar',\n  role: 'nav',\n  description: 'Two rows: a slim tinted utility bar (a note on the left, phone, language or sign-in links on the right) above the main row with brand, up to six links and one call to action. The main row collapses to a menu in narrow containers; the utility bar stays.',\n  schema,\n  defaults: {\n    brand: 'Brand name',\n    note: 'Say when people can reach you.',\n    utility: [\n      { label: '00 000 000 00', href: 'tel:+46310000000' },\n      { label: 'Language', href: '/sv' },\n      { label: 'Your account', href: '/booking' },\n    ],\n    links: [\n      { label: 'First page', href: '#rooms' },\n      { label: 'Second page', href: '#breakfast' },\n      { label: 'Third page', href: '#offers' },\n      { label: 'Fourth page', href: '#directions' },\n    ],\n    cta: { label: 'Main action', href: '#book' },\n  },\n});\n"
    },
    {
      "path": "src/blocks/navbar-utility/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/navbar-utility/index.tsx",
      "content": "import { Text, withHeadingLevel } from '../../editing';\nimport { safeHref } from '../../ui/button';\nimport { ActionLink, brandName, Container, ctaInMenu, Gate, Opt, useEditing } from '../_shared/kit';\nimport { FOCUS, MenuDetails, navLinkClass, useMenu } from '../_shared/d-chrome-kit';\nimport { cn } from '../../lib/utils';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\n// UI-49: the links go inline at @3xl (768 px) only when the row's words fit there (the defaults use 58 characters); longer or more\n// links stay in the menu until @6xl, as navbar-simple's WIDE does. Class strings are spelled out so Tailwind sees them.\nconst W = {\n  light: { link: '@3xl:w-auto @3xl:px-2.5 @3xl:text-kh-small', row: '@3xl:flex-nowrap', brand: '@3xl:mr-6 @3xl:shrink-0', button: '@3xl:hidden', details: '@3xl:flex @3xl:flex-1 @3xl:shrink @3xl:details-content:contents @3xl:details-content:content-visible', nav: '@3xl:static @3xl:flex @3xl:max-h-none @3xl:flex-1 @3xl:overflow-visible @3xl:border-0 @3xl:bg-transparent @3xl:p-0', list: '@3xl:mx-0 @3xl:flex-row @3xl:gap-1' },\n  heavy: { link: '@6xl:w-auto @6xl:px-2.5 @6xl:text-kh-small', row: '@6xl:flex-nowrap', brand: '@6xl:mr-6 @6xl:shrink-0', button: '@6xl:hidden', details: '@6xl:flex @6xl:flex-1 @6xl:shrink @6xl:details-content:contents @6xl:details-content:content-visible', nav: '@6xl:static @6xl:flex @6xl:max-h-none @6xl:flex-1 @6xl:overflow-visible @6xl:border-0 @6xl:bg-transparent @6xl:p-0', list: '@6xl:mx-0 @6xl:flex-row @6xl:gap-1' },\n} as const;\n\nfunction NavbarUtility({ props }: BlockProps<Props>) {\n  const { shown, setOpen, menuId, summaryRef, detailsRef, rootRef, rootProps } = useMenu();\n  const editing = useEditing();\n  const hasLinks = editing || props.links.some((l) => l.label);\n  const words = (props.brand ?? '').length + (props.cta?.label ?? '').length + props.links.reduce((n, l) => n + l.label.length, 0);\n  const w = props.links.length > 5 || words > 70 ? W.heavy : W.light;\n  const linkClass = cn(navLinkClass, 'w-full whitespace-nowrap px-3 text-kh-body', w.link);\n  // A long brand and call to action on a phone: the button moves into the menu below @md, only when there is a menu (UI-48).\n  const moveCta = hasLinks && ctaInMenu({ ...props, editing });\n  const utility = (props.utility ?? []).map((l, i) => ({ l, i })).filter(({ l }) => l.label || editing);\n  return (\n    <header ref={rootRef} {...rootProps} className=\"relative border-b border-kh-line bg-kh-canvas\">\n      {(props.note || utility.length > 0 || editing) && (\n        <div className=\"border-b border-kh-line bg-kh-surface-2 text-kh-muted\">\n          <Container className=\"flex min-h-9 flex-wrap items-center justify-between gap-x-6 gap-y-0 py-1\">\n            <Opt path={['note']} value={props.note} as=\"p\" className=\"text-kh-caption\" placeholder=\"Note\" />\n            {utility.length > 0 && (\n              <ul className=\"-mx-2 ml-auto flex flex-wrap\">\n                {utility.map(({ l, i }) => (\n                  <li key={i}>\n                    <a href={safeHref(l.href)} aria-current={props.current && l.href === props.current ? 'page' : undefined} className={cn('inline-flex min-h-8 items-center rounded-kh-sm px-2 text-kh-caption transition-colors hover:text-kh-ink underline-offset-4 aria-[current=page]:font-semibold aria-[current=page]:text-kh-ink aria-[current=page]:underline', FOCUS)}>\n                      <Text path={['utility', i, 'label']} value={l.label} as=\"span\" />\n                    </a>\n                  </li>\n                ))}\n              </ul>\n            )}\n          </Container>\n        </div>\n      )}\n      {/* One row at any width, as navbar-simple (2026-10-19: 'Ironbridge Plumbing' pushed the call to action onto its own row at 390):\n          the brand shrinks and breaks onto at most two lines; the menu toggle and the call to action never shrink. The editor still wraps. */}\n      <Container className={cn('flex min-h-16 items-center gap-2 py-2', editing ? cn('flex-wrap', w.row) : 'flex-nowrap')}>\n        <Gate label={props.brand || (props.wordmark?.src ? props.wordmark.alt : '')}>\n          <a href={safeHref(props.brandHref ?? '/')} className={cn('min-w-0 rounded-kh-sm text-kh-heading font-semibold tracking-tight text-kh-ink', w.brand, FOCUS)}>\n            {brandName({ brand: props.brand, wordmark: props.wordmark, placeholder: 'Brand', className: 'line-clamp-2 leading-tight hyphens-auto [overflow-wrap:anywhere]' })}\n          </a>\n        </Gate>\n        <span className=\"mr-auto\" aria-hidden />\n        {hasLinks && (\n        <MenuDetails shown={shown} onToggle={setOpen} summaryRef={summaryRef} detailsRef={detailsRef} className={w.button} detailsClass={cn('shrink-0', w.details, editing && 'order-last basis-full')}>\n          <nav\n            id={menuId}\n            aria-label=\"Main\"\n            className={cn(\n              'border-b border-kh-line bg-kh-canvas pb-4 pt-2',\n              editing ? 'order-last basis-full' : 'absolute inset-x-0 top-full z-10 max-h-[calc(100dvh-4rem)] overflow-y-auto px-kh-gutter',\n              w.nav,\n            )}\n          >\n            <ul className={cn('-mx-3 flex flex-col gap-0.5', w.list)}>\n              {props.links.map((l, i) => (\n                <Gate key={i} label={l.label}>\n                  <li>\n                    <a href={safeHref(l.href)} aria-current={props.current && l.href === props.current ? 'page' : undefined} onClick={() => setOpen(false)} className={linkClass}>\n                      <Text path={['links', i, 'label']} value={l.label} as=\"span\" />\n                    </a>\n                  </li>\n                </Gate>\n              ))}\n            </ul>\n            {moveCta && <ActionLink path={['cta']} value={props.cta} size=\"md\" className=\"mt-4 w-full @md:hidden\" />}\n          </nav>\n        </MenuDetails>\n        )}\n        <ActionLink path={['cta']} value={props.cta} size=\"md\" className={cn('shrink-0', moveCta && '@max-md:hidden')} />\n      </Container>\n    </header>\n  );\n}\n\nexport default withHeadingLevel(NavbarUtility);\n"
    }
  ]
}
