Skip to content

Commit

Permalink
FE: Improved formatting of long currency names in the wallet balances…
Browse files Browse the repository at this point in the history
… table.
  • Loading branch information
Kris Jenkins authored and krisajenkins committed Aug 3, 2020
1 parent 68904bc commit df4ed01
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 13 additions & 5 deletions web-common/src/Chain/View.purs
Expand Up @@ -27,6 +27,7 @@ import Data.Newtype (unwrap)
import Data.Number.Extra (toLocaleString)
import Data.Set (Set)
import Data.Set as Set
import Data.String.Extra (abbreviate)
import Data.Tuple.Nested ((/\))
import Halogen.HTML (ClassName(..), HTML, IProp, br_, div, div_, h2_, hr_, li_, small_, span_, strong_, table, tbody_, td, text, th, th_, thead_, tr, tr_, ul_)
import Halogen.HTML.Events (onClick)
Expand Down Expand Up @@ -212,7 +213,14 @@ balancesTable sequenceId walletKeys balances =
[ colSpan (Set.size s)
, class_ textTruncate
]
[ showCurrency currency ]
[ let
formatted = showCurrency currency
in
ClipboardAction
<$> showShortCopyLong
formatted
(Just [ text $ abbreviate 15 formatted ])
]
]
)
headings
Expand Down Expand Up @@ -409,7 +417,7 @@ valueView (Value { getValue: (AssocMap.Map currencies) }) = div_ (interleave hr_
currencyView (JsonTuple (currency /\ (AssocMap.Map tokens))) =
div_
[ div [ class_ Bootstrap.textTruncate ]
[ strong_ [ showCurrency currency ] ]
[ strong_ [ text $ showCurrency currency ] ]
, div_ (tokenView <$> tokens)
]

Expand All @@ -424,10 +432,10 @@ valueView (Value { getValue: (AssocMap.Map currencies) }) = div_ (interleave hr_
formatAmount :: Int -> String
formatAmount = toLocaleString <<< toNumber

showCurrency :: forall p i. CurrencySymbol -> HTML p i
showCurrency (CurrencySymbol { unCurrencySymbol: "" }) = text "Ada"
showCurrency :: CurrencySymbol -> String
showCurrency (CurrencySymbol { unCurrencySymbol: "" }) = "Ada"

showCurrency (CurrencySymbol { unCurrencySymbol: symbol }) = text symbol
showCurrency (CurrencySymbol { unCurrencySymbol: symbol }) = symbol

showToken :: forall p i. TokenName -> HTML p i
showToken (TokenName { unTokenName: "" }) = text "Lovelace"
Expand Down
5 changes: 0 additions & 5 deletions web-common/static/chain.scss
Expand Up @@ -138,11 +138,6 @@
height: 3rem;
}

thead th {
text-align: center;
vertical-align: middle;
}

tbody tr th:first-child {
max-width: 12rem;
overflow: hidden;
Expand Down

0 comments on commit df4ed01

Please sign in to comment.