Skip to content

Commit

Permalink
customRowHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
asim-majumder committed Nov 6, 2023
1 parent fa77fb8 commit b48ac34
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/bpk-component-scrollable-calendar/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const DefaultExampleWithCustomHeight = () => (
type: CALENDAR_SELECTION_TYPE.single,
date: new Date(2020, 3, 15),
}}
rowHeight={3}
customRowHeight={3}
/>
);

Expand Down
6 changes: 3 additions & 3 deletions packages/bpk-component-calendar/src/BpkCalendarContainer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type Props = {
initiallyFocusedDate?: Date | null;
markToday?: boolean;
markOutsideDays?: boolean;
rowHeight?: number;
customRowHeight?: number;
};
type InjectedProps = {
onDateClick: ((date: Date) => void) | null;
Expand Down Expand Up @@ -106,7 +106,7 @@ declare const withCalendarState: <P extends object>(Calendar: ComponentType<P>)
initiallyFocusedDate: null;
markToday: boolean;
markOutsideDays: boolean;
rowHeight?: number;
customRowHeight?: number;
};
contextType?: import("react").Context<any> | undefined;
};
Expand Down Expand Up @@ -159,7 +159,7 @@ declare const _default: {
initiallyFocusedDate: null;
markToday: boolean;
markOutsideDays: boolean;
rowHeight?: number;
customRowHeight?: number;
};
contextType?: import("react").Context<any> | undefined;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type Props = {
initiallyFocusedDate?: Date | null;
markToday?: boolean;
markOutsideDays?: boolean;
rowHeight?: number;
customRowHeight?: number;
};

type InjectedProps = {
Expand Down
2 changes: 1 addition & 1 deletion packages/bpk-component-calendar/src/composeCalendar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export type Props = {
preventKeyboardFocus?: boolean;
selectionConfiguration?: SelectionConfiguration;
gridClassName?: string | null;
rowHeight?: number;
customRowHeight?: number;
/**
* Key to be used to pick the desired weekDay format from the `daysOfWeek` object, for example: `nameAbbr` or `nameNarrow`.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/bpk-component-calendar/src/composeCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export type Props = {
preventKeyboardFocus?: boolean;
selectionConfiguration?: SelectionConfiguration;
gridClassName?: string | null;
rowHeight?: number;
customRowHeight?: number;
/**
* Key to be used to pick the desired weekDay format from the `daysOfWeek` object, for example: `nameAbbr` or `nameNarrow`.
*/
Expand Down Expand Up @@ -117,6 +117,7 @@ const composeCalendar = (
const BpkCalendar = ({
changeMonthLabel = null,
className = null,
customRowHeight,
dateModifiers = {},
dateProps = {},
daysOfWeek,
Expand All @@ -140,7 +141,6 @@ const composeCalendar = (
onMonthChange = null,
preventKeyboardFocus = false,
previousMonthLabel = null,
rowHeight,
selectionConfiguration = {
type: CALENDAR_SELECTION_TYPE.single,
date: null,
Expand Down Expand Up @@ -218,7 +218,7 @@ const composeCalendar = (
className={gridClasses.join(' ')}
dateProps={dateProps}
selectionConfiguration={selectionConfiguration}
rowHeight={rowHeight}
customRowHeight={customRowHeight}
{...gridProps}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('BpkCalendarScrollGridList', () => {
expect(asFragment()).toMatchSnapshot();
});

it('should render correctly with a custom "rowHeight" attribute', () => {
it('should render correctly with a custom "customRowHeight" attribute', () => {
const { asFragment } = render(
<BpkScrollableCalendarGridList
minDate={DateUtils.addDays(testDate, -1)}
Expand All @@ -90,7 +90,7 @@ describe('BpkCalendarScrollGridList', () => {
formatDateFull={formatDateFull}
DateComponent={BpkCalendarScrollDate}
weekStartsOn={0}
rowHeight={3}
customRowHeight={3}
/>,
);
expect(asFragment()).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Props = Partial<BpkCalendarGridProps> & {
focusedDate?: Date | null;
selectionConfiguration?: SelectionConfiguration;
className?: string | null;
rowHeight?: number;
customRowHeight?: number;
};
declare const BpkScrollableCalendarGridList: (props: Props) => JSX.Element;
export default BpkScrollableCalendarGridList;
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ type Props = Partial<BpkCalendarGridProps> & {
focusedDate?: Date | null;
selectionConfiguration?: SelectionConfiguration;
className?: string | null;
rowHeight?: number;
customRowHeight?: number;
};

const BpkScrollableCalendarGridList = (props: Props) => {
const {
className = null,
customRowHeight = 2.75,
focusedDate = null,
minDate,
rowHeight = 2.75,
selectionConfiguration,
...rest
} = props;
Expand All @@ -73,7 +73,7 @@ const BpkScrollableCalendarGridList = (props: Props) => {
const monthsCount = DateUtils.differenceInCalendarMonths(endDate, startDate);

// Row and month item heights are defined in rem to support text scaling
const ROW_HEIGHT = rowHeight;
const ROW_HEIGHT = customRowHeight;
// Most calendar grids have 5 rows. Calculate height in px as this is what react-window expects.
const ESTIMATED_MONTH_ITEM_HEIGHT =
(BASE_MONTH_ITEM_HEIGHT + 5 * ROW_HEIGHT) * DEFAULT_ROOT_FONT_SIZE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ exports[`BpkCalendarScrollGridList should render correctly with a "dateModifiers
</DocumentFragment>
`;

exports[`BpkCalendarScrollGridList should render correctly with a custom "rowHeight" attribute 1`] = `
exports[`BpkCalendarScrollGridList should render correctly with a custom "customRowHeight" attribute 1`] = `
<DocumentFragment>
<div
class="bpk-scrollable-calendar-grid-list"
Expand Down

0 comments on commit b48ac34

Please sign in to comment.