Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

4.6 KB
Raw Blame
/**
 * Contrast-mode treatments that belong to the exported theme rather than to the
 * SPA, so a consumer of the published `ThemeProvider` gets them with the
 * palettes they complete.
 *
 * `ThemeProvider` puts `high-contrast` on <html> and paints the palette as
 * inline custom properties (see `packages/data-provider/src/themes/highContrast.ts`). Two of those tokens
 * are not self-sufficient, and the rules below are what make them correct:
 * the selected fills are deliberately light so their label clears AAA, which
 * only works because selection is marked by a perimeter; and `::placeholder`
 * has no token at all, so it falls through to Tailwind preflight's raw
 * `gray-400`. Both defects reach package primitives — `TimePicker`,
 * `MultiSelect`, `Badge`, `DataTable`,
 * `Input`, `Textarea` — so shipping the palette without these rules ships a
 * broken palette.
 *
 * `client/src/style.css` keeps the treatments that really are SPA-only: the
 * legacy `.btn-neutral` chrome, the markdown and `@tailwindcss/typography`
 * blocks, scrollbars, and the keyboard-modality field outlines.
 */

/**
 * Selection and navigation are conveyed by a fill alone almost everywhere, and
 * these palettes keep fills light on purpose so the label on them can clear AAA
 * (see the `surface-active` note in `packages/data-provider/src/themes/highContrast.ts`). The cue is
 * therefore a perimeter: `text-primary` is 21:1 against either canvas, and it
 * is what discharges WCAG 1.4.11 for the fill.
 *
 * Four families need it. `.select-item` blanks its own outline with
 * `!important`, so this has to match that to land. Ariakit marks the navigated
 * row of every composite — menu, select, combobox — with `data-active-item`;
 * those rows otherwise carry only a `surface-hover` fill at 1.48:1 on white.
 * A selected data-table row is marked with `data-state="selected"`. And any row
 * painted with the selected-surface role marks itself with that fill and
 * nothing else. Inset so the ring reads inside the row's own radius; `span` is
 * excluded because the one inline user of the role is a highlighted passage
 * that wraps across lines and would box every fragment.
 */
html.high-contrast [data-active-item],
html.high-contrast .select-item:focus-visible,
html.high-contrast [data-state='selected'],
html.high-contrast
  :is(.bg-surface-active, .bg-surface-active-alt, .bg-surface-nav-selected):not(span),
html.high-contrast [aria-pressed='true'][class*='aria-pressed:bg-surface-nav-selected']:not(span) {
  outline: 3px solid rgb(var(--text-primary)) !important;
  outline-offset: -3px;
}

/**
 * The one inline user of the selected-surface role is a highlighted source
 * passage, which the perimeter above skips: an outline would box each wrapped
 * fragment separately. It still needs a cue, so it inverts instead — the same
 * treatment the mode gives `::selection`, 21:1 and with no geometry to wrap.
 */
html.high-contrast span:is(.bg-surface-active, .bg-surface-active-alt, .bg-surface-nav-selected) {
  background-color: rgb(var(--text-primary));
  color: rgb(var(--surface-primary));
}

/**
 * WCAG 1.4.1: a link in running text must not be told apart by colour alone,
 * and `link` against `text-primary` is under 3:1 in both palettes. Prose links
 * plus anything carrying the shared `text-link` role, which is how the auth
 * resend actions and in-dialog help links are styled — including the ones
 * rendered as a `button`. App chrome stays excluded: a nav row is not a link in
 * running text, and it is identified by its own position and perimeter.
 */
html.high-contrast :is(.markdown, .prose) a,
html.high-contrast .text-link {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/**
 * Radix tab triggers mark selection with a `surface-tertiary` fill, which is the
 * plain canvas in both palettes — a selected tab computes to the same colour as
 * its unselected siblings, leaving the current section unmarked. Same remedy,
 * inset so it reads inside the row's own radius.
 */
html.high-contrast [role='tab'][data-state='active'] {
  outline: 3px solid rgb(var(--text-primary));
  outline-offset: -3px;
}

/**
 * Placeholder text is real text, so it answers to WCAG 1.4.3 like any other.
 * Tailwind's preflight paints `::placeholder` with the raw `gray-400` #999696,
 * which is what every field that forgets a `placeholder:` utility inherits:
 * 4.06:1 on the black canvas and 3.08:1 on the white one, both under the floor.
 * Setting it here catches those fields rather than the handful that remembered,
 * and matches the utilities that did, since every text role is pure ink in
 * these palettes.
 */
html.high-contrast ::placeholder {
  color: rgb(var(--text-secondary));
  opacity: 1;
}