{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sign-in",
  "type": "registry:block",
  "title": "Sign in block",
  "description": "The page before the app: the wordmark, one left-aligned column with email, password, Sign in and a second way in, and a quiet column of what is new on a wide screen. Wrong fields say so under themselves and take focus, and a refusal shows in a callout.",
  "registryDependencies": [
    "https://littmd.vercel.app/r/litt.json",
    "https://littmd.vercel.app/r/button.json",
    "https://littmd.vercel.app/r/callout.json",
    "https://littmd.vercel.app/r/form.json",
    "https://littmd.vercel.app/r/framed.json",
    "https://littmd.vercel.app/r/input.json"
  ],
  "files": [
    {
      "path": "registry/litt/components/litt-blocks/sign-in.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n// @litt/sign-in 2026.11.03. What changed: https://littmd.vercel.app/changelog.md\n\n/**\n * Sign in: the page someone meets before the app. A block: a whole screen built from the litt parts, to copy and make\n * your own. Swap `signIn` for your auth call and the links for your routes; the layout and the words stay.\n *\n * The wordmark at the top, then one left-aligned column: a title in two inks, email and password, Sign in, and a\n * second way in under a hairline. From 1024 up a quiet column beside it says what is new. Every state is designed: an\n * empty or wrong field says so under itself and takes focus, an answer from the server shows in a callout above the\n * fields, and Sign in shows its loading state while it waits. Sign in is the one accent fill.\n */\nimport { useEffect, useId, useRef, useState, type FormEvent } from \"react\";\nimport { Button } from \"../litt/button\";\nimport { Callout } from \"../litt/callout\";\nimport { focusFirstInvalid } from \"../litt/form\";\nimport { TextField } from \"../litt/input\";\nimport { Heading, Main } from \"../litt/framed\";\n\n/* ----------------------------------------------------------------- data */\n\nconst PRODUCT = \"litt.design\";\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\n/** The links on the page. Point them at your own routes. */\nconst LINKS = { home: \"/\", forgot: \"/forgot-password\", request: \"/request-access\", terms: \"/terms\", privacy: \"/privacy\" };\n\n/** What is new, beside the form on a wide screen. Three short lines, newest first. */\nconst NEWS = [\n  { version: \"v3.2\", text: \"Preview links for every branch, shared with one click.\" },\n  { version: \"v3.1\", text: \"Build times by site, on the usage page.\" },\n  { version: \"v3.0\", text: \"A studio dashboard, rebuilt from the ground up.\" },\n];\n\ntype Fields = { email: string; password: string };\ntype Errors = Partial<Record<keyof Fields, string>>;\n\nfunction check(v: Fields): Errors {\n  return {\n    email: !v.email.trim() ? \"Enter your email.\" : EMAIL.test(v.email.trim()) ? undefined : \"Use a full address, like ines@halo.studio.\",\n    password: v.password ? undefined : \"Enter your password.\",\n  };\n}\n\n/**\n * Stands in for your auth call: it waits a moment, then answers. Here a password under eight characters is the wrong\n * one, so the page can show what a refusal looks like. Return your server's message the same way.\n */\nfunction signIn(fields: Fields): Promise<{ ok: true } | { ok: false; message: string }> {\n  return new Promise((resolve) =>\n    window.setTimeout(\n      () => resolve(fields.password.length >= 8 ? { ok: true } : { ok: false, message: \"That email and password do not match. Try again, or reset your password.\" }),\n      1000,\n    ),\n  );\n}\n\n/* ----------------------------------------------------------------- the screen */\n\nconst link =\n  \"rounded-litt-control text-litt-small text-litt-accent-text underline-offset-4 transition-colors duration-(--litt-dur-instant) ease-litt hover:underline \" +\n  \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-litt-focus\";\n/* A link inside a sentence is underlined, so it never depends on color alone to read as a link. */\nconst inlineLink =\n  \"rounded-litt-control text-litt-fg underline decoration-litt-line-strong underline-offset-4 transition-colors duration-(--litt-dur-instant) ease-litt hover:decoration-litt-fg \" +\n  \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-litt-focus\";\nconst quietLink =\n  \"rounded-litt-control text-litt-small text-litt-fg-subtle transition-colors duration-(--litt-dur-instant) ease-litt hover:text-litt-fg \" +\n  \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-litt-focus\";\n\nexport function SignIn() {\n  const form = useRef<HTMLFormElement>(null);\n  const newsId = useId();\n  const [fields, setFields] = useState<Fields>({ email: \"\", password: \"\" });\n  const [errors, setErrors] = useState<Errors>({});\n  const [failed, setFailed] = useState(0);\n  const [refused, setRefused] = useState<string | null>(null);\n  const [busy, setBusy] = useState(false);\n  const [signedIn, setSignedIn] = useState(false);\n  const alive = useRef(true);\n\n  useEffect(() => () => void (alive.current = false), []);\n  /* Two fields are too few for a summary. Once the errors have rendered, focus the first invalid field. */\n  useEffect(() => {\n    if (failed) focusFirstInvalid(form.current);\n  }, [failed]);\n\n  const change = (key: keyof Fields, value: string) => {\n    const next = { ...fields, [key]: value };\n    setFields(next);\n    if (errors[key]) setErrors({ ...errors, [key]: check(next)[key] });\n  };\n\n  const submit = async (e: FormEvent<HTMLFormElement>) => {\n    e.preventDefault();\n    if (busy) return;\n    setRefused(null);\n    const found = check(fields);\n    setErrors(found);\n    if (found.email || found.password) return setFailed((n) => n + 1);\n    setBusy(true);\n    const answer = await signIn(fields);\n    if (!alive.current) return;\n    setBusy(false);\n    if (answer.ok) setSignedIn(true);\n    else setRefused(answer.message);\n  };\n\n  return (\n    <div className=\"grid min-h-full w-full grid-rows-[auto_1fr_auto] gap-12 px-6 py-8 @container sm:px-12\">\n      <header>\n        <a href={LINKS.home} className=\"rounded-litt-control text-litt-body font-litt-title text-litt-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-litt-focus\">\n          {PRODUCT}\n        </a>\n      </header>\n\n      <Main className=\"grid w-full max-w-5xl content-center gap-16 @min-[56rem]:grid-cols-[minmax(0,25rem)_minmax(0,1fr)] @min-[56rem]:gap-24\">\n        <div className=\"grid w-full max-w-100 content-start gap-8\">\n          {/* The title and its line as one sentence in two inks; the h1 stays the name alone. */}\n          <div className=\"flex flex-wrap items-baseline gap-x-2 text-litt-h1 text-balance\">\n            <Heading level={1} className=\"text-litt-fg\">Sign in</Heading>\n            <p className=\"font-normal text-litt-fg-muted\">to the studio, and pick up where you left off.</p>\n          </div>\n\n          {signedIn ? (\n            <Callout live tone=\"success\" title=\"Signed in\" description=\"A real page would open the dashboard now.\" />\n          ) : (\n            <form ref={form} noValidate aria-label=\"Sign in\" onSubmit={submit} className=\"grid gap-6\">\n              {refused && <Callout live tone=\"danger\" title=\"Could not sign in\" description={refused} />}\n              <TextField\n                label=\"Email\"\n                type=\"email\"\n                inputMode=\"email\"\n                autoComplete=\"email\"\n                value={fields.email}\n                error={errors.email}\n                onChange={(e) => change(\"email\", e.target.value)}\n              />\n              <div className=\"grid gap-2\">\n                <TextField\n                  label=\"Password\"\n                  type=\"password\"\n                  autoComplete=\"current-password\"\n                  value={fields.password}\n                  error={errors.password}\n                  onChange={(e) => change(\"password\", e.target.value)}\n                />\n                <a href={LINKS.forgot} className={\"justify-self-start \" + link}>\n                  Forgot your password?\n                </a>\n              </div>\n              <Button type=\"submit\" variant=\"primary\" block loading={busy}>\n                Sign in\n              </Button>\n              <div className=\"flex items-center gap-4\" aria-hidden=\"true\">\n                <span className=\"h-px flex-1 bg-litt-line\" />\n                <span className=\"text-litt-caption text-litt-fg-subtle\">or</span>\n                <span className=\"h-px flex-1 bg-litt-line\" />\n              </div>\n              <Button variant=\"secondary\" block disabled={busy}>\n                Continue with GitHub\n              </Button>\n              <p className=\"text-litt-small text-litt-fg-subtle\">\n                New to {PRODUCT}?{\" \"}\n                <a href={LINKS.request} className={inlineLink}>\n                  Request access\n                </a>\n              </p>\n            </form>\n          )}\n        </div>\n\n        {/* What is new: quiet, beside the form from 1024 up and gone below, so a phone sees only the form. */}\n        <section aria-labelledby={newsId} className=\"hidden content-start gap-6 border-l border-litt-line pl-12 @min-[56rem]:grid\">\n          <Heading level={2} id={newsId} className=\"text-litt-body font-litt-title text-litt-fg\">\n            What is new\n          </Heading>\n          <ul className=\"grid gap-4\">\n            {NEWS.map((n) => (\n              <li key={n.version} className=\"flex items-baseline gap-3\">\n                <span className=\"w-10 shrink-0 text-litt-caption tabular-nums font-normal text-litt-fg-subtle\">{n.version}</span>\n                <span className=\"text-litt-small text-litt-fg-muted\">{n.text}</span>\n              </li>\n            ))}\n          </ul>\n        </section>\n      </Main>\n\n      <footer className=\"flex flex-wrap gap-x-6 gap-y-2\">\n        <a href={LINKS.terms} className={quietLink}>\n          Terms\n        </a>\n        <a href={LINKS.privacy} className={quietLink}>\n          Privacy\n        </a>\n      </footer>\n    </div>\n  );\n}\n",
      "target": "components/litt-blocks/sign-in.tsx"
    }
  ],
  "docs": "Import SignIn from components/litt-blocks/sign-in and render it as a whole page. signIn at the top of the file stands in for your auth call; return your server's message the same way, and point the links at your routes. See it live at https://littmd.vercel.app/#sign-in.",
  "meta": {
    "version": "2026.11.03",
    "released": "2026-11-03",
    "changelog": "https://littmd.vercel.app/changelog.md"
  }
}
