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

mermaid,themes - update themes #9503

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

mermaid,themes - update themes #9503

wants to merge 6 commits into from

Conversation

cscheid
Copy link
Collaborator

@cscheid cscheid commented Apr 27, 2024

This PR makes mermaid flowcharts work well across all bootswatch themes, following our work-week discussions on Friday.

Specifically, it specializes the mermaid SCSS variables to each theme, and tweaks them as necessary.

It also changes one of the defaults across all themes in the CSS emitted by mermaid-init.js itself, so that the arrow end markers look nicer.

@cscheid
Copy link
Collaborator Author

cscheid commented Apr 27, 2024

Note that it's very hard to add regression tests here, so this would be a good candidate for future visual tests.

@cderv
Copy link
Collaborator

cderv commented Apr 28, 2024

So cool ! Thanks for this.

Initially I was thinking we could add each mermaid variables into an additional theme file per bootswatch theme. idea was to simplify the update of bootstrap and keep initial bootswatch without modification for quarto.

But using git diff in an update is easy enough I guess.

Just sharing what I would have done. All good - I'll note the idea for visual testing.

@cscheid
Copy link
Collaborator Author

cscheid commented Apr 29, 2024

Initially I was thinking we could add each mermaid variables into an additional theme file per bootswatch theme. idea was to simplify the update of bootstrap and keep initial bootswatch without modification for quarto.

That might be the right way to do solve the problem. I already needed to add an additional theme file for the default theme, which doesn't have an .scss file by itself. But then, that caused all of these failures in CI for reasons I don't understand.

@cderv
Copy link
Collaborator

cderv commented Apr 29, 2024

The issue you get in CI for revealjs format is because quarto-rules.scss is shared with revealjs too

// Quarto layers
const quartoLayers = [
quartoBaseLayer(format, true, true, false, true),
quartoLayer(),
];

So you need to defined the default variables for mermaid also in a layer used with revealjs.

export const quartoBaseLayer = (
format: Format,
codeCopy = false,
tabby = false,
figResponsive = false,
codeFilename = false,
) => {
const rules: string[] = [quartoRules()];
const defaults: string[] = [quartoDefaults(format), quartoVariables()];

  • _quarto-variables.scss ?
  • not in a file like quartoDefaults ?
  • An additional specifial _quarto_mermaid_variable.scss to make them separate ?

With our SASS layering system, this is a question of where and which order so that it keeps easy to maintain in the future.

@cderv
Copy link
Collaborator

cderv commented May 2, 2024

The error are related with all the missing them options. By adding the rules into the _quarto_rules layer, it means we are making it default for Quarto base layer

export const quartoBaseLayer = (
format: Format,
codeCopy = false,
tabby = false,
figResponsive = false,
codeFilename = false,
) => {
const rules: string[] = [quartoRules()];
const defaults: string[] = [quartoDefaults(format), quartoVariables()];
if (codeCopy) {
rules.push(quartoCopyCodeRules());
defaults.push(quartoCopyCodeDefaults());
}
if (tabby) {
rules.push(quartoTabbyRules());
}
if (figResponsive) {
rules.push(quartoFigResponsiveRules());
}
if (codeFilename) {
rules.push(quartoCodeFilenameRules());
}
if (format.render[kLinkExternalIcon]) {
rules.push(quartoLinkExternalRules());
}

So the variables associated with those rules, should also be defined in the defaults layer. See above what we do for each feature we have and need variables.

I would really add some basic default in this base layer, which is used for HTML document and not for reveal. This base layer will apply for HTML format without bootstrap

// add quarto sass bundle of we aren't in bootstrap
const minimal = format.metadata[kMinimal] === true;
if (!bootstrap && !minimal) {
if (scssOptions.quartoBase) {
sassBundles.push({
dependency: kQuartoHtmlDependency,
key: kQuartoHtmlDependency,
quarto: quartoBaseLayer(
format,
!!options.copyCode,
!!options.tabby,
!!options.figResponsive,
),
});
}

I really wonder if we should not try to make those mermaid SCSS information a specific quarto internal layer that we could add in every place (no bootstrap, bootstrap, and revealjs

This will also make themes updates when we update dependencies easier. Adding to each revealjs themes, will mean manual editing when updating theme I think

@cscheid
Copy link
Collaborator Author

cscheid commented May 2, 2024

I tried doing that, but then I couldn't make the non-default themes override the defaults. I think I tried adding them to different layers and couldn't make any of it work.

I know SCSS is hard, but honestly, I think we should consider rethinking this whole thing. It feels hopeless to do something robustly and extensibly.

@cderv
Copy link
Collaborator

cderv commented May 3, 2024

I know SCSS is hard, but honestly, I think we should consider rethinking this whole thing. It feels hopeless to do something robustly and extensible.

I was started to have the feeling to understand it ! 😅 But why not rethinking all this, at least for our internal code base so that it is easier to maintain.

I find this layering system quite useful to split content, but the order matters, and currently the fact everything is split across our code base makes it hard to fully reason about.

Do you want me to give it a try based on what I learnt by looking into this for revealjs theme ?

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.

None yet

2 participants