Conversation
|
|
||
| if (diffInSeconds > TIMEAGO_NOW_THRESHOLD) { | ||
| const minutes = Math.round(diffInSeconds / MINUTE_SECONDS); | ||
| return withCustomRender(renderMinutes, minutes, `${minutes}m`); |
There was a problem hiding this comment.
Should this string (the default ones) be translated maybe? Just a guess.
There was a problem hiding this comment.
I think react-common doesn't handle translations. That's why I thought we need those custom renders to provide translations in specific apps. With this, we can create a wrapper for Timeago for example in Feeds which will handle translations there.
There was a problem hiding this comment.
Some components of design-system handles i18n, so I think it wouldn't be an issue to handle this in react-common as well. I see that we don't have any components in this repo that translates anything but maybe we should think about that.
| } | ||
|
|
||
| // less than a minute ago | ||
| return typeof (renderNow) === 'function' ? renderNow() : 'now'; |
There was a problem hiding this comment.
Shouldn't this be translated?
vforge
left a comment
There was a problem hiding this comment.
I like that idea. Good customization
| display: this.props.datetime, | ||
| }; | ||
| export default function Timeago({ | ||
| datetime, renderNow, renderDate, renderDays, renderHours, renderMinutes, |
There was a problem hiding this comment.
Can render* function return JSX/JS string? Ideally Id like to use renderNow={() => <strong>NOW!</string>}
There was a problem hiding this comment.
You can return anything because it will just call your render* function and return its result. Check this fragment out: return typeof (renderNow) === 'function' ? renderNow() : 'now'; So sure, you can use it like you did it above :)
I noticed that Timeago component had several issues, so I decided to update it because we use it in several places among different projects.
Changes:
datetimeprop - it nows correctly handleDateobject andstringrepresenting a datedatetimeattribute for<time />tag to usetoLocaleString()titleattribute for<time />minutesparam asnumberhoursparam asnumberdaysparam asnumberdateparam asstring(localDateString)