{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"columns-footer","type":"registry:block","title":"Columns footer","description":"Four columns of links, a newsletter sign-up that checks and confirms, and a language select and theme switch.","dependencies":["lucide-react"],"registryDependencies":["https://dashral.com/r/utils.json","https://dashral.com/r/button.json","https://dashral.com/r/input.json","https://dashral.com/r/native-select.json","https://dashral.com/r/segmented-control.json"],"files":[{"path":"registry/dashral/blocks/columns-footer.tsx","type":"registry:file","target":"components/dashral/blocks/columns-footer.tsx","content":"\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport { CircleCheck, Moon, Sparkles, Sun } from \"lucide-react\"\nimport { Button } from \"../button\"\nimport { Input } from \"../input\"\nimport { NativeSelect } from \"../native-select\"\nimport { SegmentedControl } from \"../segmented-control\"\n\nexport type FooterLink = { label: string; href: string }\nexport type FooterColumn = { title: string; links: FooterLink[] }\n/** A social account: its name and its icon's SVG path (a 24×24 view box). */\nexport type SocialLink = { label: string; path: string; href?: string }\nexport type FooterLanguage = { value: string; label: string }\n\nconst linksOf = (...labels: string[]): FooterLink[] => labels.map((label) => ({ label, href: \"#\" }))\nconst sampleColumns: FooterColumn[] = [\n  { title: \"Product\", links: linksOf(\"Features\", \"Integrations\", \"Pricing\", \"Changelog\", \"Roadmap\") },\n  { title: \"Company\", links: linksOf(\"About\", \"Customers\", \"Careers\", \"Press\") },\n  { title: \"Resources\", links: linksOf(\"Docs\", \"Guides\", \"Blog\", \"Community\", \"Status\") },\n  { title: \"Legal\", links: linksOf(\"Privacy\", \"Terms\", \"Security\", \"Cookies\") },\n]\nconst sampleLanguages: FooterLanguage[] = [\n  { value: \"en\", label: \"English\" },\n  { value: \"id\", label: \"Bahasa Indonesia\" },\n  { value: \"ar\", label: \"العربية\" },\n]\n\nconst sampleSocial: SocialLink[] = [\n  {\n    label: \"GitHub\",\n    path: \"M12 .5a11.5 11.5 0 0 0-3.64 22.41c.58.1.79-.25.79-.56v-2c-3.2.7-3.88-1.37-3.88-1.37-.52-1.33-1.28-1.69-1.28-1.69-1.05-.71.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.77 2.7 1.26 3.36.96.1-.75.4-1.26.73-1.55-2.55-.29-5.24-1.28-5.24-5.69 0-1.26.45-2.29 1.19-3.1-.12-.29-.52-1.46.11-3.05 0 0 .97-.31 3.17 1.18a11 11 0 0 1 5.77 0c2.2-1.49 3.17-1.18 3.17-1.18.63 1.59.23 2.76.11 3.05.74.81 1.19 1.84 1.19 3.1 0 4.42-2.7 5.4-5.26 5.68.41.36.78 1.06.78 2.14v3.17c0 .31.21.67.8.56A11.5 11.5 0 0 0 12 .5Z\",\n  },\n  { label: \"X\", path: \"M18.9 1.15h3.68l-8.04 9.19L24 22.85h-7.4l-5.8-7.58-6.63 7.58H.48l8.6-9.83L0 1.15h7.59l5.24 6.93 6.07-6.93Zm-1.29 19.5h2.04L6.48 3.24H4.3l13.31 17.41Z\" },\n  {\n    label: \"YouTube\",\n    path: \"M23.5 6.19a3.02 3.02 0 0 0-2.12-2.14C19.5 3.55 12 3.55 12 3.55s-7.5 0-9.38.5A3.02 3.02 0 0 0 .5 6.19 31.5 31.5 0 0 0 0 12a31.5 31.5 0 0 0 .5 5.81 3.02 3.02 0 0 0 2.12 2.14c1.88.5 9.38.5 9.38.5s7.5 0 9.38-.5a3.02 3.02 0 0 0 2.12-2.14A31.5 31.5 0 0 0 24 12a31.5 31.5 0 0 0-.5-5.81ZM9.55 15.57V8.43L15.82 12l-6.27 3.57Z\",\n  },\n]\n\n/**\n * A full website footer: the brand with its line and social accounts, four columns of links, a newsletter sign-up\n * that checks the address and confirms, and a bottom bar with the copyright, a language select and a light/dark\n * switch. The switch toggles the `dark` class on <html>; pass onThemeChange to use your own (next-themes, say). Every\n * part comes from props; point `onSubscribe` at your newsletter (a thrown Error shows its message under the field).\n */\nexport function ColumnsFooter({\n  brand = { name: \"Acme\", href: \"#\" },\n  tagline = \"Dashboards your team actually opens. Built for people who ship.\",\n  newsletter = { label: \"Product updates, once a month\", done: \"You're in. The next issue lands on the first Monday.\" },\n  onSubscribe,\n  social = sampleSocial,\n  columns = sampleColumns,\n  copyright,\n  languages = sampleLanguages,\n  language: languageProp,\n  onLanguageChange,\n  onThemeChange,\n}: {\n  brand?: { name: string; href: string; logo?: React.ReactNode }\n  tagline?: string\n  /** The sign-up's label and what it says once you're in; null hides it. */\n  newsletter?: { label: string; done: string } | null\n  onSubscribe?: (email: string) => Promise<void> | void\n  social?: SocialLink[]\n  columns?: FooterColumn[]\n  /** The copyright line (© this year and the brand without it). */\n  copyright?: string\n  /** None hides the select. */\n  languages?: FooterLanguage[]\n  /** The language picked, by value (the footer keeps it without it). */\n  language?: string\n  onLanguageChange?: (language: string) => void\n  onThemeChange?: (theme: \"light\" | \"dark\") => void\n}) {\n  const [email, setEmail] = useState(\"\")\n  const [state, setState] = useState<\"idle\" | \"sending\" | \"done\">(\"idle\")\n  const [error, setError] = useState<string | null>(null)\n  const [ownLanguage, setOwnLanguage] = useState(languages[0]?.value ?? \"\")\n  const language = languageProp ?? ownLanguage\n  const [theme, setTheme] = useState<\"light\" | \"dark\">(\"light\")\n  useEffect(() => setTheme(document.documentElement.classList.contains(\"dark\") ? \"dark\" : \"light\"), [])\n\n  async function subscribe(event: React.FormEvent) {\n    event.preventDefault()\n    if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email.trim())) return setError(\"Enter an email like name@company.com.\")\n    setError(null)\n    setState(\"sending\")\n    try {\n      if (onSubscribe) await onSubscribe(email.trim())\n      else await new Promise((resolve) => setTimeout(resolve, 700))\n      setState(\"done\")\n    } catch (e) {\n      setError(e instanceof Error ? e.message : \"Couldn't subscribe you. Try again.\")\n      setState(\"idle\")\n    }\n  }\n\n  function changeTheme(next: \"light\" | \"dark\") {\n    setTheme(next)\n    if (onThemeChange) return onThemeChange(next)\n    document.documentElement.classList.toggle(\"dark\", next === \"dark\")\n  }\n\n  const link = \"rounded-sm text-sm text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50\"\n\n  return (\n    <footer className=\"border-t bg-background\">\n      <div className=\"px-4 py-14 sm:px-6\">\n        <div className=\"mx-auto grid max-w-6xl gap-12 lg:grid-cols-[1.2fr_2fr]\">\n          <div className=\"grid content-start gap-6\">\n            <div>\n              <a href={brand.href} className=\"inline-flex items-center gap-2 rounded-md font-semibold tracking-tight outline-none focus-visible:ring-2 focus-visible:ring-ring/50\">\n                {brand.logo ?? (\n                  <span aria-hidden className=\"grid size-7 place-items-center rounded-lg bg-primary text-primary-foreground\">\n                    <Sparkles className=\"size-4\" />\n                  </span>\n                )}\n                {brand.name}\n              </a>\n              {tagline && <p className=\"mt-3 max-w-xs text-sm text-muted-foreground\">{tagline}</p>}\n            </div>\n\n            {!newsletter ? null : state === \"done\" ? (\n              <p role=\"status\" className=\"flex max-w-sm items-center gap-2 rounded-lg bg-success/10 px-3 py-2.5 text-sm text-success-text animate-in fade-in-0 duration-(--duration-standard)\">\n                <CircleCheck className=\"size-4 shrink-0\" aria-hidden /> {newsletter.done}\n              </p>\n            ) : (\n              <form noValidate onSubmit={subscribe} className=\"grid max-w-sm gap-2\">\n                <label htmlFor=\"footer-email\" className=\"text-sm font-medium\">\n                  {newsletter.label}\n                </label>\n                <div className=\"flex gap-2\">\n                  <Input\n                    id=\"footer-email\"\n                    type=\"email\"\n                    autoComplete=\"email\"\n                    placeholder=\"you@company.com\"\n                    value={email}\n                    onChange={(e) => {\n                      setEmail(e.target.value)\n                      setError(null)\n                    }}\n                    aria-invalid={!!error || undefined}\n                    aria-describedby={error ? \"footer-email-error\" : undefined}\n                    className=\"flex-1\"\n                  />\n                  <Button type=\"submit\" disabled={state === \"sending\"} aria-busy={state === \"sending\"}>\n                    {state === \"sending\" ? \"Subscribing…\" : \"Subscribe\"}\n                  </Button>\n                </div>\n                {error && (\n                  <p id=\"footer-email-error\" className=\"text-xs text-destructive-text\">\n                    {error}\n                  </p>\n                )}\n              </form>\n            )}\n\n            {/* Pulled in by the icon buttons' padding, so the icons line up with the text above; the hover still has room. */}\n            <ul className=\"-ms-2.5 flex gap-1\">\n              {social.map((s) => (\n                <li key={s.label}>\n                  <a\n                    href={s.href ?? \"#\"}\n                    aria-label={`${brand.name} on ${s.label}`}\n                    className=\"grid size-9 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50\"\n                  >\n                    <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden className=\"size-4\">\n                      <path d={s.path} />\n                    </svg>\n                  </a>\n                </li>\n              ))}\n            </ul>\n          </div>\n\n          <nav aria-label=\"Footer\" className=\"grid grid-cols-2 gap-8 sm:grid-cols-4\">\n            {columns.map((column) => (\n              <div key={column.title}>\n                <h2 className=\"text-sm font-semibold\">{column.title}</h2>\n                <ul className=\"mt-4 grid gap-2.5\">\n                  {column.links.map((l) => (\n                    <li key={l.label}>\n                      <a href={l.href} className={link}>\n                        {l.label}\n                      </a>\n                    </li>\n                  ))}\n                </ul>\n              </div>\n            ))}\n          </nav>\n        </div>\n      </div>\n\n      <div className=\"border-t px-4 sm:px-6\">\n        <div className=\"mx-auto flex max-w-6xl flex-col items-center gap-4 py-5 sm:flex-row sm:justify-between\">\n          <p className=\"text-xs text-muted-foreground\">{copyright ?? `© ${new Date().getFullYear()} ${brand.name}. All rights reserved.`}</p>\n          <div className=\"flex items-center gap-2\">\n            {languages.length > 0 && (\n              <NativeSelect\n                aria-label=\"Language\"\n                value={language}\n                onChange={(e) => {\n                  setOwnLanguage(e.target.value)\n                  onLanguageChange?.(e.target.value)\n                }}\n                options={languages}\n                classNames={{ select: \"h-8 w-auto text-xs\" }}\n              />\n            )}\n            <SegmentedControl\n              aria-label=\"Theme\"\n              value={theme}\n              onValueChange={(v) => changeTheme(v as \"light\" | \"dark\")}\n              options={[\n                { value: \"light\", icon: <Sun aria-hidden />, \"aria-label\": \"Light\" },\n                { value: \"dark\", icon: <Moon aria-hidden />, \"aria-label\": \"Dark\" },\n              ]}\n              className=\"h-8\"\n              classNames={{ item: \"px-2\" }}\n            />\n          </div>\n        </div>\n      </div>\n    </footer>\n  )\n}\n"}],"cssVars":{"theme":{"color-destructive-foreground":"var(--destructive-foreground)","color-destructive-text":"var(--destructive-text)","color-success":"var(--success)","color-success-foreground":"var(--success-foreground)","color-success-text":"var(--success-text)","ease-standard":"var(--ease-standard)","ease-enter":"var(--ease-enter)","ease-exit":"var(--ease-exit)","ease-spring":"var(--ease-spring)"},"light":{"destructive-foreground":"oklch(0.985 0 0)","destructive-text":"#bd2800","success":"oklch(0.508 0.118 165.612)","success-foreground":"oklch(0.985 0 0)","success-text":"oklch(0.432 0.095 166.913)","duration-fast":"160ms","duration-standard":"240ms","duration-considered":"480ms","ease-standard":"cubic-bezier(0.2, 0, 0, 1)","ease-enter":"cubic-bezier(0, 0, 0, 1)","ease-exit":"cubic-bezier(0.3, 0, 1, 1)","ease-spring":"linear(0, 0.071 4%, 0.234 8%, 0.433 12%, 0.626 17%, 0.791 21%, 0.917 25%, 1.004 29%, 1.055 33%, 1.079 38%, 1.083 42%, 1.075 46%, 1.06 50%, 1.043 54%, 1.027 58%, 1.015 62%, 1.005 67%, 0.998 71%, 0.995 75%, 0.993 79%, 0.993 83%, 0.994 88%, 0.995 92%, 0.997 96%, 1)"},"dark":{"destructive-foreground":"oklch(0.2 0 0)","destructive-text":"#ff8a5c","success":"oklch(0.696 0.17 162.48)","success-foreground":"oklch(0.2 0.04 160)","success-text":"oklch(0.765 0.177 163.223)"}}}