Skip to content

feat(comparison): add 1-click preset chips to home page empty state - #224

Merged
O2sa merged 2 commits into
O2sa:mainfrom
1-DARK:feature/comparison-presets
Oct 8, 2026
Merged

O2sa merged 2 commits into
O2sa:mainfrom
1-DARK:feature/comparison-presets

Conversation

@1-DARK

@1-DARK 1-DARK commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds clickable example-comparison chips under the compare form so first-time visitors can see the product in action with one click and zero typing.

Closes #220

Changes

  • config/comparison-presets.ts: new curated list of well-known open-source developer pairs (username pair + translation key per preset),
    plus an exported ComparisonPreset type.
  • components/preset-pills.tsx: new accessible chip list component (native <button> elements, labelled section, aria-busy while loading).
  • components/home-page-client.tsx : renders the chips directly under CompareForm while no comparison result is shown. Clicking a chip fills username1/username2 and calls handleCompare with the preset values directly (not via state, to avoid stale values), respecting the currently selected languages.
  • locales/en.json, locales/ar.json: added presets.title and a label key for each preset.

Behavior

  • Chips are shown under the form when there is no result (!displayData), including after an error so users can recover with one click.
  • Clicking a chip fills both inputs and runs the same comparison flow as the form submit, including the URL sync.
  • While loading, chips are disabled and the clicked chip shows a spinner.
  • Chips disappear once results are displayed.

Accessibility

  • Native <button type="button">: Tab to focus, Enter/Space to activate.
  • Visible focus-visible ring using theme tokens.
  • Section labelled via aria-labelledby; list marked aria-busy during load.
  • Transitions respect prefers-reduced-motion (motion-reduce).

i18n

  • New keys added to both en.json and ar.json.
  • Verified RTL layout in Arabic (flex wrapping flips correctly).

Testing

  • ✅ pnpm validate-locales
  • ✅ pnpm test
  • ✅ npx tsc --noEmit
  • ✅ pnpm lint / pnpm format:check
  • ✅ pnpm build
  • ✅ Manual: clicking each chip fills both inputs and loads the comparison
  • ✅ Manual: URL updates and only one /api/compare request is made per click
  • ✅ Manual: keyboard-only flow (Tab to chip, Enter and Space both work)
  • ✅ Manual: chips disabled with spinner during loading; hidden after results
  • ✅ Manual: works in light/dark theme and in EN/AR

Screenshots

State English (LTR) Arabic (RTL)
Empty state with preset chips image image
Results shown (chips hidden) image image

Light / dark

Light Dark
image image

@vercel

vercel Bot commented Oct 7, 2026

Copy link
Copy Markdown

@1-DARK is attempting to deploy a commit to the osama's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Thank you for the pull request! ✅

A maintainer will review this soon. Please be patient while we take a look. 🙌

@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
dev-impact Ready Ready Preview Oct 8, 2026 7:19pm UTC

@O2sa O2sa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

One change I'd request before merging: this PR currently includes commit 3bd5737 (feat(profile): add Get README Badge dialog...), which belongs to PR #223. GitHub shows both commits as part of this PR, and user-profile-client.tsx is therefore included in the changed files.

Please rebase/clean up the branch against main so PR #224 contains only the comparison preset changes. This will keep the PR isolated and prevent the changes from #223 from being merged through this PR.

The preset implementation itself looks good to me.

@1-DARK
1-DARK force-pushed the feature/comparison-presets branch from 2dca45d to 8f04133 Compare October 8, 2026 05:02
@1-DARK
1-DARK requested a review from O2sa October 8, 2026 05:02
@1-DARK
1-DARK force-pushed the feature/comparison-presets branch from 8f04133 to 738b2ca Compare October 8, 2026 05:14
@O2sa
O2sa merged commit a539b0e into O2sa:main Oct 8, 2026
0 of 2 checks passed
@O2sa

O2sa commented Oct 8, 2026

Copy link
Copy Markdown
Owner

✨ Thank you, @1-DARK! Another great contribution merged! 🚀

We truly appreciate your continued support! If you find this tool useful, please consider giving us a ⭐ star on GitHub—it helps more developers find our work and motivates us to keep improving!

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.

feature: Add 1-click comparison preset chips on Homepage Empty State

2 participants