Skip to content

Commit

Permalink
Restyle wallet screen
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfmpe committed Nov 5, 2019
1 parent 5cd9aef commit 71991ac
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 20 deletions.
1 change: 0 additions & 1 deletion backend/sass/common.blocks/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

.page__content {
display: none;
margin: 2rem;
flex-grow: 1;
}

Expand Down
38 changes: 38 additions & 0 deletions backend/sass/common.blocks/_wallet.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*********************************************************************************
Ensure classes and structure are created in accordance with the BEM methodology.
For more info: https://en.bem.info/methodology/quick-start/
*********************************************************************************/

@import '../include/defs';

.keys-list {
margin-top: 20px;
margin-left: 22px;
}

.wallet__table-row {
border-style: $std-border-style;
border-color: $std-border-color;
border-width: $std-border-width;
}

.wallet__table-heading {
@extend .table__heading;
padding-left: $medium-padding;
padding-right: $medium-padding;
}

.wallet__table-cell {
padding: $medium-padding;
text-overflow: ellipsis;
overflow: hidden;
}

.wallet__table-button {
padding: 0 $medium-padding;
margin-right: $medium-margin;

text-overflow: ellipsis;
overflow: hidden;
}
2 changes: 1 addition & 1 deletion backend/sass/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
@import 'common.blocks/error-list';
@import 'common.blocks/signal';
@import 'common.blocks/transaction-status';

@import 'common.blocks/wallet';
11 changes: 11 additions & 0 deletions frontend/src/Frontend/UI/Button.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module Frontend.UI.Button
, refreshButton
, confirmButton
, cancelButton
, receiveButton
, sendButton
, copyToClipboard
-- ** Images in buttons
, btnTextIcon
Expand Down Expand Up @@ -271,6 +273,15 @@ cancelButton :: StaticButtonConstraints t m => UiButtonCfg -> Text -> m (Event t
cancelButton cfg msg =
uiButton (cfg & uiButtonCfg_class <>~ "button_type_tertiary") $ text msg

receiveButton :: StaticButtonConstraints t m => UiButtonCfg -> m (Event t ())
receiveButton cfg =
uiButton (cfg & uiButtonCfg_class <>~ "button_type_secondary" <> "button_type_secondary") $
btnTextIcon (static @"img/receive.svg") "Receive" blank >> text "Receive"

sendButton :: StaticButtonConstraints t m => UiButtonCfg -> m (Event t ())
sendButton cfg =
uiButton (cfg & uiButtonCfg_class <>~ "button_type_secondary" <> "button_type_secondary") $
btnTextIcon (static @"img/send.svg") "Send" blank >> text "Send"

-- | Create HTML element attributes from config.
toBtnAttrs :: UiButtonCfg -> Map Text Text
Expand Down
43 changes: 25 additions & 18 deletions frontend/src/Frontend/UI/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,21 @@ uiKeyItems aWallet = do
<> "class" =: "wallet table"
events <- elAttr "table" tableAttrs $ do
el "colgroup" $ do
elAttr "col" ("style" =: "width: 16%") blank
elAttr "col" ("style" =: "width: 16%") blank
elAttr "col" ("style" =: "width: 16%") blank
elAttr "col" ("style" =: "width: 16%") blank
elAttr "col" ("style" =: "width: 16%") blank
elAttr "col" ("style" =: "width: 20%") blank
elAttr "col" ("style" =: "width: 35%") blank
elAttr "col" ("style" =: "width: 15%") blank
elAttr "col" ("style" =: "width: 35%") blank
elAttr "col" ("style" =: "width: 15%") blank
elAttr "col" ("style" =: "width: 10%") blank
el "thead" $ el "tr" $ do
let mkHeading = elClass "th" "table__heading" . text
let mkHeading = elClass "th" "wallet__table-heading" . text
traverse_ mkHeading $
[ "Account Name"
, "Public Key"
, "Chain ID"
, "Notes"
, "Balance"
, ""
]

el "tbody" $ listWithKey keyMap uiKeyItem
Expand All @@ -164,22 +165,28 @@ uiKeyItem i d = do
md <- maybeDyn $ someAccount Nothing Just <$> d
switchHold never <=< dyn $ ffor md $ \case
Nothing -> pure never
Just account -> elClass "tr" "table__row" $ do
el "td" $ dynText $ unAccountName . _account_name <$> account
Just account -> elClass "tr" "wallet__table-row" $ do
let td = elClass "td" "wallet__table-cell"

let public = keyToText . _keyPair_publicKey . _account_key <$> account
elClass "td" "wallet__key wallet__key_type_public" $ dynText public
el "td" $ dynText $ Pact._chainId . _account_chainId <$> account
el "td" $ dynText $ _account_notes <$> account
td $ dynText $ unAccountName . _account_name <$> account
td $ dynText $ keyToText . _keyPair_publicKey . _account_key <$> account
td $ dynText $ Pact._chainId . _account_chainId <$> account
td $ dynText $ _account_notes <$> account
-- TODO balance
el "td" $ text "Balance Placeholder"
td $ text "Balance Placeholder"

onDel <- elClass "td" "wallet__delete" $
deleteButton $
def & uiButtonCfg_title .~ Just "Delete key permanently"
& uiButtonCfg_class %~ (<> "wallet__add-delete-button")
td $ do
let cfg = def
& uiButtonCfg_class <>~ "wallet__table-button"

pure (attachWith (\a _ -> (i, _account_name a)) (current account) onDel)
receiveButton $ cfg & uiButtonCfg_disabled .~ True
sendButton $ cfg & uiButtonCfg_disabled .~ True

onDel <- do
deleteButton $
def & uiButtonCfg_title .~ Just "Delete key permanently"
& uiButtonCfg_class %~ (<> "wallet__add-delete-button")
pure (attachWith (\a _ -> (i, _account_name a)) (current account) onDel)

-- | Get the balance of an account from the network. 'Nothing' indicates _some_
-- failure, either a missing account or connectivity failure. We have no need to
Expand Down
6 changes: 6 additions & 0 deletions static/img/receive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions static/img/send.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 71991ac

Please sign in to comment.