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

enhance(homepage): better socials block on homepage #4472

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

marcelgerber
Copy link
Member

@marcelgerber marcelgerber commented Jan 21, 2025

Okay, I'll admit it, I spent way too much time to fix this small little annoyance 😬 But I learned a bit about grid layouts on the way, soo... :)

The video shows the two things that have changed:

CleanShot.2025-01-21.at.17.11.23.mp4

@owidbot
Copy link
Contributor

owidbot commented Jan 21, 2025

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-homepage-social-grid

SVG tester:

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

Edited: 2025-01-21 16:26:11 UTC
Execution time: 1.23 seconds

// A bunch of magic numbers!
// The 40% ensures that auto-fit creates at most 2 columns. We can't use the more sensible 50%, because grid gaps need to be accounted for.
// The 120px ensures that a column is at least 120px wide, i.e. we only get 2 columns if the container is at least 240px (+gap) wide.
grid-template-columns: repeat(auto-fit, minmax(max(40%, 120px), 1fr));
Copy link
Member

@ikesau ikesau Jan 21, 2025

Choose a reason for hiding this comment

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

Damn, this took me a while to understand too 😅

We have a --grid-gap variable to make this slightly less magic, and you could add some other element-scoped variables, too, maybe? It might make it a bit more readable (though I'd bet this code won't be touched again for years, now 😂)

--half-width: calc(50% - var(--grid-gap) / 2);
--min-column-width: max(var(--half-width), 120px);
grid-template-columns: repeat(
    auto-fit,
    minmax(var(--min-column-width), 1fr)
);

@marcelgerber marcelgerber merged commit a40f02c into master Jan 21, 2025
14 of 16 checks passed
@marcelgerber marcelgerber deleted the homepage-social-grid branch January 21, 2025 21:07
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