Skip to content

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

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

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

Conversation

@smur89

@smur89 smur89 commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a module-scope themes dict — classic, modern, minimal — exporting vetted preset bundles of preferences that hang together visually (accent, font, columnRatio, headerTextAlign). Callers spread a theme over their own overrides:

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

Closes #58.

Design notes for the reviewer

  • Scope of each bundle. The issue calls out five knobs that interact (accent, font, columnRatio, imagePosition, headerTextAlign). I shipped four — left imagePosition out because it's only meaningful when basics.image is set, and baking it into every theme would either force image-only assumptions or no-op for image-less CVs. Users add imagePosition themselves via the spread-and-override pattern.
  • No dependency on palettes (feat: export built-in palette presets #52). The issue says "builds on the palettes preset issue" (feat: export built-in palette presets #52), which hasn't shipped. Rather than block on it, themes carry raw rgb(...) accents directly — they're self-contained today. When palettes land, themes can refactor internally to reference them without changing their public API.
  • classic re-declares current defaults. Deliberate, not a redirect — themes are bundles by name, not pointers to "whatever the default is right now". Means classic will drift if defaults change; that's the cost of having a stable named bundle and I think it's worth it.
  • Module-scope export, parallel to maps-providers. Same precedent: an exported dict of named presets the user spreads into preferences. No new merge / validation logic — _strict_merge in alta() already validates the spread result against _default_preferences.
  • Font warnings in the test fixture. Inter and Source Sans 3 aren't installed on the CI host (only Lato is). The fixture overrides font: "Lato" after each non-classic theme spread so CI compiles silently. Users on local machines with the right fonts installed will get the intended typography; users without will get Typst's font-fallback warning (the existing behaviour for any unknown font value), which the README now flags.

Happy to push back on any of these — particularly the theme-vs-palette decoupling and the exact bundle contents.

Rendered output

examples/tests/themes.pdf is committed; the four pages show classic, modern (with Lato font override for CI), minimal (likewise), and the spread-and-override pattern.

Test plan

  • typst compile --root . examples/example.typ examples/example.pdf succeeds
  • Each tests/*.typ fixture compiles (make test clean — no warnings)
  • Added a tests/themes.typ fixture exercising every built-in theme + the spread-override pattern
  • Updated the README with a new "Theme presets" subsection (table + usage)

Notes for the reviewer

  • The font value for modern (Inter) and minimal (Source Sans 3) is aspirational — neither is on CI. Acceptable because Typst falls back rather than panicking, and users who install the named font get the intended look. If you'd prefer the defaults all resolve to a CI-installed font, swap modern/minimal to Lato and rely on accent + layout to differentiate them.
  • No follow-up issues filed; imagePosition and the palettes dependency are both pre-existing tracked work.

JSON Resume alignment

Not applicable — theme presets bundle template-side preferences (accent, font, columnRatio, headerTextAlign), which sit entirely outside the JSON Resume data schema (https://jsonresume.org/schema/). The themes dict is a sibling of maps-providers, not a cv.* field.

Summary by CodeRabbit

  • New Features

    • Added three built-in theme presets (classic, modern, minimal) to quickly apply coordinated visual preferences (accent, font, layout proportions, header alignment).
    • Presets are designed to be merged with additional preference overrides for further customization.
  • Documentation

    • Expanded README with a new Theme presets section, including usage examples and a comparison of the presets.
  • Tests

    • Added coverage to render sample output with each theme preset (and a preset + override combination) to ensure consistent behavior.

@smur89 smur89 force-pushed the feat/issue-58-theme-presets branch 6 times, most recently from b71dad0 to dc67958 Compare June 14, 2026 10:57
@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: 8eea6a93-2abc-450a-bfc7-4d236a8a7ec7

📥 Commits

Reviewing files that changed from the base of the PR and between dc67958 and 81671c4.

⛔ Files ignored due to path filters (2)
  • examples/preview.png is excluded by !**/*.png
  • examples/tests/themes.pdf is excluded by !**/*.pdf
📒 Files selected for processing (3)
  • README.md
  • lib.typ
  • tests/themes.typ

📝 Walkthrough

Walkthrough

Adds a themes dictionary to lib.typ exporting three preset preference bundles (classic, modern, minimal), each specifying accent, font, columnRatio, and headerTextAlign. A new test fixture renders the CV with all three themes and a spread-and-override example. README documents the feature.

Changes

Theme presets bundle

Layer / File(s) Summary
themes dictionary and README documentation
lib.typ, README.md
Defines the themes dict with classic, modern, and minimal presets—each bundling accent, font, columnRatio, and optionally headerTextAlign. README adds a "Theme presets" section with a preset table, spread-and-override usage examples, and a note on font-fallback behavior. Updates the exported dict reference table to include themes.
Theme rendering test fixture
tests/themes.typ
New test file that imports alta and themes, defines a shared cv fixture, and renders it with all three built-in themes separated by page breaks, including a themes.modern spread-and-override example.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 Hop, hop — three themes appear,
classic, modern, minimal are here!
Spread them in with a + and a grin,
Let your font and accent begin.
No more trial, no more fuss —
The rabbit presets them for us! 🎨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically summarizes the main change: exporting a themes preset dictionary with coherent visual style bundles.
Description check ✅ Passed The description comprehensively covers the summary, test plan, design rationale, and implementation details with clear explanations of key decisions.
Linked Issues check ✅ Passed The PR fully addresses issue #58 by implementing the themes dict with classic, modern, and minimal presets bundling accent, font, columnRatio, and headerTextAlign for users to spread with overrides.
Out of Scope Changes check ✅ Passed All changes directly support the themes feature: lib.typ export, README documentation, and tests/themes.typ fixture. No unrelated modifications present.
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

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

@smur89 smur89 force-pushed the feat/issue-58-theme-presets branch from dc67958 to 4e70e92 Compare June 14, 2026 11:08
Shane Murphy added 2 commits June 14, 2026 15:14
`themes` is a dict of vetted preference bundles — `classic`, `modern`,
`minimal` — each setting the four knobs that interact visually
(`accent`, `font`, `columnRatio`, `headerTextAlign`). Callers spread a
theme over their own overrides:

    #alta(cv, preferences: themes.modern + (imageSize: 7em))

Themes are partial preferences dicts; any key they don't set falls back
to `_default_preferences`, so per-document tweaks (paper, image sizing,
section order) stay one-line edits. The dict is module-scope and
exported alongside `maps-providers`, matching the precedent for exposed
preset lookups.

A `tests/themes.typ` fixture exercises each built-in theme plus the
spread-and-override pattern. Non-classic themes override `font` back to
`Lato` in the fixture so the CI host (which doesn't ship Inter or
Source Sans 3) compiles without font-fallback warnings.

Closes #58
@smur89

smur89 commented Jun 14, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #125 — rebuilt against the post-refactor module layout (internal//sections/ split, internal/labels-en.toml extraction, example_full.typ demo). Leaving open for your review/close.

@smur89 smur89 closed this Jun 14, 2026
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