Skip to content

website: fix text selection theme token - #3241

Merged
huacnlee merged 2 commits into
longbridge:mainfrom
yuuzhou5:fix/website-selection-theme-token
Sep 25, 2026
Merged

huacnlee merged 2 commits into
longbridge:mainfrom
yuuzhou5:fix/website-selection-theme-token

Conversation

@yuuzhou5

Copy link
Copy Markdown
Contributor

This is my first PR, so I’m still learning 😄 If there’s anything I should change or improve, please feel free to let me know. I’m happy to make any adjustments!

Description

Fix nearly invisible text selection on the website in some themes by mapping the selection CSS token to selection.background instead of list.active.background.

The previous mapping used the active-list background color, whose low opacity in some themes made selection highlights difficult to see.

This follows up on #3198, which introduced JSON-backed website theme tokens.

Screenshots

Before After
Before After

How to Test

  1. Start the website locally with cd website && bun run dev.
  2. Choose a custom theme from the theme palette.
  3. Select heading and body text on the page.
  4. Verify that the selection highlight uses the theme's selection.background color and is clearly visible.
  5. Repeat with other themes, including one where the highlight was previously difficult to see.

Validation

  • cd website && bun run build
  • cd website && bun run test:seo
  • Manually verified text selection visibility across multiple themes.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed that any AI-generated code is accurate.
  • Passed cargo run for story tests related to the changes. — Not applicable: website-only change.
  • Tested performance on macOS, Windows, and Linux. — Not applicable: no platform-specific changes.

@huacnlee
huacnlee merged commit 978eb67 into longbridge:main Sep 25, 2026
12 checks passed
@huacnlee

Copy link
Copy Markdown
Member

Welcome, thanks you.

madcodelife added a commit that referenced this pull request Sep 25, 2026
…ion.background` (#3242)

Follow-up to #3241.

## Summary

#3241 mapped the website's `--selection` token to
`selection.background`, but only 5 of the 36 bundled themes define that
key. The other 31 (Catppuccin, Tokyo Night, Gruvbox, Solarized, Ayu, …)
dropped the declaration and fell back to the site default, so every such
theme selected text in the same `#55a0fc` blue (light) or `#c2610a`
orange (dark), whatever its own palette.

The token map now accepts an ordered list of sources, and `selection`
resolves to `selection.background`, then `primary.background`. That
matches the component theme, which falls back to `primary` when a theme
leaves `selection.background` unset.

## Verification

- `bun run build` and `bun run test:seo` pass. The built
`theme-tokens.css` defines `--selection` for all 36 themes.
- Headless Chrome on the built `/docs/` page with the heading and first
paragraph selected. `::selection` background:

| Theme | `--selection` | `::selection` alpha |
| --- | --- | --- |
| Catppuccin Mocha | `#89b4fa` | 0.38 |
| Tokyo Night | `#7aa2f7` | 0.38 |
| Gruvbox Dark | `#d79921` | 0.38 |
| Ayu Light | `#55b4d3` | 0.38 |
| Flexoki Dark (own `selection.background`) | `#D0A21577` | 0.18 |
| Aurora Light (own `selection.background`) | `#55A0FC` | 0.38 |

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants