Skip to content

Commit

Permalink
Merge pull request #5 from knightburton/fix/v3-root
Browse files Browse the repository at this point in the history
fix: v3 - make the container more like other slot prop
  • Loading branch information
knightburton authored Oct 9, 2023
2 parents 07aab5a + 6d547e1 commit 8d28867
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ For more detailed example check the [example](./example) directory.
#### Slots
```ts
type Slots = {
container?: {
root?: React.ElementType;
};
root?: React.ElementType;
header?: {
root?: React.ElementType;
cell?: React.ElementType;
Expand All @@ -104,9 +102,7 @@ type Slots = {
#### Slot Props
```ts
type SlotProps = {
container?: {
root?: Partial<React.ComponentPropsWithRef<'div'>>;
};
root?: Partial<React.ComponentPropsWithRef<'div'>>;
header?: {
root?: Partial<React.ComponentPropsWithRef<'ul'>> & { disabled?: boolean };
cell?: Partial<React.ComponentPropsWithRef<'li'>>;
Expand Down
4 changes: 2 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ const App = () => (
onCellClick={cell => console.log(cell)}
bodyCellContentComponent={({ data }) => <span className={`${data.isMonthEven ? 'evenMonth' : ''} ${data.isToday ? 'today' : ''}`}>{getLabel(data)}</span>}
slots={{
container: { root: Container },
root: Container,
header: { cellContent: HeaderCellContent },
}}
slotProps={{
container: { root: { className: 'example-container', style: { height: 700 } } },
root: { className: 'example-container', style: { height: 700 } },
}}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ContainerPrivateProps = {
root?: React.ElementType;
};
slotProps?: {
root: ContainerProps;
root?: ContainerProps;
};
children?: React.ReactNode;
};
Expand Down
8 changes: 4 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useCallback, useMemo, useState } from 'react';
import { getCalendarBaseAttributes } from './helpers';
import { CalendarTuple, VisibilityMatrix, WeekdayIndex, BodyCellType } from './types';
import Container, { ContainerProps, ContainerPrivateProps } from './components/Container';
import Container, { ContainerProps } from './components/Container';
import Header, { HeaderProps, HeaderPrivateProps, HeaderCellContentProps, HeaderCellProps } from './components/Header';
import Body from './components/Body';
import { BodyContainerProps } from './components/BodyContainer';
Expand All @@ -25,12 +25,12 @@ type ClassNames = {
};

type Slots = {
container?: ContainerPrivateProps['slots'];
root?: React.ElementType;
header?: HeaderPrivateProps['slots'];
};

type SlotProps = {
container?: ContainerPrivateProps['slotProps'];
root?: ContainerProps;
header?: HeaderPrivateProps['slotProps'];
};

Expand Down Expand Up @@ -88,7 +88,7 @@ const IntervalCalendar = ({
);

return (
<Container slots={slots?.container} slotProps={slotProps?.container}>
<Container slots={{ root: slots?.root }} slotProps={{ root: slotProps?.root }}>
<Header weekStartsOn={weekStartsOn} locale={locale} slots={slots?.header} slotProps={slotProps?.header} />
{!!numberOfWeeks && !!startDate ? (
<Body
Expand Down

0 comments on commit 8d28867

Please sign in to comment.