Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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 | ||
] |