Skip to content
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

fix: v3 - make the container more like other slot prop #5

Merged
merged 3 commits into from
Oct 9, 2023
Merged
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: 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
Loading