-
Notifications
You must be signed in to change notification settings - Fork 563
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 elements to stretch vertically to make it possible to align content to the bottom of a fixed-height card #484
Comments
@Anbare this proposal would add some pretty neat flexibility for fixed-height cards. Any thoughts on this? |
People have wanted bottom-aligned content since the Windows 10 live tile days - ship it. The proposal seems to work. Adding vertical alignment would make sense though. |
I see the point about vertical alignment. If the textblock |
Correct. Having to think about the height of the previous element in order to align something to the bottom is a bit funky. Having two text blocks with normal (auto) heights and then just setting the second one to bottom alignment would be more intuitive based on today's UI languages. |
The only thing that's missing really is the ability to center something vertically. But this feature actually makes it possible as well. If you wanted to have a single TextBlock centered vertically, you could have:
How about that? It seems to me that might be enough. I can add an example here a bit later if necessary. |
I'm arguing that it would be a lot more straightforward and intuitive to simply add a verticalAlignment property. I know it's not technically required - it's just a lot simpler. |
Explicit vertical alignment would introduce the below as side effects:
The height property proposed here doesn't have these problems, although it does require that one thinks in terms of "reserving empty space" rather than vertical alignment; that said, when you think about it, it is the exact same principle as sizing columns. |
Also, an important thing to not forget is that the proposed height property is still necessary anyway in order to support vertical centering. So what I'm arguing at this point is that because height is necessary, and because it makes it possible to do all sorts of alignment, I think we can start with it without introducing explicit vertical alignment. |
I don't understand your second side effect, could you elaborate more? For the first side effect, we wouldn't necessarily have to render out of order. Elements could still appear in the order that they're declared. If you assigned "Top" after you first had an item assigned "Bottom", that second item would still be displayed beneath the bottom item - we don't have to perform logic to attempt to figure out what the developer meant in this weird case. I know you're trying to simplify things by building this feature with the minimal set of properties required. I'm arguing that it benefits the developer story by adding an extra (technically not necessary) property. Basically - what would be the most intuitive way a developer would think to design the picture you showed. For a XAML dev, they would assign the height of the column set to stretch, and then they would assign the second text block's vertical alignment to bottom. I don't believe that making the first text block stretch height in order to achieve bottom alignment of the second text block wouldn't be intuitive to XAML devs. |
Let's just leave this up to a third voice to come in and vote, since we're not going to convince each other. The last example would render with both text elements stacked on the bottom, since the first one sends it to the bottom, and then the second one still has to display beneath the first one since the order of the elements is still respected, so it would be displayed beneath at the "top" of the remaining bottom space. |
Maybe @danmarshall wants to chime in again. But let me still react on what you just wrote - I don't think that's realistic. Elements align within their container. You're saying the first element is sent to the bottom (so the bottom of its container, right?) then the next element is rendered below that... outside/below its own container? |
@dclaux in the first Also, I would guess that in this example:
That the verticalAlignment would not be valid. So this would also make for a bad developer story IMHO. Perhaps
But I haven't thought this through completely. |
@danmarshall first let me go back to the "bottom then top" example. We can totally make it work, that is what I was alluding to above. The logic would be:
But the drawback is now that the first element in the payload is rendered visually below the second one. Not the end of the world though. Also, please don't forget that to support center alignment we'd still need the height property as spece'd here. Now I assume this is what you're asking - notice how effortless is to evenly spread these text blocks:
|
@dclaux ok that answers my first question. Then, is there a way to have only one textblock aligned to the bottom? |
Trying to close on this. I do agree that a verticalAlignment property could be a nice addition. But given that the height property is a requirement anyway (there is no centering in a container that adjusts its height to its content, as is currently the case in Adaptive), and given that it does allow for all alignment types (even though you have to use empty "spacer" elements in some cases) I think the proposed design in this issue is the right first step, and we can revisit verticalAlignment later. Can we agree on that? Also, truth be told, vertical alignment in HTML is very hard especially in the context of elements that are dynamically sized, like with Adaptive Cards. I have been trying to implement it since yesterday with no success. There are plenty of articles on the subject on the web, you can look at this for instance to get an idea: https://stackoverflow.com/questions/79461/vertical-alignment-of-elements-in-a-div |
@danmarshall You would have to use empty containers to center or bottom align a single TextBlock, although I don't believe that would be a common thing at least when it comes to aligning to the bottom (usually, there's also something at the top...) For example, to center:
|
Yes, I would agree that the proposal is the right first step - the height property. |
Yeah agreed, we should add the height property first since it's required, and then monitor feedback about whether we should add any vertical alignment helper properties. |
Awesome, thanks guys for your help. @matthidinger can we consider this approved? If so I will merge the changes into master. |
Sounds great to me, thanks for the discussion folks. Adding to the v1 milestone for tracking as well |
The PR has been merged. |
I'll take a stab at adding this to the UWP version |
When will the online HTML visualizer on the website be updated with these new changes? I got the UWP code updated to support height, but haven't switched column "size" to "width" yet, we should probably update all the samples to use "width" too? |
Documentation is done and in the mahiding/site1.1 branch. |
Implementation status
Problem
Currently, it is not really possible to align content at the bottom of a fixed-height card. Card authors have to recourse to hacks such as inserting an invisible image of a specific height to reserve some blank space. Such hacks are very fragile because they rely on knowing what the actual height of the target container is; cards authored using such hacks risk breaking if the container's height changes.
Design
Add a new height property to all element types:
Because we are introducing a "height" property, it makes sense to also rename the "size" property of a Column to "width"
Example
Card payload
As rendered in the Windows Live Tile container:
Another example
Card payload
As rendered
The text was updated successfully, but these errors were encountered: