Repository navigation
Restyle the generated infobooks and make them work on mobile - #55
Conversation
The pages were a fixed 800px wide without a viewport meta tag, so phones rendered them zoomed out with the text running off screen. This reworks the shared stylesheet and the templates into a responsive layout that stays close to the look of the infobook inside the game: one parchment page on a dark cover, with a stitched edge, an ornamental rule under the title, and pill buttons for page navigation. All colors are still derived from the six values that config.json already defines, so no mod configuration has to change. Templates: * Add a charset and a viewport meta tag. * Replace the wall of language links with a details dropdown that needs no JavaScript, and mark the current language with aria-current. * Move the breadcrumbs into the page as a nav element. * Make the section title the h1 of the page instead of the site name, and keep the schema:name triple intact with a meta element. * Group appendices in a container so they can flow into columns. * Swap Droid Sans for Lora, and load both fonts in a single request. Fixes: * The footer loaded main.js from an absolute /assets/main.js, which 404s for every book that is not hosted at the domain root, so the ingredient variant spinner never ran. It now resolves against baseUrl. * The index template nested its each next to the ul instead of inside it, which emitted an empty ul followed by stray li siblings. * assets/main.js was matched by the *.js gitignore rule and was never committed, so it only existed in the published package. It is now tracked. * Image appendices had a hardcoded pixel size that overflowed narrow screens. They now keep their aspect ratio and scale their background with the element, so the stylesheet can shrink them to fit. Colors from formatting codes are emitted as an mc-* class with the in-game color as an inline custom property fallback, so that stylesheets can tune them for readability on parchment without losing the in-game color when they don't. Adds an optional bookIconItem config option, which shows the icon of that item next to the book name in the header. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FuDB4UAnaLnNEEv8kVuotH
ae9c58a to
4db2991
Compare
|
Heads up on the one red check here:
I have since extended those tests to cover the pure helpers as well, so the file now reports 33% instead of 16%, and the total is 58% rather than 55%. Coveralls will still read that as a decrease against master, because master was never measuring the file at all. Two options, both yours to pick:
Generated by Claude Code |
The generated books were a fixed 800px wide and had no viewport meta tag, so phones rendered them zoomed out with the text running off screen. This reworks the shared stylesheet and the templates into a responsive layout, and takes the opportunity to move the look closer to the infobook inside the game.
Design
The in-game book is a parchment page on a leather cover, with a stitched edge, a small ornamental divider and rounded pill buttons. The web version now follows that:
border_light, a faint paper grain, an inner vignette and a dashed stitch line along the right edge.border_mutedand outlined inborder, matching the button sprite in the book textures.Every color is still derived from the six values that
config.jsonalready defines, usingcolor-mix(), so no mod configuration has to change. Mods that want to deviate can override the derived tokens (--page,--ink,--link,--frame, ...) in their own stylesheet.Templates
detailsdropdown that needs no JavaScript, and mark the current language witharia-current.navelement.h1of the page instead of the site name, so every page has exactly oneh1that describes it. Theschema:nametriple is unchanged: it moved to ametaelement in the header with the same"Mod - Book"value.Fixes found along the way
main.jsfrom an absolute/assets/main.js. Both deployed books live under/book/, so that has always 404'd and the ingredient variant spinner never ran. It now resolves againstbaseUrl.index.pugnested itseachnext to theulinstead of inside it, which emitted an empty<ul></ul>followed by stray<li>siblings.assets/main.jsis matched by the*.jsline in.gitignoreand was never committed, so it exists only inside the published tarball. A publish from a fresh clone would have dropped it. It is now tracked through a negation.Formatting colors
formatStringemitted inline hex colors, which meant the in-game yellow, gray and white were unreadable on parchment and impossible to tune from CSS. Each colored span now carries a class and the in-game color as an inline custom property fallback:A stylesheet that knows nothing about
--mc-*still gets exactly the old color, and the shared stylesheet redefines the 16 codes so they stay recognisable while remaining readable on the page background. The 16 repeated replacement lines are now table-driven, andHtmlInfoBookSerializer.colorCodesis public so plugins can reuse the mapping.New config option
bookIconItemis optional and takes an item id, such as"integrateddynamics:on_the_dynamics_of_integration". Its exported icon is shown next to the book name in the header. It falls back toiconwhen unset or when that item has no exported icon, andiconfalls back to it, so existing configs keep working untouched.Compatibility
IInfobookPlugin, the appendix handler interfaces and every public serializer method keep their signatures. The newISerializeContextfields are optional.config.jsonkey is required or renamed.^5.2.x, so they pick this up on their next build, and their own stylesheets still position recipe icons at absolute pixel offsets. The companion PRs move those over:Release order
Merging and releasing this first, then merging the two companion PRs, keeps the deployed books consistent: their
^5.2.xranges resolve to the new release at build time, so the deploy that follows each merge picks up the new templates and the matching stylesheet together.Going the other way around, or deploying a mod repo in between, pairs new templates with an old mod stylesheet for one deploy. That only misplaces recipe machine icons, and the next deploy fixes it, but doing it in this order avoids it entirely.
Verification
npm run build,npm run lintandnpm testpass. Added 8 tests forformatString, which had none; this neededesModuleInteropin the test tsconfig, since no test had imported the serializer before.🤖 Generated with Claude Code
https://claude.ai/code/session_01FuDB4UAnaLnNEEv8kVuotH