Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display custom logo when using kadenamint networks #622

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion common/src/Common/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{-# LANGUAGE ViewPatterns #-}

module Common.Network
( NetworkName
( NetworkName(..)
, textNetworkName
, mkNetworkName
, networksPath
Expand Down
1 change: 1 addition & 0 deletions frontend/frontend.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ library
, bimap
, bound
, bytestring
, case-insensitive
, cassava
, common
, constraints
Expand Down
21 changes: 15 additions & 6 deletions frontend/src/Frontend/ReplGhcjs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import Control.Lens
import Control.Monad.Reader (ask)
import Control.Monad.State.Strict
import Data.Aeson (FromJSON, ToJSON)
import Data.CaseInsensitive (original)
import Data.Default (Default (..))
import Data.Function (on)
import Data.Some (Some(..))
import Data.String (IsString)
import Data.Text (Text)
import GHCJS.DOM.EventM (on)
import qualified GHCJS.DOM.EventM as EventM
import GHCJS.DOM.GlobalEventHandlers (keyPress)
import GHCJS.DOM.KeyboardEvent (getCtrlKey, getKey, getKeyCode, getMetaKey)
import GHCJS.DOM.Types (HTMLElement (..), unElement)
Expand Down Expand Up @@ -95,7 +97,14 @@ app sidebarExtra fileFFI appCfg = Store.versionedFrontend (Store.versionedStorag
ideL <- makeIde fileFFI appCfg cfg
FRPHandler signingReq signingResp <- handleEndpoints ideL appCfg

walletSidebar sidebarExtra
let
logo = divClass "sidebar__logo" $ elDynAttr "img" ?? blank $ ffor (ideL ^. network_selectedNetwork) $ \n ->
let matches = T.isPrefixOf `on` T.toLower
in "src" =: if "kadenamint" `matches` original (unNetworkName n)
then static @"img/logo-kadenamint.png"
else static @"img/logo.png"

walletSidebar logo sidebarExtra
updates <- divClass "page" $ do
let mkPageContent c = divClass (c <> " page__content visible")

Expand Down Expand Up @@ -194,9 +203,9 @@ walletSidebar
)
=> m ()
-> m ()
walletSidebar sidebarExtra = elAttr "div" ("class" =: "sidebar") $ do
divClass "sidebar__logo" $ elAttr "img" ("src" =: static @"img/logo.png") blank

-> m ()
walletSidebar logo sidebarExtra = elAttr "div" ("class" =: "sidebar") $ do
logo
elAttr "div" ("class" =: "sidebar__content") $ do
route <- demux . fmap (\(r :/ _) -> Some r) <$> askRoute

Expand Down Expand Up @@ -241,7 +250,7 @@ codePanel appCfg cls m = elDynKlass "div" (cls <> "pane") $ do
getCtrlEnterEvent e = do
(onCtrlEnter, triggerEv) <- newTriggerEvent
let htmlElement = HTMLElement . unElement $ _element_raw e
void $ liftJSM $ htmlElement `on` keyPress $ do
void $ liftJSM $ htmlElement `EventM.on` keyPress $ do
ev <- ask
hasCtrl <- liftJSM $ getCtrlKey ev
hasMeta <- liftJSM $ getMetaKey ev
Expand Down
Binary file added static/img/logo-kadenamint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.