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

EthicalAds: use theme-logic to decide position #309

Merged
merged 25 commits into from
May 21, 2024

Conversation

github-actions bot and others added 5 commits May 6, 2024 17:31
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.
@humitos
Copy link
Member Author

humitos commented May 16, 2024

This is how it works now:

Peek 2024-05-16 20-04

It seems there may be something wrong with the classes because it doesn't render properly when it goes to the navbar. Any clue here?

@humitos
Copy link
Member Author

humitos commented May 16, 2024

This is how it works in Alabaster-like themes.

Peek 2024-05-16 20-10

@humitos
Copy link
Member Author

humitos commented May 16, 2024

Hrm... I was missing including the CSS file 👍🏼 -- it should work after I figure it out how to include it without using web components 😅

@humitos
Copy link
Member Author

humitos commented May 16, 2024

With the correct CSS it looks 👍🏼 , but I'm not sure yet why it's not being loaded by default:

Peek 2024-05-16 20-49

@humitos
Copy link
Member Author

humitos commented May 16, 2024

It seems it figured it out. I only need to understand why the css that I'm injecting via

import styleSheet from "./ethicalads.css";
does not affect the ad. I think @agjohnson may have an idea here.

@humitos
Copy link
Member Author

humitos commented May 16, 2024

However, activating the CSS manually looks great!

Peek 2024-05-16 21-22

@davidfischer
Copy link
Contributor

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.

@humitos
Copy link
Member Author

humitos commented May 17, 2024

I figured this out. I think it's working as expected. Here are some examples:

Theme Image
Read the Docs Screenshot_2024-05-17_11-32-06
Alabaster Screenshot_2024-05-17_11-33-44
Docusaurus Screenshot_2024-05-17_11-34-05
Material for MkDocs Screenshot_2024-05-17_11-34-32

@humitos
Copy link
Member Author

humitos commented May 17, 2024

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.

@humitos
Copy link
Member Author

humitos commented May 17, 2024

I added some extra code here to work on Docusaurus and Material for MkDocs in a better integrated way 😄

Theme Image
Docusaurus Screenshot_2024-05-17_12-20-59
Material for MkDocs Screenshot_2024-05-17_12-21-09

@humitos
Copy link
Member Author

humitos commented May 17, 2024

IMO, this PR is ready to review and deploy. We can continue iterating and adding more cases in the following PRs.

@humitos humitos self-assigned this May 17, 2024
@humitos
Copy link
Member Author

humitos commented May 17, 2024

Added another integration for Sphinx Book Theme (Jupyter Book)

Screenshot_2024-05-17_13-38-00

Copy link
Contributor

@davidfischer davidfischer left a 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?

src/ethicalads.js Outdated Show resolved Hide resolved
@ericholscher
Copy link
Member

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]>
@humitos
Copy link
Member Author

humitos commented May 21, 2024

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 (isReadTheDocsLikeTheme(), etc) to determine where to inject the ad based on the theme/doctool. I'm fine with that since we can give users a better experience than always using the stickybox.

@humitos humitos merged commit 94ef5b3 into humitos/ad-stickybox-placement May 21, 2024
4 checks passed
@humitos humitos deleted the humitos/ad-above-fold branch May 21, 2024 08:31
@ericholscher
Copy link
Member

@humitos yea, we definitely want logic around where to inject -- I think removing our own custom CSS is the next step 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants