Skip to content

Single theme-aware AI flow diagram SVG - #507

Merged
Devon-White merged 8 commits into
Devon/ai-tool-guidefrom
fern/ai-flow-theme-test
Jul 27, 2026
Merged

Single theme-aware AI flow diagram SVG#507
Devon-White merged 8 commits into
Devon/ai-tool-guidefrom
fern/ai-flow-theme-test

Conversation

@fern-api

@fern-api fern-api Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Replaces the AI flow diagram's light/dark SVG pair with a single theme-aware SVG file.

Requested by: Fern Support

What changed

  • ai-agent-flow-light.svg + ai-agent-flow-dark.svg → one ai-agent-flow-themed.svg.
  • ai/overview.mdx embeds it with a single plain <img>, no .light-only / .dark-only pair.

How one file covers both modes

CSS custom properties do not cross into the separate document of an img-embedded SVG, so the file cannot read --accent. But color-scheme does propagate: Fern sets style="color-scheme: dark" on <html> with the theme toggle, that inherits to the img, and the browser passes the embedding element's color-scheme into the image's own document. So a media query inside the file tracks the site toggle rather than the visitor's OS:

.swflow-theme { --swflow-chip: #044EF4; --swflow-ink: #070c2d; --swflow-on-chip: #ffffff; }
@media (prefers-color-scheme: dark) {
  .swflow-theme { --swflow-chip: #40E0D0; --swflow-ink: #f0f0f4; --swflow-on-chip: #0e0e18; }
}

Four custom properties are the entire difference between the modes; the geometry exists once. Verified in Chrome: swaps on the toggle with no reload, in the page and in the zoom modal.

Staying an <img> also keeps Fern's native image zoom, which is img-only — an inline SVG loses it, and <Frame> does not add it back.

Also explored (and why not)

  • Inline SVG via an MDX snippet — puts the markup in the page document, so var(--accent) / --grayscale-12 / --sw-* from brand-tokens.css all resolve and nothing is duplicated per diagram. Rejected only because it forfeits image zoom.
  • A component that fetches and inlines the asset — Fern serves assets from signed S3 URLs, so a failed fetch silently falls back to <img> and renders light colors on a dark page.
  • External stylesheet inside the SVG (@import, <?xml-stylesheet?>, data-URI) — all blocked; SVG-as-image loads no external resources.

Authoring the next themed diagram

  1. One prefixed root class holding the mode-dependent custom properties, plus a prefers-color-scheme: dark block overriding them.
  2. Colored fills/strokes go through classes — var() is invalid in SVG presentation attributes.
  3. No < or > inside <style>; a standalone .svg is parsed as XML.
  4. Keep the word "diagram" out of the filename so the img[src*="diagram"] invert rules in styles.css don't restyle it.

.light-only / .dark-only remain in styles.css as generic utilities — no page uses them now, so they can be removed separately if you want.

@fern-api

fern-api Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Requested by: Devon White
Slack thread: View conversation

@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@fern-api fern-api Bot changed the title Test: single theme-aware AI call flow diagram Single theme-aware AI flow diagram via inline snippet Jul 27, 2026
@fern-api fern-api Bot changed the title Single theme-aware AI flow diagram via inline snippet Single theme-aware AI flow diagram SVG Jul 27, 2026
@Devon-White
Devon-White merged commit 7a9254d into Devon/ai-tool-guide Jul 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant