-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Example usage with "Balance" component * Introduce sass and sass-variables * Remove "connect" from balance component
- Loading branch information
Showing
11 changed files
with
200 additions
and
122 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
declare module '*.scss' { | ||
const content: Record<string, string> | ||
export default content | ||
} | ||
|
||
declare module '*.svg' { | ||
const content: any | ||
export default content | ||
} |
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 '../../variables.scss'; | ||
|
||
.balanceRow { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
|
||
.balanceTitle { | ||
margin-bottom: 0; | ||
} | ||
|
||
.refreshButton { | ||
padding: 10px 24px 10px 58px; | ||
position: relative; | ||
|
||
&::before { | ||
content: ''; | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: contain; | ||
position: absolute; | ||
left: 24px; | ||
top: 0; | ||
bottom: 0; | ||
margin: auto; | ||
width: 20px; | ||
height: 20px; | ||
background-image: url('../../../public/assets/refresh_button_symbol.svg'); | ||
} | ||
|
||
&:hover::before { | ||
background-image: url('../../../public/assets/refresh_button_symbol_active.svg'); | ||
} | ||
|
||
@media screen and (min-width: $breakpoint-tablet) and (max-width: $breakpoint-desktop-small) { | ||
text-indent: -9999em; | ||
padding-left: 24px; | ||
|
||
&::before { | ||
left: 0; | ||
right: 0; | ||
} | ||
} | ||
|
||
@media screen and (max-width: $breakpoint-mobile) { | ||
text-indent: -9999em; | ||
padding-left: 24px; | ||
|
||
&::before { | ||
left: 0; | ||
right: 0; | ||
} | ||
} | ||
} |
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,55 +1,54 @@ | ||
import {h} from 'preact' | ||
import printAda from '../../helpers/printAda' | ||
import Conversions from './conversions' | ||
import {State, getActiveAccountInfo} from '../../state' | ||
import {getActiveAccountInfo} from '../../state' | ||
import {AdaIcon} from './svg' | ||
import actions from '../../actions' | ||
import {connect} from '../../libs/unistore/preact' | ||
import {useSelector, useActions} from '../../helpers/connect' | ||
import {Lovelace} from '../../types' | ||
import styles from './balance.module.scss' | ||
|
||
interface Props { | ||
balance: Lovelace | ||
reloadWalletInfo: (state: any) => void | ||
conversionRates: any | ||
} | ||
|
||
const Balance = ({balance, reloadWalletInfo, conversionRates}: Props) => ( | ||
<div className="balance card"> | ||
<h2 className="card-title balance-title">Available balance</h2> | ||
<div className="balance-row"> | ||
<div className="balance-amount" data-cy="SendBalanceAmount"> | ||
{isNaN(Number(balance)) ? balance : `${printAda(balance)}`} | ||
<AdaIcon /> | ||
const Balance = () => { | ||
const {reloadWalletInfo} = useActions(actions) | ||
const {conversionRates, balance} = useSelector((state) => ({ | ||
conversionRates: state.conversionRates && state.conversionRates.data, | ||
balance: getActiveAccountInfo(state).balance as Lovelace, | ||
})) | ||
return ( | ||
<div className="balance card"> | ||
<h2 className={`card-title ${styles.balanceTitle}`}>Available balance</h2> | ||
<div className={styles.balanceRow}> | ||
<div className="balance-amount" data-cy="SendBalanceAmount"> | ||
{isNaN(Number(balance)) ? balance : `${printAda(balance)}`} | ||
<AdaIcon /> | ||
</div> | ||
<button | ||
className={`button secondary balance ${styles.refreshButton}`} | ||
onClick={reloadWalletInfo} | ||
> | ||
Refresh | ||
</button> | ||
</div> | ||
<button className="button secondary balance refresh" onClick={reloadWalletInfo}> | ||
Refresh | ||
</button> | ||
{conversionRates && <Conversions balance={balance} conversionRates={conversionRates} />} | ||
{/* <div className="buy-ada-partner-wrapper"> | ||
<a | ||
className="button primary outline buy-ada-partner-link" | ||
href="https://exchange.adalite.io/" | ||
target="_blank" | ||
> | ||
Buy/Sell ADA | ||
</a> | ||
<span className="buy-ada-partner-logo"> | ||
Powered by | ||
<img | ||
className="buy-ada-partner-logo-img" | ||
src="assets/coinswitch-logo.svg" | ||
alt="CoinSwitch logo" | ||
/> | ||
</span> | ||
</div> */} | ||
</div> | ||
{conversionRates && <Conversions balance={balance} conversionRates={conversionRates} />} | ||
{/* <div className="buy-ada-partner-wrapper"> | ||
<a | ||
className="button primary outline buy-ada-partner-link" | ||
href="https://exchange.adalite.io/" | ||
target="_blank" | ||
> | ||
Buy/Sell ADA | ||
</a> | ||
<span className="buy-ada-partner-logo"> | ||
Powered by | ||
<img | ||
className="buy-ada-partner-logo-img" | ||
src="assets/coinswitch-logo.svg" | ||
alt="CoinSwitch logo" | ||
/> | ||
</span> | ||
</div> */} | ||
</div> | ||
) | ||
) | ||
} | ||
|
||
export default connect( | ||
(state: State) => ({ | ||
conversionRates: state.conversionRates && state.conversionRates.data, | ||
balance: getActiveAccountInfo(state).balance, | ||
}), | ||
actions | ||
)(Balance) | ||
export default Balance |
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,4 @@ | ||
$breakpoint-mobile: 767px; | ||
$breakpoint-tablet: 1024px; | ||
$breakpoint-desktop-small: 1112px; | ||
$breakpoint-desktop-large: 1366px; |
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
Oops, something went wrong.