Skip to content

feat(repos): add sort options (stars/forks/recently updated) to Popular Repositories#203

Open
Adit-Jain-srm wants to merge 2 commits into
PRODHOSH:mainfrom
Adit-Jain-srm:feat/144-repo-sort-options
Open

feat(repos): add sort options (stars/forks/recently updated) to Popular Repositories#203
Adit-Jain-srm wants to merge 2 commits into
PRODHOSH:mainfrom
Adit-Jain-srm:feat/144-repo-sort-options

Conversation

@Adit-Jain-srm

@Adit-Jain-srm Adit-Jain-srm commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds sort controls to the Popular Repositories section so users can reorder by stars, forks, or most recently updated.

Related Issue

Closes #144

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Chore / dependency update

Changes Made

Single file: src/components/profile/ProfileView.tsx

  1. Added pushed_at?: string to GitHubRepo interface (GitHub REST API always returns this field)
  2. Added repoSort state variable (stars/forks/updated, defaults to stars)
  3. Replaced the "Popular repositories" heading with a heading + pill sort buttons row
  4. Sort is applied client-side using [...repos].sort() on a copy (never mutates the prop)
  5. Pill buttons use the same green/grey style as the year navigation pills (DESIGN.md pill-tag-green for active, pill-tag-soft for inactive)

AI Usage

  • I did not use AI for any part of the code in this PR
  • I used AI for coding (Cursor with Claude) and I fully understand every change I made, including which functions I changed, why I changed them, and what side effects they could create

The sort creates a shallow copy with spread to avoid mutating the prop. pushed_at is an ISO date string so localeCompare gives correct chronological ordering. Stars/forks use numeric subtraction for descending sort.

Screenshots (if UI change)

Three small pill buttons ("Stars" | "Forks" | "Recent") appear to the right of the "Popular repositories" heading. The active one is green, inactive ones are grey with a hairline border.

Checklist

  • I was assigned to the issue before opening this PR
  • My branch is up to date with main
  • Code works locally and I have tested it
  • No console.log left in src/
  • If schema changed - both schema.sql and a new migration file are included
  • If this is a UI change - I read DESIGN.md and followed the design system (colors, spacing, typography, components)
  • Docs updated if needed
  • PR title follows Conventional Commits format (feat:, fix:, docs:, etc.)
  • This PR description is written in my own words

Summary by CodeRabbit

  • New Features
    • Added pill-style sorting controls to the “Popular repositories” section.
    • Users can reorder repositories by Stars, Forks, or Most Recent (“Recent”).
  • UI Improvements
    • Updated the repositories header layout to align the sorting options alongside the title in a single row.

…ar Repositories (Closes PRODHOSH#144)

Adds three pill-style sort buttons above the repo grid. Sorting is client-side using Array.sort() on a copy of the repos prop. Default is stars descending. Added pushed_at to GitHubRepo interface (already returned by GitHub REST API). Pill style matches DESIGN.md pill-tag-green/soft pattern.

Signed-off-by: Adit Jain <aditjain2005@gmail.com>
@github-actions github-actions Bot added frontend Related to UI / Next.js UI Visual / design changes labels Jun 25, 2026
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6b28bcdb-7179-4147-8fc1-9f15509965eb

📥 Commits

Reviewing files that changed from the base of the PR and between 5f11cd0 and f072668.

📒 Files selected for processing (1)
  • src/components/profile/ProfileView.tsx

📝 Walkthrough

Walkthrough

ProfileView now lets “Popular repositories” be reordered on the client by stars, forks, or recent activity. The component tracks the selected sort mode in state, adds sort toggles in the section header, and renders the repositories from a sorted copy.

Changes

Popular repositories sorting

Layer / File(s) Summary
Sort state and repo field
src/components/profile/ProfileView.tsx
GitHubRepo gains optional pushed_at, and ProfileView tracks the active sort mode in repoSort.
Sort controls and list ordering
src/components/profile/ProfileView.tsx
The popular repositories header renders Stars/Forks/Recent toggle buttons, and the repo list is rendered from a sorted copy using stars, forks, or pushed_at.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PRODHOSH/ossfolio#128: Also changes src/components/profile/ProfileView.tsx around the “Popular repositories” section, including header behavior and conditional rendering.

Suggested reviewers

  • PRODHOSH

Poem

Hop, hop—three buttons gleam tonight,
Stars, forks, recent, all in sight.
I sort the pile with a twitch of nose,
And every repo takes its pose.
🐰✨ The freshest hops now lead the row.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding repository sort options for stars, forks, and recent updates.
Linked Issues check ✅ Passed The PR appears to satisfy #144 by adding client-side sort toggles, default stars ordering, copy-based sorting, and recent-updated support.
Out of Scope Changes check ✅ Passed The changes stay focused on the Popular Repositories sort UI and related data support, with no clear unrelated additions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@Adit-Jain-srm

Copy link
Copy Markdown
Contributor Author

Could you add the elusoc label? Issue #144 has ELUSOC + ADVENTURER. Thanks!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/profile/ProfileView.tsx`:
- Around line 812-830: The repo sort buttons in ProfileView behave like a
single-select toggle group, but the current active state is not exposed to
assistive tech. Update the button group rendered in ProfileView so it has a
clear label and each button reflects its selected state via aria-pressed, using
the existing repoSort and setRepoSort logic to keep the active mode announced by
screen readers.
- Around line 842-846: The sort in ProfileView is being applied after the repo
list has already been trimmed to six items, so Forks and Recent can only reorder
the existing star-biased subset. Move the top-6 cutoff out of the fetch path in
the [username] page so ProfileView receives the full repo list, then let
ProfileView’s repoSort-based sort run before any slicing; use the existing
ProfileView map block and the repos handling in the page component as the fix
points.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 85c8bed3-3ee4-4a0d-b1c2-b198f81d9a26

📥 Commits

Reviewing files that changed from the base of the PR and between 40f062c and 5f11cd0.

📒 Files selected for processing (1)
  • src/components/profile/ProfileView.tsx

Comment thread src/components/profile/ProfileView.tsx Outdated
Comment thread src/components/profile/ProfileView.tsx
Signed-off-by: Adit Jain <aditjain2005@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Related to UI / Next.js UI Visual / design changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add sort options (stars / forks / recently updated) to Popular Repositories

1 participant