forked from austintgriffith/burner-wallet
-
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.
Merge pull request austintgriffith#209 from vrde/master
Simplify balance view and "advanced features"
- Loading branch information
Showing
5 changed files
with
150 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { Text } from "rimble-ui"; | ||
|
||
// Here are all the classes that can be used to style the balance. | ||
// Some of them are not in use now, but are listed for clarity. | ||
|
||
const StyledBalance = styled.div` | ||
text-align: center; | ||
padding: 20px 0; | ||
color: var(--primary); | ||
.otherAssets { | ||
color: var(--dark-text); | ||
} | ||
span { | ||
font-size: 200%; | ||
} | ||
.integer { | ||
font-size: 400%; | ||
} | ||
.group { | ||
} | ||
.decimal { | ||
} | ||
.fraction { | ||
} | ||
.literal { | ||
} | ||
.currency { | ||
font-size: 100%; | ||
} | ||
`; | ||
|
||
export default ({ mainAmount, otherAmounts, currencyDisplay }) => { | ||
if (isNaN(mainAmount) || typeof mainAmount === "undefined") { | ||
mainAmount = 0.0; | ||
} | ||
|
||
const otherAssetsTotal = Object.values(otherAmounts).reduce( | ||
(acc, curr) => acc + parseInt(curr, 10), | ||
0 | ||
); | ||
const parts = currencyDisplay(mainAmount, true); | ||
|
||
return ( | ||
<> | ||
<StyledBalance> | ||
{parts.map(({ type, value }) => ( | ||
<Text.span className={type}>{value}</Text.span> | ||
))} | ||
{otherAssetsTotal > 0 && ( | ||
<Text className="otherAssets" italic fontSize={1} textAlign="center"> | ||
+{currencyDisplay(otherAssetsTotal)} in other assets | ||
</Text> | ||
)} | ||
</StyledBalance> | ||
<hr /> | ||
</> | ||
); | ||
}; |