{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "wordmark",
  "type": "registry:ui",
  "title": "Wordmark",
  "description": "A text logo of one or more stacked lines: a name over its tagline, or the same name in several languages or scripts. Each line is a `Wordmark.Line` with its own `lang` (and `dir` for a right-to-left script), so a screen reader, a hyphenator and the…",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "foundation",
    "pattern"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/patterns/wordmark.tsx",
      "target": "components/ui/patterns/wordmark.tsx",
      "type": "registry:ui",
      "content": "import * as React from 'react';\n\n// @interlace/wordmark v1.3.1 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/wordmark\n// What changed since: https://ds.interlace.tools/c/wordmark#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — Wordmark\n *\n * A text logo of one or more stacked lines: a name over its tagline, or the\n * same name in several languages or scripts. Each line is a `Wordmark.Line`\n * with its own `lang` (and `dir` for a right-to-left script), so a screen\n * reader, a hyphenator and the browser's font fallback all know which\n * language each line is. It goes in `Topbar`'s `logo` slot, a footer, or\n * anywhere the name stands alone.\n *\n * ## Variants\n *\n * | `variant` | Looks like                                                   |\n * | --------- | ------------------------------------------------------------ |\n * | `framed`  | A page-coloured plate, brand-coloured text, an inset rule     |\n * | `plain`   | The stacked lines alone, in the surrounding text colour       |\n *\n * ## Sizes\n *\n * | `size`       | Lockup                                                     |\n * | ------------ | ---------------------------------------------------------- |\n * | `md`         | The full lockup (default)                                  |\n * | `sm`         | About two thirds: text a step down, a thinner plate        |\n * | `responsive` | `sm` below the `md` breakpoint, `md` from it: for a topbar |\n *\n * ## Fonts\n *\n * Lines use the heading font (`--font-heading`). For a script that font\n * lacks, add a font for it to the same stack (`--font-heading: \"Inter\",\n * \"Noto Sans Arabic\", sans-serif`): the browser picks a font per glyph, so\n * each line gets the right one with no per-language setting. Loading fonts\n * is the site's job; this file names none.\n *\n * ## Name\n *\n * A link's name must contain the words printed on it (WCAG 2.5.3, Label in\n * Name), or a person who speaks the words to a voice control finds nothing.\n * A wordmark prints every `Wordmark.Line`, so:\n *\n * - **One language or a tagline:** `label` must contain the lines, for\n *   example \"Acme Field notes, home\".\n * - **Several scripts:** leave `label` out. The link is then named by its\n *   lines, each in its own `lang`, and `hint=\", home\"` says where it goes\n *   (visually hidden, after the lines). Do not write one translated name in\n *   `label`: it will not contain the other lines.\n * - **Check it:** run axe with `label-content-name-mismatch` enabled on the\n *   page that holds the logo.\n *\n * In development a `label` that does not contain every line logs one\n * warning; it is silent in production. `hint` is ignored when `label` is\n * given, and is not allowed without `href`.\n *\n * Without `href` the wordmark is an image of text: `role=\"img\"` with `label`\n * (required) as its name.\n *\n * ## Anatomy\n *\n *   Wordmark                 (a | span — data-slot=\"wordmark\", data-variant, data-size)\n *     ├─ WordmarkLine × n    (span — lang, dir)\n *     └─ hint                (span — data-slot=\"wordmark-hint\", sr-only; link only)\n *\n * ## MIN_VIEWPORT — 320\n *\n * The lockup is about 9rem wide at most; nothing wraps.\n *\n * | Rule | Concept                 | Where in this file                                       |\n * | ---- | ----------------------- | -------------------------------------------------------- |\n * | R4   | Extends native el       | `a` / `span` props                                       |\n * | R6   | data-slot per part      | wordmark / wordmark-line / wordmark-hint                                |\n * | R7   | cn + ...rest            | `cn(…, className)` + `{...props}`                        |\n * | R8   | Enums, not booleans     | `variant`, `size`                                        |\n * | R14  | Declares min viewport   | `data-min-viewport` on the root + exported const         |\n * | R19  | Tokens only             | `bg-background`, `text-primary`, `outline-primary`       |\n * | R25  | Server component        | No hooks → no `'use client'`                             |\n * | R26  | A11y from native el     | A link or an image with one name; each line keeps its `lang` |\n */\n\nimport { cn } from '@/lib/utils';\n\n// Bundlers replace `process.env.NODE_ENV` at build time; this only types it, with no @types/node.\ndeclare const process: { env: { NODE_ENV?: string } };\n\nexport const MIN_VIEWPORT = 320 as const;\n\nexport type WordmarkVariant = 'framed' | 'plain';\n\nexport type WordmarkSize = 'md' | 'sm' | 'responsive';\n\nconst VARIANT: Record<WordmarkVariant, string> = {\n  // A plate in the page colour with a brand rule set inside its edge.\n  framed: 'bg-background text-primary border-background outline-primary',\n  plain: '',\n};\n\n// The plate's padding and rule. `sm` keeps the proportions at about two\n// thirds; `responsive` is `sm` on a phone and `md` from the `md` breakpoint,\n// so a stacked lockup does not take a fifth of a phone's screen in a sticky bar.\nconst MD_FRAME = 'rounded-lg border-[3px] px-5 pt-2 pb-1.5 outline-[3px] outline-offset-[-7px]';\nconst SM_FRAME = 'rounded-md border-2 px-3 pt-1 pb-0.5 outline-2 outline-offset-[-5px]';\nconst FRAME: Record<WordmarkSize, string> = {\n  md: MD_FRAME,\n  sm: SM_FRAME,\n  responsive: `${SM_FRAME} md:rounded-lg md:border-[3px] md:px-5 md:pt-2 md:pb-1.5 md:outline-[3px] md:outline-offset-[-7px]`,\n};\n\ntype WordmarkCommon = {\n  /** @default 'framed' */\n  variant?: WordmarkVariant;\n  /** `sm` is about two thirds the size; `responsive` is `sm` below the `md` breakpoint. @default 'md' */\n  size?: WordmarkSize;\n  /** One `Wordmark.Line` per script, top to bottom. */\n  children: React.ReactNode;\n};\n\ntype WordmarkLinkProps = Omit<React.ComponentProps<'a'>, 'children'> &\n  WordmarkCommon & {\n    href: string;\n    /**\n     * The link's name, replacing its lines. Leave it out and the link is named by its lines. When given\n     * it must contain every line (\"Acme Field notes, home\"): WCAG 2.5.3, Label in Name.\n     */\n    label?: string;\n    /** Words only a screen reader needs, after the lines: \", home\". Ignored when `label` is given. */\n    hint?: string;\n  };\n\ntype WordmarkImageProps = Omit<React.ComponentProps<'span'>, 'children'> &\n  WordmarkCommon & {\n    href?: undefined;\n    /** The image's name, read once: \"Acme\". */\n    label: string;\n    hint?: never;\n  };\n\ntype WordmarkProps = WordmarkLinkProps | WordmarkImageProps;\n\n// The text of each line that is a plain string, in order, looking through fragments. A line\n// built from elements is skipped: its text is only known after render, so nothing is claimed.\nfunction lineTexts(children: React.ReactNode): string[] {\n  const texts: string[] = [];\n  React.Children.forEach(children, (child) => {\n    if (!React.isValidElement<{ children?: React.ReactNode }>(child)) return;\n    if (child.type === React.Fragment) {\n      texts.push(...lineTexts(child.props.children));\n    } else if (child.type === WordmarkLine) {\n      const parts = React.Children.toArray(child.props.children);\n      if (parts.every((part) => typeof part === 'string' || typeof part === 'number')) {\n        const text = parts.join('').trim();\n        if (text) texts.push(text);\n      }\n    }\n  });\n  return texts;\n}\n\nconst squash = (text: string) => text.replace(/\\s+/g, ' ').trim().toLowerCase();\n\nfunction warnIfLabelMissesLines(label: string, children: React.ReactNode) {\n  if (process.env.NODE_ENV === 'production') return;\n  const name = squash(label);\n  const missing = lineTexts(children).filter((line) => !name.includes(squash(line)));\n  if (missing.length > 0) {\n    console.warn(\n      `Wordmark: label \"${label}\" does not contain the visible ${missing.length === 1 ? 'line' : 'lines'} ` +\n        `${missing.map((m) => `\"${m}\"`).join(', ')} (WCAG 2.5.3, Label in Name). ` +\n        'Leave `label` out to name the link by its lines, or write a label that contains them.',\n    );\n  }\n}\n\nfunction Wordmark({ label, hint, variant = 'framed', size = 'md', href, className, children, ...props }: WordmarkProps) {\n  const classes = cn(\n    'group/wordmark font-heading inline-flex shrink-0 flex-col items-center leading-[1.05] whitespace-nowrap',\n    VARIANT[variant],\n    variant === 'framed' && FRAME[size],\n    // The focus ring is a box-shadow, so the framed plate keeps its inset rule.\n    href && 'focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n    href && variant === 'plain' && 'focus-visible:outline-hidden',\n    className,\n  );\n  const shared = {\n    'data-slot': 'wordmark',\n    'data-variant': variant,\n    'data-size': size,\n    'data-min-viewport': String(MIN_VIEWPORT),\n    className: classes,\n  };\n  if (href === undefined) {\n    return (\n      <span role=\"img\" aria-label={label} {...shared} {...(props as React.ComponentProps<'span'>)}>\n        {children}\n      </span>\n    );\n  }\n  if (label !== undefined) warnIfLabelMissesLines(label, children);\n  return (\n    <a href={href} aria-label={label} {...shared} {...(props as React.ComponentProps<'a'>)}>\n      {children}\n      {label === undefined && hint ? (\n        <span data-slot=\"wordmark-hint\" className=\"sr-only\">\n          {hint}\n        </span>\n      ) : null}\n    </a>\n  );\n}\n\ntype WordmarkLineProps = React.ComponentProps<'span'> & {\n  /** The line's language: \"en\", \"ja\", \"ar\". */\n  lang: string;\n};\n\nfunction WordmarkLine({ className, children, ...props }: WordmarkLineProps) {\n  // A trailing space (collapsed, so invisible) separates this line from the next in the name a\n  // browser computes and in the text axe reads, in any CSS: \"ACME アクメ أكمي\", not \"ACMEアクメأكمي\".\n  return (\n    <span\n      data-slot=\"wordmark-line\"\n      className={cn(\n        'block text-base font-extrabold first:text-lg [&:lang(en)]:tracking-wide',\n        // The size lives on the Wordmark; a line reads it from there.\n        'group-data-[size=sm]/wordmark:text-xs group-data-[size=sm]/wordmark:first:text-sm',\n        'max-md:group-data-[size=responsive]/wordmark:text-xs max-md:group-data-[size=responsive]/wordmark:first:text-sm',\n        className,\n      )}\n      {...props}\n    >\n      {children}{' '}\n    </span>\n  );\n}\n\nconst WordmarkWithLine = Object.assign(Wordmark, { Line: WordmarkLine });\n\nexport { WordmarkWithLine as Wordmark, WordmarkLine };\nexport type { WordmarkProps, WordmarkLinkProps, WordmarkImageProps, WordmarkLineProps };\n"
    }
  ],
  "meta": {
    "tier": "pattern",
    "client": false,
    "minViewport": 320,
    "loading": false,
    "version": "1.3.1",
    "since": "2.0.0"
  },
  "docs": "## @interlace/wordmark\n\nInstalled to `components/ui/patterns/wordmark.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/patterns/wordmark';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/wordmark\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
