import { Component } from 'inferno';
import moment from 'moment';
-import { getMomentLanguage, setupTippy } from '../utils';
+import { getMomentLanguage, capitalizeFirstLetter } from '../utils';
import { i18n } from '../i18next';
interface MomentTimeProps {
when_?: string;
updated?: string;
};
+ showAgo?: boolean;
}
export class MomentTime extends Component<MomentTimeProps, any> {
moment.locale(lang);
}
- componentDidMount() {
- setupTippy();
- }
-
render() {
if (this.props.data.updated) {
return (
<span
- data-tippy-content={this.format(this.props.data.updated)}
+ data-tippy-content={`${capitalizeFirstLetter(
+ i18n.t('modified')
+ )} ${this.format(this.props.data.updated)}`}
className="font-italics pointer unselectable"
>
- {i18n.t('modified')} {moment.utc(this.props.data.updated).fromNow()}
+ <svg class="icon icon-inline mr-1">
+ <use xlinkHref="#icon-edit-2"></use>
+ </svg>
+ {moment.utc(this.props.data.updated).fromNow(!this.props.showAgo)}
</span>
);
} else {
className="pointer unselectable"
data-tippy-content={this.format(str)}
>
- {moment.utc(str).fromNow()}
+ {moment.utc(str).fromNow(!this.props.showAgo)}
</span>
);
}