<commit_before>module Toolbox.Views (..) where

import Html exposing (..)
import Html.Attributes exposing (..)
import Toolbox.Action exposing (Action)
import Toolbox.Types exposing (Ingredient, Model)


view : Signal.Address Action -> Model -> Html
view address model =
  case model.response of
    Just r ->
      div
        [ class "container" ]
        [ div
            [ class "row" ]
            [ div
                [ class "col-sm-4" ]
                [ div
                    [ class "card" ]
                    [ div
                        [ class "card-block" ]
                        [ h4 [ class "card-title" ] [ text "Ingredients" ] ]
                    , div
                        [ class "list-group list-group-flush" ]
                        (List.map ingredientItem r.ingredients)
                    ]
                ]
            , div
                [ class "col-sm-8" ]
                [ h2 [] [ text "Recipe (TODO)" ] ]
            ]
        ]

    Nothing ->
      div
        [ class "alert alert-info" ]
        [ text "Please wait..." ]


ingredientItem : Ingredient -> Html
ingredientItem i =
  a
    [ class "list-group-item", href "#" ]
    [ img [ src i.image, width 32, height 32 ] []
    , text i.name
    ]<commit_msg>Disable event propagation and send NoOp action on click.<commit_after>module Toolbox.Views (..) where

import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Json.Decode
import Toolbox.Action exposing (Action(..))
import Toolbox.Types exposing (Ingredient, Model)


view : Signal.Address Action -> Model -> Html
view address model =
  case model.response of
    Just r ->
      div
        [ class "container" ]
        [ div
            [ class "row" ]
            [ div
                [ class "col-sm-4" ]
                [ div
                    [ class "card" ]
                    [ div
                        [ class "card-block" ]
                        [ h4 [ class "card-title" ] [ text "Ingredients" ] ]
                    , div
                        [ class "list-group list-group-flush" ]
                        (List.map (ingredientItem address) r.ingredients)
                    ]
                ]
            , div
                [ class "col-sm-8" ]
                [ h2 [] [ text "Recipe (TODO)" ] ]
            ]
        ]

    Nothing ->
      div
        [ class "alert alert-info" ]
        [ text "Please wait..." ]


ingredientItem : Signal.Address Action -> Ingredient -> Html
ingredientItem address i =
  a
    [ class "list-group-item", href "#", clickHandler address NoOp ]
    [ img [ src i.image, width 32, height 32 ] []
    , text i.name
    ]


clickHandler address action =
  onWithOptions
    "click"
    { stopPropagation = True, preventDefault = True }
    Json.Decode.value
    (\_ -> Signal.message address action)
{'fraction_non_alphanumeric': 0.11165217391304348, 'fraction_numerical': 0.005565217391304348, 'mean_word_length': 1.3401139137510172, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '632321', 'n_tokens_mistral': 846, 'n_tokens_neox': 785, 'n_words': 215}