Skip to content

EthicalAds: split .ethical-alabaster CSS class into .ethical-light-theme #477

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

Open
humitos opened this issue Dec 19, 2024 · 6 comments
Open
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code

Comments

@humitos
Copy link
Member

humitos commented Dec 19, 2024

We should not be using .ethical-alabaster for documentation tools that are not Sphinx and are not Alabaster theme. However, as they were looking better than the default style, we started used them there.

We should create a new CSS class for these cases.

@humitos humitos added Improvement Minor improvement to code Accepted Accepted issue on our roadmap labels Dec 19, 2024
@github-project-automation github-project-automation bot moved this to Planned in 📍Roadmap Jan 8, 2025
@ericholscher ericholscher self-assigned this Jan 28, 2025
@ericholscher
Copy link
Member

I looked at this briefly, and all the styling seems to be specific to Alasbaster? Seems like we should probably keep this named alabaster, and not apply it to other themes?

addons/src/ethicalads.css

Lines 204 to 219 in e7d1d5f

/* Alabaster specific customizations */
.ethical-alabaster a.ethical-image-link {
/* Alabaster adds a border even to image links on hover */
border: 0 !important;
}
.ethical-alabaster hr {
/* Alabaster needs some extra spacing before the footer ad */
margin-top: 2em;
}
.ethical-alabaster::before {
/* Alabaster's search box above the ad is floating */
clear: both;
content: "";
display: table;
margin-top: 3em;
}

@humitos
Copy link
Member Author

humitos commented Feb 19, 2025

These rules work fine with Sphinx light themes, where we are already using it, that's why the rename was proposed. It seems it's not alabaster-specific. We can keep the .ethical-alabaster if we want and create another class; but we will be copying the same rules.

@ericholscher
Copy link
Member

ericholscher commented Feb 19, 2025

But it seems like it's adding padding and adjusting the page around the alabaster theme, not anything to do with the color?

@humitos
Copy link
Member Author

humitos commented Feb 20, 2025

Right, but we are using that class with those rules for other themes than alabaster. Even, for other documentation tools that are not Sphinx:

addons/src/ethicalads.js

Lines 88 to 191 in 398478a

} else if (docTool.isSphinxFuroLikeTheme()) {
// NOTE: The code to handle furo theme shouldn't be required,
// since furo uses explicit placement.
// However, the Jinja context variable READTHEDOCS is not injected anymore,
// and furo does not includes the explicit placement due to this.
// This is a temporal solution while they fix this.
selector = ".sidebar-tree";
element = document.querySelector(selector);
if (this.elementAboveTheFold(element)) {
placement.classList.add("ethical-alabaster");
placement.setAttribute("data-ea-type", "readthedocs-sidebar");
placement.setAttribute("id", "furo-sidebar-ad-placement");
knownPlacementFound = true;
}
} else if (docTool.isSphinxBookThemeLikeTheme()) {
selector = ".sidebar-primary-items__start.sidebar-primary__section";
element = document.querySelector(selector);
if (this.elementAboveTheFold(element)) {
placement.classList.add("ethical-alabaster");
placement.setAttribute("data-ea-type", "readthedocs-sidebar");
knownPlacementFound = true;
}
} else if (docTool.isSphinxAlabasterLikeTheme()) {
selector = "div.sphinxsidebar > div.sphinxsidebarwrapper";
element = document.querySelector(selector);
if (this.elementAboveTheFold(element)) {
placement.classList.add("ethical-alabaster");
placement.setAttribute("data-ea-type", "readthedocs-sidebar");
knownPlacementFound = true;
}
} else if (docTool.isMaterialMkDocsTheme()) {
selector = ".md-sidebar__scrollwrap";
element = document.querySelector(selector);
if (this.elementAboveTheFold(element)) {
// TODO: use a more styled CSS class.
// See https://github.com/readthedocs/ethical-ad-client/issues/193
placement.classList.add("ethical-alabaster");
placement.setAttribute("data-ea-type", "readthedocs-sidebar");
knownPlacementFound = true;
}
} else if (docTool.isDocusaurusTheme()) {
selector = ".menu.thin-scrollbar.menu_SIkG";
element = document.querySelector(selector);
if (this.elementAboveTheFold(element)) {
// TODO: use a more styled CSS class.
// See https://github.com/readthedocs/ethical-ad-client/issues/193
placement.classList.add("ethical-alabaster");
placement.classList.add("ethical-docusaurus");
placement.setAttribute("data-ea-type", "readthedocs-sidebar");
placement.setAttribute("data-ea-style", "image");
knownPlacementFound = true;
}
} else if (docTool.isDocsify()) {
selector = "main > aside > div.sidebar-nav";
element = document.querySelector(selector);
if (this.elementAboveTheFold(element)) {
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");
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;
}
} else if (docTool.isVitePress()) {
selector = "aside";
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;
}

@ericholscher
Copy link
Member

ericholscher commented Feb 20, 2025

Right, but I'm saying that it doesn't make sense to apply that class there? Is it actually doing anything, since the structure of the content isn't the same?

I'm a little confused what the goal here is. Are we trying to make a class that applies different changes to light-themed docs that aren't already implemented?

@humitos
Copy link
Member Author

humitos commented Feb 20, 2025

Is it actually doing anything, since the structure of the content isn't the same?

Have you tried removing that class and showing an ad on pages from those documentation tools?

I'm a little confused what the goal here is.

The goal is to no use a class called -alabaster on themes that are not alabaster. If all those themes where we are currently using -alabaster are light themes, the new CSS class could be called -light-theme. On the other hand, if that's not true for all the current usages, we can use different class names.

@ericholscher ericholscher removed their assignment Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code
Projects
Status: Planned
Development

No branches or pull requests

2 participants