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

[SHIBA-2119] Added Optional Height Prop for Scrollable Calendar #3057

Merged
merged 10 commits into from
Nov 7, 2023

Conversation

AsimAM
Copy link
Contributor

@AsimAM AsimAM commented Nov 2, 2023

We want to be able to pass an optional heigh prop to add extra whitespace between months.

See the images below for reference.

Screenshot 2023-11-02 at 14 19 19

Screenshot 2023-11-02 at 14 18 45

Remember to include the following changes:

  • README.md (If you have created a new component)
  • Component README.md
  • Tests
  • Storybook examples created/updated
  • For breaking changes or deprecating components/properties, migration guides added to the description of the PR. If the guide has large changes, consider creating a new Markdown page inside the component's docs folder and link it here

@@ -75,6 +63,20 @@ const BpkScrollableCalendarGridList = (props: Props) => {
const endDate = startOfDay(startOfMonth(rest.maxDate));
const monthsCount = DateUtils.differenceInCalendarMonths(endDate, startDate);

// These constants are here to facilitate calculating the height
// Row and month item heights are defined in rem to support text scaling
const ROW_HEIGHT = 2.75;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this down, so it can be assigned by the optional prop.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we need to move any constants within the component and having this run with every render, we need to be careful what we move and also we shouldn't be using capital letters for these

Copy link
Contributor Author

@AsimAM AsimAM Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#3057 (comment)

Yeah, makes sense.

With us now updating the ROW_HEIGHT via the prop, we don't need to move all of these constants down.

We will be in a middle state though where some dimension properties are still constant whilst others are not.

@@ -66,6 +66,7 @@ export type Props = {
initiallyFocusedDate?: Date | null;
markToday?: boolean;
markOutsideDays?: boolean;
monthHeight?: number;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to specify this prop specifically as the <Calendar> component passes the rest of the props via {...calendarProps}

See here

Copy link

github-actions bot commented Nov 2, 2023

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against 8cec8cd

Copy link

github-actions bot commented Nov 2, 2023

Visit https://backpack.github.io/storybook-prs/3057 to see this build running in a browser.

@AsimAM AsimAM added the minor Non breaking change label Nov 2, 2023
Copy link

github-actions bot commented Nov 2, 2023

Visit https://backpack.github.io/storybook-prs/3057 to see this build running in a browser.

Copy link

github-actions bot commented Nov 2, 2023

Visit https://backpack.github.io/storybook-prs/3057 to see this build running in a browser.

// Row and month item heights are defined in rem to support text scaling
const ROW_HEIGHT = 2.75;
// This is the additional height of each grid without any rows.
const BASE_MONTH_ITEM_HEIGHT = monthHeight;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this constant actually represents the additional height of the grid month so the white spaces around and between rows. I think it might get confusing if we use the monthHeight prop for it.
I was thinking of having a prop for a row, rather than a month. But we could also do it like this, but would need to rename the prop as monthHeight sounds like it's a prop for the whole month which is a bit confusing as not each month will be always having the same size

Copy link
Contributor Author

@AsimAM AsimAM Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

I've updated it so that we're passing a prop for ROW_HEIGHT.

Copy link

github-actions bot commented Nov 6, 2023

Visit https://backpack.github.io/storybook-prs/3057 to see this build running in a browser.

Copy link

github-actions bot commented Nov 6, 2023

Visit https://backpack.github.io/storybook-prs/3057 to see this build running in a browser.

@AsimAM AsimAM changed the title [SHIBA-2119] Added Optional Month Height Prop [SHIBA-2119] Added Optional Height Prop for Scrollable Calendar Nov 6, 2023
Copy link

github-actions bot commented Nov 6, 2023

Visit https://backpack.github.io/storybook-prs/3057 to see this build running in a browser.

@AsimAM AsimAM requested a review from anambl November 7, 2023 09:25
@@ -60,11 +55,13 @@ type Props = Partial<BpkCalendarGridProps> & {
focusedDate?: Date | null;
selectionConfiguration?: SelectionConfiguration;
className?: string | null;
customRowHeight?: number;
Copy link
Contributor

@anambl anambl Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding a JSDOC comment to specify this value should be in rem - and same with the other components where this is part of the API. That's gonna reflect in the Storybook API docs then too automatically!

Copy link
Contributor Author

@AsimAM AsimAM Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I opted for regular comments instead of JSDOC comments due to consistency (a lot of the other props are being specified by regular comments) and it would look odd to have JSDoc for a singular prop. But happy to change it if it is still the preference.

Screenshot 2023-11-07 at 12 38 56

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, that's totally fine!

Copy link

github-actions bot commented Nov 7, 2023

Visit https://backpack.github.io/storybook-prs/3057 to see this build running in a browser.

@anambl anambl merged commit f6a9ca0 into main Nov 7, 2023
9 checks passed
@anambl anambl deleted the SHIBA-2119_month_height_propp branch November 7, 2023 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Non breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants