Commit 0e5d4847 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Pages] thermite -> reactix migration for some components

parent 0df64011
...@@ -7,6 +7,8 @@ import Effect (Effect) ...@@ -7,6 +7,8 @@ import Effect (Effect)
import React (ReactElement) import React (ReactElement)
import React.DOM (a, button, div, footer, hr', img, li, p, span, text, ul) import React.DOM (a, button, div, footer, hr', img, li, p, span, text, ul)
import React.DOM.Props (_data, _id, aria, className, href, onClick, role, src, style, tabIndex, target, title, height, width) import React.DOM.Props (_data, _id, aria, className, href, onClick, role, src, style, tabIndex, target, title, height, width)
import Reactix as R
import Reactix.DOM.HTML as H
import Thermite (Render, Spec, _render, defaultPerformAction, defaultRender, focus, simpleSpec, withState, noState, cmapProps) import Thermite (Render, Spec, _render, defaultPerformAction, defaultRender, focus, simpleSpec, withState, noState, cmapProps)
-- import Unsafe.Coerce (unsafeCoerce) -- import Unsafe.Coerce (unsafeCoerce)
...@@ -31,7 +33,7 @@ import Gargantext.Pages.Layout.Specs.Search as S ...@@ -31,7 +33,7 @@ import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Pages.Layout.Specs.SearchBar as SB import Gargantext.Pages.Layout.Specs.SearchBar as SB
import Gargantext.Pages.Layout.States (AppState, _addCorpusState, _graphExplorerState, _loginState, _searchState) import Gargantext.Pages.Layout.States (AppState, _addCorpusState, _graphExplorerState, _loginState, _searchState)
import Gargantext.Router (Routes(..)) import Gargantext.Router (Routes(..))
import Gargantext.Utils.Reactix (scuff) import Gargantext.Utils.Reactix as R2
layoutSpec :: Spec AppState {} Action layoutSpec :: Spec AppState {} Action
layoutSpec = layoutSpec =
...@@ -94,7 +96,7 @@ layout0 layout = ...@@ -94,7 +96,7 @@ layout0 layout =
withState \st -> withState \st ->
case st.loginState.authData of case st.loginState.authData of
Just (AuthData {tree_id}) -> Just (AuthData {tree_id}) ->
ls $ cmapProps (const {root: tree_id, mCurrentRoute: st.currentRoute}) as ls $ cmapProps (const {root: tree_id, mCurrentRoute: st.currentRoute}) $ noState $ Tree.treeview
Nothing -> Nothing ->
outerLayout1 outerLayout1
, rs bs , rs bs
...@@ -111,8 +113,6 @@ layout0 layout = ...@@ -111,8 +113,6 @@ layout0 layout =
] (render d p s c) ] ] (render d p s c) ]
cont = over _render \render d p s c -> [ div [className "row" ] (render d p s c) ] cont = over _render \render d p s c -> [ div [className "row" ] (render d p s c) ]
as = noState Tree.treeview
bs = innerLayout $ layout bs = innerLayout $ layout
innerLayout :: Spec AppState {} Action innerLayout :: Spec AppState {} Action
...@@ -142,7 +142,7 @@ layout1 layout = ...@@ -142,7 +142,7 @@ layout1 layout =
[ withState \st -> [ withState \st ->
case st.loginState.authData of case st.loginState.authData of
Just (AuthData {tree_id}) -> Just (AuthData {tree_id}) ->
ls $ cmapProps (const {root: tree_id, mCurrentRoute: st.currentRoute}) as ls $ cmapProps (const {root: tree_id, mCurrentRoute: st.currentRoute}) $ noState $ Tree.treeview
Nothing -> Nothing ->
outerLayout1 outerLayout1
, rs bs , rs bs
...@@ -156,8 +156,6 @@ layout1 layout = ...@@ -156,8 +156,6 @@ layout1 layout =
rs = over _render \render d p s c -> [ div [if (s.showTree) then className "col-md-10" else className "col-md-12"] (render d p s c) ] rs = over _render \render d p s c -> [ div [if (s.showTree) then className "col-md-10" else className "col-md-12"] (render d p s c) ]
cont = over _render \render d p s c -> [ div [className "row" ] (render d p s c) ] cont = over _render \render d p s c -> [ div [className "row" ] (render d p s c) ]
as = noState Tree.treeview
bs = innerLayout $ layout bs = innerLayout $ layout
innerLayout :: Spec AppState {} Action innerLayout :: Spec AppState {} Action
...@@ -180,29 +178,29 @@ searchBar = simpleSpec defaultPerformAction render ...@@ -180,29 +178,29 @@ searchBar = simpleSpec defaultPerformAction render
] [ div [className "container-fluid" ] [ div [className "container-fluid"
] ]
[ div [ className "navbar-inner" ] [ div [ className "navbar-inner" ]
[ divLogo [ R2.scuff divLogo
, div [ className "collapse navbar-collapse" , div [ className "collapse navbar-collapse"
] ]
$ [ divDropdownLeft ] $ [ R2.scuff divDropdownLeft ]
<> [ scuff (SB.searchBar SB.defaultProps) ] <> [ R2.scuff (SB.searchBar SB.defaultProps) ]
<> [ divDropdownRight d s ] <> [ R2.scuff $ divDropdownRight d s ]
] ]
] ]
] ]
] ]
divLogo :: ReactElement divLogo :: R.Element
divLogo = a [ className "navbar-brand logoSmall" divLogo = H.a { className: "navbar-brand logoSmall"
, href "#/" , href: "#/"
] [ img [ src "images/logoSmall.png" } [ H.img { src: "images/logoSmall.png"
, title "Back to home." , title: "Back to home."
, width "30" , width: "30"
, height "28" , height: "28"
] }
] ]
divDropdownLeft :: ReactElement divDropdownLeft :: R.Element
divDropdownLeft = divDropdownLeft' (LiNav { title : "About Gargantext" divDropdownLeft = divDropdownLeft' (LiNav { title : "About Gargantext"
, href : "#" , href : "#"
, icon : "glyphicon glyphicon-info-sign" , icon : "glyphicon glyphicon-info-sign"
...@@ -210,32 +208,33 @@ divDropdownLeft = divDropdownLeft' (LiNav { title : "About Gargantext" ...@@ -210,32 +208,33 @@ divDropdownLeft = divDropdownLeft' (LiNav { title : "About Gargantext"
} }
) )
divDropdownLeft' :: LiNav -> ReactElement divDropdownLeft' :: LiNav -> R.Element
divDropdownLeft' mb = ul [className "nav navbar-nav"] divDropdownLeft' mb = H.ul {className: "nav navbar-nav"}
[ ul [className "nav navbar-nav pull-left"] [ H.ul {className: "nav navbar-nav pull-left"}
[ li [className "dropdown"] [ H.li {className: "dropdown"}
[ menuButton mb [ menuButton mb
, menuElements' , menuElements'
] ]
] ]
] ]
menuButton :: LiNav -> ReactElement menuButton :: LiNav -> R.Element
menuButton (LiNav { title : title' menuButton (LiNav { title : title'
, href : href' , href : href'
, icon : icon' , icon : icon'
, text : text' , text : text'
}) = a [ className "dropdown-toggle navbar-text" }) = H.a { className: "dropdown-toggle navbar-text"
, _data {toggle: "dropdown"} , data: {toggle: "dropdown"}
, href href', role "button" , href: href'
, title title' , role: "button"
][ span [ aria {hidden : true} , title: title'
, className icon' } [ H.span { aria: {hidden : true}
] [] , className: icon'
, text (" " <> text') } []
] , H.text (" " <> text')
]
menuElements' :: ReactElement
menuElements' :: R.Element
menuElements' = menuElements-- title, icon, text menuElements' = menuElements-- title, icon, text
[ -- =========================================================== [ -- ===========================================================
[ LiNav { title : "Quick start, tutorials and methodology" [ LiNav { title : "Quick start, tutorials and methodology"
...@@ -271,14 +270,14 @@ menuElements' = menuElements-- title, icon, text ...@@ -271,14 +270,14 @@ menuElements' = menuElements-- title, icon, text
] -- =========================================================== ] -- ===========================================================
-- | Menu in the sidebar, syntactic sugar -- | Menu in the sidebar, syntactic sugar
menuElements :: Array (Array LiNav) -> ReactElement menuElements :: Array (Array LiNav) -> R.Element
menuElements ns = dropDown $ intercalate divider $ map (map liNav) ns menuElements ns = dropDown $ intercalate divider $ map (map liNav) ns
where where
dropDown :: Array ReactElement -> ReactElement dropDown :: Array R.Element -> R.Element
dropDown = ul [className "dropdown-menu"] dropDown = H.ul {className: "dropdown-menu"}
divider :: Array ReactElement divider :: Array R.Element
divider = [li [className "divider"] []] divider = [H.li {className: "divider"} []]
-- | surgar for target : "blank" -- | surgar for target : "blank"
--data LiNav_ = LiNav_ { title :: String --data LiNav_ = LiNav_ { title :: String
...@@ -294,52 +293,52 @@ data LiNav = LiNav { title :: String ...@@ -294,52 +293,52 @@ data LiNav = LiNav { title :: String
, text :: String , text :: String
} }
liNav :: LiNav -> ReactElement liNav :: LiNav -> R.Element
liNav (LiNav { title : title' liNav (LiNav { title : title'
, href : href' , href : href'
, icon : icon' , icon : icon'
, text : text' , text : text'
} }
) = li [] [ a [ tabIndex (-1) ) = H.li {} [ H.a { tabIndex: (-1)
, target "blank" , target: "blank"
, title title' , title: title'
, href href' , href: href'
] [ span [ className icon' ] [] } [ H.span { className: icon' } []
, text $ " " <> text' , H.text $ " " <> text'
] ]
] ]
logLinks :: (Action -> Effect Unit) -> AppState -> ReactElement logLinks :: (Action -> Effect Unit) -> AppState -> R.Element
logLinks d s = case s.loginState.authData of logLinks d s = case s.loginState.authData of
Nothing -> loginLink Nothing -> loginLink
Just _ -> logoutLink Just _ -> logoutLink
where where
loginLink = loginLink =
a [ aria {hidden : true} H.a { aria: {hidden : true}
, className "glyphicon glyphicon-log-in" , className: "glyphicon glyphicon-log-in"
, onClick $ \e -> d ShowLogin , on: {click: \e -> d ShowLogin}
, style {color:"white"} , style: {color:"white"}
, title "Log in and save your time" , title: "Log in and save your time"
-- TODO hover: bold -- TODO hover: bold
] }
[text " Login / Signup"] [H.text " Login / Signup"]
-- TODO dropdown to logout -- TODO dropdown to logout
logoutLink = logoutLink =
a [ aria {hidden : true} H.a { aria: {hidden : true}
, className "glyphicon glyphicon-log-out" , className: "glyphicon glyphicon-log-out"
, onClick $ \e -> d Logout , on: {click: \e -> d Logout}
, style {color:"white"} , style: {color:"white"}
, title "Log out" -- TODO , title: "Log out" -- TODO
-- TODO hover: bold -- TODO hover: bold
] }
[text " Logout"] [H.text " Logout"]
divDropdownRight :: (Action -> Effect Unit) -> AppState -> ReactElement divDropdownRight :: (Action -> Effect Unit) -> AppState -> R.Element
divDropdownRight d s = divDropdownRight d s =
ul [className "nav navbar-nav pull-right"] H.ul {className: "nav navbar-nav pull-right"}
[ li [className "dropdown"] [ H.li {className: "dropdown"}
[ logLinks d s ] [ logLinks d s ]
] ]
......
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