Commit e02121a7 authored by Abinaya Sudhir's avatar Abinaya Sudhir

Search bar as a spec done

parent f5aa2ab3
...@@ -2,7 +2,6 @@ module Navigation where ...@@ -2,7 +2,6 @@ module Navigation where
import DOM import DOM
import Gargantext.Data.Lang import Gargantext.Data.Lang
import Prelude hiding (div)
import AddCorpusview as AC import AddCorpusview as AC
import AnnotationDocumentView as D import AnnotationDocumentView as D
...@@ -19,13 +18,15 @@ import Login as LN ...@@ -19,13 +18,15 @@ import Login as LN
import NTree as NT import NTree as NT
import Network.HTTP.Affjax (AJAX) import Network.HTTP.Affjax (AJAX)
import PageRouter (Routes(..)) import PageRouter (Routes(..))
import Prelude hiding (div)
import React (ReactElement) import React (ReactElement)
import React.DOM (a, button, div, footer, form, hr, i, img, input, li, p, span, text, ul) import React.DOM (a, button, div, footer, form, hr, i, img, input, li, p, span, text, ul)
import React.DOM.Props (Props, _data, _id, _type, aria, className, href, name, onClick, placeholder, role, src, style, tabIndex, target, title) import React.DOM.Props (Props, _data, _id, _type, aria, className, href, name, onChange, onClick, placeholder, role, src, style, tabIndex, target, title)
import React.DOM.Props as RP import React.DOM.Props as RP
import SearchForm as S import SearchForm as S
import Tabview as TV import Tabview as TV
import Thermite (PerformAction, Render, Spec, _render, cotransform, defaultRender, focus, modifyState, simpleSpec, withState) import Thermite (PerformAction, Render, Spec, _render, cotransform, defaultRender, focus, modifyState, simpleSpec, withState)
import Unsafe.Coerce (unsafeCoerce)
import UserPage as UP import UserPage as UP
...@@ -42,6 +43,7 @@ type AppState = ...@@ -42,6 +43,7 @@ type AppState =
, annotationdocumentView :: D.State , annotationdocumentView :: D.State
, ntreeView :: NT.State , ntreeView :: NT.State
, tabview :: TV.State , tabview :: TV.State
, search :: String
} }
initAppState :: AppState initAppState :: AppState
...@@ -56,6 +58,7 @@ initAppState = ...@@ -56,6 +58,7 @@ initAppState =
, annotationdocumentView : D.initialState , annotationdocumentView : D.initialState
, ntreeView : NT.exampleTree , ntreeView : NT.exampleTree
, tabview : TV.initialState , tabview : TV.initialState
, search : ""
} }
data Action data Action
...@@ -70,6 +73,8 @@ data Action ...@@ -70,6 +73,8 @@ data Action
| AnnotationDocumentViewA D.Action | AnnotationDocumentViewA D.Action
| TreeViewA NT.Action | TreeViewA NT.Action
| TabViewA TV.Action | TabViewA TV.Action
| Search String
| Go
performAction :: forall eff props. PerformAction ( dom :: DOM performAction :: forall eff props. PerformAction ( dom :: DOM
...@@ -78,6 +83,13 @@ performAction :: forall eff props. PerformAction ( dom :: DOM ...@@ -78,6 +83,13 @@ performAction :: forall eff props. PerformAction ( dom :: DOM
performAction (SetRoute route) _ _ = void do performAction (SetRoute route) _ _ = void do
modifyState $ _ {currentRoute = pure route} modifyState $ _ {currentRoute = pure route}
performAction (Search s) _ _ = void do
modifyState $ _ {search = s}
performAction Go _ _ = void do
modifyState id
performAction _ _ _ = void do performAction _ _ _ = void do
modifyState id modifyState id
...@@ -408,13 +420,11 @@ divSearchBar = simpleSpec performAction render ...@@ -408,13 +420,11 @@ divSearchBar = simpleSpec performAction render
, placeholder "Query, URL or FILE (works with Firefox or Chromium browsers)" , placeholder "Query, URL or FILE (works with Firefox or Chromium browsers)"
, _type "text" , _type "text"
, style { height: "35px" , style { height: "35px"
-- , color: "white"
-- , background : "#A1C2D8"
} }
, onChange \e -> dispatch $ Search (unsafeCoerce e).target.value
] [] ] []
-- TODO add button in navbar (and "enter" execution) , div []
-- , div [] [button [][]] [ button [onClick \e -> dispatch Go, className "btn btn-primary", style {marginTop : "10px"}] [text "Enter"] ]
] ]
] ]
......
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