-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.purs
70 lines (55 loc) · 2.01 KB
/
Main.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
module Main where
import Prelude
import Components.Background (backgroundComponent)
import Components.Footer (footerComponent)
import Components.Header (headerComponent)
import Contexts (Contexts)
import Contexts.ColorMode (ColorScheme(..), ColorTarget(..)) as CM
import Contexts.ColorMode (provideColorMode, useColor)
import Contexts.Page (providePage, usePage)
import Data.Page (Page(..))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Hooks.UseAdjustWindowHeight (useAdjustWindowHeight)
import Hooks.UseClass (useClass)
import Jelly (Component, ch, chSig, el, launchApp, (:=))
import Pages.About (aboutPageComponent)
import Pages.NotFound (notFoundPageComponent)
import Pages.PostInfo (postInfoPageComponent)
import Pages.Posts (postsPageComponent)
import Pages.Top (topPageComponent)
import Pages.Works (worksPageComponent)
main :: Effect Unit
main = do
colorMode <- provideColorMode
page <- providePage
launchApp root { colorMode, page }
root :: Component Contexts
root = el "div" do
useAdjustWindowHeight
useColor CM.Primary CM.Text
useClass $ pure "font-default"
useClass $ pure "w-screen min-w-[22rem]"
useClass $ pure "flex flex-col items-start"
pageSig /\ _ <- usePage
ch $ backgroundComponent
ch $ headerComponent
ch $ el "div" do
useClass $ pure "overflow-y-auto w-full flex-1"
ch $ el "div" do
useClass $ pure "min-h-[calc(100%-12rem)] sm:min-h-[calc(100%-8rem)]"
chSig do
page <- pageSig
pure $ case page of
PageAbout -> aboutPageComponent
PageWorks -> worksPageComponent
PageWorkInfo workId -> notFoundPageComponent $ pure $ "works" <> show
workId
PagePosts -> postsPageComponent
PagePostInfo postId -> postInfoPageComponent $ pure postId
PageNotFound path -> notFoundPageComponent $ pure path
PageLinks -> notFoundPageComponent $ pure "links"
PageTop -> topPageComponent
ch footerComponent
ch $ el "div" do
"id" := pure "dialog-container-root"