entria-components icon indicating copy to clipboard operation
entria-components copied to clipboard

Date totally reusable component using moment library

Open renatobenks-zz opened this issue 7 years ago • 9 comments

<Date />

Why we not haves a Date component where him it's working nicely with dates where on javascript it's so hard works?

What u think about guys?

This point makes sense?

renatobenks-zz avatar Oct 25 '17 19:10 renatobenks-zz

Is it just for rendering a date, or does it do more?

fuechter avatar Oct 25 '17 19:10 fuechter

I think that a component will only make sense when we're rendering something... We have this one that's a wrapper for date-fns with a custom parser... Maybe we could improve it. 😄

felippepuhle avatar Oct 25 '17 19:10 felippepuhle

Not, the real intention here it's to works with date through props. But, with that, We'll gonna need a parser where we could export too. Like bellow:

import Date from '@entria/components/Date';
// we can too export a helper for works with date ;) but this, would be only a abstraction from moment
// for example, this helper could named `parseDate`, whatever
import { parseDate } from '@entria/components/Date';

// for date rendering
<Date date={date}  />
// or with children (because we can take the children like string and work it)
<Date>{date}</Date>
<Date>{new Date()}</Date> // could be rendering too
// this way, the full prop would be default
<Date>26/10</Date> // could be rendering too
<Date month>26/10</Date> // like that, would render only 10

// but on my think this will gonna helps with examples bellow
// rendering only month in date
<Date month date={date} />
<Date year date={date} />
<Date full date={date} />

There's a lot of possibilities! :tada:

renatobenks-zz avatar Oct 25 '17 19:10 renatobenks-zz

@felippepuhle we can reuse this like a helper and haves a component for that! Of course, we need first improve this helper.

renatobenks-zz avatar Oct 25 '17 19:10 renatobenks-zz

@felippepuhle moment it's better than date-fns hahaha https://momentjs.com/

renatobenks-zz avatar Oct 25 '17 19:10 renatobenks-zz

But I'm thinking that date-fns and moment haves different objectives and we could work with both!

renatobenks-zz avatar Oct 25 '17 19:10 renatobenks-zz

Feel free to send a PR implementing this guy on @entria/utils... I keep my assertion that it will only be used to render something, but that's awesome too... 🎉

I don't think that's a good idea use both of them(date-fns and moment) at the same project... I never used moment, date-fns always solved my problems... So, I can't say which one is better \o/

felippepuhle avatar Oct 25 '17 19:10 felippepuhle

If this it's solving your issues, so this seems be a good idea. But, take a look so on moment project, because I really believe that you'll gonna see than moment lib can safe better the javascript using dates, for a lot of reasons, but take your own, reading it hahaha

renatobenks-zz avatar Oct 25 '17 19:10 renatobenks-zz

With a React component for that we can grow up our possibilities. Think it! @alexandref93 @felippepuhle

renatobenks-zz avatar Oct 25 '17 19:10 renatobenks-zz