Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes docs for styled. #472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/Html/Styled.elm
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,25 @@ type alias Attribute msg =


{-| Takes a function that creates an element, and pre-applies styles to it.
bigButton : List (Attribute msg) -> List (Html msg) -> Html msg
bigButton =
styled button
[ padding (px 30)
, fontWeight bold
]
view : Model -> Html msg
view model =
[ text "These two buttons are identical:"
, bigButton [][ text "Hi!" ]
, button [ css [ padding (px 30), fontWeight bold ] ][ text "Hi!" ]
][ text "These two buttons are identical:"
, bigButton [] [ text "Hi!" ]
, button [ css [ padding (px 30), fontWeight bold ] ] [] [ text "Hi!" ]
]

bigButton : List (Attribute msg) -> List (Html msg) -> Html msg
bigButton =
styled button
[ padding (px 30)
, fontWeight bold
]


view : Model -> Html msg
view model =
div []
[ text "These two buttons are identical:"
, bigButton [] [ text "Hi!" ]
, button
[ css [ padding (px 30), fontWeight bold ] ]
[ text "Hi!" ]
]

Here, the `bigButton` function we've defined using `styled button` is
identical to the normal `button` function, except that it has pre-applied
the attribute of `css [ padding (px 30), fontWeight bold ]`.
Expand Down