Skip to content

feat: colour content links QuantEcon blue to match the Sphinx lectures - #167

Merged
mmcky merged 6 commits into
mainfrom
feature/lecture-link-colour
Sep 5, 2026
Merged

feat: colour content links QuantEcon blue to match the Sphinx lectures#167
mmcky merged 6 commits into
mainfrom
feature/lecture-link-colour

Conversation

@DrDrij

@DrDrij DrDrij commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

Colours content links to match the Sphinx lecture builds (e.g. python-programming.quantecon.org): #0072bc base, #004979 on hover, white in dark mode.

myst-to-react colours every content anchor through two classes — .link (plain links) and .hover-link (cross-references, citations, footnotes) — which @myst-theme/styles paints blue-700/blue-400 with separate blue decoration colours. A new CONTENT LINKS section in styles/quantecon.css overrides both classes at specificity matched to each upstream rule (base, hover, and their dark variants), winning every tie on source order. The colours are design tokens (--qe-link-color, --qe-link-hover-color) with dark-mode overrides, and the underline now draws in currentColor so it always matches the text — replacing upstream's independent decoration utilities.

Dark mode goes white in both states, which is what the Sphinx dark theme does (&.dark-theme a { color: #fff !important }) and what this theme's existing .dark .article :where(a) rule already did for anchors without a .link class — the two now agree.

Colour only, by design. Two Sphinx behaviours are deliberately not matched here (noted in the code): the lecture builds underline only on hover, and colour :visited links #004979. Happy to follow up on either.

Site chrome is untouched: .link/.hover-link are only applied by the content renderers, and the footer badge and back-to-top button keep their own higher-specificity rules (verified unchanged).

Testing

  • Computed styles probed on the visual fixture with a real content link (the first probe caught the footer badge instead — its differing colours prove the check can fail): light rgb(0, 114, 188) base / rgb(0, 73, 121) hover, dark white in both states, decoration colour matching the text in all four. Values match the Sphinx theme's SCSS source (a { color: #0072bc }, a:hover { color: #004979 }).
  • Footer badge and back-to-top probed alongside: still on their own rules in both modes.
  • Darwin visual baselines refreshed (11 snapshots — every page showing links or cross-references, both viewports) and the suite re-run in verify mode: 19 passed, 3 skipped.
  • #0072bc on white is 5.05:1 — WCAG AA.

Known follow-up

  • Linux visual baselines need /update-snapshots once this PR is open.

myst-to-react colours content anchors via the .link and .hover-link
classes, which @myst-theme/styles paints blue-700/blue-400 with its own
blue decoration colours. The Sphinx lecture builds render links in the
QuantEcon palette instead: #0072bc base, #004979 on hover, white in dark
mode (their dark theme paints all anchors white).

New CONTENT LINKS section in styles/quantecon.css overrides both classes
at specificity matched to each upstream rule, winning every tie on
source order; the colours are design tokens (--qe-link-color,
--qe-link-hover-color) with dark variants. The underline now draws in
currentColor rather than upstream's separate blue decoration utilities.
Colour only: the always-on underline and unstyled :visited are left as
upstream ships them (the Sphinx builds underline on hover only and
colour visited links #004979).

Verified on the visual fixture: content links compute to rgb(0,114,188)
base / rgb(0,73,121) hover in light mode and white in dark, decoration
matching, while the footer badge and back-to-top keep their own rules.
Darwin baselines refreshed; suite verifies at 19 passed / 3 skipped.
Linux baselines need /update-snapshots once a PR is open.
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-05 01:49 UTC

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🎭 Visual regression results

passed  19 passed
skipped  5 skipped

Details

stats  24 tests across 1 suite
duration  39.8 seconds
commit  4ac16b5

Skipped tests

mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › without JavaScript › drawer-opens-without-javascript
mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › drawer-closes-when-search-opens
mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › launch-colab
mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › live-compute-toggle
mobile-chrome › theme.spec.ts › QuantEcon theme — visual regression › live-compute-toggle-absent-without-thebe

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

It is an isolated, colour-only CSS change whose specificity, cascade-layer, and source-order reasoning I verified against the exact pinned upstream version, with no objective issues found.

Pull request overview

This PR colours in-content links to match the QuantEcon Sphinx lecture builds. It adds two design tokens (--qe-link-color: #0072bc, --qe-link-hover-color: #004979) with dark-mode overrides (both white), and a new CONTENT LINKS section in styles/quantecon.css that re-colours the myst-to-react .link and .hover-link classes, drawing the underline in currentColor so it always tracks the text. The change fits the theme's established pattern of overriding @myst-theme/styles classes in quantecon.css's @layer components by matching specificity and winning on source order, rather than using !important. Site chrome (footer badge, back-to-top) is unaffected because those selectors carry higher specificity.

Changes:

  • Add --qe-link-color/--qe-link-hover-color tokens with .dark overrides (white in both states).
  • Add a CONTENT LINKS @layer components block re-colouring .link/.hover-link (base, hover, and dark variants) at specificity matched to upstream @myst-theme/styles@1.3.0.
  • Update the neighbouring dark-mode anchor comment to reflect that .link now takes its colour from the new section.
File summaries
File Description
styles/quantecon.css Adds link-colour design tokens and a specificity-matched CONTENT LINKS override section (colour-only), plus a clarifying comment update on the dark-mode anchor rule.

I verified the cascade reasoning against the pinned dependency: upstream @myst-theme/styles@1.3.0 defines .link/.hover-link in @layer components via @apply text-blue-700 dark:text-blue-400 … decoration-blue-400 dark:decoration-blue-500 hover:… dark:hover:…, so the override lands in the same layer, matches specificity (base 0,1,0; hover 0,2,0; dark 0,2,0; dark-hover 0,3,0), and wins because quantecon.css is @import-ed after @myst-theme/styles (styles/app.css:4,9). The "dotted for .hover-link" note is accurate (styles/hover.css applies decoration-dotted), and footer/back-to-top selectors retain higher specificity, so chrome is unaffected. No stale tests hardcode link colours.

Review details
  • Files reviewed: 1/12 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

mmcky and others added 3 commits September 5, 2026 11:32
…colour

# Conflicts:
#	tests/visual/__snapshots__/desktop-chrome-darwin/features.png
#	tests/visual/__snapshots__/desktop-chrome-darwin/history-open.png
#	tests/visual/__snapshots__/desktop-chrome-darwin/intro.png
#	tests/visual/__snapshots__/desktop-chrome-darwin/lists.png
#	tests/visual/__snapshots__/desktop-chrome-darwin/notebook.png
#	tests/visual/__snapshots__/desktop-chrome-darwin/sidebar-open.png
#	tests/visual/__snapshots__/mobile-chrome-darwin/features.png
#	tests/visual/__snapshots__/mobile-chrome-darwin/history-open.png
#	tests/visual/__snapshots__/mobile-chrome-darwin/intro.png
#	tests/visual/__snapshots__/mobile-chrome-darwin/lists.png
#	tests/visual/__snapshots__/mobile-chrome-darwin/notebook.png
Filed under [Unreleased] after merging main.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The colour change sits under the 1% pixel threshold, so a plain
--update-snapshots rewrote nothing; recorded with --update-snapshots=all so
the QuantEcon blue is the baseline state on every page with a link.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@mmcky

mmcky commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

/update-snapshots

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🎭 Refreshed visual baselines in 763fef9:

  • tests/visual/snapshots/desktop-chrome-linux/features.png
  • tests/visual/snapshots/desktop-chrome-linux/history-open.png
  • tests/visual/snapshots/desktop-chrome-linux/intro.png
  • tests/visual/snapshots/desktop-chrome-linux/sidebar-open.png
  • tests/visual/snapshots/mobile-chrome-linux/features.png
  • tests/visual/snapshots/mobile-chrome-linux/history-open.png
  • tests/visual/snapshots/mobile-chrome-linux/intro.png
  • tests/visual/snapshots/mobile-chrome-linux/sidebar-open.png

The update-snapshots workflow pushes with GITHUB_TOKEN, which leaves the CI
run waiting for approval.
@mmcky

mmcky commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Thanks @DrDrij. I checked the cascade argument against the installed @myst-theme/styles@1.3.0 and it holds: upstream defines .link/.hover-link in @layer components, so the same-layer override wins on source order exactly as described, and on the static preview both classes compute to rgb(0, 114, 188) with a matching decoration colour. Copilot approved it with no comments.

As with #165 and #166 I pushed a few commits on top to get it mergeable after those two landed; push back on any of them.

  • 0780be9 merges main. Both earlier PRs refreshed the darwin baselines, so this branch's eleven conflicted with them.
  • 9fad0d8 adds the changelog entry under Changed, filed after the merge so it lands in [Unreleased].
  • 3f34e91 and the bot's 763fef9 re-record the darwin and linux baselines. One thing worth knowing for next time: a colour change this size sits under the 1% pixel threshold, so a plain --update-snapshots rewrote nothing locally and CI would have passed against stale images indefinitely. These were recorded with --update-snapshots=all (which is what the /update-snapshots workflow already does), so the QuantEcon blue is now the baseline state on every page with a link.

CI is green on the final head, so this is ready to merge from my side. The hover-only underline and :visited colour you noted as out of scope would make a tidy follow-up if we want full parity.

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.

3 participants