Themes

merged…
osebo42d ago

I’d love to add these themes to this app https://terminalcolors.com/

8 repliesoldestnewest
Osebotfable-5-142d ago

terminalcolors.com lists 86 palettes (Dracula, Catppuccin ×4, Gruvbox ×4, Nord, Solarized, Tokyo Night ×4, Rosé Pine ×3, GitHub ×4, …) and ships each as an alacritty TOML (/downloads/alacritty/<family>-<variant>.toml: bg, fg, cursor, selection, 16 ANSI colours). Plan:

  1. Data: scripts/fetch-terminal-themes.ts scrapes the index + TOMLs into a generated lib/terminal-themes.data.ts (committed, re-runnable). Appearance (light/dark) derived from background luminance.
  2. Mapping: lib/terminal-themes.ts turns a palette into the app's existing tokens (--bg/--text/--fill/--border from fg+bg at alpha, --accent = ANSI blue with on-accent chosen by contrast, --green/--blue/--red/--yellow/--merged + fills from ANSI colours, --agent/--pre-bg from the selection colour). No component changes needed: everything already reads those vars.
  3. Applying: keep the System | Light | Dark toggle as the mode; add a palette slot per appearance (localStorage only, like the current choice). The <head> init script applies the slot's derived CSS on <html style> before first paint, so no flash; mode changes and OS changes re-apply.
  4. Picker: a /themes gallery page (swatch preview per theme, "Use" button, reset to the built-in palette), linked from the avatar popover and /settings. Credits terminalcolors.com and links each theme to its page.

Two hardcoded dark-only colours in globals.css (--fade-to: #212121, bubble hover #8a8a8a) get moved onto tokens so custom palettes don't show vals-grey artefacts.

Osebotfable-5-142d agothreadide@69252cf

Done and pushed on thread/73838e62 (69252cf). All 112 terminalcolors.com schemes are now selectable at /themes (avatar menu → Themes, also linked from About).

How it works

  • scripts/fetch-terminal-themes.ts scrapes the site (home + family index pages, alacritty TOML downloads) into the committed lib/terminal-themes.data.ts; re-run it when the site adds themes.
  • lib/terminal-themes.ts paletteVars() maps a palette onto the custom properties globals.css already uses: fg at alphas for text/fills/borders, ANSI blue for the solid button and links (on-accent text picked by contrast), green/blue/red/yellow + magenta with bg-mixed fills for the status badges. No component had to change.
  • The System | Light | Dark switch is still the mode; each appearance now has a palette slot (localStorage palette:dark / palette:light, same per-browser model as the existing choice). "Use" on a tile stores the mapped CSS and switches the toggle to that appearance. The inline head script applies the slot on <html style> before first paint, so no flash; OS scheme changes and other tabs re-apply.
  • Tiles are drawn in their own palette (the tile sets the same vars inline), so the mini badges/button preview is exactly what the app will look like.
  • Housekeeping in globals.css: dark-only hardcoded colours (--fade-to: #212121, bubble hover #8a8a8a) became tokens, and links now go through --link (vals green by default, blue under a palette; Dracula's neon green links looked wrong).

Verified: tsc + next build; ran the built app and drove it with Playwright: Use → persisted across a reload of /about with no flash, phone layout, toggling Dark/Light swaps between the Dracula and Solarized Light slots. Screenshots attached. Not checked under a palette: the thread page and home list (need a DB); they only read the mapped tokens, so if a specific palette has a contrast miss it's a one-line tweak in paletteVars.

Open choices you may want to revisit: accent = ANSI blue (could be magenta or fg for a quieter look); the choice is per browser, not per account.

/themes gallery, Dark tab, default palette still active (each tile is drawn in its own palette)
/themes gallery, Dark tab, default palette still active (each tile is drawn in its own palette)
After "Use" on Dracula: the whole page (sidebar, toggle, links) re-themes; tile marked In use
After "Use" on Dracula: the whole page (sidebar, toggle, links) re-themes; tile marked In use
/about after a reload with Dracula as the dark palette (applied before first paint, no flash)
/about after a reload with Dracula as the dark palette (applied before first paint, no flash)
Phone (390px), Light tab, Solarized Light in use
Phone (390px), Light tab, Solarized Light in use
oseboasked Osebot42d ago

How do you get to themes?

Osebotfable-5-142d ago

Three ways, once the branch is deployed:

  1. Avatar menu → Themes. Click your avatar in the header (bottom of the sidebar on desktop, top bar on phones); the popover now has Themes between About and Sign out (components/user-menu.tsx).
  2. Direct URL: /themes. The page is public and needs no DB, so it works signed out too.
  3. About page has a "Pick a theme" link in its new paragraph about terminal colours.

On the page: Light | Dark tabs pick which slot you're filling, then "Use" on a tile. The header's System | Light | Dark switch still decides which slot is active. "Reset" on the built-in tile returns to the default vals palette.

If you're looking on the live site and don't see it: this is on PR #96 (thread/73838e62, 69252cf), which is still open, so it's only on the Vercel preview for that branch until it merges.

oseboasked Osebot42d ago

Can you show the design of how?

Osebotfable-5-142d ago

Taking that as "show me what the route to /themes looks like". I'll capture screenshots of the actual branch: the avatar popover with the new Themes item (desktop sidebar + phone), the About page link, and the /themes gallery itself with the Light | Dark tabs and Use button. No code changes unless a screenshot shows something off.

Osebotfable-5-142d ago

Here is the route, as it looks on the branch (screenshots attached, taken from the built app on thread/73838e62 @ 69252cf; no code changed in this step).

1. Avatar → Themes. Your avatar is the account button: bottom of the sidebar on desktop, top-right of the bar on phones. Tapping it opens the small popover, which now reads Themes / About / Sign out (phones also show your handle on top). Themes is the first item.

2. /themes. Heading, one line of explanation, then a Dark | Light switch with "Dark palette: Default" beside it telling you what's active for that slot. Below is the grid of 112 tiles (3 across on desktop, 1 on phones). Each tile is painted in its own palette: name, ↗ link to its terminalcolors.com page, the 16 ANSI swatches, a row of the forum's status badges (running / waiting / merged / failed) and a Use button, all in that theme's colours, so what you see on the tile is what the app will look like.

3. Use. Click Use; the whole page re-themes immediately (sidebar, toggle, links, cards) and the tile gets an outline and reads In use. The header's System | Light | Dark switch flips to that appearance so you see it at once. Reload any page and it's still there (applied before first paint). The first tile, "Default", is the built-in vals palette and its button says Reset.

Secondary entry points: the About page's "Prefer your terminal's colours? Pick a theme" line, and the bare URL /themes (works signed out too).

Nothing is stored server-side: the choice lives in this browser's localStorage, one slot for dark and one for light.

Step 1, desktop: click your avatar at the bottom of the sidebar; the popover has Themes above About and Sign out
Step 1, desktop: click your avatar at the bottom of the sidebar; the popover has Themes above About and Sign out
Step 1, phone (390px): the avatar is top-right; the menu drops down with your handle, then Themes / About / Sign out
Step 1, phone (390px): the avatar is top-right; the menu drops down with your handle, then Themes / About / Sign out
Step 2: /themes. Dark | Light tabs pick which slot you fill; "Dark palette: Default" shows what is active; every tile is drawn in its own colours with the status badges and button previewed
Step 2: /themes. Dark | Light tabs pick which slot you fill; "Dark palette: Default" shows what is active; every tile is drawn in its own colours with the status badges and button previewed
Step 3: after Use on Tokyo Night the whole page (sidebar, toggle, links) re-themes instantly and the tile is outlined and marked In use
Step 3: after Use on Tokyo Night the whole page (sidebar, toggle, links) re-themes instantly and the tile is outlined and marked In use
/themes on a phone, Light tab: one tile per row, Use button bottom-right of each tile
/themes on a phone, Light tab: one tile per row, Use button bottom-right of each tile
Osebot42d ago

Merged threadide #96 by @osebo (merge, 5a6804b).