From d2adff01914671340e6d56a11ea649226ec960e7 Mon Sep 17 00:00:00 2001 From: Martin Krulis Date: Wed, 20 Jul 2022 21:21:13 +0200 Subject: [PATCH] Improving appearance of date time, adding full time in overlay for comment times. --- .../widgets/Comments/Comment/Comment.js | 2 +- .../widgets/Comments/Comment/Status/Posted.js | 19 ++++++++++++++++--- src/components/widgets/DateTime/DateTime.js | 13 ++++++++----- src/components/widgets/DateTime/DateTime.less | 4 ---- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/components/widgets/Comments/Comment/Comment.js b/src/components/widgets/Comments/Comment/Comment.js index ccd2ec80a..9d7245a02 100644 --- a/src/components/widgets/Comments/Comment/Comment.js +++ b/src/components/widgets/Comments/Comment/Comment.js @@ -47,7 +47,7 @@ const Comment = ({ })}> {user.name} - {status === 'posted' && } + {status === 'posted' && } {status === 'failed' && repost && repost(id)} />} {status === 'pending' && } diff --git a/src/components/widgets/Comments/Comment/Status/Posted.js b/src/components/widgets/Comments/Comment/Status/Posted.js index 505a127bf..42a869587 100644 --- a/src/components/widgets/Comments/Comment/Status/Posted.js +++ b/src/components/widgets/Comments/Comment/Status/Posted.js @@ -1,20 +1,33 @@ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import { FormattedRelativeTime } from 'react-intl'; +import DateTime from '../../../DateTime'; -const Posted = ({ right, postedAt }) => ( +const OVERLAY_PROPS = { + showRelative: false, +}; + +const Posted = ({ id, right, postedAt }) => ( - + ); Posted.propTypes = { + id: PropTypes.string.isRequired, right: PropTypes.bool.isRequired, postedAt: PropTypes.number.isRequired, }; diff --git a/src/components/widgets/DateTime/DateTime.js b/src/components/widgets/DateTime/DateTime.js index ac64bedf7..c449b0d70 100644 --- a/src/components/widgets/DateTime/DateTime.js +++ b/src/components/widgets/DateTime/DateTime.js @@ -5,6 +5,7 @@ import { FormattedDate, FormattedTime, FormattedRelativeTime } from 'react-intl' import classnames from 'classnames'; import Icon from '../../icons'; +import { EMPTY_OBJ } from '../../../helpers/common'; import styles from './DateTime.less'; @@ -40,28 +41,27 @@ const dateTime = ({ + {(showTime || showRelative) && } )} - ​ + {showTime && ( + {showRelative && } )} - ​ + {showRelative && ( @@ -76,6 +76,7 @@ const DateTime = ({ showTime = true, showRelative = false, showOverlay = false, + overlayProps = EMPTY_OBJ, overlayTooltipId = 'datetime', customTooltip = null, ...props @@ -96,6 +97,7 @@ const DateTime = ({ showSeconds: true, isDeadline: false, noWrap: false, + ...overlayProps, })} }> @@ -133,6 +135,7 @@ DateTime.propTypes = { showOverlay: PropTypes.bool, overlayTooltipId: PropTypes.string, customTooltip: PropTypes.any, + overlayProps: PropTypes.object, }; export default DateTime; diff --git a/src/components/widgets/DateTime/DateTime.less b/src/components/widgets/DateTime/DateTime.less index c1812979d..c49681954 100644 --- a/src/components/widgets/DateTime/DateTime.less +++ b/src/components/widgets/DateTime/DateTime.less @@ -10,7 +10,3 @@ .trailingRelative::after { content: ')'; } - -.standaloneRelative { - font-style: italic; -}