elm-bootstrap-html icon indicating copy to clipboard operation
elm-bootstrap-html copied to clipboard

Update for Elm 0.18

Open BryanJBryce opened this issue 8 years ago • 5 comments

Update for Elm 0.18

BryanJBryce avatar Dec 08 '16 04:12 BryanJBryce

Any guides on what needs to be done?

AlexDenisov avatar Dec 13 '16 18:12 AlexDenisov

Just like the elm-html-shorthand library, this library has the problem that names ending in ' are no longer allowed in Elm 0.18. So another naming scheme needs to be though of.

One (ugly) solution would be to use a double underscore for those functions in place of '. Another would be to namespace the functions instead?

stkb avatar Dec 13 '16 18:12 stkb

I should mention, I'm somewhat hesitant to update and publish this package again. It is very incomplete and since the last time this was updated there has been pretty amazing progress on html widgets in other packages. The best option for most people would be to evaluate these instead I think.

Alternatively this package probably needs to be forked and published by someone with the resources to complete it and maintain it properly (or possibly starting again from scratch with a bootstrap package).

Is anyone using this in their own projects?

rehno-lindeque avatar Dec 13 '16 22:12 rehno-lindeque

@rehno-lindeque I tried to update it to 0.18, but run into the same problem with ' names.

For now, I just extracted 6-7 functions that I'm using in my project into custom module.

Also I decided to get rid of ' / _ convention and to have extra attributes array as the first parameter.

e.g.

type alias BtnParam msg =
  { icon : Maybe (Html msg)
  , label : Maybe String
  , tooltip : Maybe String
  }


btnParam : BtnParam msg
btnParam =
  { icon = Nothing
  , label = Nothing
  , tooltip = Nothing
  }


button : List (Attribute msg) -> BtnParam msg -> msg -> Html msg
button attrs { icon, label, tooltip } x =
  let
    btnBody =
      case ( icon, label ) of
        ( Just icon_, Just label_ ) ->
          [ icon_, text (" " ++ label_) ]

        ( Just icon_, _ ) ->
          [ icon_ ]

        ( Nothing, Just label_ ) ->
          [ text label_ ]

        ( Nothing, Nothing ) ->
          []

    tooltip_ =
      tooltip
        |> Maybe.map (\t -> [ A.title t ])
        |> Maybe.withDefault []
  in
    button
      ([ A.type_ "button"
       , class "btn"
       , onClick x
       ]
        ++ attrs
        ++ tooltip_
      )
      btnBody


btnPrimary : List (Attribute msg) -> BtnParam msg -> msg -> Html msg
btnPrimary attrs =
  button ([ class "btn-primary" ] ++ attrs)


btnSuccess : List (Attribute msg) -> BtnParam msg -> msg -> Html msg
btnSuccess attrs =
  button ([ class "btn-success" ] ++ attrs)

scarfacedeb avatar Dec 14 '16 18:12 scarfacedeb

i pushed a pull-request with updates

robotarmy avatar Jan 01 '17 04:01 robotarmy