Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ env:
jobs:
lint:
name: Static code analysis
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm

steps:
- name: Checkout
Expand All @@ -26,7 +26,7 @@ jobs:

typescript:
name: Type checking
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm

steps:
- name: Checkout
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:

format:
name: Formatting
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm

steps:
- name: Checkout
Expand All @@ -75,7 +75,7 @@ jobs:

unit:
name: Unit tests
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/close-stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
close-issues:
name: Close stale issues
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm

steps:
- name: Close stale issues
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
runs-on: ubuntu-24.04-arm

steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"recommendations": ["biomejs.biome", "eamodio.gitlens"],
"unwantedRecommendations": ["dbaeumer.jshint"]
"recommendations": ["biomejs.biome"],
"unwantedRecommendations": ["dbaeumer.jshint", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
2 changes: 1 addition & 1 deletion packages/react-calendar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"react-dom": "^18.2.0",
"rimraf": "^6.0.0",
"typescript": "^5.5.2",
"vitest": "^2.1.1"
"vitest": "^3.0.5"
},
"peerDependencies": {
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
Expand Down
10 changes: 10 additions & 0 deletions packages/react-calendar/src/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ export type CalendarProps = {
* @example ({ activeStartDate, date, view }) => view === 'month' && date.getDay() === 0 ? <p>It's Sunday!</p> : null
*/
tileContent?: TileContentFunc | React.ReactNode;
/**
* Class name(s) that will be applied to a given calendar item tileContent wrapper (day on month view, month on year view and so on).
*
* @example 'class1 class2'
* @example ['class1', 'class2 class3']
* @example ({ activeStartDate, date, view }) => view === 'month' && date.getDay() === 3 ? 'wednesday' : null
*/
tileContentWrapperClassName?: TileClassNameFunc | ClassName;
/**
* Pass a function to determine if a certain day should be displayed as disabled.
*
Expand Down Expand Up @@ -653,6 +661,7 @@ const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttribu
showWeekNumbers,
tileClassName,
tileContent,
tileContentWrapperClassName,
tileDisabled,
value: valueProps,
view: viewProps,
Expand Down Expand Up @@ -1021,6 +1030,7 @@ const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttribu
onMouseOver: selectRange ? onMouseOver : undefined,
tileClassName,
tileContent,
tileContentWrapperClassName,
tileDisabled,
value,
valueType,
Expand Down
21 changes: 20 additions & 1 deletion packages/react-calendar/src/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ type TileProps = {
* @example ({ activeStartDate, date, view }) => view === 'month' && date.getDay() === 0 ? <p>It's Sunday!</p> : null
*/
tileContent?: TileContentFunc | React.ReactNode;
/**
* Class name(s) that will be applied to a given calendar item tileContent wrapper (day on month view, month on year view and so on).
*
* @example 'class1 class2'
* @example ['class1', 'class2 class3']
* @example ({ activeStartDate, date, view }) => view === 'month' && date.getDay() === 3 ? 'wednesday' : null
*/
tileContentWrapperClassName?: TileClassNameFunc | ClassName;

/**
* Pass a function to determine if a certain day should be displayed as disabled.
*
Expand Down Expand Up @@ -91,6 +100,7 @@ export default function Tile(props: TileProps): React.ReactElement {
style,
tileClassName: tileClassNameProps,
tileContent: tileContentProps,
tileContentWrapperClassName: tileContentWrapperClassNameProps,
tileDisabled,
view,
} = props;
Expand All @@ -107,6 +117,13 @@ export default function Tile(props: TileProps): React.ReactElement {
return typeof tileContentProps === 'function' ? tileContentProps(args) : tileContentProps;
}, [activeStartDate, date, tileContentProps, view]);

const tileContentWrapperClassName = useMemo(() => {
const args = { activeStartDate, date, view };

return typeof tileContentWrapperClassNameProps === 'function' ? tileContentWrapperClassNameProps(args) : tileContentWrapperClassNameProps;
}, [activeStartDate, date, tileContentWrapperClassNameProps, view]);


return (
<button
className={clsx(classes, tileClassName)}
Expand All @@ -122,7 +139,9 @@ export default function Tile(props: TileProps): React.ReactElement {
type="button"
>
{formatAbbr ? <abbr aria-label={formatAbbr(locale, date)}>{children}</abbr> : children}
{tileContent}
<div className={clsx(tileContentWrapperClassName)}>
{tileContent}
</div>
</button>
);
}
4 changes: 2 additions & 2 deletions sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.2.0",
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.0.0",
"vite": "^5.0.0"
"vite": "^6.0.0"
}
}
Loading