mdgriffith / style-elements

Create styles that don't mysteriously break!
http://package.elm-lang.org/packages/mdgriffith/style-elements/latest
BSD 3-Clause "New" or "Revised" License
445 stars 49 forks source link

`el` accepts `center` but ignores it #101

Closed rtfeldman closed 6 years ago

rtfeldman commented 6 years ago

The big picture of what I'm trying to do

I'm making a thing that looks like this:

screen shot 2017-10-14 at 5 30 58 pm

The first thing I tried to get whee! centered in the middle led to a surprising result.

What I did

 el Elm [ width (fillPortion 1), center ] (text "whee!")

I put this in the middle of a row. The element to the left ("Title" in the screenshot) had alignLeft and the element to the right ("rtfeldman" in the screenshot) had alignRight.

All three had width (fillPosition 1). My intention was to center this middle one with center.

What I Expected To Happen

"whee!" would get centered, like in the screenshot. (The screenshot shows what I was going for, not what this code actually did.)

What Actually Happened

"whee!" was left-aligned within its container element like so:

screen shot 2017-10-14 at 5 34 45 pm

When I swapped el for row, with no other changes, the layout worked as I'd hoped:

screen shot 2017-10-14 at 5 30 58 pm

This suggests passing center to el compiles but has no effect. I would have expected that either:

Versions

thorebear commented 6 years ago

According to the documentation passing center to a singular element like el will affect the alignment of the individual element, not the child of the element. So I think this is the expected behavior.

thorebear commented 6 years ago

To clarify: You get the element centered, if you remove the width attribute, since the el element will have space to "center" in.

mdgriffith commented 6 years ago

This issue inspired an overhaul for how alignment works under the hood for v5...so, that's awesome! 😄