Commit 7ad9be28 authored by James Laver's avatar James Laver

make texts tabs appear again. now have endless loop

parent 7016c787
......@@ -14,21 +14,23 @@ tabs props = R.createElement tabsCpt props []
-- this is actually just the list of tabs, not the tab contents itself
tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponent "Tabs" cpt
tabsCpt = R.hooksComponent "G.C.Tab.tabs" cpt
where
cpt props _ = do
(activeTab /\ setActiveTab) <- R.useState' props.selected
pure $
H.div { className: "tab-content" }
H.div {}
[ H.nav {}
[ H.div { className: "nav nav-tabs" }
(mapWithIndex (item setActiveTab activeTab) props.tabs) ] ]
item setActiveTab selected index (name /\ _) =
(mapWithIndex (button setActiveTab activeTab) props.tabs) ]
, H.div { className: "tab-content" } $ mapWithIndex (item activeTab) props.tabs ]
button setActiveTab selected index (name /\ _) =
H.a { className, on: { click } } [ H.text name ]
where
eq = index == selected
className = "nav-item nav-link" <> (if eq then " active" else "")
click e = setActiveTab (const index)
item selected index (_ /\ cpt) = tab { selected, index } [ cpt ]
-- TODO: document what these are (selection, item indices)
type TabProps = ( selected :: Int, index :: Int )
......@@ -38,7 +40,7 @@ tab = R.createElement tabCpt
-- | A tab only shows its contents if it is currently selected
tabCpt :: R.Component TabProps
tabCpt = R.staticComponent "Tab" cpt
tabCpt = R.staticComponent "G.C.Tab.tab" cpt
where
cpt { selected, index } children = H.div { className } children'
where
......
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