Skip to content

Commit

Permalink
render fruit list
Browse files Browse the repository at this point in the history
  • Loading branch information
maxfarseer committed Feb 16, 2020
1 parent 9847eae commit 74f335b
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions src/Main.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
module Main exposing (main)

import Browser
import Html exposing (h1, text)
import Html exposing (Html, div, h1, li, text, ul)



-- переменные (аналог const XXX = ... )


fruits : List String
fruits =
[ "яблоко", "банан", "груша" ]



-- функции для отрисовки


renderItem : String -> Html msg
renderItem fruitName =
li [] [ text fruitName ]


renderFruits : List String -> Html msg
renderFruits data =
let
list =
List.map renderItem data
in
ul [] list



-- главная view функция


main =
h1 [] [ text "Hello, Elm!" ]
div []
[ h1 []
[ text "Сезон фруктов!" ]
, renderFruits fruits
]

0 comments on commit 74f335b

Please sign in to comment.