-
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
Support explicit column width in pixels #1026
Comments
Hey David, Since Width is already a string couldn't we use that string with a differentiator to specify the width in pixels? It would save on the ambiguity when both width and pixelWidth are specified. How do we handle?
Why not do what HTML does and have 50px mean that the units are pixels? Thoughts? |
The reason I went with Overall it seems to me that introducing explicit properties for pixel sizes is cleaner. The rule would be that Thoughts? |
David, Thanks for the explanation, with the image scenario, I completely agree that overloading But If we keep the names generic The rule would still apply that |
I used the names pixelWidth and pixelHeight so as to be able to type them as number and be explicit as to what unit they were expressed in. What you suggest is definitely an option. However it requires that we make these properties strings instead of numbers. I would prefer using actual numbers when possible, it makes payload validation and schema-based IntelliSense easier. Also note that the "width" property in Column can be expressed as a number, representing a weight. I'd say it would be a bit weird to let authors specify a weight as a number but pixels as a string. Typically, if we used "width" and "height" as string, it would likely be so we support values like "*" for stretch, "auto" for automatic, "150px" for explicit pixels. Both "*" and "auto" are already handled via the "size" property. So if we used "width" and "height" as strings IMO it would really only be in order to maybe support additional units in the future, such as "mm", "in", "em" or whatnot, and I am really not sure we would ever need to go there. All that said, I am open. If there is a consensus around "width" and "height" as strings, I can live with it. |
My opinion for future-proofing would be either (in order of preference):
{
"type": "Image",
"width": {
"value": 50,
"unit": "px"
}
} |
The question is, do we actually need to future proof this? This page lists supported units in CSS; I do not imagine we'd ever want to support any of them aside from % (e.g. our weight sizing for Column) and explicit pixels... |
BTW we might want to make a quick decision here, as I believe pixelWidth/pixelHeight is already in the process of being implemented in either the Android or iOS SDK (or both) and if we go with that for image then we should do the same for Column IMO. |
I would rather keep Width and Height and have them as strings for future proofing even if we don't make use of other units. |
I can live with that. That said going with this approach on Column will introduce some inconsistency given that Column.width can be expressed as a number to represent a weight. |
I have one question regarding to relative width; i.e. width without unit (e.g. "px"). in a columnset with both explicit and relative width, how relative width should be handled? For example, column 1 has "50px" and column 2 has "5". Should we consider explicit width in determining the width for relative widths? |
Any column that requests an explicit width in pixels gets what it asked for. All other columns (weight, auto or stretch) share the remaining space. |
Documentation is done and in the mahiding/site1.1 branch. |
Implementation status
Problem
Achieving table-like layouts with Adaptive is hard because one has to use several ColumnSets on top of each other and there are only two ways to ensure that all columns in all those set have the same widths:
Solution
Allow columns to have an explicit width, expressed in pixels. Essentially, make it possible in an easy and straightforward way to do what is already possible with a column containing an explicitly sized invisible image, which card authors will do to achieve the results they want.
Example use:
As rendered:

The text was updated successfully, but these errors were encountered: