-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(issues) Extra group times into a reusable component
I need this exact same logic and presentation in the events-v2 modal. Having a separate display component will help with that. Refs SEN-708
- Loading branch information
Showing
3 changed files
with
82 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react'; | ||
import styled from 'react-emotion'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import {t} from 'app/locale'; | ||
import InlineSvg from 'app/components/inlineSvg'; | ||
import TimeSince from 'app/components/timeSince'; | ||
import space from 'app/styles/space'; | ||
import overflowEllipsis from 'app/styles/overflowEllipsis'; | ||
|
||
/** | ||
* Renders the first & last seen times for a group or event with | ||
* a clock icon. | ||
*/ | ||
const Times = props => { | ||
const {lastSeen, firstSeen} = props; | ||
return ( | ||
<Container> | ||
<div css={overflowEllipsis}> | ||
{lastSeen && ( | ||
<React.Fragment> | ||
<GroupTimeIcon src="icon-clock-sm" /> | ||
<TimeSince date={lastSeen} suffix={t('ago')} /> | ||
</React.Fragment> | ||
)} | ||
{firstSeen && lastSeen && ( | ||
<span className="hidden-xs hidden-sm"> — </span> | ||
)} | ||
{firstSeen && ( | ||
<TimeSince date={firstSeen} suffix={t('old')} className="hidden-xs hidden-sm" /> | ||
)} | ||
</div> | ||
</Container> | ||
); | ||
}; | ||
Times.propTypes = { | ||
lastSeen: PropTypes.string, | ||
firstSeen: PropTypes.string, | ||
}; | ||
|
||
const Container = styled('div')` | ||
margin-right: ${space(2)}; | ||
flex-shrink: 1; | ||
min-width: 0; /* flex-hack for overflow-ellipsised children */ | ||
`; | ||
|
||
const GroupTimeIcon = styled(InlineSvg)` | ||
/* this is solely for optics, since TimeSince always begins | ||
with a number, and numbers do not have descenders */ | ||
font-size: 11px; | ||
margin-right: 4px; | ||
transform: translateY(-1px); | ||
`; | ||
|
||
export default Times; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters