Improve RelativeTimestamp theme

virtuoso-debug
Justin 2022-06-23 14:22:25 -04:00
rodzic 0a9e1c808b
commit 11f8bf979a
1 zmienionych plików z 4 dodań i 2 usunięć

Wyświetl plik

@ -120,6 +120,7 @@ class RelativeTimestamp extends React.Component {
intl: PropTypes.object.isRequired,
timestamp: PropTypes.string.isRequired,
year: PropTypes.number.isRequired,
theme: PropTypes.string,
futureDate: PropTypes.bool,
};
@ -129,6 +130,7 @@ class RelativeTimestamp extends React.Component {
static defaultProps = {
year: (new Date()).getFullYear(),
theme: 'inherit',
};
shouldComponentUpdate(nextProps, nextState) {
@ -173,13 +175,13 @@ class RelativeTimestamp extends React.Component {
}
render() {
const { timestamp, intl, year, futureDate, ...textProps } = this.props;
const { timestamp, intl, year, futureDate, theme, ...textProps } = this.props;
const date = new Date(timestamp);
const relativeTime = futureDate ? timeRemainingString(intl, date, this.state.now) : timeAgoString(intl, date, this.state.now, year);
return (
<Text {...textProps} theme='muted' tag='time' title={intl.formatDate(date, dateFormatOptions)}>
<Text {...textProps} theme={theme} tag='time' title={intl.formatDate(date, dateFormatOptions)}>
{relativeTime}
</Text>
);