halogen-websocket-ipc-playzone/src/App/Nav.purs

69 lines
3.1 KiB
Plaintext
Raw Normal View History

2023-07-08 04:17:13 +02:00
module App.Nav where
import Prelude
import CSSClasses as C
import Halogen.HTML as HH
2023-07-08 05:41:41 +02:00
import Halogen.HTML.Events as HE
2023-07-08 04:17:13 +02:00
import Halogen.HTML.Properties as HP
import Halogen.HTML.Properties.ARIA as ARIA
import Bulma as Bulma
2023-07-08 05:41:41 +02:00
netlibre_navbar :: forall w i. Boolean -> Boolean -> i -> i -> i -> i -> i -> HH.HTML w i
netlibre_navbar authenticated admin actionHome actionDomainList actionAuthdAdmin actionRegister actionLogin =
2023-07-08 04:17:13 +02:00
main_nav
[ nav_brand [ logo, burger_menu ]
, nav_menu
[ navbar_start
2023-07-08 05:41:41 +02:00
[ link_home
, case authenticated of
false -> HH.div_ []
true -> link_domains
, case authenticated, admin of
true, true -> link_authd_admin
_, _ -> HH.div_ []
--, dropdown "List of something"
-- [ dropdown_element "something 1"
-- , dropdown_element "something 2"
-- , dropdown_element "something 3"
-- , dropdown_separator
-- , dropdown_element "something 4"
-- ]
2023-07-08 04:17:13 +02:00
]
, navbar_end
[ navbar_item
[ HH.div [HP.classes C.buttons]
2023-07-08 05:41:41 +02:00
[ nav_button_strong "Register" actionRegister
, nav_button_light "Login" actionLogin
2023-07-08 04:17:13 +02:00
]
]
]
]
]
where
main_nav = HH.nav [ HP.classes C.navbar, ARIA.label "main navigation", ARIA.role "navigation" ]
logo = HH.a [HP.classes C.navbar_item, HP.href "/"] [HH.img [HP.src "/logo.jpeg", HP.width 112, HP.height 28]]
burger_menu
= HH.a [HP.classes C.navbar_burger, ARIA.label "menu", ARIA.expanded "false", Bulma.data_target "navbarExample" ]
[ HH.span [ARIA.hidden "true"] []
, HH.span [ARIA.hidden "true"] []
, HH.span [ARIA.hidden "true"] []
]
nav_brand = HH.div [HP.classes C.navbar_brand]
nav_menu = HH.div [HP.id "navbarExample", HP.classes C.navbar_menu]
navbar_start = HH.div [HP.classes C.navbar_start]
navbar_end = HH.div [HP.classes C.navbar_end]
2023-07-08 05:41:41 +02:00
link_home = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionHome)] [HH.text "Home"]
link_domains = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionDomainList)] [HH.text "Domain List"]
link_authd_admin = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionAuthdAdmin)] [HH.text "Authd Admin"]
2023-07-08 04:17:13 +02:00
dropdown title dropdown_elements
= HH.div [HP.classes (C.navbar_item <> C.has_dropdown <> C.is_hoverable)]
[ dropdown_title title, HH.div [HP.classes C.navbar_dropdown] dropdown_elements ]
dropdown_title str = HH.a [HP.classes C.navbar_link] [HH.text str]
dropdown_element str = HH.a [HP.classes C.navbar_item] [HH.text str]
dropdown_separator = HH.hr [HP.classes C.navbar_divider]
2023-07-08 05:41:41 +02:00
nav_button_strong str action
= HH.a [HP.classes (C.button <> C.is_primary), HE.onClick (\_ -> action)] [HH.strong [] [HH.text str]]
nav_button_light str action
= HH.a [HP.classes (C.button <> C.is_light), HE.onClick (\_ -> action)] [HH.text str]
2023-07-08 04:17:13 +02:00
navbar_item = HH.div [HP.classes C.navbar_item]