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

Add styles based on the documentation tool #473

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
21 changes: 20 additions & 1 deletion src/flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import { classMap } from "lit/directives/class-map.js";
import { default as objectPath } from "object-path";

import styleSheet from "./flyout.css";
import { AddonBase, addUtmParameters, getLinkWithFilename } from "./utils";
import styleMkDocsMaterial from "./flyout.mkdocs.material.css";
import styleSphinxFuro from "./flyout.sphinx.furo.css";
import {
AddonBase,
addUtmParameters,
getLinkWithFilename,
docTool,
} from "./utils";
import { SPHINX, MKDOCS_MATERIAL } from "./constants";
import {
EVENT_READTHEDOCS_SEARCH_SHOW,
EVENT_READTHEDOCS_FLYOUT_HIDE,
Expand Down Expand Up @@ -387,6 +395,17 @@ export class FlyoutAddon extends AddonBase {
for (const elem of elems) {
elem.loadConfig(config);
}

this.addCustomStyle();
}

addCustomStyle() {
const doctool = docTool.documentationTool;
if (doctool === MKDOCS_MATERIAL) {
document.adoptedStyleSheets.push(styleMkDocsMaterial);
} else if (doctool == SPHINX && docTool.isSphinxFuroLikeTheme()) {
document.adoptedStyleSheets.push(styleSphinxFuro);
}
humitos marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/flyout.mkdocs.material.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:root {
/* Reduce Read the Docs' flyout font a little bit */
--readthedocs-flyout-font-size: 0.7rem;
}
4 changes: 4 additions & 0 deletions src/flyout.sphinx.furo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:root {
/* Reduce Read the Docs' flyout font a little bit */
--readthedocs-flyout-font-size: 0.75rem;
}