Merge branch 'fix-text-theme' into 'develop'
Improve RelativeTimestamp theme See merge request soapbox-pub/soapbox-fe!1564
This commit is contained in:
commit
04a56c2ad5
1 changed files with 4 additions and 2 deletions
|
@ -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>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue