Improve RelativeTimestamp theme

This commit is contained in:
Justin 2022-06-23 14:22:25 -04:00
parent 0a9e1c808b
commit 11f8bf979a
1 changed files with 4 additions and 2 deletions

View File

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