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

EthicalAd: specific placement for Antora and mdBook #475

Merged
merged 14 commits into from
Jan 14, 2025
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ We maintain a list of examples to check our JavaScript client is working correct
* `Docusaurus <https://test-builds.readthedocs.io/en/docusaurus/>`_
* `Jekyll <https://test-builds.readthedocs.io/en/jekyll/>`_
* `Jupyter Book <https://test-builds.readthedocs.io/en/jupyter-book/>`_
* `mdBook <https://test-builds.readthedocs.io/en/mdbook/>`_
* `MkDocs <https://test-builds.readthedocs.io/en/mkdocs/>`_
* `MkDocs (Material theme) <https://test-builds.readthedocs.io/en/mkdocs-material/>`_
* `MkDocs (Terminal theme) <https://test-builds.readthedocs.io/en/mkdocs-terminal/>`_
Expand Down
9 changes: 9 additions & 0 deletions src/doctools.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,37 @@
* values.
**/
@layer defaults {
:root[data-readthedocs-tool="docusaurus"] {
--readthedocs-flyout-header-font-size: 0.9rem;
}

:root[data-readthedocs-tool="mkdocs-material"] {
--readthedocs-font-size: 0.58rem;
--readthedocs-flyout-header-font-size: 0.7rem;
--readthedocs-flyout-font-size: 0.58rem;
}

:root[data-readthedocs-tool="antora"] {
--readthedocs-font-size: 0.7rem;
--readthedocs-flyout-header-font-size: 0.8rem;
--readthedocs-flyout-font-size: 0.7rem;
}

:root[data-readthedocs-tool="mdbook"] {
--readthedocs-font-size: 1.3rem;
--readthedocs-flyout-header-font-size: 1.5rem;
--readthedocs-flyout-font-size: 1.3rem;
}

:root[data-readthedocs-tool="sphinx"][data-readthedocs-tool-theme="furo"] {
--readthedocs-font-size: 0.725rem;
--readthedocs-flyout-header-font-size: 0.845rem;
--readthedocs-flyout-font-size: 0.725rem;
}

:root[data-readthedocs-tool="sphinx"][data-readthedocs-tool-theme="immaterial"] {
--readthedocs-font-size: 0.58rem;
--readthedocs-flyout-header-font-size: 0.7rem;
--readthedocs-flyout-font-size: 0.58rem;
}
}
22 changes: 22 additions & 0 deletions src/ethicalads.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,28 @@ export class EthicalAdsAddon extends AddonBase {
placement.classList.add("ethical-alabaster");
placement.classList.add("ethical-docsify");

placement.setAttribute("data-ea-type", "readthedocs-sidebar");
placement.setAttribute("data-ea-style", "image");
knownPlacementFound = true;
}
} else if (docTool.isAntora()) {
selector = "aside nav.nav-menu";
element = document.querySelector(selector);

if (this.elementAboveTheFold(element)) {
placement.classList.add("ethical-alabaster");
Copy link
Member

Choose a reason for hiding this comment

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

Should we rename this something more generic?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. We should use something like ethical-light-theme; considering that we are using it for that use case. However, it's not a 1:1 match. We will need to keep -alabaster as well since there are some thing very specific to it, I think. I opened #477


placement.setAttribute("data-ea-type", "readthedocs-sidebar");
placement.setAttribute("data-ea-style", "image");
knownPlacementFound = true;
}
} else if (docTool.isMdBook()) {
selector = "nav#sidebar mdbook-sidebar-scrollbox";
element = document.querySelector(selector);

if (this.elementAboveTheFold(element)) {
placement.classList.add("ethical-alabaster");

placement.setAttribute("data-ea-type", "readthedocs-sidebar");
placement.setAttribute("data-ea-style", "image");
knownPlacementFound = true;
Expand Down