Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
d79f4a46
Commit
d79f4a46
authored
Apr 06, 2018
by
Abinaya Sudhir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tab as a component... Working tab
parent
e5d62a6d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
54 deletions
+24
-54
Navigation.purs
src/Navigation.purs
+1
-1
Tabview.purs
src/Tabview.purs
+23
-53
No files found.
src/Navigation.purs
View file @
d79f4a46
...
@@ -203,7 +203,7 @@ pagesComponent s =
...
@@ -203,7 +203,7 @@ pagesComponent s =
selectSpec DocView = layout0 $ focus _docViewState _docViewAction DV.layoutDocview
selectSpec DocView = layout0 $ focus _docViewState _docViewAction DV.layoutDocview
selectSpec UserPage = layout0 $ focus _userPageState _userPageAction UP.layoutUser
selectSpec UserPage = layout0 $ focus _userPageState _userPageAction UP.layoutUser
selectSpec (AnnotationDocumentView i) = layout0 $ focus _annotationdocumentviewState _annotationdocumentviewAction D.docview
selectSpec (AnnotationDocumentView i) = layout0 $ focus _annotationdocumentviewState _annotationdocumentviewAction D.docview
selectSpec Tabview = layout0 $ focus _tabviewState _tabviewAction TV.tab
Spec
selectSpec Tabview = layout0 $ focus _tabviewState _tabviewAction TV.tab
1
-- To be removed
-- To be removed
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
...
...
src/Tabview.purs
View file @
d79f4a46
...
@@ -6,12 +6,16 @@ import DOM (DOM)
...
@@ -6,12 +6,16 @@ import DOM (DOM)
import Data.Array (fold)
import Data.Array (fold)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, over, prism, view)
import Data.Lens (Lens', Prism', lens, over, prism, view)
import Data.List (List, fromFoldable)
import Data.Tuple (Tuple(..))
import DocView as DV
import DocView as DV
import Network.HTTP.Affjax (AJAX)
import Network.HTTP.Affjax (AJAX)
import Prelude hiding (div)
import Prelude hiding (div)
import React.DOM (a, div, li, text, ul)
import React.DOM (a, div, li, text, ul)
import React.DOM.Props (_data, _id, aria, className, href, role)
import React.DOM.Props (_data, _id, aria, className, href, role)
import Sourceview as SV
import Sourceview as SV
import Tab (tabs)
import Tab as Tab
import Termsview as TV
import Termsview as TV
import Thermite (Render, Spec, _performAction, _render, defaultPerformAction, defaultRender, focus, focusState, simpleSpec, withState)
import Thermite (Render, Spec, _performAction, _render, defaultPerformAction, defaultRender, focus, focusState, simpleSpec, withState)
...
@@ -20,19 +24,15 @@ data Action
...
@@ -20,19 +24,15 @@ data Action
| SourceviewA SV.Action
| SourceviewA SV.Action
| AuthorviewA AV.Action
| AuthorviewA AV.Action
| TermsviewA TV.Action
| TermsviewA TV.Action
|
ChangeTab
|
TabViewA Tab.Action
| NoOp
| NoOp
data TabTitle = TabTitle String Int
newtype TabTitleState = TabTitleState {tabTitles :: Array TabTitle, selectedTab :: Int}
type State =
type State =
{ docview :: DV.State
{ docview :: DV.State
, authorview :: AV.State
, authorview :: AV.State
, sourceview :: SV.State
, sourceview :: SV.State
, termsview :: TV.State
, termsview :: TV.State
,
tabTitle :: TabTitleState
,
activeTab :: Int
}
}
initialState :: State
initialState :: State
...
@@ -41,10 +41,7 @@ initialState =
...
@@ -41,10 +41,7 @@ initialState =
, authorview : AV.initialState
, authorview : AV.initialState
, sourceview : SV.initialState
, sourceview : SV.initialState
, termsview : TV.initialState
, termsview : TV.initialState
, tabTitle : TabTitleState
, activeTab : 0
{ selectedTab : 1
, tabTitles : [TabTitle "Documentsview" 1, TabTitle "Sourceview" 2, TabTitle "Authorview" 3, TabTitle "Termsview" 4]
}
}
}
_doclens :: Lens' State DV.State
_doclens :: Lens' State DV.State
...
@@ -63,9 +60,14 @@ _termslens :: Lens' State TV.State
...
@@ -63,9 +60,14 @@ _termslens :: Lens' State TV.State
_termslens = lens (\s -> s.termsview) (\s ss -> s {termsview = ss})
_termslens = lens (\s -> s.termsview) (\s ss -> s {termsview = ss})
_tab
titlelens :: Lens' State TabTitle
State
_tab
lens :: Lens' State Tab.
State
_tab
titlelens = lens (\s -> s.tabTitle) (\s ss -> s {tabTitle
= ss})
_tab
lens = lens (\s -> s.activeTab) (\s ss -> s {activeTab
= ss})
_tabAction :: Prism' Action Tab.Action
_tabAction = prism TabViewA \ action ->
case action of
TabViewA laction -> Right laction
_-> Left action
_docAction :: Prism' Action DV.Action
_docAction :: Prism' Action DV.Action
_docAction = prism DocviewA \ action ->
_docAction = prism DocviewA \ action ->
...
@@ -116,44 +118,12 @@ authorPageActionSpec = simpleSpec (view _performAction authorPageSpec) defaultRe
...
@@ -116,44 +118,12 @@ authorPageActionSpec = simpleSpec (view _performAction authorPageSpec) defaultRe
termsPageActionSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
termsPageActionSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
termsPageActionSpec = simpleSpec (view _performAction termsPageSpec) defaultRender
termsPageActionSpec = simpleSpec (view _performAction termsPageSpec) defaultRender
tabSpec' :: forall eff props. Spec eff State props Action
tabSpec' = container $ fold
[ withState $ wrapSpec docPageSpec
tab1 :: forall eff props. Spec ( dom :: DOM, console :: CONSOLE, ajax :: AJAX
, withState $ wrapSpec authorPageSpec
| eff) State props Action
, withState $ wrapSpec sourcePageSpec
tab1 = tabs _tablens _tabAction $ fromFoldable [ Tuple "Doc View" docPageSpec
, withState $ wrapSpec termsPageSpec
, Tuple "Author View" authorPageSpec
]
, Tuple "Source View" sourcePageSpec
where
, Tuple "Terms View" termsPageSpec
container :: Spec eff State props Action -> Spec eff State props Action
]
container = over _render \render d p s c ->
[ div [className "tab-content"] $ render d p s c ]
containerTabContent st = over _render \render d p s c ->
[ div [className "tab-pane fade"] $ render d p s c ]
wrapSpec spec st =
simpleSpec defaultPerformAction (view _render spec)
tabSpec :: forall eff props. Spec (dom :: DOM, console::CONSOLE, ajax :: AJAX | eff) State props Action
tabSpec = fold
[ focusState _tabtitlelens tabTitleSpec
, tabSpec'
, docPageActionSpec
, sourcePagesActionSpec
, authorPageActionSpec
, termsPageActionSpec
]
tabTitleSpec :: forall eff props. Spec eff TabTitleState props Action
tabTitleSpec = simpleSpec defaultPerformAction render
where
render :: Render TabTitleState props Action
render dispatch _ state@(TabTitleState st)_ =
[ ul [className "nav nav-tabs", _id "myTab", role "tablist"]
(map (item st.selectedTab) st.tabTitles)
]
where
item sid (TabTitle title iid) =
li [className "nav-item"]
[ a [className (if sid == iid then "nav-link active" else "nav-link"), _id ("tv-page-tab-item-" <> show iid), _data {toggle : "tab"}, href "", role "tab", aria {controls : title, selected : (if sid == iid then "true" else "false")}]
[ text title]
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment