@@ -4,8 +4,8 @@ import Browser
44import Browser.Dom as Dom
55import ConcurrentTask exposing (ConcurrentTask )
66import ConcurrentTask.Browser.Dom
7- import Html exposing (Html , button , div , input , p , text )
8- import Html.Attributes exposing ( class , id )
7+ import Html as H exposing (Html )
8+ import Html.Attributes as A
99import Html.Events exposing (onClick )
1010import Json.Decode as Decode
1111
@@ -222,33 +222,49 @@ port receive : (Decode.Value -> msg) -> Sub msg
222222
223223view : Model -> Html Msg
224224view model =
225- div [ class " row" ]
226- [ input [ id " input" ] []
227- , div [ class " box" , id " box" ] [ text " What size am i?" ]
228- , div [ class " scrolly-box" , id " scrolly-box" ]
229- [ text " Scroll mee!!"
230- , p [] [ text " ..." ]
231- , p [] [ text " ..." ]
232- , p [] [ text " ..." ]
233- , p [] [ text " ..." ]
234- , p [] [ text " ..." ]
235- , p [] [ text " ..." ]
225+ H . div
226+ [ A . class " col gap-xs pa-s"
227+ , A . style " max-width" " 800px"
228+ ]
229+ [ H . input [ A . id " input" ] []
230+ , H . div
231+ [ A . class " pa-s"
232+ , A . style " background-color" " dodgerblue"
233+ , A . style " color" " white"
234+ , A . id " box"
235+ ]
236+ [ H . text " What size am i?" ]
237+ , H . div
238+ [ A . class " pa-s"
239+ , A . style " width" " 100px"
240+ , A . style " height" " 100px"
241+ , A . style " background-color" " cornflowerblue"
242+ , A . style " overflow-y" " scroll"
243+ , A . id " scrolly-box"
244+ ]
245+ [ H . text " Scroll mee!!"
246+ , H . p [] [ H . text " ..." ]
247+ , H . p [] [ H . text " ..." ]
248+ , H . p [] [ H . text " ..." ]
249+ , H . p [] [ H . text " ..." ]
250+ , H . p [] [ H . text " ..." ]
251+ , H . p [] [ H . text " ..." ]
236252 ]
237253 , showViewport model
238254 , showWindowViewport model
239255 , showElement model
240- , div [ class " buttons " ]
241- [ button [ onClick FocusClicked ] [ text " Focus the Input" ]
242- , button [ onClick BlurClicked ] [ text " Blur the Input" ]
256+ , H . div [ A . class " row gap-xs " ]
257+ [ H . button [ onClick FocusClicked ] [ H . text " Focus the Input" ]
258+ , H . button [ onClick BlurClicked ] [ H . text " Blur the Input" ]
243259 ]
244- , div [ class " buttons " ]
245- [ button [ onClick SetViewportOfElementClicked ] [ text " Scroll top of the scroll box" ]
246- , button [ onClick ScrollTopClicked ] [ text " Scroll Window to Top" ]
260+ , H . div [ A . class " row gap-xs " ]
261+ [ H . button [ onClick SetViewportOfElementClicked ] [ H . text " Scroll top of the scroll box" ]
262+ , H . button [ onClick ScrollTopClicked ] [ H . text " Scroll Window to Top" ]
247263 ]
248- , div [ class " buttons " ]
249- [ button [ onClick GetBoxViewportClicked ] [ text " Get Viewport of the blue box" ]
250- , button [ onClick GetWindowViewportClicked ] [ text " Get Window Viewport" ]
251- , button [ onClick GetElementClicked ] [ text " Get Element size of the blue box" ]
264+ , H . div [ A . class " row gap-xs " ]
265+ [ H . button [ onClick GetBoxViewportClicked ] [ H . text " Get Viewport of the blue box" ]
266+ , H . button [ onClick GetWindowViewportClicked ] [ H . text " Get Window Viewport" ]
267+ , H . button [ onClick GetElementClicked ] [ H . text " Get Element size of the blue box" ]
252268 ]
253269 ]
254270
@@ -257,36 +273,36 @@ showViewport : Model -> Html msg
257273showViewport model =
258274 case model. foundViewport of
259275 Nothing ->
260- text " "
276+ H . text " "
261277
262278 Just vp ->
263- div []
264- [ div [] [ text " Found blue box viewport!" ]
265- , div [] [ text ( Debug . toString vp) ]
279+ H . div []
280+ [ H . div [] [ H . text " Found blue box viewport!" ]
281+ , H . div [] [ H . text ( Debug . toString vp) ]
266282 ]
267283
268284
269285showWindowViewport : Model -> Html msg
270286showWindowViewport model =
271287 case model. foundWindowViewport of
272288 Nothing ->
273- text " "
289+ H . text " "
274290
275291 Just vp ->
276- div []
277- [ div [] [ text " Found window viewport!" ]
278- , div [] [ text ( Debug . toString vp) ]
292+ H . div []
293+ [ H . div [] [ H . text " Found window viewport!" ]
294+ , H . div [] [ H . text ( Debug . toString vp) ]
279295 ]
280296
281297
282298showElement : Model -> Html msg
283299showElement model =
284300 case model. foundElement of
285301 Nothing ->
286- text " "
302+ H . text " "
287303
288304 Just vp ->
289- div []
290- [ div [] [ text " Found blue box element size!" ]
291- , div [] [ text ( Debug . toString vp) ]
305+ H . div []
306+ [ H . div [] [ H . text " Found blue box element size!" ]
307+ , H . div [] [ H . text ( Debug . toString vp) ]
292308 ]
0 commit comments