-
Notifications
You must be signed in to change notification settings - Fork 114
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(date-picker): create package #1499
Conversation
🦋 Changeset detectedLatest commit: 0d871d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
Size Change: +439 B (0%) Total Size: 555 kB
ℹ️ View Unchanged
|
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 0d871d9:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff! Super close. Small comments and the verbal ones from Zoom then lgtm!
"name": "@twilio-paste/date-picker", | ||
"version": "0.0.0", | ||
"category": "user input", | ||
"status": "alpha", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this prod from now, or in the future ticket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I think we're going with production for everything now.
"tsc": "tsc" | ||
}, | ||
"dependencies": { | ||
"date-fns": "^2.21.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can safely remove ^
as you brought up because it will reduce margin for error in consumer installs.
export type DatePickerProps = Omit<InputProps, 'type'>; | ||
|
||
const DatePicker = React.forwardRef<HTMLInputElement, DatePickerProps>((props, ref) => { | ||
return <Input type="date" {...props} ref={ref} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move {...props}
to before the type="date"
to prevent overrides in JS-land.
// that Date would automatically be instantiated in UTC+0. | ||
|
||
export const returnDateFormatter = (dateValue: string, dateFormat: string): string => { | ||
const time = 'T12:00:00-00:00'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would break if someone, somehow, passed in a dateValue string with time already concatenated.
Maybe consider a check like:
const time = 'T12:00:00-00:00';
export const returnDateFormatter = (dateString: string, dateFormat: string): string => {
let dateValue = dateString;
if (!dateValue.contains("T")) {
dateValue = new Date(dateValue.concat(time));
}
return format(Number(dateValue), dateFormat);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then add 1 test
<> | ||
<Label htmlFor={uidDP}>Label</Label> | ||
<DatePicker id={uidDP} aria-describedby={uidHT} {...props} /> | ||
<HelpText id={uidHT}>Help text</HelpText> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make these examples a little more realistic because we have plans to use stories in Tests, the doc site, and more in the future.
i.e.: HelpText shouldn't be "help text" :P
"@twilio-paste/anchor": "^5.0.3", | ||
"@twilio-paste/box": "^4.0.5", | ||
"@twilio-paste/combobox": "^7.0.2", | ||
"@twilio-paste/help-text": "^6.0.3", | ||
"@twilio-paste/icons": "^5.2.0", | ||
"@twilio-paste/input": "^3.0.6", | ||
"@twilio-paste/input-box": "^4.0.4", | ||
"@twilio-paste/label": "^6.0.3", | ||
"@twilio-paste/style-props": "^3.0.1", | ||
"@twilio-paste/styling-library": "^0.3.1", | ||
"@twilio-paste/text": "^4.0.4", | ||
"@twilio-paste/theme": "^5.0.1", | ||
"@twilio-paste/types": "^3.1.1", | ||
"@twilio-paste/uid-library": "^0.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we using anchor, box, combobox, help-text, icons, label, text, or uid-library anywhere other than in stories? If not, we can remove those from here and the devDeps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't they need to be dependencies if I'm using them in stories?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storybook has been modified in our repository to resolve (read: find) the src files in each of our packages. So it knows how to find Paste dependencies. This makes it easier to manage and use Storybook. This means we can get hot reloads on our changes to code, and also means that we don't need to couple storybook dependencies to the thing we're shipping in each package.
// Write date picker stories and export to use in test file | ||
// Stories: default, one using onChange with formatter function (copy combobox controlled using state story) and render value, replicate input stories |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder to remove this comment.
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
b28a7cd
to
9a410c4
Compare
// Change to pointer cursor on cal icon | ||
'&::-webkit-calendar-picker-indicator:hover': { | ||
cursor: props.readOnly || props.disabled ? 'default' : 'pointer', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richbachman made these changes (along with line 58), just want to get someone else's eyes on it before I merge it in to make sure it's the right approach to solving the cursor fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
type="time"
to Input, Input-box, FormreturnDateFormatter
funcContributing to Twilio