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

Add a CSS Class or Style Color to Past DateTime #223

Open
jasondavis opened this issue May 23, 2015 · 6 comments
Open

Add a CSS Class or Style Color to Past DateTime #223

jasondavis opened this issue May 23, 2015 · 6 comments

Comments

@jasondavis
Copy link

In my app that is using this TimeAgo library I would like to style the text with a different color using CSS when the DateTime text is past the current DateTime of today.

So if it says 4 days from now it will be regular just how it is normally.
However if it is in the past like 4 days ago then I could have the text be in a different color like red.

Looking in Chrome Dev tools, it does not appear to add any special CSS class or styles to the time element in which would let me target a past date string.

Does anyone know of a simple way, or anyway really that I could change the text color if the date is in the past?

I saw another post on StackOverflow with the same question buit no answers so far here http://stackoverflow.com/questions/30410273/jquery-timeago-library-to-change-color-of-text-if-the-datetime-is-in-the-past

Any ideas or help?

@rmm5t
Copy link
Owner

rmm5t commented May 26, 2015

I don't think I have a good answer here. There's no direct support for this right now, but it's something I would consider.

Perhaps a timeago-past and timeago-future style class could be added to the elements to represent whether the underlying time is in the past or future.

I'd be willing to accept a clean PR to add this feature.

@chaimleib
Copy link

+1

@jakerb
Copy link

jakerb commented Aug 28, 2015

Here's a Gist of Timeago with colors for tense. You can change the default blue and red to either a color name of hex value from the inPastColor variable.
enjoy

@chaimleib
Copy link

Thanks, but the Gist does not play nicely with internationalization or custom strings. We need something with deeper integration.

@jakerb
Copy link

jakerb commented Aug 28, 2015

Hi @chaimleib, I've rewritten the Gist for this so it works better for internationalisation. Let me know your thoughts on the update.

@PaoloFalomo
Copy link

@jakerb does this replace the timeagojs or do we need just to add it as source after timeagojs?

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

No branches or pull requests

5 participants