-
Notifications
You must be signed in to change notification settings - Fork 12
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
EthicalAds: use theme-logic to decide position #309
EthicalAds: use theme-logic to decide position #309
Conversation
Packages: updated via `ncu -u` Co-authored-by: humitos <[email protected]>
Packages: updated via `ncu -u` Co-authored-by: humitos <[email protected]>
We can add a better link once we have built the documentation for the flyout/addons. Closes #302.
Closes #169 Closes #172 --------- Co-authored-by: Manuel Kaufmann <[email protected]>
The logic/idea is borrowed from the old implementation at https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js#L51 Related https://github.com/readthedocs/addons/pull/295/files#r1600336686
Hrm... I was missing including the CSS file 👍🏼 -- it should work after I figure it out how to include it without using web components 😅 |
It seems it figured it out. I only need to understand why the css that I'm injecting via Line 4 in 2e64849
|
Some of this is historical. When the ad appears in the stickybox in the lower right corner, it uses the CSS directly from the ad client. However, when it appears in the sidebar, it's usually using some custom RTD CSS. Part of the reason for this is that Alabaster and the RTD look quite different and the exact same ad placement may not work in both. We might want to use the light theme with Alabaster and the dark theme with RTD-like themes. I'm not sure. |
In my opinion, the next step here is to integrate the ad in a better way with other themes/tools. This is, for example, do not use stickybox in Material for MkDocs and place it in the left/right bar. |
IMO, this PR is ready to review and deploy. We can continue iterating and adding more cases in the following PRs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks good.
As I mentioned at #295, we might be able to remove some of the isSphinxReadTheDocsLikeTheme()
/isSphinxAlabasterLikeTheme()
code by using the styling directly from the ad client instead of "readthedocs-sidebar"
(just use data-ea-type="image"
, the default). Using the custom readthedocs-sidebar
means you're responsible for the styling basically. I'm not sure this code can be removed 100% because you still might want to inject the ad in different places on different themes but you probably could just accept light/dark mode depending on the theme. However, what you have seems to look good although it does sort of mean RTD continues to maintain custom ad CSS. Perhaps switching to the built-in image placement in a v2?
Yea, if we could get away from custom RTD CSS that would be great. Hopefully the ad styles on the ad client should be enough for most things, but I agree we don't need to block this work on that, so we can merge this and then figure out deprecating the CSS styles. |
Packages: updated via `ncu -u` Co-authored-by: humitos <[email protected]>
I'm not opposed to move the CSS styles into the ad client and rely on light/dark mode only. However, we will still need some code in the addons ( |
@humitos yea, we definitely want logic around where to inject -- I think removing our own custom CSS is the next step 👍 |
The logic/idea is borrowed from the old implementation at
https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/core/static-src/core/js/doc-embed/sponsorship.js#L51
Related https://github.com/readthedocs/addons/pull/295/files#r1600336686