Skip to content

Feature/chapter read time badge#431

Open
DharshiniPujarolla wants to merge 8 commits into
MRIARC-08:mainfrom
DharshiniPujarolla:feature/chapter-read-time-badge
Open

Feature/chapter read time badge#431
DharshiniPujarolla wants to merge 8 commits into
MRIARC-08:mainfrom
DharshiniPujarolla:feature/chapter-read-time-badge

Conversation

@DharshiniPujarolla

@DharshiniPujarolla DharshiniPujarolla commented Jun 25, 2026

Copy link
Copy Markdown

Closes #408

Summary

Adds a small "Estimated Read Time" badge to each chapter card, calculated client-side from chapter.content using words / 200 (avg. reading speed).

Changes

  • Added getReadTime(content?: string | null): number | null helper
  • Extended ChapterType with content?: string | null
  • Renders a 📖 ~X min read badge per chapter card, styled with bg-primary/10 / text-primary/70 rounded-pill, consistent with existing conventions in this file
  • Badge hides gracefully when content is null, empty, or whitespace-only

Testing

Verified getReadTime() directly:

  • 850-word content → 5 (Math.ceil(850/200))
  • Empty string → null
  • nullnull
  • Whitespace-only string → null

Confirmed content is included in the /api/ncert/chapters response — repository uses include: { chapters: true } with no field-level select, so no backend changes needed.

Full in-browser visual check was blocked locally by a Google OAuth client_id config issue (unrelated to this change). JSX conditional follows the same pattern as existing conditional UI in this file.

Notes

  • No backend/schema changes
  • .gitignore updated to exclude .idea/

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

@DharshiniPujarolla is attempting to deploy a commit to the Adarsh's projects Team on Vercel.

A member of the Team first needs to authorize it.

@DharshiniPujarolla

DharshiniPujarolla commented Jun 25, 2026

Copy link
Copy Markdown
Author

Hi @MRIARC-08 ,
I have done closed the previous pr's and have done the necessary changes.
Please review this pr and let me know if there are any changes
Thank you

@MRIARC-08 MRIARC-08 added gssoc gssoc level:beginner GSSoC difficulty: beginner type:design Design or UI related contribution labels Jun 27, 2026

@MRIARC-08 MRIARC-08 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.

@DharshiniPujarolla Thanks for reopening this. Please clean up the branch before review: pnpm-lock.yaml should not remove the repo security overrides or update the dependency tree for a read-time badge, and the touched page still has Prettier errors. Keep the PR focused on src/app/ncert/[class]/[subject]/page.tsx, run the formatter, and push the result.

@DharshiniPujarolla

Copy link
Copy Markdown
Author

@MRIARC-08,
thanks for the detailed feedback! I've cleaned up the branch:
pnpm-lock.yaml — confirmed no changes here; the security overrides and dependency tree are untouched.
.gitignore — reverted the stray pnpm-workspace.yaml entry that had snuck in.
page.tsx — ran Prettier on src/app/ncert/[class]/[subject]/page.tsx, formatting errors are resolved.
Please reviews this PR.

@DharshiniPujarolla

Copy link
Copy Markdown
Author

@MRIARC-08 can you please go through the changes when you have time and let me know if there is anything i need to do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc gssoc level:beginner GSSoC difficulty: beginner type:design Design or UI related contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UI] Add Estimated Read Time Badge to Chapter Cards

2 participants