Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Scan: Polish UI & remove unused #2754

Merged
merged 7 commits into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

### Scan

- (impv) [\#2754](https://github.com/bandprotocol/bandchain/pull/2754) Polish UI, remove unused
- (impv) [\#2747](https://github.com/bandprotocol/bandchain/pull/2747) Patch for fast sync and new GuanYu DB
- (impv) [\#2740](https://github.com/bandprotocol/bandchain/pull/2740) Add UI test for all pages
- (impv) [\#2731](https://github.com/bandprotocol/bandchain/pull/2731) Add no transaction placeholder and fix mobile margin
Expand Down
1 change: 1 addition & 0 deletions scan/src/AppStyle.re
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ video {
p {
font-size: 14px;
line-height: 1.3;
margin-bottom: 1em;
}

h1,
Expand Down
6 changes: 5 additions & 1 deletion scan/src/components/ChainIDBadge.re
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type chainID =
| GuanYuDevnet
| GuanYuTestnet
| GuanYuPOA
| GuanYuMainnet
| Unknown;

let parseChainID =
Expand All @@ -83,12 +84,14 @@ let parseChainID =
| "band-guanyu-testnet2"
| "band-guanyu-testnet3" => GuanYuTestnet
| "band-guanyu-poa" => GuanYuPOA
| "band-guanyu-mainnet" => GuanYuMainnet
| _ => Unknown;

let getLink =
fun
| WenchangTestnet => "https://wenchang-testnet3.cosmoscan.io/"
| WenchangMainnet => "https://cosmoscan.io/"
| WenchangMainnet
| GuanYuMainnet => "https://cosmoscan.io/"
| GuanYuDevnet => "https://guanyu-devnet.cosmoscan.io/"
| GuanYuTestnet => "https://guanyu-testnet3.cosmoscan.io/"
| GuanYuPOA => "https://guanyu-poa.cosmoscan.io/"
Expand All @@ -101,6 +104,7 @@ let getName =
| GuanYuDevnet => "guanyu-devnet"
| GuanYuTestnet => "guanyu-testnet"
| GuanYuPOA => "guanyu-poa"
| GuanYuMainnet => "guanyu-mainnet"
| Unknown => "unknown";

[@react.component]
Expand Down
45 changes: 20 additions & 25 deletions scan/src/pages/BlockHomePage.re
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ let renderBodyMobile = (reserveIndex, blockSub: ApolloHooks.Subscription.variant

[@react.component]
let make = () => {
let (page, setPage) = React.useState(_ => 1);
let pageSize = 10;

let allSub = Sub.all2(BlockSub.getList(~pageSize, ~page, ()), BlockSub.count());
let blocksSub = BlockSub.getList(~pageSize=10, ~page=1, ());
let isMobile = Media.isMobile();

<Section>
Expand All @@ -112,9 +109,18 @@ let make = () => {
<Row.Grid alignItems=Row.Center marginBottom=40 marginBottomSm=24>
<Col.Grid col=Col.Twelve>
<Heading value="All Blocks" size=Heading.H2 marginBottom=40 marginBottomSm=24 />
{switch (allSub) {
| Data((_, blocksCount)) =>
<Heading value={(blocksCount |> Format.iPretty) ++ " In total"} size=Heading.H3 />
{switch (blocksSub) {
| Data(blocks) =>
<Heading
value={
blocks
->Belt.Array.get(0)
->Belt.Option.mapWithDefault(0, ({height}) => height |> ID.Block.toInt)
->Format.iPretty
++ " In total"
}
size=Heading.H3
/>
| _ => <LoadingCensorBar width=65 height=21 />
}}
</Col.Grid>
Expand Down Expand Up @@ -172,24 +178,13 @@ let make = () => {
</Col.Grid>
</Row.Grid>
</THead.Grid>}
{switch (allSub) {
| Data((blocks, blocksCount)) =>
let pageCount = Page.getPageCount(blocksCount, pageSize);
<>
{blocks
->Belt_Array.mapWithIndex((i, e) =>
isMobile
? renderBodyMobile(i, Sub.resolve(e)) : renderBody(i, Sub.resolve(e))
)
->React.array}
{isMobile
? React.null
: <Pagination
currentPage=page
pageCount
onPageChange={newPage => setPage(_ => newPage)}
/>}
</>;
{switch (blocksSub) {
| Data(blocks) =>
blocks
->Belt_Array.mapWithIndex((i, e) =>
isMobile ? renderBodyMobile(i, Sub.resolve(e)) : renderBody(i, Sub.resolve(e))
)
->React.array
| _ =>
Belt_Array.make(10, ApolloHooks.Subscription.NoData)
->Belt_Array.mapWithIndex((i, noData) =>
Expand Down
47 changes: 30 additions & 17 deletions scan/src/pages/ProposalHomePage.re
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module Styles = {
let badgeContainer = {
style([Media.mobile([position(`absolute), right(`px(16)), top(`px(16))])]);
};

let noDataImage = style([width(`auto), height(`px(70)), marginBottom(`px(16))]);
};

module ProposalCard = {
Expand Down Expand Up @@ -170,23 +172,34 @@ let make = () => {
<Row.Grid>
{switch (allSub) {
| Data((proposals, bondedTokenCount, voteStatSub)) =>
proposals
->Belt_Array.mapWithIndex((i, proposal) => {
let turnoutRate =
(
voteStatSub->Belt_MapInt.get(proposal.id |> ID.Proposal.toInt)
|> Belt_Option.getWithDefault(_, 0.)
)
/. (bondedTokenCount |> Coin.getBandAmountFromCoin)
*. 100.;
<ProposalCard
key={i |> string_of_int}
reserveIndex=i
proposalSub={Sub.resolve(proposal)}
turnoutRate
/>;
})
->React.array
proposals->Belt.Array.size > 0
? proposals
->Belt_Array.mapWithIndex((i, proposal) => {
let turnoutRate =
(
voteStatSub->Belt_MapInt.get(proposal.id |> ID.Proposal.toInt)
|> Belt_Option.getWithDefault(_, 0.)
)
/. (bondedTokenCount |> Coin.getBandAmountFromCoin)
*. 100.;
<ProposalCard
key={i |> string_of_int}
reserveIndex=i
proposalSub={Sub.resolve(proposal)}
turnoutRate
/>;
})
->React.array
: <EmptyContainer>
<img src=Images.noSource className=Styles.noDataImage />
<Heading
size=Heading.H4
value="No Proposal"
align=Heading.Center
weight=Heading.Regular
color=Colors.bandBlue
/>
</EmptyContainer>
| _ =>
Belt_Array.make(pageSize, ApolloHooks.Subscription.NoData)
->Belt_Array.mapWithIndex((i, noData) =>
Expand Down
16 changes: 13 additions & 3 deletions scan/src/pages/TxHomePage.re
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let make = () => {
let pageSize = 10;

let txsSub = TxSub.getList(~pageSize, ~page, ());
let latestTxsSub = TxSub.getList(~pageSize=1, ~page=1, ());
let txsCountSub = TxSub.count();

let isMobile = Media.isMobile();
Expand All @@ -13,9 +14,18 @@ let make = () => {
<Row.Grid alignItems=Row.Center marginBottom=40 marginBottomSm=24>
<Col.Grid col=Col.Twelve>
<Heading value="All Transactions" size=Heading.H2 marginBottom=40 marginBottomSm=24 />
{switch (txsCountSub) {
| Data(txsCountSub) =>
<Heading value={(txsCountSub |> Format.iPretty) ++ " In total"} size=Heading.H3 />
{switch (latestTxsSub) {
| Data(txs) =>
<Heading
value={
txs
->Belt.Array.get(0)
->Belt.Option.mapWithDefault(0, ({id}) => id)
->Format.iPretty
++ " In total"
}
size=Heading.H3
/>
| _ => <LoadingCensorBar width=65 height=21 />
}}
</Col.Grid>
Expand Down
7 changes: 6 additions & 1 deletion scan/src/reusable/EmptyContainer.re
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module Styles = {
open Css;
let emptyContainer =
style([justifyContent(`center), alignItems(`center), flexDirection(`column)]);
style([
justifyContent(`center),
alignItems(`center),
flexDirection(`column),
width(`percent(100.)),
]);

let height = he => style([height(he)]);
let display = dp => style([display(dp ? `flex : `none)]);
Expand Down
13 changes: 12 additions & 1 deletion scan/src/reusable/Markdown.re
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
module Styles = {
open Css;

let container = style([
selector("a", [wordBreak(`breakAll)]),
])
}


[@react.component]
let make = (~value) => {
value->MarkedJS.marked->MarkedJS.parse;
<div className=Styles.container>
value->MarkedJS.marked->MarkedJS.parse
</div>
};