-
-
Notifications
You must be signed in to change notification settings - Fork 474
docs: add missing controlled datepicker example #1640
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
docs: add missing controlled datepicker example #1640
Conversation
…by adding the missing datepicker.value.tsx example file that demonstrates controlled datepicker usage with value prop and ability to clear by passing null
|
|
@SarthakAltudo is attempting to deploy a commit to the Themesberg Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughAdds a new client-side React example implementing a controlled Datepicker component with helper buttons and exported example metadata, and re-exports that metadata from the example index. (No other behavioral changes.) Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/examples/datepicker/datepicker.value.tsx (1)
1-69: Resolve Prettier/code style warning from CICI reports a Prettier/style issue for this file. Please run the repo’s formatter (for example,
pnpm lintor Prettier with--writeas configured here) to normalize formatting before merging, rather than formatting manually.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/web/examples/datepicker/datepicker.value.tsx(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-07-27T04:19:32.056Z
Learnt from: rluders
Repo: themesberg/flowbite-react PR: 1314
File: packages/ui/src/components/Datepicker/helpers.ts:112-119
Timestamp: 2024-07-27T04:19:32.056Z
Learning: The `getFormattedDate` function in `packages/ui/src/components/Datepicker/helpers.ts` should use `DateFNSFormat` directly with the date and format string for proper localization support, mapping language codes to locale objects from `date-fns/locale`.
Applied to files:
apps/web/examples/datepicker/datepicker.value.tsx
🧬 Code graph analysis (1)
apps/web/examples/datepicker/datepicker.value.tsx (2)
packages/ui/src/components/Button/Button.tsx (1)
Button(65-109)apps/web/components/code-demo.tsx (1)
CodeData(48-48)
🪛 GitHub Actions: CI
apps/web/examples/datepicker/datepicker.value.tsx
[warning] 1-1: Code style issues found in the above file. Run Prettier with --write to fix.
🔇 Additional comments (3)
apps/web/examples/datepicker/datepicker.value.tsx (3)
7-35: Stringified example matches the live component usageThe
codestring mirrors the liveComponentimplementation and clearly demonstrates a controlled Datepicker withvalueandonChange, plus "Set to Today" and "Clear" actions. This should render well in the docs as a self-contained snippet.
37-58: Controlled Datepicker behavior looks correctThe component correctly models a controlled Datepicker:
selectedDatestate,value={selectedDate},onChange={setSelectedDate}, and safe rendering ofselectedDate.toLocaleDateString()behind a truthy check. The "Set to Today" and "Clear" buttons exercise both non-null andnullvalues, which aligns with the controlled example the docs describe.
60-69: CodeData export aligns with docs infra expectationsThe
value: CodeDataobject usestype: "single", provides the TSX code, agithubSlugmatching the file path, and an actual<Component />instance. This is consistent with how other examples are wired and should allow<Example name="datepicker.value" />to resolve and render correctly.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thanks for the contribution! |
SutuSebastian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to export the newly created demo file in apps/web/examples/datepicker/index.ts like:
export { value } from "./datepicker.value";
SutuSebastian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run bun run format to format the files
Hi @SutuSebastian I'm unable to run |
|
@SarthakPandey2002 that's actually a bug, good catch! to by-pass ur issue, in from !path.includes(tailwindPluginCssFile)to !path.replace(/\\/g, "/").includes(tailwindPluginCssFile)and run the format command again |
|
@SutuSebastian formatting changes done |
SutuSebastian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!

Description
Adds the missing controlled datepicker example that was referenced in the documentation but not rendering.
Fixes
Closes #1588
Changes
datepicker.value.tsxexample file demonstrating:valueproponChangehandler with state managementnullwith "Clear" buttonSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.