Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: axomdbook #335

Closed
wants to merge 3 commits into from
Closed

WIP: axomdbook #335

wants to merge 3 commits into from

Conversation

Gankra
Copy link
Contributor

@Gankra Gankra commented May 22, 2023

  • adds the contents of https://github.com/axodotdev/axomdbook to oranda-css/mdbook-theme/
  • has each build of oranda store those files in the binary
  • if mdbook.theme = true (or None) then we
    • delete the user's theme dir if it exists
    • write_all the files stored in the binary to that dir (creating dirs as needed)
    • toml_edit the their book.toml to set the "axo" theme as the preferred default for html output

The argument for doing these mutations to their project (instead of injecting them with the mdbook library API) is so that mdbook build on its own produces the same results. This is currently done on every build, so the user cannot hand-edit the result, as it will just be silently overwritten.

image

@Gankra
Copy link
Contributor Author

Gankra commented May 22, 2023

This is... arguably shippable as written? just marking it WIP due to my lack of confidence in the approach.

Comment on lines +217 to +225
--color-axo-pink: hsla(326, 100%, 73%, 1);
--color-axo-pink-dark: hsla(326, 52%, 58%, 1);
--color-axo-orange: hsla(0, 87%, 70%, 1);
--color-axo-orange-dark: hsla(356, 75%, 64%, 1);
--color-axo-highlighter: hsla(51, 100%, 50%, 1);
--color-axo-black: hsla(0, 0%, 5%, 1);

--title-fg: var(--color-axo-pink);
--main-font: Comfortaa;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thankfully mdbook is already heavily variable'd, so 95% of the theme is just settings vars. These are the values we ostensibly want tailwind to inject.

The remaining 5% are:

  • a couple more surgical edits to the "real" css to introduce distinctions where we want to make two things that were previously styled the same in mdbook have different styling to more closely match oranda/axo
    • --title-fg and --main-font are new variables that govern these distinctions; all other themes avoid setting these, triggering default values.
  • edit to the JS to change the localStorage key for the theme, to avoid conflicts when someone launches a local mdbook that doesn't have the axo theme (causes that other mdbook's JS to crash)
  • edit to the JS to tell mdbook that "axo" is a dark theme (affects the JS that does code block syntax highlighting)

@Gankra
Copy link
Contributor Author

Gankra commented May 22, 2023

See https://github.com/axodotdev/axomdbook/issues for some out-standing issues with the actual theme

See axodotdev/axomdbook@0a052c6 for the precise edits that were made to the default mdbook theme

See https://rust-lang.github.io/mdBook/format/theme/index.html for docs on mdbook themeing

Comment on lines +118 to +129
fn deserialize_toml_edit(src: &SourceFile) -> Result<toml_edit::Document> {
let toml = src
.contents()
.parse::<toml_edit::Document>()
.map_err(|details| {
let span = details.span().map(|span| span.into());
OrandaError::TomlEdit {
source: src.clone(),
span,
details,
}
})?;
Ok(toml)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIXME: factor into axoasset (cargo-dist also uses a variation of this for editing Cargo.toml in init)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--fg: #bcbdd0;

--sidebar-bg: var(--color-axo-black);
--sidebar-fg: var(--color-axo-orange);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
--sidebar-fg: var(--color-axo-orange);
--sidebar-fg: var(--fg);

Suggested on discord, makes the sidebar items grey instead of orange by default

@Gankra Gankra closed this May 23, 2023
@Gankra Gankra mentioned this pull request May 23, 2023
@shadows-withal shadows-withal deleted the axomdbook branch June 26, 2023 18:12
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.

1 participant