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
89f75591
Commit
89f75591
authored
Jan 14, 2022
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[home] allow switching landing page lang
parent
5472fb06
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
8 deletions
+62
-8
Data.purs
src/Gargantext/Components/App/Data.purs
+4
-0
Lang.purs
src/Gargantext/Components/Lang.purs
+48
-1
Home.purs
src/Gargantext/Components/Nodes/Home.purs
+5
-5
Router.purs
src/Gargantext/Components/Router.purs
+1
-1
TopBar.purs
src/Gargantext/Components/TopBar.purs
+4
-1
No files found.
src/Gargantext/Components/App/Data.purs
View file @
89f75591
...
...
@@ -7,6 +7,7 @@ import Data.Maybe (Maybe(..))
import Data.Set as Set
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Components.Lang as Lang
import Gargantext.Components.Nodes.Lists.Types as ListsT
import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Components.Themes as Themes
...
...
@@ -25,6 +26,7 @@ type App =
, forestOpen :: OpenNodes
, graphVersion :: T2.Reload
, handed :: Handed
, lang :: Lang.LandingLang
, reloadForest :: T2.Reload
, reloadMainPage :: T2.Reload
, reloadRoot :: T2.Reload
...
...
@@ -51,6 +53,7 @@ emptyApp =
, forestOpen : OpenNodes $ Set.empty
, graphVersion : T2.newReload
, handed : RightHanded
, lang : Lang.LL_EN
, reloadForest : T2.newReload
, reloadMainPage : T2.newReload
, reloadRoot : T2.newReload
...
...
@@ -76,6 +79,7 @@ type Boxes =
, forestOpen :: T.Box OpenNodes
, graphVersion :: T2.ReloadS
, handed :: T.Box Handed
, lang :: T.Box Lang.LandingLang
, reloadForest :: T2.ReloadS
, reloadMainPage :: T2.ReloadS
, reloadRoot :: T2.ReloadS
...
...
src/Gargantext/Components/Lang.purs
View file @
89f75591
module Gargantext.Components.Lang where
import Gargantext.Prelude
import Data.Argonaut (class EncodeJson, encodeJson)
import Data.Array as A
import Data.Maybe (Maybe(..))
import Gargantext.Prelude (class Eq, class Show, show, class Read)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Lang"
-- Language used for search
allLangs :: Array Lang
...
...
@@ -36,6 +45,44 @@ instance EncodeJson Lang where
-- Language used for the landing page
data LandingLang = LL_EN | LL_FR
derive instance Eq LandingLang
instance Show LandingLang where
show LL_EN = "EN"
show LL_FR = "FR"
-- @TODO a possible method/class that a real i18n logic could later replace
class Show t <= Translate t where
translate :: Lang -> t -> String
allFeLangs :: Array LandingLang
allFeLangs = [ LL_EN, LL_FR ]
type LangSwitcherProps = (
lang :: T.Box LandingLang
, langs :: Array LandingLang
)
langSwitcher :: R2.Component LangSwitcherProps
langSwitcher = R.createElement langSwitcherCpt
langSwitcherCpt :: R.Component LangSwitcherProps
langSwitcherCpt = here.component "langSwitcher" cpt
where
cpt { lang, langs} _ = do
currentLang <- T.useLive T.unequal lang
let option l = H.option { value: show l} [ H.text $ show l]
let options = map option langs
pure $ R2.select { className: "form-control"
, defaultValue: show currentLang
, on: {change: onChange lang } } options
where
onChange box e = do
let value = R.unsafeEventValue e
let mLang = A.head $ A.filter (\l -> value == show l) langs
case mLang of
Nothing -> pure unit
Just l -> do
T.write_ l box
\ No newline at end of file
src/Gargantext/Components/Nodes/Home.purs
View file @
89f75591
...
...
@@ -52,9 +52,7 @@ langLandingData LL_EN = En.landingData
------------------------------------------------------------------------
type HomeProps =
( boxes :: Boxes
, lang :: LandingLang
)
( boxes :: Boxes )
homeLayout :: R2.Leaf HomeProps
homeLayout = R2.leafComponent homeLayoutCpt
...
...
@@ -62,12 +60,14 @@ homeLayoutCpt :: R.Component HomeProps
homeLayoutCpt = here.component "homeLayout" cpt
where
cpt { boxes: boxes@{ backend
, lang
, sessions
, showLogin }
, lang
} _ = do
} _ = do
backend' <- T.useLive T.unequal backend
sessions' <- T.useLive T.unequal sessions
let landingData = langLandingData lang
lang' <- T.useLive T.unequal lang
let landingData = langLandingData lang'
pure $
H.span {}
[ H.div { className: "home-title container1" }
...
...
src/Gargantext/Components/Router.purs
View file @
89f75591
...
...
@@ -451,7 +451,7 @@ home = R.createElement homeCpt
homeCpt :: R.Component Props
homeCpt = here.component "home" cpt where
cpt { boxes } _ = do
pure $ homeLayout { boxes
, lang: LL_EN
}
pure $ homeLayout { boxes }
lists :: R2.Component SessionNodeProps
lists = R.createElement listsCpt
...
...
src/Gargantext/Components/TopBar.purs
View file @
89f75591
...
...
@@ -6,6 +6,7 @@ import Data.Foldable (intercalate)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.GraphExplorer.ToggleButton as Toggle
import Gargantext.Components.Themes (themeSwitcher, allThemes)
import Gargantext.Components.Lang (langSwitcher, allFeLangs)
import Gargantext.Types (Handed(..), reverseHanded)
import Gargantext.Utils.Reactix as R2
import Reactix as R
...
...
@@ -23,7 +24,7 @@ topBar = R.createElement topBarCpt
topBarCpt :: R.Component TopBarProps
topBarCpt = here.component "topBar" cpt
where
cpt { boxes: { handed, showTree, theme } } children = do
cpt { boxes: { handed,
lang,
showTree, theme } } children = do
handed' <- T.useLive T.unequal handed
pure $ H.div { className: "navbar navbar-expand-lg navbar-dark bg-dark"
...
...
@@ -43,6 +44,8 @@ topBarCpt = here.component "topBar" cpt
, smiley
, H.li { className: "nav-item" } [ themeSwitcher { theme
, themes: allThemes } [] ]
, H.li { className: "nav-item" } [ langSwitcher { lang
, langs: allFeLangs } [] ]
, Toggle.treeToggleButton { state: showTree } []
] <> children)
]
...
...
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