forked from LN-Zap/zap-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix LN-Zap#3600
- Loading branch information
Showing
10 changed files
with
91 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,42 @@ | ||
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 = '12hour', format, month = 'long', value }) => { | ||
const is12Hour = timeDisplayMode === '12hour' | ||
|
||
switch (format) { | ||
case 'date': | ||
return <FormattedDate day="2-digit" month={month} value={value} year="numeric" /> | ||
case 'time': | ||
return <FormattedTime hour12={is12Hour} value={value} /> | ||
default: | ||
return ( | ||
<FormattedDate | ||
day="2-digit" | ||
hour="numeric" | ||
hour12={is12Hour} | ||
minute="numeric" | ||
month={month} | ||
value={value} | ||
year="numeric" | ||
/> | ||
) | ||
} | ||
} | ||
|
||
FormattedDateTime.propTypes = { | ||
format: PropTypes.oneOf(['date', 'time']), | ||
month: PropTypes.string, | ||
timeDisplayMode: PropTypes.oneOf(['12hour', '24hour']), | ||
value: PropTypes.oneOfType([PropTypes.number, 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' |