Skip to content

Optimize image handling and restore layout specifications#10

Open
mhaadiabu wants to merge 16 commits into
devcongress:mainfrom
mhaadiabu:main
Open

Optimize image handling and restore layout specifications#10
mhaadiabu wants to merge 16 commits into
devcongress:mainfrom
mhaadiabu:main

Conversation

@mhaadiabu
Copy link
Copy Markdown

Fix broken UI and migrate all <img> to Astro's <Image>

Five small UI fixes plus a full <img><Image> migration.

UI fixes

  • Mission CTA stretched full-width inside a flex column, making the centered text look misplaced. Pinned to flex-start.

Before:
image

After:
image

  • .eyebrow referenced an undefined --text-s token and fell back to 1rem. Now points at --text-xs.
  • Partner .has-bg padding was 20px; AGENTS.md documents 8px. Restored.
  • .card hover used to lift the card (translate(-2,-2) + shadow appears), which fought the static offset shadows on .stat-card, .reg-card, and .stream-wrap. Inverted: cards rest with an offset shadow and press down on hover to absorb it. Bouncy easing. Same mechanic applied per-card so each absorbs its own larger colored shadow.
    Before:
image

After:
image

<img><Image>

  • Site logo moved to src/assets/ and imported in Navbar, Footer, and both meetup nav bars.
  • Admin profile photos sized to 400x400.
  • Partner logos use per-logo width/height from YAML data; schema extended.
  • Meetup page: speaker portraits (400x400), gallery thumbnails (1600x1200). Lightbox <img> left alone (src is set at runtime by JS).

No visual change for end users. Build emits webp/avif with proper srcset.

Tooling

  • sharp added so remote images actually get optimized.
  • 11 remote image domains authorized in astro.config.mjs. www.unicef.org excluded — source returns 403 to the optimizer; logo still renders, just unoptimized.
  • .astro/ added to .gitignore and untracked. 11 stale tracked files removed from the index.

Build impact

Sharp optimizes ~12 remote sources at build. Biggest: 328KB GitHub avatar → 21KB webp. pnpm build stays under 6s.

Test plan

  • pnpm dev and scroll the home page — confirm mission CTA left-aligns, eyebrow labels are small uppercase, partner logos have tighter padding.
  • Hover any .card (stats, program, meetup) — confirm it presses down rather than lifts.
  • Visit a meetup detail page — confirm speaker portraits and gallery photos load via <Image> (no layout shift).
  • pnpm build succeeds; only warnings should be pre-existing remote URL issues.

mhaadiabu added 16 commits June 2, 2026 16:56
The .astro/ directory is regenerated on every build/dev run and contains content schemas, generated types, and the data store. Tracking it causes spurious diffs on every build.
The .btn-mission is inline-flex inside a flex column with default align-items: stretch, so it stretched to full column width and its centered text looked misaligned. align-self: flex-start keeps the button at content width on the left.
font-size referenced --text-s, an undefined CSS variable, so eyebrow labels fell back to inherited 1rem. Switched to --text-xs (0.75rem), the actual small-uppercase label size in the type scale.
AGENTS.md documents that partner logos with a backgroundColor get 8px padding via the has-bg class. The implementation had drifted to 20px. Restored to 8px per spec.
Cards previously lifted on hover (translate -2,-2 and a shadow appeared), which fought the static offset shadows already on .stat-card, .reg-card, and .stream-wrap — the hover shadow stacked on top of the static one and the card jumped in the wrong direction.

Inverted the mechanic: cards now rest with an offset shadow, and on hover they translate by the shadow's offset so the shadow is absorbed into the card — a clean Dodonut-style press. The bouncy cubic-bezier on .card adds a tactile feel without being noisy.

Per-card hover rules were added for the three components that use a larger colored shadow (.stat-card 6px pink, .reg-card 6px black, .stream-wrap 8px pink) so the press exactly absorbs each one.
Allow Astro's image optimizer to fetch and process remote images used across the site (Twitter avatars, GitHub avatars, Slack CDN, partner CDNs). www.unicef.org is intentionally left out — the source URL returns 403 to the optimizer; the partner logo still loads via <Image> without optimization.
Astro's default image service uses sharp to transform and recompress images at build time. Adding it as a direct dependency so remote images can be optimized into webp/avif with proper srcset generation.
Moving logo.png into src/ so Astro can bundle and optimize it. The unused logo-nav.png, logo-sm.png, logo-source.png, and logo@2x.png variants are dropped — they were never referenced anywhere in the codebase.
Replaced raw <img> with <Image> in four files:

- Navbar, Footer, and both meetup nav bars: logo now imports from src/assets/ instead of /images/logo.png. The component infers intrinsic dimensions and lazy-decodes.
- meetups/[slug].astro: speaker portraits use Image at 400x400, and photo gallery thumbnails at 1600x1200 — the sizes those remote sources actually are. The lightbox <img> stays because its src is set at runtime via JS.
Astro's <Image> requires intrinsic width/height for remote sources to prevent layout shift. Adding optional width/height fields to the partner schema so partner logos can declare their real dimensions.
Each partner YAML now declares the natural width/height of its logo. Values come from explicit dimensions in the source URL where present (mest 300x49, old-mutual 960x440, paystack 1600 wide) and from the SVG viewBox for fido (332x96). Kweku and unicef are estimated from visual inspection.
Replaced <img> in PartnersSection with <Image>, passing through the per-partner width/height from the content data (falling back to 300x100 if missing). The backgroundColor inline style and has-bg class flow through to the <Image> output, preserving the tinted logo cards.
Replaced <img> in AdminsSection with <Image>, sized to 400x400 — the natural size of the Twitter avatars used. Width/height attrs now flow through so the cards don't shift on load.
Astro regenerates the .astro/ directory on every build/dev run — content schemas, type definitions, and the data store. It was being tracked from before .gitignore had an entry, so it kept showing up as modified on every build. The directory is already in .gitignore; this just removes the existing tracked files from the index. They'll be regenerated locally on the next dev/build and never pushed.
- Add overflow-x: clip to html and body (clip is stricter than hidden
  and prevents the iOS Safari rubber-band scroll when any descendant
  is wider than the viewport)
- Reduce hero button horizontal padding on mobile (<600px) so the CTAs
  fit within the viewport
- Replace implicit minmax(auto, 1fr) with explicit minmax(0, 1fr) in all
  grid-template-columns — the auto minimum was allowing columns to grow
  past their fr share to fit wide text content, pushing the document
  wider than the viewport
- Center the mission section content on mobile, make the Join CTA
  full-width with a media query restoring left-align and flex-start
  on >=900px
The previous flex layout with fixed height: 100px and width: auto let
wide logos (Paystack 1600x280, MEST 300x49) overflow the viewport on
small screens — they were being cut off by the body overflow clip.

Switched to a responsive grid (2/3/4/6 cols at 0/500/768/1024px) and
constrain each logo with max-width: 100% + max-height: 72px on mobile
(100px on desktop) + width/height auto, so every logo scales to fit
its cell while keeping its aspect ratio.
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.

1 participant