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 dateformat and placeholder prop for datepicker input [DSSUP-199] #2472

Merged

Conversation

tewarig
Copy link
Contributor

@tewarig tewarig commented Jan 14, 2025

Description

  • Added dateFormat and placeholder props:
    The dateFormat prop allows custom formatting for the date displayed in the input.
    The placeholder prop enables customization of the placeholder text, which defaults to the date format. This is useful since the placeholder text might differ from the date format or could be unclear to users.
  • Removed the chevron icon when the picker prop is used.

Additional Information

this fixes -
#2469
#2470

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 Jan 14, 2025

🦋 Changeset detected

Latest commit: 107e9d7

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 Patch

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 Jan 14, 2025

✅ PR title follows Conventional Commits specification.

@tewarig tewarig changed the title Feat: add dateformat and placeholder prop for datepicker input Feat: add dateformat and placeholder prop for datepicker input [FC-1234] Jan 14, 2025
@tewarig tewarig changed the title Feat: add dateformat and placeholder prop for datepicker input [FC-1234] feat: add dateformat and placeholder prop for datepicker input [FC-1234] Jan 14, 2025
Copy link

codesandbox-ci bot commented Jan 14, 2025

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 107e9d7:

Sandbox Source
razorpay/blade: basic Configuration

@@ -92,12 +92,13 @@ const _DatePickerInput = (
successText,
errorText,
helpText,
dateFormat,
placeholder,
Copy link
Member

Choose a reason for hiding this comment

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

Its fine to not expose placeholder right? dateFormat can have its own defined placeholder I'm guessing 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should expose the placeholder.
If someone wants to change it from "DD/MM/YYYY" to something like "Select Date," it should be allowed.
developers may want to modify the placeholder to suit their needs.
We should allow developers to modify the placeholder because having a predefined one could impose unnecessary constraints.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah fine. just keep the default as it was before.

Copy link
Member

Choose a reason for hiding this comment

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

If we set placeholder to "Select Date" how would the end-user know which format they are supposed to enter date in 🤔

Works to have placeholder for now since we'll have good default anyways. Can discuss it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay leaving placeholder for now. with default value DD/MM/YYYY.

/**
* Sets the date format to be displayed in the input field.
*/
dateFormat?: string;
Copy link
Member

Choose a reason for hiding this comment

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

can we have more explit types like 'DD/MM/YYYY' | 'MMM' etc?

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 can expose limited options here in dateFormat, but I think using a string is more ideal. What if the user wants to display the date like 'yyyy/mm/dd'? Using a string here allows more flexibility in how the date is formatted. Let me know if we should define an explicit type.

There is one thing, though maybe I should change the default type based on the picker prop as well.

Copy link
Member

Choose a reason for hiding this comment

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

But in this case the consumer wouldn't get autocomplete on which formats are possible no? they'll have to read documentation for that.

What if the user wants to display the date like 'yyyy/mm/dd'?

Also, this is something that we should avoid exposing. If one datepicker on one product is dd/mm/yyyy, other is mm/dd/yyyy, and other is yyyy/mm/dd the consumer will have different experiences of typing dates in all products so this is something that we can put guardrails on.

IMO we can support dd/mm/yyyy | mmm | mmmm | yyyy. This should cover most usecases while keeping the experience consistent.

There is one thing, though maybe I should change the default type based on the picker prop as well.

We can if we want but its fine even if we skip this since I don't see anyone using day picker just to show month. That experience will look visibly broken so consumers won't do it most likely

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added explit formats

@rzpcibot
Copy link
Collaborator

rzpcibot commented Jan 14, 2025

Bundle Size Report

Updated Components
Status Component Base Size (kb) Current Size (kb) Diff
DatePicker 86.770 86.982 +0.212 KB
Fade 1.054 1.053 -0.001 KB

Generated by 🚫 dangerJS against 107e9d7

@tewarig tewarig added the P0 Critical label Jan 14, 2025
@tewarig tewarig changed the title feat: add dateformat and placeholder prop for datepicker input [FC-1234] feat: add dateformat and placeholder prop for datepicker input [DSSUP-199] Jan 14, 2025
return format;
}
if (picker === 'day') {
return 'DD';
Copy link
Member

@saurabhdaware saurabhdaware Jan 15, 2025

Choose a reason for hiding this comment

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

@anuraghazra @tewarig Shouldn't day picker also be dd/mm/yyyy by default? just the date number won't be useful in most scenarios no?

Like I would normally use day picker when I want people to only choose a day of given month but I would still want user to know which month they've chosen right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, will change this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@tewarig tewarig force-pushed the feat/add-dateformat-and-placeholder-prop-for-datepicker-input branch from 5c2e8bb to 87bd14e Compare January 15, 2025 07:30
saurabhdaware
saurabhdaware previously approved these changes Jan 15, 2025
anuraghazra
anuraghazra previously approved these changes Jan 15, 2025
Copy link
Member

@anuraghazra anuraghazra left a comment

Choose a reason for hiding this comment

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

Mostly LGTM

@tewarig tewarig dismissed stale reviews from anuraghazra and saurabhdaware via 2ce7b18 January 15, 2025 08:44
@tewarig tewarig merged commit 7025932 into master Jan 15, 2025
13 of 15 checks passed
@tewarig tewarig deleted the feat/add-dateformat-and-placeholder-prop-for-datepicker-input branch January 15, 2025 09:19
Comment on lines -138 to -141
<Link
onClick={() => {
onLevelChange('year');
}}
Copy link
Contributor Author

@tewarig tewarig Jan 15, 2025

Choose a reason for hiding this comment

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

need to change to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 Critical
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants