{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "logo",
  "title": "Logo",
  "description": "the brand from lib/brand.ts (Studio › Use system › Brand assets) · one-colour logos follow the theme · placeholder + name without one",
  "dependencies": [
    "react-native-svg@15.15.4"
  ],
  "registryDependencies": [
    "@halftone-native/kit-setup",
    "@halftone-native/lib-brand",
    "@halftone-native/lib-brand-context",
    "@halftone-native/lib-embed",
    "@halftone-native/lib-palette-context",
    "@halftone-native/lib-theme",
    "@halftone-native/lib-theme-context",
    "@halftone-native/lib-utils",
    "@halftone-native/text"
  ],
  "files": [
    {
      "path": "components/kit/logo.tsx",
      "content": "import { Text } from '@/components/ui/text';\nimport type { BrandImage } from '@/lib/brand';\nimport { useBrand } from '@/lib/brand-context';\nimport { usePalette } from '@/lib/palette-context';\nimport type { ThemeColorName } from '@/lib/theme';\nimport { useKitTheme } from '@/lib/theme-context';\nimport { cn } from '@/lib/utils';\nimport { Image, View } from 'react-native';\nimport { SvgXml } from 'react-native-svg';\n\ntype Props = {\n  /** `full` the logo (default), `mark` the square mark (falls back to the logo). */\n  variant?: 'full' | 'mark';\n  /** Height in points. Width follows the logo's shape. Default 24. */\n  size?: number;\n  /** The name to show (and read out) when there's no logo: a sample's product name. Default the brand's name. */\n  name?: string;\n  /** The theme colour a one-colour logo takes. Default `foreground`; `primaryForeground` on a primary fill. */\n  tone?: ThemeColorName;\n  className?: string;\n};\n\n/**\n * The brand's logo from lib/brand.ts (Studio's brand download), in the scheme on screen. A one-colour\n * logo takes the theme's text colour, so it works in light and dark; a coloured one can have a dark version.\n * Without a logo: a placeholder square and the name, so screens look the same before a brand is applied.\n */\nexport function Logo({ variant = 'full', size = 24, name, tone = 'foreground', className }: Props) {\n  const brand = useBrand();\n  const { scheme } = useKitTheme();\n  const palette = usePalette();\n  const label = name ?? brand.name;\n  const light = variant === 'mark' ? (brand.mark ?? brand.logo) : brand.logo;\n  const dark = variant === 'mark' ? (brand.mark ? brand.markDark : brand.logoDark) : brand.logoDark;\n  const image: BrandImage | undefined = scheme === 'dark' && dark ? dark : light;\n\n  if (!image) {\n    return (\n      <View className={cn('flex-row items-center gap-2', className)} accessible accessibilityRole=\"image\" accessibilityLabel={label}>\n        {/* On a fill (tone other than foreground) the square and the name take that tone, so they stay visible. */}\n        <View\n          className={cn('rounded-md', tone === 'foreground' && 'bg-primary')}\n          style={{ width: Math.round(size * 0.8), height: Math.round(size * 0.8), backgroundColor: tone === 'foreground' ? undefined : palette[tone] }}\n        />\n        {variant === 'full' ? (\n          <Text className=\"font-semibold\" style={tone === 'foreground' ? undefined : { color: palette[tone] }}>\n            {label}\n          </Text>\n        ) : null}\n      </View>\n    );\n  }\n  const width = Math.round(size * image.aspect);\n  return (\n    <View className={className} accessible accessibilityRole=\"image\" accessibilityLabel={label}>\n      {image.svg ? (\n        <SvgXml xml={image.svg} width={width} height={size} color={image.mono ? palette[tone] : undefined} />\n      ) : (\n        <Image source={{ uri: image.png }} style={{ width, height: size }} resizeMode=\"contain\" />\n      )}\n    </View>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/kit/logo.tsx"
    },
    {
      "path": "lib/brand.ts",
      "content": "/**\n * Your brand, as <Logo> shows it (components/kit/logo.tsx). Replace this file by unzipping the brand\n * download from Studio (halftonedesignsystem.com/studio › Use system › Brand assets): it carries\n * your logo inline, so it renders the same on a phone, in a static export and in the frames on the docs site.\n *\n * No logo (the default): <Logo> draws a placeholder square and the name, as the kit always has.\n */\nexport type BrandImage = {\n  /** The logo as SVG text, or */\n  svg?: string;\n  /** as a PNG data URL (data:image/png;base64,…). */\n  png?: string;\n  /** Every colour in the SVG is currentColor: the logo takes the theme's text colour in light and dark. */\n  mono?: boolean;\n  /** Width / height. */\n  aspect: number;\n};\n\nexport type Brand = {\n  name: string;\n  /** The full logo (often a wordmark), and its dark-theme version when it isn't mono. */\n  logo?: BrandImage;\n  logoDark?: BrandImage;\n  /** The square mark (app icon, small places); falls back to the logo. */\n  mark?: BrandImage;\n  markDark?: BrandImage;\n};\n\nexport const BRAND: Brand = { name: 'Halftone' };\n",
      "type": "registry:component",
      "target": "lib/brand.ts"
    },
    {
      "path": "lib/brand-context.tsx",
      "content": "import { BRAND, type Brand, type BrandImage } from '@/lib/brand';\nimport { EMBED, useEmbedMessage } from '@/lib/embed';\nimport * as React from 'react';\nimport { Platform } from 'react-native';\n\n/**\n * The brand on screen: lib/brand.ts, or the docs studio's live one in an embedded session. The studio posts\n * `{ type: 'kit:brand', v: 1, brand }` (brand null = back to lib/brand.ts) and keeps the latest in\n * sessionStorage for the next frame's first paint. Every image is checked before it is shown.\n */\nexport const EMBED_BRAND_KEY = 'kit.embed.brand';\nconst MAX_SVG = 300_000;\nconst MAX_PNG = 400_000;\n\nfunction isBrandImage(value: unknown): value is BrandImage {\n  if (!value || typeof value !== 'object') return false;\n  const v = value as BrandImage;\n  if (typeof v.aspect !== 'number' || !(v.aspect > 0 && v.aspect < 50)) return false;\n  if (typeof v.png === 'string') return v.png.startsWith('data:image/png;base64,') && v.png.length <= MAX_PNG;\n  if (typeof v.svg === 'string') return v.svg.length <= MAX_SVG && /^<svg\\b/i.test(v.svg.trim()) && !/<script|<foreignObject|\\son[a-z]+\\s*=/i.test(v.svg);\n  return false;\n}\n\n/** A message's brand, checked: the brand, null to go back to lib/brand.ts, or undefined to ignore it. */\nexport function parseEmbedBrand(data: unknown): Brand | null | undefined {\n  const d = data as { type?: unknown; v?: unknown; brand?: unknown } | null;\n  if (d?.type !== 'kit:brand' || d.v !== 1) return undefined;\n  if (d.brand === null) return null;\n  const b = d.brand as Partial<Brand> | undefined;\n  if (!b || typeof b.name !== 'string' || !b.name.trim()) return undefined;\n  const out: Brand = { name: b.name.slice(0, 80) };\n  for (const key of ['logo', 'logoDark', 'mark', 'markDark'] as const) if (isBrandImage(b[key])) out[key] = b[key];\n  return out;\n}\n\nfunction cachedBrand(): Brand | null {\n  if (!EMBED.embedded || Platform.OS !== 'web' || typeof window === 'undefined') return null;\n  try {\n    const raw = window.sessionStorage.getItem(EMBED_BRAND_KEY);\n    return raw ? (parseEmbedBrand({ type: 'kit:brand', v: 1, brand: JSON.parse(raw) }) ?? null) : null;\n  } catch {\n    return null;\n  }\n}\n\nconst BrandContext = React.createContext<Brand>(BRAND);\n\nexport function BrandProvider({ children }: { children: React.ReactNode }) {\n  const [brand, setBrand] = React.useState<Brand>(() => cachedBrand() ?? BRAND);\n  const onBrand = React.useCallback((data: unknown) => {\n    const next = parseEmbedBrand(data);\n    if (next !== undefined) setBrand(next ?? BRAND);\n  }, []);\n  useEmbedMessage('kit:brand', onBrand);\n  return <BrandContext.Provider value={brand}>{children}</BrandContext.Provider>;\n}\n\n/** The brand on screen (lib/brand.ts, or the docs studio's live one). */\nexport const useBrand = () => React.useContext(BrandContext);\n",
      "type": "registry:component",
      "target": "lib/brand-context.tsx"
    }
  ],
  "meta": {
    "exports": [
      "Logo"
    ],
    "api": "<Logo variant?=\"full|mark\" size? name? tone? />"
  },
  "categories": [
    "media"
  ],
  "type": "registry:component"
}