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(date-picker): create package #1499

Merged
merged 6 commits into from
Jun 9, 2021
Merged

feat(date-picker): create package #1499

merged 6 commits into from
Jun 9, 2021

Conversation

nkrantz
Copy link
Collaborator

@nkrantz nkrantz commented May 26, 2021

  • Added date-picker package
  • Added type="time" to Input, Input-box, Form
  • Wrote tests for Date Picker and returnDateFormatter func

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

@changeset-bot
Copy link

changeset-bot bot commented May 26, 2021

🦋 Changeset detected

Latest commit: 0d871d9

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

This PR includes changesets to release 4 packages
Name Type
@twilio-paste/input Patch
@twilio-paste/core Minor
@twilio-paste/input-box Patch
@twilio-paste/date-picker 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

@github-actions
Copy link
Contributor

github-actions bot commented May 26, 2021

Size Change: +439 B (0%)

Total Size: 555 kB

Filename Size Change
packages/paste-core/components/input-box/dist/index.es.js 1.93 kB +5 B (0%)
packages/paste-core/components/input-box/dist/index.js 2.23 kB +5 B (0%)
packages/paste-core/components/input/dist/index.es.js 1.46 kB +103 B (+8%) 🔍
packages/paste-core/components/input/dist/index.js 1.81 kB +98 B (+6%) 🔍
packages/paste-core/core-bundle/dist/index.js 1.07 kB +23 B (+2%)
packages/paste-core/core-bundle/dist/date-picker.js 205 B +205 B (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
packages/paste-core/components/alert-dialog/dist/index.es.js 2.67 kB 0 B
packages/paste-core/components/alert-dialog/dist/index.js 3 kB 0 B
packages/paste-core/components/alert/dist/index.es.js 1.26 kB 0 B
packages/paste-core/components/alert/dist/index.js 1.61 kB 0 B
packages/paste-core/components/anchor/dist/index.es.js 1.52 kB 0 B
packages/paste-core/components/anchor/dist/index.js 1.83 kB 0 B
packages/paste-core/components/avatar/dist/index.es.js 1.71 kB 0 B
packages/paste-core/components/avatar/dist/index.js 2.04 kB 0 B
packages/paste-core/components/base-radio-checkbox/dist/index.es.js 1.13 kB 0 B
packages/paste-core/components/base-radio-checkbox/dist/index.js 1.5 kB 0 B
packages/paste-core/components/breadcrumb/dist/index.es.js 1.08 kB 0 B
packages/paste-core/components/breadcrumb/dist/index.js 1.41 kB 0 B
packages/paste-core/components/button/dist/index.es.js 10.1 kB 0 B
packages/paste-core/components/button/dist/index.js 10.4 kB 0 B
packages/paste-core/components/card/dist/index.es.js 697 B 0 B
packages/paste-core/components/card/dist/index.js 1.04 kB 0 B
packages/paste-core/components/checkbox/dist/index.es.js 2.34 kB 0 B
packages/paste-core/components/checkbox/dist/index.js 2.65 kB 0 B
packages/paste-core/components/combobox/dist/index.es.js 13.2 kB 0 B
packages/paste-core/components/combobox/dist/index.js 13.5 kB 0 B
packages/paste-core/components/date-picker/dist/index.es.js 8.3 kB 0 B
packages/paste-core/components/date-picker/dist/index.js 8.65 kB 0 B
packages/paste-core/components/disclosure/dist/index.es.js 2.26 kB 0 B
packages/paste-core/components/disclosure/dist/index.js 2.6 kB 0 B
packages/paste-core/components/form/dist/index.es.js 256 B 0 B
packages/paste-core/components/form/dist/index.js 692 B 0 B
packages/paste-core/components/heading/dist/index.es.js 889 B 0 B
packages/paste-core/components/heading/dist/index.js 1.23 kB 0 B
packages/paste-core/components/help-text/dist/index.es.js 923 B 0 B
packages/paste-core/components/help-text/dist/index.js 1.27 kB 0 B
packages/paste-core/components/inline-control-group/dist/index.es.js 956 B 0 B
packages/paste-core/components/inline-control-group/dist/index.js 1.3 kB 0 B
packages/paste-core/components/label/dist/index.es.js 1.13 kB 0 B
packages/paste-core/components/label/dist/index.js 1.48 kB 0 B
packages/paste-core/components/list/dist/index.es.js 778 B 0 B
packages/paste-core/components/list/dist/index.js 1.13 kB 0 B
packages/paste-core/components/menu/dist/index.es.js 1.9 kB 0 B
packages/paste-core/components/menu/dist/index.js 2.23 kB 0 B
packages/paste-core/components/modal/dist/index.es.js 2.65 kB 0 B
packages/paste-core/components/modal/dist/index.js 2.98 kB 0 B
packages/paste-core/components/pagination/dist/index.es.js 3.04 kB 0 B
packages/paste-core/components/pagination/dist/index.js 3.31 kB 0 B
packages/paste-core/components/paragraph/dist/index.es.js 570 B 0 B
packages/paste-core/components/paragraph/dist/index.js 914 B 0 B
packages/paste-core/components/popover/dist/index.es.js 1.45 kB 0 B
packages/paste-core/components/popover/dist/index.js 1.79 kB 0 B
packages/paste-core/components/radio-group/dist/index.es.js 1.59 kB 0 B
packages/paste-core/components/radio-group/dist/index.js 1.93 kB 0 B
packages/paste-core/components/screen-reader-only/dist/index.es.js 652 B 0 B
packages/paste-core/components/screen-reader-only/dist/index.js 996 B 0 B
packages/paste-core/components/select/dist/index.es.js 1.55 kB 0 B
packages/paste-core/components/select/dist/index.js 1.87 kB 0 B
packages/paste-core/components/separator/dist/index.es.js 758 B 0 B
packages/paste-core/components/separator/dist/index.js 1.1 kB 0 B
packages/paste-core/components/spinner/dist/index.es.js 744 B 0 B
packages/paste-core/components/spinner/dist/index.js 1.14 kB 0 B
packages/paste-core/components/table/dist/index.es.js 1.74 kB 0 B
packages/paste-core/components/table/dist/index.js 2.07 kB 0 B
packages/paste-core/components/tabs/dist/index.es.js 2.02 kB 0 B
packages/paste-core/components/tabs/dist/index.js 2.34 kB 0 B
packages/paste-core/components/textarea/dist/index.es.js 5.04 kB 0 B
packages/paste-core/components/textarea/dist/index.js 5.08 kB 0 B
packages/paste-core/components/toast/dist/index.es.js 3 kB 0 B
packages/paste-core/components/toast/dist/index.js 3.32 kB 0 B
packages/paste-core/components/tooltip/dist/index.es.js 1.1 kB 0 B
packages/paste-core/components/tooltip/dist/index.js 1.45 kB 0 B
packages/paste-core/components/truncate/dist/index.es.js 588 B 0 B
packages/paste-core/components/truncate/dist/index.js 934 B 0 B
packages/paste-core/components/typography/dist/index.es.js 1.38 kB 0 B
packages/paste-core/components/typography/dist/index.js 1.74 kB 0 B
packages/paste-core/core-bundle/dist/alert-dialog.js 210 B 0 B
packages/paste-core/core-bundle/dist/alert.js 194 B 0 B
packages/paste-core/core-bundle/dist/anchor.js 197 B 0 B
packages/paste-core/core-bundle/dist/animation-library.js 211 B 0 B
packages/paste-core/core-bundle/dist/aspect-ratio.js 205 B 0 B
packages/paste-core/core-bundle/dist/avatar.js 200 B 0 B
packages/paste-core/core-bundle/dist/base-radio-checkbox.js 218 B 0 B
packages/paste-core/core-bundle/dist/box.js 195 B 0 B
packages/paste-core/core-bundle/dist/breadcrumb.js 204 B 0 B
packages/paste-core/core-bundle/dist/button.js 201 B 0 B
packages/paste-core/core-bundle/dist/card.js 199 B 0 B
packages/paste-core/core-bundle/dist/checkbox.js 201 B 0 B
packages/paste-core/core-bundle/dist/combobox-primitive.js 213 B 0 B
packages/paste-core/core-bundle/dist/combobox.js 203 B 0 B
packages/paste-core/core-bundle/dist/customization.js 206 B 0 B
packages/paste-core/core-bundle/dist/design-tokens.js 209 B 0 B
packages/paste-core/core-bundle/dist/disclosure-primitive.js 213 B 0 B
packages/paste-core/core-bundle/dist/disclosure.js 204 B 0 B
packages/paste-core/core-bundle/dist/dropdown-library.js 211 B 0 B
packages/paste-core/core-bundle/dist/flex.js 196 B 0 B
packages/paste-core/core-bundle/dist/form.js 197 B 0 B
packages/paste-core/core-bundle/dist/grid.js 196 B 0 B
packages/paste-core/core-bundle/dist/heading.js 199 B 0 B
packages/paste-core/core-bundle/dist/help-text.js 204 B 0 B
packages/paste-core/core-bundle/dist/inline-control-group.js 218 B 0 B
packages/paste-core/core-bundle/dist/input-box.js 206 B 0 B
packages/paste-core/core-bundle/dist/input.js 200 B 0 B
packages/paste-core/core-bundle/dist/label.js 196 B 0 B
packages/paste-core/core-bundle/dist/list.js 195 B 0 B
packages/paste-core/core-bundle/dist/media-object.js 202 B 0 B
packages/paste-core/core-bundle/dist/menu-primitive.js 210 B 0 B
packages/paste-core/core-bundle/dist/menu.js 196 B 0 B
packages/paste-core/core-bundle/dist/modal-dialog-primitive.js 219 B 0 B
packages/paste-core/core-bundle/dist/modal.js 196 B 0 B
packages/paste-core/core-bundle/dist/non-modal-dialog-primitive.js 224 B 0 B
packages/paste-core/core-bundle/dist/pagination.js 199 B 0 B
packages/paste-core/core-bundle/dist/paragraph.js 202 B 0 B
packages/paste-core/core-bundle/dist/popover.js 201 B 0 B
packages/paste-core/core-bundle/dist/radio-group.js 208 B 0 B
packages/paste-core/core-bundle/dist/reakit-library.js 211 B 0 B
packages/paste-core/core-bundle/dist/screen-reader-only.js 214 B 0 B
packages/paste-core/core-bundle/dist/select.js 197 B 0 B
packages/paste-core/core-bundle/dist/separator.js 199 B 0 B
packages/paste-core/core-bundle/dist/sibling-box.js 206 B 0 B
packages/paste-core/core-bundle/dist/spinner.js 198 B 0 B
packages/paste-core/core-bundle/dist/stack.js 200 B 0 B
packages/paste-core/core-bundle/dist/style-props.js 202 B 0 B
packages/paste-core/core-bundle/dist/styling-library.js 210 B 0 B
packages/paste-core/core-bundle/dist/table.js 195 B 0 B
packages/paste-core/core-bundle/dist/tabs-primitive.js 210 B 0 B
packages/paste-core/core-bundle/dist/tabs.js 196 B 0 B
packages/paste-core/core-bundle/dist/text.js 195 B 0 B
packages/paste-core/core-bundle/dist/textarea.js 198 B 0 B
packages/paste-core/core-bundle/dist/theme.js 196 B 0 B
packages/paste-core/core-bundle/dist/toast.js 195 B 0 B
packages/paste-core/core-bundle/dist/tooltip-primitive.js 212 B 0 B
packages/paste-core/core-bundle/dist/tooltip.js 198 B 0 B
packages/paste-core/core-bundle/dist/truncate.js 198 B 0 B
packages/paste-core/core-bundle/dist/types.js 196 B 0 B
packages/paste-core/core-bundle/dist/uid-library.js 208 B 0 B
packages/paste-core/layout/aspect-ratio/dist/index.es.js 709 B 0 B
packages/paste-core/layout/aspect-ratio/dist/index.js 1.11 kB 0 B
packages/paste-core/layout/flex/dist/index.es.js 2.1 kB 0 B
packages/paste-core/layout/flex/dist/index.js 2.41 kB 0 B
packages/paste-core/layout/grid/dist/index.es.js 1.65 kB 0 B
packages/paste-core/layout/grid/dist/index.js 1.96 kB 0 B
packages/paste-core/layout/media-object/dist/index.es.js 577 B 0 B
packages/paste-core/layout/media-object/dist/index.js 987 B 0 B
packages/paste-core/layout/stack/dist/index.es.js 1.14 kB 0 B
packages/paste-core/layout/stack/dist/index.js 1.47 kB 0 B
packages/paste-core/primitives/box/dist/index.es.js 1.46 kB 0 B
packages/paste-core/primitives/box/dist/index.js 1.81 kB 0 B
packages/paste-core/primitives/combobox/dist/index.es.js 142 B 0 B
packages/paste-core/primitives/combobox/dist/index.js 561 B 0 B
packages/paste-core/primitives/disclosure/dist/index.es.js 155 B 0 B
packages/paste-core/primitives/disclosure/dist/index.js 570 B 0 B
packages/paste-core/primitives/menu/dist/index.es.js 209 B 0 B
packages/paste-core/primitives/menu/dist/index.js 622 B 0 B
packages/paste-core/primitives/modal-dialog/dist/index.es.js 23.5 kB 0 B
packages/paste-core/primitives/modal-dialog/dist/index.js 23.4 kB 0 B
packages/paste-core/primitives/non-modal-dialog/dist/index.es.js 176 B 0 B
packages/paste-core/primitives/non-modal-dialog/dist/index.js 590 B 0 B
packages/paste-core/primitives/sibling-box/dist/index.es.js 744 B 0 B
packages/paste-core/primitives/sibling-box/dist/index.js 1.16 kB 0 B
packages/paste-core/primitives/tabs/dist/index.es.js 153 B 0 B
packages/paste-core/primitives/tabs/dist/index.js 572 B 0 B
packages/paste-core/primitives/text/dist/index.es.js 1.13 kB 0 B
packages/paste-core/primitives/text/dist/index.js 1.49 kB 0 B
packages/paste-core/primitives/tooltip/dist/index.es.js 163 B 0 B
packages/paste-core/primitives/tooltip/dist/index.js 578 B 0 B
packages/paste-customization/dist/index.es.js 6.53 kB 0 B
packages/paste-customization/dist/index.js 6.8 kB 0 B
packages/paste-libraries/animation/dist/index.es.js 24.2 kB 0 B
packages/paste-libraries/animation/dist/index.js 24.5 kB 0 B
packages/paste-libraries/dropdown/dist/index.es.js 26.4 kB 0 B
packages/paste-libraries/dropdown/dist/index.js 26.5 kB 0 B
packages/paste-libraries/reakit/dist/index.es.js 48.4 kB 0 B
packages/paste-libraries/reakit/dist/index.js 48.6 kB 0 B
packages/paste-libraries/styling/dist/index.es.js 26.6 kB 0 B
packages/paste-libraries/styling/dist/index.js 27 kB 0 B
packages/paste-libraries/uid/dist/index.es.js 1.72 kB 0 B
packages/paste-libraries/uid/dist/index.js 2.1 kB 0 B
packages/paste-style-props/dist/index.es.js 5.11 kB 0 B
packages/paste-style-props/dist/index.js 5.63 kB 0 B
packages/paste-theme/dist/index.es.js 3.13 kB 0 B
packages/paste-theme/dist/index.js 3.34 kB 0 B
packages/paste-types/dist/index.es.js 20 B 0 B
packages/paste-types/dist/index.js 20 B 0 B

compressed-size-action

@codesandbox-ci
Copy link

codesandbox-ci bot commented May 26, 2021

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:

Sandbox Source
@twilio-paste/nextjs-template Configuration

Copy link
Contributor

@TheSisb TheSisb left a 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",
Copy link
Contributor

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?

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 we're going with production for everything now.

"tsc": "tsc"
},
"dependencies": {
"date-fns": "^2.21.3"
Copy link
Contributor

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} />;
Copy link
Contributor

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';
Copy link
Contributor

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);
}

Copy link
Contributor

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>
Copy link
Contributor

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

Comment on lines 31 to 39
"@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",
Copy link
Contributor

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.

Copy link
Collaborator Author

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?

Copy link
Contributor

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.

Comment on lines 12 to 13
// 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
Copy link
Contributor

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.

@SiTaggart SiTaggart changed the title Date picker feat(date-picker): create package May 26, 2021
@cypress
Copy link

cypress bot commented May 28, 2021



Test summary

2 0 0 0Flakiness 0


Run details

Project Paste
Status Passed
Commit 0d871d9
Started Jun 9, 2021 3:57 PM
Ended Jun 9, 2021 3:58 PM
Duration 00:32 💡
OS Linux Ubuntu - 20.04
Browser Electron 83

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

@nkrantz nkrantz marked this pull request as ready for review June 1, 2021 20:17
Copy link
Contributor

@TheSisb TheSisb left a comment

Choose a reason for hiding this comment

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

LGTM!

@nkrantz nkrantz force-pushed the date-picker-comp branch 5 times, most recently from b28a7cd to 9a410c4 Compare June 8, 2021 17:33
Comment on lines +81 to +83
// Change to pointer cursor on cal icon
'&::-webkit-calendar-picker-indicator:hover': {
cursor: props.readOnly || props.disabled ? 'default' : 'pointer',
Copy link
Collaborator Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

🚢

@nkrantz nkrantz merged commit ed8e7cc into main Jun 9, 2021
@nkrantz nkrantz deleted the date-picker-comp branch June 9, 2021 16:02
@TwilioPasteBot TwilioPasteBot mentioned this pull request Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants