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

Date totally reusable component using moment library #40

Open
renatobenks-zz opened this issue Oct 25, 2017 · 9 comments
Open

Date totally reusable component using moment library #40

renatobenks-zz opened this issue Oct 25, 2017 · 9 comments
Assignees

Comments

@renatobenks-zz
Copy link

<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 renatobenks-zz self-assigned this Oct 25, 2017
@renatobenks-zz renatobenks-zz changed the title Date totally reusable component with moment Date totally reusable component using moment library Oct 25, 2017
@fuechter
Copy link

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

@felippepuhle
Copy link
Contributor

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. 😄

@renatobenks-zz
Copy link
Author

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! 🎉

@renatobenks-zz
Copy link
Author

renatobenks-zz commented Oct 25, 2017

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

@renatobenks-zz
Copy link
Author

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

@renatobenks-zz
Copy link
Author

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

@felippepuhle
Copy link
Contributor

felippepuhle commented Oct 25, 2017

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/

@renatobenks-zz
Copy link
Author

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

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

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

No branches or pull requests

3 participants