Landing.purs 5.58 KB
Newer Older
1 2 3 4 5 6 7 8
module Landing where

import Control.Monad.Cont.Trans (lift)
import Control.Monad.Eff.Console (CONSOLE)
import DOM (DOM)
import Network.HTTP.Affjax (AJAX)
import Prelude hiding (div)
import React.DOM (a, button, div, footer, h1, h3, hr, i, img, li, p, span, text, ul)
9 10
import React.DOM.Props (Props, _data, _id, aria, className, href, onClick, role, src, style, tabIndex, target, title)
import React (ReactElement)
11 12 13 14
import Routing.Hash.Aff (setHash)
import Thermite (PerformAction, Render, Spec, simpleSpec)
import Thermite as T

15 16 17 18 19 20
import Gargantext.Data.Landing
import Gargantext.Data.Lang

import Gargantext.Lang.Landing.EnUS as En
import Gargantext.Lang.Landing.FrFR as Fr

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
newtype State = State
  { userName :: String
  , password :: String
  }


initialState :: State
initialState = State
  {userName : ""
 , password : ""
  }

data Action
  = NoOp
  | Documentation
36
  | Enter
37
  | Login
38 39 40
  | SignUp


Alexandre Delanoë's avatar
Alexandre Delanoë committed
41 42
performAction :: forall eff props. PerformAction ( console :: CONSOLE
                                                 , ajax    :: AJAX
Abinaya Sudhir's avatar
Abinaya Sudhir committed
43 44
                                                 , dom     :: DOM
                                                 | eff
Alexandre Delanoë's avatar
Alexandre Delanoë committed
45
                                                 ) State props Action
46 47 48 49 50 51
performAction NoOp _ _ = void do
  T.modifyState \state -> state

performAction Documentation _ _ = void do
  T.modifyState \state -> state

52 53
performAction Enter _ _ = void do
  lift $ setHash "/search"
54 55
  T.modifyState \state -> state

56 57 58 59
performAction Login _ _ = void do
  lift $ setHash "/login"
  T.modifyState \state -> state

60 61 62
performAction SignUp _ _ = void do
  T.modifyState \state -> state

Alexandre Delanoë's avatar
Alexandre Delanoë committed
63

64 65
-- Layout |

66 67
layoutLanding :: forall props eff . Lang -> Spec ( console :: CONSOLE
                                              , ajax    :: AJAX
Abinaya Sudhir's avatar
Abinaya Sudhir committed
68
                                              , dom     :: DOM
69 70 71 72
                                              | eff
                                              ) State props Action
layoutLanding FR = layoutLanding' Fr.landingData
layoutLanding EN = layoutLanding' En.landingData
73 74 75

------------------------------------------------------------------------

76 77
layoutLanding' :: forall props eff . LandingData -> Spec ( console :: CONSOLE
                                                   , ajax    :: AJAX
Abinaya Sudhir's avatar
Abinaya Sudhir committed
78
                                                   , dom     :: DOM
79 80 81
                                                   | eff
                                                   ) State props Action
layoutLanding' hd = simpleSpec performAction render
82 83 84
  where
    render :: Render State props Action
    render dispatch _ state _ =
Abinaya Sudhir's avatar
Abinaya Sudhir committed
85
      [ div [ className "container1" ] [ jumboTitle hd false                 ]
Alexandre Delanoë's avatar
Alexandre Delanoë committed
86
      , div [ className "container1" ] [] -- put research here
Abinaya Sudhir's avatar
Abinaya Sudhir committed
87
      , div [ className "container1" ] [ blocksRandomText' hd                ]
88 89 90
      ]
------------------------------------------------------------------------

91 92
blocksRandomText' :: LandingData -> ReactElement
blocksRandomText' (LandingData hd) = blocksRandomText hd.blockTexts
93 94 95


blocksRandomText :: BlockTexts -> ReactElement
Abinaya Sudhir's avatar
Abinaya Sudhir committed
96
blocksRandomText (BlockTexts bt) =
97 98 99 100 101 102 103
  div [ className "row" ] ( map showBlock bt.blocks )
    where
      showBlock :: BlockText -> ReactElement
      showBlock (BlockText b) =
        div [ className "col-md-4 content" ]
              [ h3 [] [ a [ href b.href, title b.title]
                          [ i [className b.icon] []
104
                          , text ("   " <> b.titleText)
105 106 107
                          ]
                      ]
              , p [] [ text b.text ]
108
              , p [] [ docButton b.docButton ]
109 110
              ]

Alexandre Delanoë's avatar
Alexandre Delanoë committed
111
docButton :: Button -> ReactElement
112
docButton (Button b) = a [ className "btn btn-outline-primary btn-sm spacing-class"
Alexandre Delanoë's avatar
Alexandre Delanoë committed
113 114 115 116
              , href b.href
              , target "blank"
              , title b.title
              ] [ span [ aria {hidden : true}
Abinaya Sudhir's avatar
Abinaya Sudhir committed
117
                       , className "glyphicon glyphicon-hand-right"
Alexandre Delanoë's avatar
Alexandre Delanoë committed
118 119 120 121
                       ]  []
                , text b.text
                ]

122 123
jumboTitle :: LandingData -> Boolean -> ReactElement
jumboTitle (LandingData hd) b = div jumbo
124
                   [ div [className "row"             ]
Alexandre Delanoë's avatar
Alexandre Delanoë committed
125 126
                     [ div [ className "col-md-8 content"]
                           [ p [ className "left" ]
Alexandre Delanoë's avatar
Alexandre Delanoë committed
127
                               [ div [_id "logo-designed" ]
Alexandre Delanoë's avatar
Alexandre Delanoë committed
128 129 130 131 132 133 134 135 136 137 138 139
                                 [ img [ src "images/logo.png"
                                       , title hd.logoTitle
                                       ] []
                                 ]
                               ]
                           ]
                     , div [ className "col-md-4 content"]
                           [ img [ src "images/Gargantextuel.jpg"
                                   , _id "funnyimg"
                                   , title hd.imageTitle
                                   ]
                                   []
140 141 142
                           ]
                     ]
                   ]
143 144
                  where
                    jumbo = case b of
145
                                 true  -> [className "jumbotron"]
146
                                 false -> []
147

148 149
imageEnter :: LandingData -> Props -> ReactElement
imageEnter (LandingData hd) action =  div [className "row"]
150 151 152
                           [ div [className "col-md-offset-5 col-md-6 content"]
                             [ img [ src "images/Gargantextuel-212x300.jpg"
                                   , _id "funnyimg"
Alexandre Delanoë's avatar
Alexandre Delanoë committed
153
                                   , title hd.imageTitle
154
                                   , action
Abinaya Sudhir's avatar
Abinaya Sudhir committed
155
                                   ]
156 157 158
                                   []
                             ]
                           ]