-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(calendar): add custom cell content to Calendar #3554
Open
1amageek
wants to merge
32
commits into
heroui-inc:canary
Choose a base branch
from
1amageek:canary
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+821
−86
Open
Changes from 25 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a24b443
feat(calendar): add custom cell content
1amageek 487be5e
refactor(calendar-cell): add useRef hook to improve performance
1amageek 7a0fa5c
refactor: improve CalendarCell by destructuring props and adding type…
1amageek a449568
test(calendar): add test for custom cell content in Calendar and Rang…
1amageek 0218de1
chore: add changeset for custom cell content feature in Calendar and …
1amageek 4d40ddd
refactor: use shared template component for custom cell content in ca…
1amageek c0f2b34
feat: add calendar width and custom cell templates for calendar and r…
1amageek 448ab55
feat(calendar): add renderCellContent prop for custom cell content
1amageek 9445d2b
feat(calendar): move renderCellContent to context
1amageek 930d4af
feat(calendar): add cell components and context management
1amageek 9fc7840
feat(calendar): implement custom cell content rendering
1amageek b327e40
feat(docs): add custom cell content examples for calendar components
1amageek b2fcf12
fix(theme): correct typo in calendar cellBody height class
1amageek 39dd82c
Merge branch 'canary' into canary
1amageek 0f22c26
feat(calendar): add day of week calculation to CalendarCell component
1amageek 2ae85a9
refactor(calendar): improve calendar cell components and remove unuse…
1amageek 01b3ba2
feat(calendar): update components to use CalendarCellHeader
1amageek 874af0b
refactor(theme): update gridBodyRow styles for better spacing
1amageek e814634
refactor(calendar): integrate CalendarCellHeader into calendar cell c…
1amageek 24ccded
feat(calendar): add support for custom cell content in calendar compo…
1amageek 1cd1d21
feat(calendar): add role and aria-label to birthday events
1amageek 8902936
feat(calendar): add calendar cell components and context support
1amageek 84a85d7
feat(calendar): add calendar cell components and context support
1amageek 9e6ca20
feat(calendar): update documentation
1amageek 9091f51
chore: update changelog for calendar customization
1amageek b920894
feat(calendar): add calendar cell
1amageek a16dcf4
fix(calendar): fix conflicts
1amageek 5b46ae7
fix(calendar): fix conflicts
1amageek 6a20973
Merge branch 'canary' into canary
1amageek b62c31c
fix(calendar): calendar-cell-header
1amageek 0d443a0
fix(calendar): heroui
1amageek e405bc4
fix(calendar): remove
1amageek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@nextui-org/calendar": minor | ||
--- | ||
|
||
Added the `renderCellContent` prop to the `Calendar` and `RangeCalendar` components, allowing developers to specify custom content for each calendar cell. Updated the existing tests and added new test cases to cover the custom cell content functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
"@nextui-org/calendar": major | ||
--- | ||
|
||
### Changes | ||
- Added support for customizing calendar cells. | ||
- You can now use `children` to customize the content of calendar cells. | ||
- The default structure of calendar cells has been updated to improve flexibility. | ||
|
||
### Breaking Changes | ||
- **WHAT**: The following changes might affect existing implementations: | ||
1. Style class names have been renamed (e.g., `cellButton` → `cellHeader`). | ||
2. The internal structure of calendar cells has changed, which may cause existing styles to no longer apply. | ||
- **WHY**: These changes were made to provide better flexibility and support for modern styling and customization. | ||
- **HOW**: | ||
1. If you are using custom styles, update the class names to the new ones. | ||
2. Use `children` to customize the content of calendar cells. | ||
3. Refer to the example below for implementation: | ||
Comment on lines
+10
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as you mentioned there is no breaking change in previous comment. please revise. |
||
|
||
```jsx | ||
<Calendar> | ||
{(date) => ( | ||
<div style={{ backgroundColor: "lightblue" }}> | ||
<span>{date.day}</span> | ||
</div> | ||
)} | ||
</Calendar> | ||
``` |
50 changes: 50 additions & 0 deletions
50
apps/docs/content/components/calendar/custom-cell-content.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from "react"; | ||
import { | ||
Calendar, | ||
CalendarCellContent, | ||
CalendarCellHeader, | ||
CalendarCellBody, | ||
} from "@nextui-org/react"; | ||
|
||
export default function App() { | ||
return ( | ||
<Calendar calendarWidth={400}> | ||
{(date) => ( | ||
<CalendarCellContent> | ||
<CalendarCellHeader /> | ||
<CalendarCellBody> | ||
<div className="flex flex-col w-full text-tiny gap-0.5 px-0.5"> | ||
{date.day % 7 === 0 && ( | ||
<span | ||
aria-label="Calendar event" | ||
className="bg-red-500/20 w-full rounded-md px-1 text-red-400 line-clamp-1" | ||
role="status" | ||
> | ||
MTG | ||
</span> | ||
)} | ||
{date.day % 5 === 0 && ( | ||
<span | ||
aria-label="calendar event" | ||
className="bg-green-500/20 w-full rounded-md px-1 text-green-400 line-clamp-1" | ||
role="status" | ||
> | ||
MTG | ||
</span> | ||
)} | ||
{date.day % 3 === 0 && ( | ||
<span | ||
aria-label="calendar event" | ||
className="bg-yellow-500/20 w-full rounded-md px-1 text-yellow-400 line-clamp-1" | ||
role="status" | ||
> | ||
MTG | ||
</span> | ||
)} | ||
1amageek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</CalendarCellBody> | ||
</CalendarCellContent> | ||
)} | ||
</Calendar> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
apps/docs/content/components/calendar/custom-cell-content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import App from "./custom-cell-content.raw.jsx?raw"; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
apps/docs/content/components/range-calendar/custom-cell-content.raw.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
RangeCalendar, | ||
CalendarCellContent, | ||
CalendarCellHeader, | ||
CalendarCellBody, | ||
} from "@nextui-org/react"; | ||
|
||
export default function App() { | ||
return ( | ||
<RangeCalendar calendarWidth={400}> | ||
{(date) => ( | ||
<CalendarCellContent> | ||
<CalendarCellHeader /> | ||
<CalendarCellBody> | ||
<div className="flex flex-col w-full text-tiny gap-0.5 px-0.5"> | ||
{date.day % 7 === 0 && ( | ||
<span | ||
aria-label="calendar event" | ||
className="bg-red-500/20 w-full rounded-md px-1 text-red-400 line-clamp-1" | ||
role="status" | ||
> | ||
MTG | ||
</span> | ||
)} | ||
{date.day % 5 === 0 && ( | ||
<span | ||
aria-label="calendar event" | ||
className="bg-green-500/20 w-full rounded-md px-1 text-green-400 line-clamp-1" | ||
role="status" | ||
> | ||
MTG | ||
</span> | ||
)} | ||
{date.day % 3 === 0 && ( | ||
<span | ||
aria-label="calendar event" | ||
className="bg-yellow-500/20 w-full rounded-md px-1 text-yellow-400 line-clamp-1" | ||
role="status" | ||
> | ||
MTG | ||
</span> | ||
)} | ||
</div> | ||
</CalendarCellBody> | ||
</CalendarCellContent> | ||
)} | ||
</RangeCalendar> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
apps/docs/content/components/range-calendar/custom-cell-content.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import App from "./custom-cell-content.raw.jsx?raw"; | ||
|
||
const react = { | ||
"/App.jsx": App, | ||
}; | ||
|
||
export default { | ||
...react, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
change to patch