Gutenberg: Move DatePicker and TimePicker to own Component

Created on 23 Oct 2019  路  8Comments  路  Source: WordPress/gutenberg

See #17497

The DatePicker and TimePicker components are included as part of the DateTimePicker component, they should be split out to their own components, with their own README and Story files.

Since they were previously included as part of the DateTimePicker component, to avoid breaking backward compatibility, they should be imported & exported properly in the old component

Good First Issue [Package] Components

Most helpful comment

Can I pick this one? It's my first time contributing to open source, but I think I can do this properly.

All 8 comments

Can I pick this one? It's my first time contributing to open source, but I think I can do this properly.

@jpbelo Awesome!! Go for it :D. Excited to see your pull request!

I eventually sorted it out by installing webpack-cli manually.
But when you have a fresh clone and run yarn and then yarn dev, you will be prompted to install webpack-cli (yes/no). It then gets stuck there. Maybe there's a bug in.

Since they were previously included as part of the DateTimePicker component, to avoid breaking backward compatibility, they should be imported & exported properly in the old component

@mkaz - do you propose to deprecate the old one with a note for developers to use new components instead? I'm fine with that, I just wanted to make sure it's clear.

Can someone give me help here? I鈥檓 not sure why travis failed...

@gziolo I'm not quite sure how to deprecate, or if it is actually needed. Now that I talk it out, maybe it won't be an issue. The comment (also it was originally from @ItsJonQ , but I feel the same) is basically to not break anyone's code that might of previous done something like:

import { DatePicker } from '/date-time';

So inside of date-time/index.js we could include

import { DatePicker} from '../date-picker';
export { DatePicker };

Thinking about it, I don't think externally people import using ./date-time they do so using the package @wordpress/components like so
```
import { DatePicker } from '@wordpress/components';
````

So just updating the components/src/index.js to pull from the correct spot should be sufficient, right?

@mkaz
I think you are correct on how external users import from @wordpress/components.

Regarding the import/export from date-picker, I think I covered that here:
https://github.com/WordPress/gutenberg/pull/18087/files#diff-52f4edceeb4c11275063e5868f3c66ff

Yes, it's totally fine to have 3 components exposed. We can also put all of them in their own files if that helps. We don't have strict rules for exports from the @wordpress/components package, see some examples:

https://github.com/WordPress/gutenberg/blob/711f9ff1ee44208e3f18da441637db59e6891267/packages/components/src/index.js#L37
https://github.com/WordPress/gutenberg/blob/711f9ff1ee44208e3f18da441637db59e6891267/packages/components/src/index.js#L67

In fact, we are exposing 3 components at the moment, what do we miss?:
https://github.com/WordPress/gutenberg/blob/711f9ff1ee44208e3f18da441637db59e6891267/packages/components/src/index.js#L14

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hedgefield picture hedgefield  路  3Comments

mhenrylucero picture mhenrylucero  路  3Comments

maddisondesigns picture maddisondesigns  路  3Comments

jasmussen picture jasmussen  路  3Comments

moorscode picture moorscode  路  3Comments