Skip to content

Instantly share code, notes, and snippets.

@duncanmalashock
Last active January 19, 2022 13:46
Show Gist options
  • Save duncanmalashock/6812059beb9589c704122a06f0afbd8d to your computer and use it in GitHub Desktop.
Save duncanmalashock/6812059beb9589c704122a06f0afbd8d to your computer and use it in GitHub Desktop.
"Config" Builder
module Button exposing (Config, config, withIcon, withSizeLarge, view)
import Html exposing (Html)
import Icon exposing (Icon)
type alias Config msg =
{ onClick : msg
, label : String
, maybeIcon : Maybe Icon
, size : Size
}
config : { onClick : msg, label : String } -> Config msg
withIcon : Icon -> Config msg -> Config msg
withSizeLarge : Config msg -> Config msg
view : Config msg -> Html msg
module ExampleUsage exposing (view)
import Button
import Icon exposing (Icon)
import Html exposing (Html)
view : Html msg
view =
Button.config
{ onClick = ButtonClicked
, label = "Click me!"
}
|> Button.withIcon Icon.Okay
|> Button.withSizeLarge
|> Button.view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment