@@ -65,15 +65,16 @@ instance showGroup :: Show Group where
65
65
type HTML m = H.ComponentHTML Action Slots m
66
66
67
67
type Slots =
68
- ( child :: H.Slot (Const Void ) Void String )
68
+ (child :: H.Slot (Const Void ) Void String )
69
+
69
70
_child = Proxy :: Proxy " child"
70
71
71
72
-- | Takes stories config and mount element, and renders the storybook.
72
- runStorybook
73
- :: Stories Aff
74
- -> Array Group
75
- -> HTMLElement
76
- -> Aff Unit
73
+ runStorybook ::
74
+ Stories Aff ->
75
+ Array Group ->
76
+ HTMLElement ->
77
+ Aff Unit
77
78
runStorybook stories groups body = do
78
79
app' <- runUI app { stories, groups } body
79
80
void $ H .liftEffect $ hashes $ \_ next ->
@@ -84,7 +85,7 @@ type Input m =
84
85
, groups :: Array Group
85
86
}
86
87
87
- app :: ∀ m . H.Component Query (Input m ) Void m
88
+ app :: forall m . H.Component Query (Input m ) Void m
88
89
app =
89
90
H .mkComponent
90
91
{ initialState
@@ -99,31 +100,32 @@ app =
99
100
render :: State m -> HTML m
100
101
render state =
101
102
HH .body_
102
- [ HH .div
103
- [ HP .class_ $ HH.ClassName " min-h-screen" ]
104
- [ renderSidebar state
105
- , renderContainer state
103
+ [ HH .div
104
+ [ HP .class_ $ HH.ClassName " min-h-screen" ]
105
+ [ renderSidebar state
106
+ , renderContainer state
107
+ ]
106
108
]
107
- ]
108
109
109
110
renderContainer :: State m -> HTML m
110
111
renderContainer state =
111
112
HH .div
112
- [ HP .class_ $ HH.ClassName " md:ml-80" ]
113
- [ HH .div
114
- [ HP .class_ $ HH.ClassName " fixed w-full" ]
113
+ [ HP .class_ $ HH.ClassName " md:ml-80" ]
115
114
[ HH .div
116
- [ HP .class_ $ HH.ClassName " pin-t bg-white md:hidden relative border-b border-grey-light h-12 py-8 flex items-center" ]
117
- [ HH .a
118
- [ HP .class_ $ HH.ClassName " mx-auto inline-flex items-center"
119
- , HP .href " " ]
120
- [ HH .text " CitizenNet UI Guide" ]
121
- ]
115
+ [ HP .class_ $ HH.ClassName " fixed w-full" ]
116
+ [ HH .div
117
+ [ HP .class_ $ HH.ClassName " pin-t bg-white md:hidden relative border-b border-grey-light h-12 py-8 flex items-center" ]
118
+ [ HH .a
119
+ [ HP .class_ $ HH.ClassName " mx-auto inline-flex items-center"
120
+ , HP .href " "
121
+ ]
122
+ [ HH .text " CitizenNet UI Guide" ]
123
+ ]
124
+ ]
125
+ , HH .div
126
+ [ HP .class_ $ HH.ClassName " p-12 w-full container mx-auto" ]
127
+ [ renderSlot state ]
122
128
]
123
- , HH .div
124
- [ HP .class_ $ HH.ClassName " p-12 w-full container mx-auto" ]
125
- [ renderSlot state ]
126
- ]
127
129
128
130
renderSlot :: State m -> HTML m
129
131
renderSlot state =
@@ -135,71 +137,71 @@ app =
135
137
renderSidebar :: State m -> HTML m
136
138
renderSidebar state =
137
139
Backdrop .backdrop
138
- [ HP .id " sidebar"
139
- , HP .classes
140
- ( HH.ClassName <$>
141
- [ " hidden"
142
- , " fixed"
143
- , " pin-y"
144
- , " pin-l"
145
- , " overflow-y-auto"
146
- , " md:overflow-visible"
147
- , " scrolling-touch"
148
- , " md:scrolling-auto"
149
- , " w-4/5"
150
- , " md:w-full"
151
- , " md:max-w-xs"
152
- , " flex-none"
153
- -- , "border-r-2"
154
- -- , "border-grey-light"
155
- , " md:flex"
156
- , " flex-col"
157
- ]
158
- )
159
- ]
160
- [ HH .div
161
- [ HP .class_ $ HH.ClassName " flex-1 p-6 overflow-y-auto" ]
162
- [ HH .header_
163
- [ Format .heading
164
- [ HP .class_ $ HH.ClassName " flex" ]
165
- [ HH .img
166
- [ HP .class_ $ HH.ClassName " mr-2"
167
- , HP .src " https://citizennet.com/manager/images/logo.svg"
168
- ]
169
- , HH .text " Ocelot"
140
+ [ HP .id " sidebar"
141
+ , HP .classes
142
+ ( HH.ClassName <$>
143
+ [ " hidden"
144
+ , " fixed"
145
+ , " pin-y"
146
+ , " pin-l"
147
+ , " overflow-y-auto"
148
+ , " md:overflow-visible"
149
+ , " scrolling-touch"
150
+ , " md:scrolling-auto"
151
+ , " w-4/5"
152
+ , " md:w-full"
153
+ , " md:max-w-xs"
154
+ , " flex-none"
155
+ -- , "border-r-2"
156
+ -- , "border-grey-light"
157
+ , " md:flex"
158
+ , " flex-col"
159
+ ]
160
+ )
161
+ ]
162
+ [ HH .div
163
+ [ HP .class_ $ HH.ClassName " flex-1 p-6 overflow-y-auto" ]
164
+ [ HH .header_
165
+ [ Format .heading
166
+ [ HP .class_ $ HH.ClassName " flex" ]
167
+ [ HH .img
168
+ [ HP .class_ $ HH.ClassName " mr-2"
169
+ , HP .src " https://citizennet.com/manager/images/logo.svg"
170
+ ]
171
+ , HH .text " Ocelot"
172
+ ]
173
+ ]
174
+ , HH .nav
175
+ [ HP .class_ $ HH.ClassName " text-base overflow-y-auto" ]
176
+ (renderGroups state)
170
177
]
171
- ]
172
- , HH .nav
173
- [ HP .class_ $ HH.ClassName " text-base overflow-y-auto" ]
174
- (renderGroups state)
175
178
]
176
- ]
177
179
178
180
renderGroups :: State m -> Array (HTML m )
179
181
renderGroups state =
180
182
mapFlipped (M .toUnfoldable state.partitions) $ \(Tuple group stories) ->
181
183
HH .div
182
- [ HP .class_ $ HH.ClassName " mb-6" ]
183
- [ Format .caption_
184
- [ HH .text $ show group ]
185
- , renderGroup state.route stories
186
- ]
184
+ [ HP .class_ $ HH.ClassName " mb-6" ]
185
+ [ Format .caption_
186
+ [ HH .text $ show group ]
187
+ , renderGroup state.route stories
188
+ ]
187
189
188
190
renderGroup :: String -> Stories m -> HTML m
189
191
renderGroup route stories =
190
- HH .ul [ HP .class_ $ HH.ClassName " list-reset" ] $
191
- mapFlipped (M .toUnfoldable stories) $ \( Tuple href { anchor }) ->
192
- HH .li
193
- [ HP .class_ $ HH.ClassName " mb-3 " ]
194
- [ HH .a
195
- [ HP .classes $
196
- Format .linkClasses <>
197
- ( if href == route then [ HH.ClassName " font-medium " ] else [] )
198
- , HP . href $ " # " <> unsafeEncodeURI href
199
- ]
200
- [ HH .text anchor ]
201
- ]
202
-
192
+ HH .ul [ HP .class_ $ HH.ClassName " list-reset" ]
193
+ $ mapFlipped (M .toUnfoldable stories)
194
+ $ \( Tuple href { anchor }) ->
195
+ HH .li
196
+ [ HP .class_ $ HH.ClassName " mb-3 " ]
197
+ [ HH .a
198
+ [ HP .classes $
199
+ Format .linkClasses <>
200
+ ( if href == route then [ HH.ClassName " font-medium " ] else [] )
201
+ , HP .href $ " # " <> unsafeEncodeURI href
202
+ ]
203
+ [ HH .text anchor ]
204
+ ]
203
205
204
206
eval :: forall a . Query a -> H.HalogenM (State m ) Action Slots Void m (Maybe a )
205
207
eval (RouteChange route next) = do
@@ -209,7 +211,7 @@ app =
209
211
-- --------
210
212
-- Helpers
211
213
212
- partitionByGroup :: ∀ m . Group -> Stories m -> Tuple Group (Stories m )
214
+ partitionByGroup :: forall m . Group -> Stories m -> Tuple Group (Stories m )
213
215
partitionByGroup g = Tuple g <<< M .filter (\{ group } -> group == g)
214
216
215
217
unsafeEncodeURI :: String -> String
0 commit comments