feat(calendar): add custom cell content
Closes #
📝 Description
This PR adds the ability to render custom content in calendar cells. It introduces a new renderCellContent prop that allows developers to specify custom content for each calendar cell.
⛳️ Current behavior (updates)
Currently, the calendar cells render only the default formatted date content, and there is no way to customize the content within each cell.
🚀 New behavior
With this PR, developers can pass a renderCellContent function as a prop to the Calendar component. This function receives the date of the cell and allows custom content to be rendered within the cell. If renderCellContent is not provided, the cell will fall back to rendering the default formatted date.
💣 Is this a breaking change (Yes/No):
No
📝 Additional Information
This update enhances the flexibility and customizability of the calendar component, allowing for a wide range of use cases where specific content needs to be displayed within calendar cells.
Summary by CodeRabbit
-
New Features
- Added
renderCellContentprop to theCalendarandRangeCalendarcomponents, enabling custom rendering of cell content.
- Added
-
Documentation
- Updated stories to demonstrate usage of the new
renderCellContentfeature.
- Updated stories to demonstrate usage of the new
🦋 Changeset detected
Latest commit: 448ab55c773ef02423c1c9192c75702896cc2d57
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 3 packages
| Name | Type |
|---|---|
| @nextui-org/calendar | Minor |
| @nextui-org/date-picker | Patch |
| @nextui-org/react | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| nextui-storybook-v2 | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 29, 2024 3:55am |
@1amageek is attempting to deploy a commit to the NextUI Inc Team on Vercel.
A member of the Team first needs to authorize it.
[!IMPORTANT]
Review skipped
More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.
214 files out of 279 files are above the max files limit of 50. Please upgrade to Pro plan to get higher limits.
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
The recent updates introduced a renderCellContent prop across various components of the calendar package. This new optional property allows developers to customize the content rendered within each calendar cell by providing a function that returns React.ReactNode. This enhancement spans multiple files, adding this functionality to the Calendar, RangeCalendar, and related components such as CalendarMonth, CalendarBase, and CalendarCell.
Changes
| Files/Groups | Change Summary |
|---|---|
packages/components/calendar/src/calendar-base.tsx |
Added renderCellContent to CalendarBaseProps, updated props destructuring, and passed it down to CalendarMonth. |
packages/components/calendar/src/calendar-cell.tsx |
Added renderCellContent to CalendarCellProps, updated rendering logic to use it, and changed the wrapper element. |
packages/components/calendar/src/calendar-month.tsx |
Added renderCellContent prop to customize cell content in the calendar grid. |
packages/components/calendar/src/calendar.tsx |
Included renderCellContent in Props for custom cell content rendering in the Calendar component. |
packages/components/calendar/src/use-calendar.ts |
Added renderCellContent to the props of useCalendar function, enabling cell content customization. |
packages/components/calendar/src/use-range-calendar.ts |
Included renderCellContent in Props for useRangeCalendar, allowing custom rendering of cell content. |
packages/components/calendar/stories/calendar.stories.tsx |
Introduced a new exported entity CustomCellContent for demonstrating custom cell content in stories. |
packages/components/calendar/stories/range-calendar.stories.tsx |
Added CustomCellContent demonstrating custom cell rendering in range-calendar.stories.tsx. |
.changeset/popular-seals-appear.md |
Documented the addition of the renderCellContent prop to enhance the Calendar and RangeCalendar components and noted updates to tests to validate this feature. |
Sequence Diagram(s)
sequenceDiagram
participant Developer as Developer
participant Calendar as Calendar Component
participant CalendarMonth as CalendarMonth Component
participant CalendarCell as CalendarCell Component
Developer->>Calendar: Adds `renderCellContent` prop
Calendar->>CalendarMonth: Passes `renderCellContent` prop
CalendarMonth->>CalendarCell: Passes `renderCellContent` prop with date
CalendarCell->>renderCellContent: Calls rendering function with date
renderCellContent-->>CalendarCell: Custom content as `ReactNode`
CalendarCell-->>CalendarMonth: Returns custom content
CalendarMonth-->>Calendar: Renders custom content in calendar
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai generate interesting stats about this repository and render them as a table.@coderabbitai show all the console.log statements in this repository.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@wingkwong I have addressed your change requests. Please take a look when you get a chance.
@1amageek mark it in 2.5.0 first. will review again after 2.4.3.