Jack Mallers
7 years ago
13 changed files with 340 additions and 66 deletions
@ -0,0 +1,83 @@ |
|||
import React from 'react' |
|||
import PropTypes from 'prop-types' |
|||
|
|||
import styles from './Countdown.scss' |
|||
|
|||
class Countdown extends React.Component { |
|||
constructor(props) { |
|||
super(props) |
|||
console.log('countDownDate: ', props.countDownDate) |
|||
this.state = { |
|||
days: null, |
|||
hours: null, |
|||
minutes: null, |
|||
seconds: null, |
|||
expired: false, |
|||
interval: null |
|||
} |
|||
|
|||
this.timerInterval = this.timerInterval.bind(this) |
|||
} |
|||
|
|||
componentDidMount() { |
|||
const interval = setInterval(this.timerInterval, 1000) |
|||
// store interval in the state so it can be accessed later
|
|||
this.setState({ interval }) |
|||
} |
|||
|
|||
componentWillUnmount() { |
|||
// use interval from the state to clear the interval
|
|||
clearInterval(this.state.interval) |
|||
} |
|||
|
|||
timerInterval() { |
|||
const convertTwoDigits = n => n > 9 ? n : ('0' + n).slice(-2) |
|||
|
|||
const now = new Date().getTime() |
|||
const distance = (this.props.countDownDate * 1000) - now |
|||
|
|||
if (distance <= 0) { |
|||
this.setState({ expired: true }) |
|||
clearInterval(this.state.interval) |
|||
return |
|||
} |
|||
|
|||
const days = convertTwoDigits(Math.floor(distance / (1000 * 60 * 60 * 24))) |
|||
const hours = convertTwoDigits(Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))) |
|||
const minutes = convertTwoDigits(Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60))) |
|||
const seconds = convertTwoDigits(Math.floor((distance % (1000 * 60)) / 1000)) |
|||
|
|||
this.setState({ days, hours, minutes, seconds }) |
|||
} |
|||
|
|||
render() { |
|||
const { days, hours, minutes, seconds, expired } = this.state |
|||
|
|||
if (expired) { return <span className={`${styles.container} ${styles.expired}`}>Expired</span> } |
|||
if (!days && !hours && !minutes && !seconds) { return <span className={styles.container} /> } |
|||
|
|||
return ( |
|||
<span className={styles.container}> |
|||
<i className={styles.caption}>Expires in</i> |
|||
<i> |
|||
{days > 0 && `${days}:`} |
|||
</i> |
|||
<i> |
|||
{hours > 0 && `${hours}:`} |
|||
</i> |
|||
<i> |
|||
{minutes > 0 && `${minutes}:`} |
|||
</i> |
|||
<i> |
|||
{seconds >= 0 && `${seconds}`} |
|||
</i> |
|||
</span> |
|||
) |
|||
} |
|||
} |
|||
|
|||
Countdown.propTypes = { |
|||
countDownDate: PropTypes.number.isRequired |
|||
} |
|||
|
|||
export default Countdown |
@ -0,0 +1,16 @@ |
|||
@import '../../variables.scss'; |
|||
|
|||
.container { |
|||
display: block; |
|||
text-align: center; |
|||
font-size: 12px; |
|||
min-height: 12px; |
|||
|
|||
&.expired { |
|||
color: $red; |
|||
} |
|||
} |
|||
|
|||
.caption { |
|||
margin-right: 4px; |
|||
} |
@ -0,0 +1,127 @@ |
|||
@import '../../variables.scss'; |
|||
|
|||
.container { |
|||
color: $white; |
|||
} |
|||
|
|||
.content { |
|||
background: $spaceblue; |
|||
width: 85%; |
|||
margin: 50px auto; |
|||
padding-top: 30px; |
|||
|
|||
.top { |
|||
padding: 10px 60px; |
|||
|
|||
.details { |
|||
display: flex; |
|||
flex-direction: row; |
|||
justify-content: space-between; |
|||
margin-bottom: 40px; |
|||
|
|||
.amount { |
|||
display: flex; |
|||
flex-direction: row; |
|||
align-items: center; |
|||
position: relative; |
|||
|
|||
.symbol { |
|||
color: $red; |
|||
|
|||
&.active { |
|||
color: $green; |
|||
} |
|||
} |
|||
|
|||
h1 { |
|||
font-size: 40px; |
|||
margin-right: 10px; |
|||
} |
|||
|
|||
.currentCurrency { |
|||
cursor: pointer; |
|||
transition: 0.25s all; |
|||
|
|||
&:hover { |
|||
opacity: 0.5; |
|||
} |
|||
|
|||
span { |
|||
font-size: 14px; |
|||
|
|||
&:nth-child(1) { |
|||
font-weight: bold; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
ul { |
|||
visibility: hidden; |
|||
position: absolute; |
|||
top: 40px; |
|||
right: -50px; |
|||
|
|||
&.active { |
|||
visibility: visible; |
|||
} |
|||
|
|||
li { |
|||
padding: 8px 15px; |
|||
background: #191919; |
|||
cursor: pointer; |
|||
transition: 0.25s hover; |
|||
border-bottom: 1px solid #0f0f0f; |
|||
|
|||
&:hover { |
|||
background: #0f0f0f; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
.date { |
|||
font-size: 12px; |
|||
text-align: right; |
|||
|
|||
.notPaid { |
|||
color: #FF8A65; |
|||
margin-top: 5px; |
|||
} |
|||
|
|||
p { |
|||
margin-bottom: 5px; |
|||
|
|||
&:nth-child(2) { |
|||
opacity: 0.5; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
.bottom { |
|||
background: #31343f; |
|||
padding: 40px; |
|||
|
|||
.txHash, .blockHash { |
|||
margin: 40px 0; |
|||
|
|||
h4 { |
|||
font-size: 10px; |
|||
margin-bottom: 10px; |
|||
} |
|||
|
|||
p { |
|||
font-size: 14px; |
|||
text-decoration: underline; |
|||
cursor: pointer; |
|||
transition: all 0.25s; |
|||
|
|||
&:hover { |
|||
opacity: 0.5; |
|||
} |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue