Commit b7fe9456 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[topBar] fix info dropdown so that it's purescript-only

parent e558ac4c
...@@ -39,8 +39,8 @@ topBarCpt = R.hooksComponentWithModule thisModule "topBar" cpt ...@@ -39,8 +39,8 @@ topBarCpt = R.hooksComponentWithModule thisModule "topBar" cpt
<> "the interface by clicking on me. Click " <> "the interface by clicking on me. Click "
<> "again to come back to previous state." <> "again to come back to previous state."
, className: "nav navbar-nav" <> navHanded , className: "nav navbar-nav" <> navHanded
} [handedChooser { handed }] } [handedChooser { handed } []]
, H.ul { className: "nav navbar-nav" <> navHanded} [divDropdownLeft] , H.ul { className: "nav navbar-nav" <> navHanded} [divDropdownLeft {} []]
{-, H.ul { title: "Dark Mode soon here" {-, H.ul { title: "Dark Mode soon here"
, className : "nav navbar-nav" , className : "nav navbar-nav"
} [ H.li {} [ H.a {} [ H.span {className : "fa fa-moon"}[] } [ H.li {} [ H.a {} [ H.span {className : "fa fa-moon"}[]
...@@ -70,32 +70,28 @@ logo handed = ...@@ -70,32 +70,28 @@ logo handed =
navHanded = if handed == LeftHanded then " navbar-right" else "" navHanded = if handed == LeftHanded then " navbar-right" else ""
divDropdownLeft :: R.Element divDropdownLeft :: R2.Component ()
divDropdownLeft = divDropdownLeft = R.createElement divDropdownLeftCpt
divDropdownLeft' $
LiNav { title : "About Gargantext" divDropdownLeftCpt :: R.Component ()
divDropdownLeftCpt = R.hooksComponentWithModule thisModule "divDropdownLeft" cpt
where
cpt {} _ = do
show <- R.useState' false
pure $ H.li { className: "dropdown" } [
menuButton { element: menuElement, show } []
, menuElements { elements, show } []
]
menuElement = LiNav { title : "About Gargantext"
, href : "#" , href : "#"
, icon : "fa fa-info-circle" , icon : "fa fa-info-circle"
, text : "Info" } , text : "Info" }
divDropdownLeft' :: LiNav -> R.Element elements = [
divDropdownLeft' mb = [
H.li {className: "dropdown"} [ menuButton mb, menuElements' ] LiNav { title : "Quick start, tutorials and methodology"
menuButton :: LiNav -> R.Element
menuButton (LiNav { title, href, icon, text } ) =
H.a { className: "dropdown-toggle navbar-text"
, data: {toggle: "dropdown"}
, href, title
, role: "button" }
[ H.span { aria: {hidden : true}, className: icon } []
, H.text (" " <> text) ]
menuElements' :: R.Element
menuElements' = menuElements-- title, icon, text
[ -- ===========================================================
[ LiNav { title : "Quick start, tutorials and methodology"
, href : "https://iscpif.fr/gargantext/your-first-map/" , href : "https://iscpif.fr/gargantext/your-first-map/"
, icon : "fa fa-lightbulb-o" , icon : "fa fa-lightbulb-o"
, text : "Tutorials" , text : "Tutorials"
...@@ -145,13 +141,46 @@ menuElements' = menuElements-- title, icon, text ...@@ -145,13 +141,46 @@ menuElements' = menuElements-- title, icon, text
] ]
] -- =========================================================== ] -- ===========================================================
-- | Menu in the sidebar, syntactic sugar type MenuButtonProps = (
menuElements :: Array (Array LiNav) -> R.Element element :: LiNav
menuElements ns = dropDown $ intercalate divider $ map (map liNav) ns , show :: R.State Boolean
)
menuButton :: R2.Component MenuButtonProps
menuButton = R.createElement menuButtonCpt
where where
dropDown :: Array R.Element -> R.Element menuButtonCpt :: R.Component MenuButtonProps
dropDown = H.ul {className: "dropdown-menu"} menuButtonCpt = R.hooksComponentWithModule thisModule "menuButton" cpt
cpt { element: LiNav { title, href, icon, text }, show: (_ /\ setShow) } _ = do
pure $ H.a { className: "dropdown-toggle navbar-text"
-- , data: {toggle: "dropdown"}
, href, title
, on: { click: \_ -> setShow $ not }
, role: "button" } [
H.span { aria: {hidden : true}, className: icon } []
, H.text (" " <> text)
]
-- | Menu in the sidebar, syntactic sugar
type MenuElementsProps = (
elements :: Array (Array LiNav)
, show :: R.State Boolean
)
menuElements :: R2.Component MenuElementsProps
menuElements = R.createElement menuElementsCpt
where
menuElementsCpt :: R.Component MenuElementsProps
menuElementsCpt = R.hooksComponentWithModule thisModule "menuElements" cpt
cpt { show: false /\ _ } _ = do
pure $ H.div {} []
cpt { elements, show: (true /\ setShow) } _ = do
pure $ H.ul { className: "dropdown-menu"
, on: { click: setShow $ const false }
, style: { display: "block" } } $ intercalate divider $ map (map liNav) elements
where
divider :: Array R.Element divider :: Array R.Element
divider = [H.li {className: "divider"} []] divider = [H.li {className: "divider"} []]
...@@ -189,8 +218,8 @@ type HandedChooserProps = ( ...@@ -189,8 +218,8 @@ type HandedChooserProps = (
handed :: R.State Handed handed :: R.State Handed
) )
handedChooser :: Record HandedChooserProps -> R.Element handedChooser :: R2.Component HandedChooserProps
handedChooser props = R.createElement handedChooserCpt props [] handedChooser = R.createElement handedChooserCpt
handedChooserCpt :: R.Component HandedChooserProps handedChooserCpt :: R.Component HandedChooserProps
handedChooserCpt = R.hooksComponentWithModule thisModule "handedChooser" cpt handedChooserCpt = R.hooksComponentWithModule thisModule "handedChooser" cpt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment