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
Allen Lee
purescript-gargantext
Commits
4c3523d7
Commit
4c3523d7
authored
Apr 01, 2018
by
Abinaya Sudhir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tabview Added
parent
4f37a46f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
18 deletions
+108
-18
DocView.purs
src/DocView.purs
+0
-2
Tabview.purs
src/Tabview.purs
+108
-16
No files found.
src/DocView.purs
View file @
4c3523d7
...
@@ -158,8 +158,6 @@ layoutDocview = simpleSpec performAction render
...
@@ -158,8 +158,6 @@ layoutDocview = simpleSpec performAction render
]
]
]
]
performAction :: PerformAction _ State _ Action
performAction :: PerformAction _ State _ Action
performAction (ChangePageSize ps) _ _ = void (cotransform (\state -> changePageSize ps state ))
performAction (ChangePageSize ps) _ _ = void (cotransform (\state -> changePageSize ps state ))
...
...
src/Tabview.purs
View file @
4c3523d7
...
@@ -3,29 +3,67 @@ module Tabview where
...
@@ -3,29 +3,67 @@ module Tabview where
import Authorview as AV
import Authorview as AV
import Control.Monad.Eff.Console (CONSOLE)
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import DOM (DOM)
import Data.Array (fold)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Lens (
Prism', prism
)
import Data.Lens (
Lens', Prism', lens, over, prism, view
)
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.Props (_data, _id, aria, className, href, role)
import Sourceview as SV
import Sourceview as SV
import Termsview as TV
import Termsview as TV
import Thermite (PerformAction, Render, Spec, focus, modifyState, simpleSpec)
import Thermite (Render, Spec, _performAction, _render, defaultPerformAction, defaultRender, focus, focusState, simpleSpec, withState)
data Action
data Action
= DocviewA DV.Action
= DocviewA DV.Action
| SourceviewA SV.Action
| SourceviewA SV.Action
| AuthorviewA AV.Action
| AuthorviewA AV.Action
| TermsviewA TV.Action
| TermsviewA TV.Action
| ChangeTab
data TabTitle = TabTitle String Int
newtype TabTitleState = TabTitleState {tabTitles :: Array TabTitle, selectedTab :: Int}
type State = String
type State =
{ docview :: DV.State
, authorview :: AV.State
, sourceview :: SV.State
, termsview :: TV.State
, tabTitle :: TabTitleState
}
initialState :: State
initialState :: State
initialState = ""
initialState =
{ docview : DV.tdata
, authorview : AV.initialState
, sourceview : SV.initialState
, termsview : TV.initialState
, tabTitle : TabTitleState
{ selectedTab : 1
, tabTitles : [TabTitle "Docview" 1, TabTitle "Sourceview" 2, TabTitle "Authorview" 3, TabTitle "Termsview" 4]
}
}
_doclens :: Lens' State DV.State
_doclens = lens (\s -> s.docview) (\s ss -> s {docview = ss})
_authorlens :: Lens' State AV.State
_authorlens = lens (\s -> s.authorview) (\s ss -> s {authorview = ss})
_sourcelens :: Lens' State SV.State
_sourcelens = lens (\s -> s.sourceview) (\s ss -> s {sourceview = ss})
_termslens :: Lens' State TV.State
_termslens = lens (\s -> s.termsview) (\s ss -> s {termsview = ss})
_tabtitlelens :: Lens' State TabTitleState
_tabtitlelens = lens (\s -> s.tabTitle) (\s ss -> s {tabTitle = ss})
_docAction :: Prism' Action DV.Action
_docAction :: Prism' Action DV.Action
...
@@ -53,14 +91,68 @@ _termsAction = prism TermsviewA \ action ->
...
@@ -53,14 +91,68 @@ _termsAction = prism TermsviewA \ action ->
TermsviewA laction -> Right laction
TermsviewA laction -> Right laction
_-> Left action
_-> Left action
docPageSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
docPageSpec = focus _doclens _docAction DV.layoutDocview
-- docPageSpec :: forall eff props. Spec (console :: CONSOLE, ajax :: AJAX | eff) State props Action
-- docPageSpec = focus _fackLens _docAction DV.matchesSpec
authorPageSpec :: forall eff props. Spec (dom :: DOM, console::CONSOLE, ajax :: AJAX | eff) State props Action
authorPageSpec = focus _authorlens _authorAction AV.authorSpec
-- authorPagesSpec :: forall eff props. Spec (console::CONSOLE, ajax :: AJAX | eff) State props Action
-- authorPagesSpec = focus _fackLens _profilePageAction AV.profilePageSpec
sourcePageSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
sourcePageSpec = focus _sourcelens _sourceAction SV.sourceSpec
-- sourcePageSpec :: forall eff props. Spec (console :: CONSOLE, ajax :: AJAX | eff) State props Action
termsPageSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
-- sourcePageSpec = focus _fackLens _messageAction SV.myMessagesSpec
termsPageSpec = focus _termslens _termsAction TV.termsSpec
docPageActionSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
docPageActionSpec = simpleSpec (view _performAction docPageSpec) defaultRender
sourcePagesActionSpec :: forall eff props. Spec (dom :: DOM, console::CONSOLE, ajax :: AJAX | eff) State props Action
sourcePagesActionSpec = simpleSpec (view _performAction sourcePageSpec) defaultRender
authorPageActionSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
authorPageActionSpec = simpleSpec (view _performAction authorPageSpec) defaultRender
termsPageActionSpec :: forall eff props. Spec (dom :: DOM, console :: CONSOLE, ajax :: AJAX | eff) State props Action
termsPageActionSpec = simpleSpec (view _performAction termsPageSpec) defaultRender
tabSpec' :: forall eff props. Spec eff State props Action
tabSpec' = container $ fold
[ withState $ wrapSpec docPageSpec
, withState $ wrapSpec authorPageSpec
, withState $ wrapSpec sourcePageSpec
, withState $ wrapSpec termsPageSpec
]
where
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