Skip to content

feat: export themes preset bundles for coherent visual styles#125

Open
smur89 wants to merge 2 commits into
mainfrom
feat/issue-58-theme-presets-v2
Open

feat: export themes preset bundles for coherent visual styles#125
smur89 wants to merge 2 commits into
mainfrom
feat/issue-58-theme-presets-v2

Conversation

@smur89

@smur89 smur89 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a module-scope themes dict (classic, modern, minimal) of vetted preset bundles — each themes the four knobs that interact visually (accent, font, columnRatio, headerTextAlign). Callers spread a theme over their own overrides:

#import "@preview/altacv:1.1.1": alta, themes // x-release-please-version
#alta(cv, preferences: themes.modern + (imageSize: 7em))

Closes #58. Supersedes #70 (PR predates the lib.typinternal//sections/ split + the internal/labels-en.toml extraction).

Design notes

  • classic re-declares current defaults (including columnRatio: 0.65, matching _default_preferences) — themes are by-name bundles, not pointers to "whatever the default is right now". Defaults can shift without silently shifting classic.
  • imagePosition is intentionally not bundled: it only makes sense when basics.image is set; baking it would either force image-only assumptions or no-op for image-less CVs.
  • Themes reference palettes.* for accents, so any future palette tweak ripples through.
  • modern (Inter) and minimal (Source Sans 3) fonts are aspirational. Neither is on CI. The fixture overrides font: "Lato" for those themes so make test stays silent; users with the named font installed get the intended typography, others get Typst's standard font-fallback warning.

Test plan

  • make testtests/themes.typ and all pre-existing fixtures green.
  • tests/themes.typ iterates themes.keys() so a future theme auto-extends the fixture; assert.eq pins each theme's declared font so a typo ("Intr") is caught even though the CI-host fallback would mask it visually.
  • Tracked examples/tests/themes.pdf.
  • README updated with a Theme presets subsection (table + spread-and-override example).

Summary by CodeRabbit

  • New Features

    • Added three built-in theme presets: classic, modern, and minimal, each combining font, accent colour, and layout-related styling.
    • Presets can be composed with your own overrides for a tailored appearance.
  • Documentation

    • Updated the README with usage guidance for theme presets, including how preset values apply and how unspecified settings fall back to defaults.
    • Expanded the “Helpers” examples to include the new themes helper alongside existing helpers.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5dca15f7-e360-432f-8bef-7ccc91a14a63

📥 Commits

Reviewing files that changed from the base of the PR and between 74e677a and ea77820.

⛔ Files ignored due to path filters (1)
  • examples/tests/themes.pdf is excluded by !**/*.pdf
📒 Files selected for processing (4)
  • README.md
  • internal/presets.typ
  • lib.typ
  • tests/themes.typ

📝 Walkthrough

Walkthrough

A themes preset bundle (classic, modern, minimal) is added to internal/presets.typ, each defining font, accent, columnRatio, and headerTextAlign. It is re-exported from lib.typ, exercised in a new tests/themes.typ fixture, and documented in README.md.

Changes

Theme Presets Bundle

Layer / File(s) Summary
themes preset definition and re-export
internal/presets.typ, lib.typ
Adds the themes dict with classic, modern, and minimal entries — each setting font, accent (via palettes), columnRatio, and headerTextAlign. Updates the lib.typ import to include themes alongside existing presets.
Test fixture
tests/themes.typ
New fixture renders a sample CV four times: once per built-in theme and once demonstrating the spread-and-override pattern (themes.modern with font and imageSize overrides). Includes font assertions and CI font workaround.
README documentation
README.md
Adds a "Theme presets" subsection covering the three presets, the spread syntax, and font-fallback behaviour. Extends the Helpers table and import snippet to include themes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • smur89/alta-typst#79: The new themes presets reference palettes entries (teal, navy, charcoal) directly, making this a direct continuation of the palette preset infrastructure introduced in that PR.

Poem

🐇 Three themes hopped in, all tidy and bright,
Classic, Modern, Minimal — each set just right.
Spread them and override with a flick of a key,
columnRatio, accent, and font all agree.
No more trial and error at the end of the day —
The rabbit has bundled the knobs away! 🎨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: exporting a themes preset bundle for visual styles.
Description check ✅ Passed The description is comprehensive and follows the template with all key sections filled: summary, design notes, and test plan.
Linked Issues check ✅ Passed All coding requirements from issue #58 are met: themes dict with classic/modern/minimal presets, spreading syntax support, palette integration, and documentation.
Out of Scope Changes check ✅ Passed All changes directly support the themes preset feature: presets file, library exports, tests, and README documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/issue-58-theme-presets-v2

Comment @coderabbitai help to get the list of available commands and usage tips.

Shane Murphy added 2 commits June 14, 2026 22:32
Adds a module-scope `themes` dict — `classic`, `modern`, `minimal` —
of vetted preset bundles. Each theme bundles `accent`, `font`,
`columnRatio`, and `headerTextAlign` — the four knobs that interact
visually. Callers spread a theme over their own overrides:

    #import "@preview/altacv:1.1.0": alta, themes
    #alta(cv, preferences: themes.modern + (imageSize: 7em))

Closes #58.

Design:
- `classic` re-declares current defaults — themes are by-name bundles,
  not pointers to "whatever the default is right now". A future
  defaults change will not silently shift `classic`.
- `imagePosition` deliberately omitted: it is only meaningful when
  `basics.image` is set, so baking it into every bundle would either
  force image-only assumptions or no-op for image-less CVs.
- Themes use `palettes.*` for accents (not raw hex), so any future
  palette adjustment ripples through.
- `modern` (`Inter`) and `minimal` (`Source Sans 3`) fonts are
  aspirational — neither is on CI. The fixture overrides `font: "Lato"`
  for those themes so `make test` is silent; users with the named font
  installed get the intended typography, others get Typst's standard
  font-fallback warning. README flags this.
- `themes.classic.columnRatio: 0.64 → 0.65` so the 'canonical alta look'
  matches `_default_preferences.columnRatio: 0.65`. Update the README
  table cell accordingly (64/36 → 65/35).
- Trim the 27-line preamble above `themes` in `internal/presets.typ`
  to match the brevity of sibling presets (`palettes`, `maps-providers`);
  the spread-and-override usage now lives only in the README to remove
  the source-vs-docs drift surface.
- Replace the three hand-written `#alta(...)` calls in `tests/themes.typ`
  with a `for key in themes.keys()` loop mirroring `tests/palettes.typ`,
  so adding a future theme auto-extends the fixture instead of needing
  a parallel edit.
- Add `assert.eq` pins on `themes.{classic,modern,minimal}.font` at the
  top of the fixture so a typo in the declared theme font is caught
  there (the CI-host font fallback would otherwise mask it via an
  identical-looking snapshot).
@smur89 smur89 force-pushed the feat/issue-58-theme-presets-v2 branch from 74e677a to ea77820 Compare June 14, 2026 20:32
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.

feat: theme preset bundles

1 participant