<commit_before>module Scorched.View.Component.Button exposing (build)

import Svg exposing (Svg)
import Svg.Attributes as Attr
import Svg.Events as Events

import Scorched.Model.Types exposing (Msg(..), Specification(..), ButtonSpec, Control, Direction(..))
import Scorched.Model.Geometry exposing (Dimension, Offset)

import Scorched.View.Helper as Helper

import Scorched.View.Component.BorderBox as BorderBox
import Scorched.View.Component.KeyedLabel as KeyedLabel

build : Control -> Bool -> Svg Msg
build ({spec} as control) disabled =
  case spec of
    Button buttonSpec ->
      case disabled of
        True -> buildDisabled control
        False -> buildEnabled control buttonSpec
    _ -> Svg.g [] []

buildEnabled : Control -> ButtonSpec -> Svg Msg
buildEnabled {label, key, offset, spec} {dimensions, invert, action} =
  Svg.g
    [ Attr.class "button"
    , Attr.transform (Helper.translate offset)
    , Attr.fontWeight "600"
    , Attr.letterSpacing "-1px"
    , Attr.wordSpacing "-3px"
    , Events.onClick action
    , Events.onMouseDown (ControlToggle label None)
    , Events.onMouseUp (ControlToggle label None)
    ]
    [ BorderBox.build dimensions 2 invert
    , KeyedLabel.build label key {x=5, y=12}
    ]

buildDisabled : Control -> Svg Msg
buildDisabled control = Svg.g [] []<commit_msg>initial render of disabled buttons<commit_after>module Scorched.View.Component.Button exposing (build)

import Svg exposing (Svg)
import Svg.Attributes as Attr
import Svg.Events as Events

import Scorched.Model.Types exposing (Msg(..), Specification(..), ButtonSpec, Control, Direction(..))
import Scorched.Model.Geometry exposing (Dimension, Offset)

import Scorched.View.Helper as Helper

import Scorched.View.Component.BorderBox as BorderBox
import Scorched.View.Component.KeyedLabel as KeyedLabel

build : Control -> Bool -> Svg Msg
build ({spec} as control) disabled =
  case spec of
    Button buttonSpec ->
      case disabled of
        True -> buildDisabled control buttonSpec
        False -> buildEnabled control buttonSpec
    _ -> Svg.g [] []

buildEnabled : Control -> ButtonSpec -> Svg Msg
buildEnabled {label, key, offset, spec} {dimensions, invert, action} =
  Svg.g
    [ Attr.class "button"
    , Attr.transform (Helper.translate offset)
    , Attr.fontWeight "600"
    , Attr.letterSpacing "-1px"
    , Attr.wordSpacing "-3px"
    , Events.onClick action
    , Events.onMouseDown (ControlToggle label None)
    , Events.onMouseUp (ControlToggle label None)
    ]
    [ BorderBox.build dimensions 2 invert
    , KeyedLabel.build label key {x=5, y=12}
    ]

buildDisabled : Control -> ButtonSpec -> Svg Msg
buildDisabled {label, offset} {dimensions} =
  Svg.g
    [ Attr.class "button"
    , Attr.transform (Helper.translate offset)
    , Attr.fontWeight "600"
    , Attr.letterSpacing "-1px"
    , Attr.wordSpacing "-3px"
    ]
    [ BorderBox.build dimensions 2 False
    , Svg.text_ [ Attr.x "5" , Attr.y "12" ] [ Svg.text label ]
    ]
{'fraction_non_alphanumeric': 0.10696266397578204, 'fraction_numerical': 0.009081735620585268, 'mean_word_length': 3.4520958083832336, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, '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': '1870821', 'n_tokens_mistral': 957, 'n_tokens_neox': 925, 'n_words': 266}