This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): use date formatting component for rendering date [#3600]
- Loading branch information
Showing
10 changed files
with
89 additions
and
52 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
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
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
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
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,40 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { connect } from 'react-redux' | ||
import { FormattedDate, FormattedTime } from 'react-intl' | ||
import { settingsSelectors } from 'reducers/settings' | ||
|
||
const mapStateToProps = state => ({ | ||
timeDisplayMode: settingsSelectors.currentConfig(state).timeDisplayMode, | ||
}) | ||
|
||
const FormattedDateTime = ({ timeDisplayMode, format, month = 'long', value }) => { | ||
const hour12 = timeDisplayMode && timeDisplayMode === '12hour' ? 1 : 0 | ||
switch (format) { | ||
case 'date': | ||
return <FormattedDate day="2-digit" month={month} value={value} year="numeric" /> | ||
case 'time': | ||
return <FormattedTime hour12={hour12} value={value} /> | ||
default: | ||
return ( | ||
<FormattedDate | ||
day="2-digit" | ||
hour="numeric" | ||
hour12={hour12} | ||
minute="numeric" | ||
month={month} | ||
value={value} | ||
year="numeric" | ||
/> | ||
) | ||
} | ||
} | ||
|
||
FormattedDateTime.propTypes = { | ||
format: PropTypes.string, | ||
month: PropTypes.string, | ||
timeDisplayMode: PropTypes.string, | ||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]).isRequired, | ||
} | ||
|
||
export default connect(mapStateToProps)(FormattedDateTime) |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
export CopyButton from './CopyButton' | ||
export CryptoSelector from './CryptoSelector' | ||
export CryptoValue from './CryptoValue' | ||
export FormattedDateTime from './FormattedDateTime' | ||
export FiatSelector from './FiatSelector' | ||
export FiatValue from './FiatValue' | ||
export CryptoValueSelector from './CryptoValueSelector' |