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 fallback for explorer index page thumbnails #4236

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

ikesau
Copy link
Member

@ikesau ikesau commented Nov 29, 2024

image

Annoyingly this took more effort than I thought it would because I had to add it to the hyrdation pipeline.

I could have written a script tag in the footer like this:

<script>
  document.querySelectorAll('.explorer-index-page__card img').forEach(img => {
    img.onerror = function() {
      const errorDiv = document.createElement('div');
      errorDiv.innerHTML = '<svg /> <h2 />...';
      errorDiv.className = 'explorer-index-page__card-error';
      this.parentNode.replaceChild(errorDiv, this);
    };
  });
</script>

but idk, I feel like that's a dangerous path to start going down for the rest of my team's sanity 😅

I tested this in Chrome and Safari too (because apparently things can go wrong even when you're just rendering rectangles)

@ikesau ikesau requested a review from marcelgerber November 29, 2024 19:02
@ikesau ikesau self-assigned this Nov 29, 2024
@owidbot
Copy link
Contributor

owidbot commented Nov 29, 2024

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-explorer-page-fallback

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2024-11-29 19:18:58 UTC
Execution time: 1.17 seconds

Copy link
Member

@marcelgerber marcelgerber left a comment

Choose a reason for hiding this comment

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

Annoyingly this took more effort than I thought it would because I had to add it to the hyrdation pipeline.

Oh god, yes, that's annoying. I was aghast when I first found out that there's not a simple img::error CSS selector that one could use for that. Go innovate, browser people.

@@ -66,6 +67,9 @@ export const runSiteFooterScripts = (
runCookiePreferencesManager()
void runDetailsOnDemand()
break
case SiteFooterContext.explorerIndexPage:
hydrateExplorerIndex()
Copy link
Member

Choose a reason for hiding this comment

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

Ahh, you need a bunch more here: Definitely runSiteNavigation, runCookiePreferencesManager, maybe also runSiteTools.

@ikesau ikesau merged commit bac04dd into master Dec 2, 2024
21 checks passed
@ikesau ikesau deleted the explorer-page-fallback branch December 2, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants