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

Allow batching of attributes #54

wants to merge 2 commits into
base: master


None yet
3 participants
Copy link

commented Oct 16, 2018

When composing styles one might have functions that define borders or fonts or backgrounds etc.
These functions usually need to return Lists of Attribute msg, as more than one attribute is needed to define a border for example.

This can get awkward when using them:

el (List.append thinBorder headerFont [ width fill, padding 8]) <| text "Header"

This pull requests introduces the batchAttributes function:

batchAttributes : List (Attribute msg) -> Attribute msg

Then, the thinBorder function can return a single Attribute msg and the above example becomes simpler:

el [thinBorder, headerFont, width fill, padding 8] <| text "Header"

With thinBorder looking like:

thinBorder : Attribute msg
thinBorder =
        [ Border.width 1
        , Border.solid
        , Border.color <| greyscale 0.65
        , Border.rounded 3

This comment has been minimized.

Copy link

commented Nov 13, 2018

I wanted to ask about your opinion and the status about this PR.

Are you considering merging it? Or do you not like it?
Any decision would be helpful for us, as we currently use this as a fork, but would probably rewind to the original version if it will not be merged. (Which is totally OK)

Thanks in advance.


This comment has been minimized.

Copy link

commented Dec 3, 2018

Would also be useful to have the "none" element but as an attribute, so you can do stuff like

if condition then 
    Background.image "img.png"

This comment has been minimized.

Copy link

commented Dec 4, 2018

@AlmightyFloppyFish here's a hack for you:

none : Element.Attribute msg
none =
    Html.Attributes.classList [] |> Element.htmlAttribute

This comment has been minimized.

Copy link

commented Jun 6, 2019

From a discussion in discourse:

I’ve discussed that feature extensively on the slack and am aware people want something like that. It’s a weird one because it’s simultaneously a small change, but one that would likely have a large effect on how people organize their code.
It’s a large design decision and I’m hesitant to make that decision lightly or without exploring other options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.