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

feat: add DatePicker component #2173

Merged
merged 46 commits into from
May 27, 2024
Merged

feat: add DatePicker component #2173

merged 46 commits into from
May 27, 2024

Conversation

anuraghazra
Copy link
Member

Description

Changes

Additional Information

Component Checklist

  • Update Component Status Page
  • Perform Manual Testing in Other Browsers
  • Add KitchenSink Story
  • Add Interaction Tests (if applicable)
  • Add changeset

Copy link

changeset-bot bot commented May 14, 2024

🦋 Changeset detected

Latest commit: 79cc179

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@razorpay/blade Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented May 14, 2024

✅ PR title follows Conventional Commits specification.

@@ -70,7 +71,7 @@ const _BottomSheetBody = ({
paddingTop={bottomSheetHasActionList ? 'spacing.3' : padding}
paddingBottom={bottomSheetHasActionList ? 'spacing.3' : padding}
ref={contentRef}
overflow="auto"
overflow={overflow ?? 'auto'}
Copy link
Member

Choose a reason for hiding this comment

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

define it as overflow = 'auto' in top only maybe as default value

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Comment on lines +207 to 210
xsmall: 'medium',
small: 'medium',
medium: 'medium',
large: 'medium',
Copy link
Member

Choose a reason for hiding this comment

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

do we need this object if its all medium 🙈

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's keep like this for now, sizes might change later.

Comment on lines 160 to 169
levelsGroup: 'DatePicker-levelsGroup',
day: 'DatePicker-cell',
monthsListControl: 'DatePicker-cell',
yearsListControl: 'DatePicker-cell',
calendarHeader: 'DatePicker-header',
monthRow: 'DatePicker-row',
yearsListRow: 'DatePicker-row',
monthsListRow: 'DatePicker-row',
weekdaysRow: 'DatePicker-row',
weekday: 'DatePicker-weekday',
Copy link
Member

Choose a reason for hiding this comment

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

maintain this in some tokens.ts / constants.ts file maybe? since we're reusing these strings while writing CSS also

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

<BaseBox display="flex" flexDirection="column" gap="spacing.5">
{isMobile ? null : <Divider />}
<BaseBox
width={isMobile ? '100%' : undefined}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
width={isMobile ? '100%' : undefined}
width={{ base: '100%, m: undefined }}

Copy link
Member Author

Choose a reason for hiding this comment

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

nice

marginTop={
// Hacky layouting because the we cannot put this inside the internal layout of BaseInput.
hasLabel && !isLabelPositionLeft
? `calc(${makeSize(iconVerticalMargin[size])} + ${isLarge ? '20px' : '15px'})`
Copy link
Member

Choose a reason for hiding this comment

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

use spacing tokens / sizing tokens

Copy link
Member Author

Choose a reason for hiding this comment

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

done

id="start-date"
labelPosition={labelPosition}
label={label}
placeholder="DD MMM YYYY"
Copy link
Member

Choose a reason for hiding this comment

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

Static placeholder? this is not configurable like other inputs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. non configurable.

flexDirection="column"
gap="spacing.2"
backgroundColor="surface.background.gray.moderate"
minWidth={makeSpace(160)}
Copy link
Member

Choose a reason for hiding this comment

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

use sizing token?

Copy link
Member Author

Choose a reason for hiding this comment

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

done, but at this point I'm actually questioning the use/existence of size tokens. We seem to randomly add pixel values in here.

Comment on lines 70 to 72
console.error(
'[@mantine/dates/use-uncontrolled-dates] Value must be type of `[string, string]`',
);
Copy link
Member

Choose a reason for hiding this comment

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

not using throwBladeError utility?

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

display="flex"
flexDirection="column"
gap="spacing.5"
data-nice
Copy link
Collaborator

Choose a reason for hiding this comment

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

what? 😆

Comment on lines 263 to 268
<FloatingPortal>
<FloatingFocusManager
initialFocus={defaultInitialFocusRef}
context={context}
guards={true}
>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember reading that FloatingPortal & FloatingFocusManager should always be mounted otherwise it may cause some issues

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 Never heard about it. We do this in Popover,Tooltip etc components too.

And is also documented/present on their official examples: https://codesandbox.io/p/sandbox/withered-shadow-ot38mm

Copy link

codesandbox-ci bot commented May 22, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 79cc179:

Sandbox Source
razorpay/blade: basic Configuration

@anuraghazra anuraghazra added the Review - L2 Second level of review label May 22, 2024
* test: add single datepicker tests

* test: add date range tests

* chore: minor changes

* feat: add more tests

* chore: update web snaps

* chore: update rn snaps

* chore: update
* chore: added storybook docs

* chore: add docs for min,max,exclude date

* chore: add storybook controls

* chore: add locale example

* chore: minor
@rzpcibot
Copy link
Collaborator

rzpcibot commented May 23, 2024

Bundle Size Report

Updated Components
Status Component Base Size (kb) Current Size (kb) Diff
Accordion, AccordionItemHeader, AccordionItemBody, AccordionItem 4.479 7.323 +2.844 KB
ActionList, ActionListItem, ActionListItemBadge, ActionListItemBadgeGroup, ActionListItemIcon, ActionListItemText, ActionListSection 9.888 12.758 +2.870 KB
Alert 8.352 11.218 +2.866 KB
Amount -1.749 1.112 +2.861 KB
Avatar, AvatarGroup 0.579 3.420 +2.841 KB
Badge -2.057 0.797 +2.854 KB
BladeProvider -1.214 1.629 +2.843 KB
BottomSheet 6.534 9.371 +2.837 KB
Box -2.092 0.776 +2.868 KB
Breadcrumb, BreadcrumbItem -0.320 2.486 +2.806 KB
ButtonGroup -1.747 1.118 +2.865 KB
Card, CardBody, CardHeader, CardHeaderIcon, CardHeaderIconButton, CardHeaderLeading, CardHeaderTrailing, CardFooter, CardFooterLeading, CardFooterTrailing 6.271 9.106 +2.835 KB
Carousel, CarouselItem 4.001 6.850 +2.849 KB
Checkbox 3.102 5.953 +2.851 KB
Chip, ChipGroup 4.735 7.586 +2.851 KB
Collapsible, CollapsibleLink, CollapsibleButton, CollapsibleBody 6.629 9.455 +2.826 KB
Counter -2.090 0.773 +2.863 KB
DatePicker 0.000 79.146 +79.146 KB
Divider -2.340 0.533 +2.873 KB
Drawer, DrawerBody, DrawerHeader 13.278 16.549 +3.271 KB
Dropdown, DropdownOverlay, DropdownButton, DropdownLink, DropdownFooter, DropdownHeader 24.940 27.711 +2.771 KB
FileUpload 11.677 14.539 +2.862 KB
Indicator -1.820 1.046 +2.866 KB
List, ListItem, ListItemLink, ListItemCode, ListItemText 2.179 4.999 +2.820 KB
Modal 9.913 13.109 +3.196 KB
Popover, PopoverInteractiveWrapper 17.598 21.071 +3.473 KB
ProgressBar 0.257 3.077 +2.820 KB
Radio 1.899 4.733 +2.834 KB
Skeleton -2.119 0.745 +2.864 KB
SpotlightPopoverTour, SpotlightPopoverTourFooter, SpotlightPopoverTourStep 25.745 29.329 +3.584 KB
StepGroup, StepItem, StepItemIcon, StepItemIndicator 3.845 6.696 +2.851 KB
Switch 1.654 4.501 +2.847 KB
Table, TableHeader, TableHeaderCell, TableHeaderRow, TableBody, TableCell, TableRow, TableFooter, TableFooterCell, TableFooterRow, TablePagination, TableToolbar, TableToolbarActions 54.465 57.437 +2.972 KB
Tabs, TabItem, TabList, TabPanel 3.762 7.009 +3.247 KB
Tag 0.598 3.453 +2.855 KB
ToastContainer, useToast 9.576 12.418 +2.842 KB
Tooltip, TooltipInteractiveWrapper 12.558 16.071 +3.513 KB
Button 3.085 5.880 +2.795 KB
IconButton -2.105 0.789 +2.894 KB
CheckboxGroup 1.317 4.134 +2.817 KB
SelectInput, AutoComplete 16.213 19.072 +2.859 KB
OTPInput 10.279 13.169 +2.890 KB
PasswordInput 11.930 14.767 +2.837 KB
PhoneNumberInput 51.037 54.097 +3.060 KB
SearchInput 14.504 17.364 +2.860 KB
TextArea 12.828 15.688 +2.860 KB
TextInput 14.424 17.291 +2.867 KB
Link -0.765 2.088 +2.853 KB
RadioGroup 1.285 4.107 +2.822 KB
Spinner -1.032 1.809 +2.841 KB
Code -2.269 0.601 +2.870 KB
Display -2.378 0.494 +2.872 KB
Heading, getHeadingProps -2.430 0.440 +2.870 KB
Text -2.866 0.000 +2.866 KB

Generated by 🚫 dangerJS against 79cc179

saurabhdaware
saurabhdaware previously approved these changes May 27, 2024
packages/blade/package.json Outdated Show resolved Hide resolved
@saurabhdaware
Copy link
Member

Approve the chromatic reviews

@anuraghazra anuraghazra merged commit 2ed5299 into master May 27, 2024
14 checks passed
@anuraghazra anuraghazra deleted the anu/datepicker branch May 27, 2024 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review - L2 Second level of review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants