Merge branch 'fix-text-theme' into 'develop'

Improve RelativeTimestamp theme

See merge request soapbox-pub/soapbox-fe!1564
virtuoso-debug
Justin 2022-06-23 18:39:32 +00:00
commit 04a56c2ad5
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>
);