Re: [csswg-drafts] [css-logical] Flow-relative syntax for `margin`-like shorthands (#1282)

The CSS Working Group just discussed `flow-relative syntax for margin-like shorthands`.

<details><summary>The full IRC log of that discussion</summary>
&lt;TabAtkins> Topic: flow-relative syntax for margin-like shorthands<br>
&lt;TabAtkins> github: https://github.com/w3c/csswg-drafts/issues/1282<br>
&lt;fantasai> https://github.com/w3c/csswg-drafts/issues/1282#issuecomment-952428897<br>
&lt;fantasai> https://github.com/w3c/csswg-drafts/issues/1282#issuecomment-1105613943<br>
&lt;TabAtkins> miriam: fantasai and I looked at this last year, with Jen<br>
&lt;TabAtkins> miriam: CSS was built around physical property - trbl, width/height<br>
&lt;TabAtkins> miriam: For various reasons logical props are more resilient, especially with multiple langs<br>
&lt;TabAtkins> miriam: Whether that's building it in pruposely, or automated translation<br>
&lt;TabAtkins> miriam: It woudl be great if we could move toward a world where flow-relative logical props are the defualt<br>
&lt;TabAtkins> miriam: The easier solution is that we just add `-logical` to various props<br>
&lt;TabAtkins> miriam: But long-term that feels like a second-class citizen, not the default<br>
&lt;TabAtkins> miriam: We'd like to get to a simple, clean way to default to relative<br>
&lt;TabAtkins> miriam: Our plan is multi-step, starting with a property-by-property flag of some sort<br>
&lt;TabAtkins> miriam: Whether tha'ts a new prop name, a !flag, or something<br>
&lt;TabAtkins> miriam: That says "I want this property to be read as logical"<br>
&lt;TabAtkins> miriam: And once we've defined that for each property...<br>
&lt;TabAtkins> fantasai: Adn we'd add physical equivs so you could explicitly which way, if you wanted<br>
&lt;TabAtkins> fantasai: Wouldn't chang the default, just let you be more specific<br>
&lt;TabAtkins> miriam: Once defined for all props, we could look at a block-level or even file-level change of the default<br>
&lt;r12a> q+<br>
&lt;TabAtkins> miriam: So like an at-rule that switches default to logical for everything in it<br>
&lt;TabAtkins> miriam: Or even a file-level switch.<br>
&lt;addison> q+ to clarify relationship to rtl vs. ltr<br>
&lt;TabAtkins> miriam: Would have to be lexically scoped to the file; separate files shouldn't interact.<br>
&lt;r12a> qq+<br>
&lt;TabAtkins> miriam: The second comment fantasai linked is someone just saying "let's add an 's' to the property 'margins' and 'paddings'"<br>
&lt;dbaron> Do some of the "property-by-property" mean "declaration-by-declaration"?<br>
&lt;TabAtkins> miriam: There's some other syntax approaches that I didn't look at closely<br>
&lt;astearns> ack r12a<br>
&lt;Zakim> r12a, you wanted to react to dholbert<br>
&lt;emilio> q+<br>
&lt;TabAtkins> r12a: You alreayd talked about cascading - I've been using these logical props for a long time as much as possible<br>
&lt;TabAtkins> r12a: I've been using them for arabic and hebrew pages, and I've found there are occasionally situations where you really need to leave margin-left in the code, otherwise things break<br>
&lt;TabAtkins> r12a: there's not many, but some cases<br>
&lt;TabAtkins> r12a: So we should be careful and warn people that if we provide a big switch and say "this'll fix everything" it can break things, too. careful applying it en masse<br>
&lt;TabAtkins> miriam: Right. The logical shorthands would likely be in a different order than the physical anyway, so updates would require more than just the flag.<br>
&lt;astearns> ack addison<br>
&lt;Zakim> addison, you wanted to clarify relationship to rtl vs. ltr<br>
&lt;TabAtkins> miriam: So the situation is more like you use this when writing a new file, not adapting an old file.<br>
&lt;TabAtkins> addison: I think Richard was saying sometimes you need both so you need both options.<br>
&lt;astearns> q+<br>
&lt;rachelandrew> q+<br>
&lt;TabAtkins> fantasai: Right, that's part of our proposal<br>
&lt;r12a> q+<br>
&lt;TabAtkins> addison: And it's not so much as when people are mixing langs in a page, but rather they want the same stylesheet for both their LTR and RTL translations without much fiddling.<br>
&lt;astearns> ack emilio<br>
&lt;TabAtkins> emilio: The "switch per file" doesn't work for BEM<br>
&lt;TabAtkins> emilio: The simplest solution is having different properties, but that's not ideal<br>
&lt;astearns> s/BEM/OM/<br>
&lt;emilio> yeah, the OM<br>
&lt;fremy> q?<br>
&lt;TabAtkins> fantasai: The browser could parse it in and use the declarations... Our proposal provides two shorthand syntaxes, both explicit, in addition to the current "ambiguous" one.<br>
&lt;TabAtkins> fantasai: So the ambiguous would get decided as one or the other.<br>
&lt;TabAtkins> emilio: How would you decide that when writing it out with JS?<br>
&lt;TabAtkins> fantasai: For inline styles you'd use the explicit switch<br>
&lt;TabAtkins> emilio: Right but then el1.style.margin = el2.style.margin loses the detail<br>
&lt;TabAtkins> fantasai: The OM is currently locked into physical, so we're probably stuck with that. Any ideas?<br>
&lt;TabAtkins> dbaron: I think if you want a file-level switch, you need it to store the information in each declaration.<br>
&lt;TabAtkins> dbaron: So I think when you said property-by-property, at least some of the time you meant decl-by-decl<br>
&lt;TabAtkins> miriam: yeah<br>
&lt;TabAtkins> dbaron: So a file-level switch will have to alter the declarations at parse time to store the information, and possibly indistinguishable in the OM.<br>
&lt;emilio> q+<br>
&lt;TabAtkins> fremy: It's common to bundle CSS, so per-file is an issue<br>
&lt;TabAtkins> [discussion about ease of "s" suffix or "l-" prefix]<br>
&lt;TabAtkins> fantasai: That still makes logical CSS a second-level, more awkward option<br>
&lt;TabAtkins> astearns: My question on file-levle switch - is there a specific set of shorthands this would apply to? Or is it just certian ambiguous properties?<br>
&lt;TabAtkins> astearns: If we add new shorthands, will they use this switch?<br>
&lt;TabAtkins> fantasai: Note it's not just shorthands, it's every property that assigns in a physical orientation.<br>
&lt;TabAtkins> astearns: So it's not an allowlist, it's a set of props with this characteristic<br>
&lt;astearns> ack astearns<br>
&lt;TabAtkins> fantasai: Right, so we'd like look at overflow, which is x/y, and we'd define that it can also be block/inline<br>
&lt;TabAtkins> miriam: But like 'left' won't change, it just gets a different property<br>
&lt;astearns> ack rachelandrew<br>
&lt;TabAtkins> fantasai: But like text-shadow shoudl be able to assign block/inline, etc<br>
&lt;dbaron> text-shadow may be the exception to wanting the default to be logical!<br>
&lt;TabAtkins> rachelandrew: Issues 'margins' (suffix), that's easily typo'd. Very confusing especially since th eorder changes<br>
&lt;TabAtkins> rachelandrew: Not sure if we need a file switch at all, kinda like the staged approach.<br>
&lt;TabAtkins> rachelandrew: Wonder if, once we have the prop-by-prop, that'll be enough, especially since we know most authors use postprocessors which can handle the "file-level" itself<br>
&lt;florian> q+<br>
&lt;TabAtkins> rachelandrew: So we can find out if we even need the second step once we've done all the properties individually.<br>
&lt;astearns> ack r12a<br>
&lt;TabAtkins> r12a: The switch sound like it could b euseful bc it maeks things easier in some circumstances, but it's more complex<br>
&lt;TabAtkins> r12a: We've been stuck for over a year on just margin and padding, tho<br>
&lt;addison> q+ to say the "order" isn't different, also that the proposal for interim work seems agreeable?<br>
&lt;TabAtkins> r12a: The margin-inline/etc already exist and are great, but don't have the 4-value sorted out<br>
&lt;TabAtkins> r12a: So it seems like just a nomenclature, wish we could sort that out.<br>
&lt;astearns> ack emilio<br>
&lt;TabAtkins> The "order" is indeed different, depending on your language, addison<br>
&lt;TabAtkins> emilio: So the devil is in the details of 'margin'. If a logical version of the shorthands is something we need eventually anyway<br>
&lt;TabAtkins> emilio: I think it would be great ot make progress here so we can just do logical margins<br>
&lt;TabAtkins> TabAtkins: That exact thing is step 1 of this proposal<br>
&lt;TabAtkins> emilio: So yeah can we resolve on that?<br>
&lt;TabAtkins> emilio: And come up with a consistent model second<br>
&lt;iank_> +1 to emilio<br>
&lt;astearns> ack fantasai<br>
&lt;astearns> ack florian<br>
&lt;TabAtkins> florian: The point of discussing this switch now is not to have it now, but to be consistent with the switch eventually<br>
&lt;emilio> s/consistent model/consistent model for how to switch margin to the logical thing<br>
&lt;TabAtkins> florian: bc if properties all work in different ways, we can never introduce the switch, at least not simply<br>
&lt;r12a> q+<br>
&lt;TabAtkins> florian: So we don't need to decide on the switch, just need a model where we can intro it eventually<br>
&lt;addison> consistency and completeness<br>
&lt;TabAtkins> florian: Goal is to not just *enable* logical stylesheets, but make them *not harder* than physical<br>
&lt;astearns> ack dbaron<br>
&lt;TabAtkins> dbaron: Responding to emilio, I think it wasn't clear if we want `margin-logical: values` or `margin: values !logical`<br>
&lt;TabAtkins> dbaron: I think we need to be careful about assuming the end-state is everything-logical<br>
&lt;TabAtkins> dbaron: text-shadow was mentioned, and shadows in particular you usually want consistency of light sources.<br>
&lt;TabAtkins> dbaron: So want the light in upper-left, even if you have vertical Japanese or RTL hebrew mixed with your English<br>
&lt;TabAtkins> dbaron: So might need some more thought about the end state<br>
&lt;astearns> ack addison<br>
&lt;Zakim> addison, you wanted to say the "order" isn't different, also that the proposal for interim work seems agreeable?<br>
&lt;TabAtkins> addison: I think the switch is an end state, and primary challenge is agreement on interim bits. Does seem to be important.<br>
&lt;florian> q+<br>
&lt;TabAtkins> addison: And to get complete<br>
&lt;TabAtkins> addison: So let's focus on that.<br>
&lt;astearns> ack r12a<br>
&lt;TabAtkins> astearns: Right, but agreeing that we *will* have a switch is a good impetus<br>
&lt;TabAtkins> r12a: Dont' agree it's a good impetus since it's been years we've been talking about it without delivering<br>
&lt;TabAtkins> q+<br>
&lt;dbaron> s/have vertical Japanese/have Japanese with a mix of vertical and horizontal/<br>
&lt;TabAtkins> r12a: Let's just make a decision<br>
&lt;TabAtkins> r12a: All the explicit logical properties already work, just the shorthand is missing<br>
&lt;jensimmons> :dir<br>
&lt;TabAtkins> r12a: Meanwhile while we wait, need a way to change properties, currently browsers use :dir to do so<br>
&lt;astearns> ack florian<br>
&lt;TabAtkins> florian: Here's a concrete proposal, tying to david's earlier point about storing state<br>
&lt;TabAtkins> florian: I propose we don't go with extended names. Instae we use !syntax, and add a propdef line for specifying what the property defaults to if you don't specify the !.<br>
&lt;TabAtkins> florian: So for like text-decoration you'd say "Default Directions: n/a", but margin would say "Default Directions: physical", etc<br>
&lt;TabAtkins> florian: And later we can worry about a global switch, maybe with smarts about shadows, etc.<br>
&lt;TabAtkins> florian: But first is the state in the propdef table.<br>
&lt;emilio> q+<br>
&lt;fantasai> TabAtkins: What Florian said.<br>
&lt;astearns> ack TabAtkins<br>
&lt;TabAtkins> emilio: Not a fan of the bang, would prefer a ? mark<br>
&lt;miriam> q+<br>
&lt;TabAtkins> emilio: Would prefer a separate shorthand, even with `-physical` and `-logical`<br>
&lt;emeyer> q+<br>
&lt;astearns> ack emilio<br>
&lt;TabAtkins> emilio: Less to figure out there<br>
&lt;TabAtkins> emilio: Lots of thing to sort out to make !logical work<br>
&lt;TabAtkins> ?? What things?<br>
&lt;TabAtkins> emilio: And I just don't like the aesthetics<br>
&lt;TabAtkins> florian: It helps with the mental model if the front and back look similar<br>
&lt;TabAtkins> emilio: Complexity - we don't have conditional shorthands that expand one way or another based on some condition<br>
&lt;TabAtkins> emilio: So how do we define that, how do they serialize<br>
&lt;TabAtkins> emilio: Easier to say that margin-logical expands to the 4 logicals, margin-physical expands to the 4 physicals<br>
&lt;TabAtkins> emilio: But for the ! thing margin could expand to 8 properties, choosing any 4 depending conditionally<br>
&lt;TabAtkins> fantasai: I think you can say it expands to all of them unconditionally, but the order is conditional<br>
&lt;TabAtkins> emilio: So if you have 8 declarations...<br>
&lt;TabAtkins> fantasai: You set the wrong ones to initial, and the right ones to the values<br>
&lt;TabAtkins> fantasai: Just th eorder needs changing<br>
&lt;TabAtkins> fantasai: And we simplify in serialization<br>
&lt;TabAtkins> emilio: Say you have all 8 defined, and you serialize the margin shorthand<br>
&lt;TabAtkins> emilio: What form do you use?<br>
&lt;florian> s/with the mental model if the front and back look similar/with the mental model, adding a ! in the declaration ties well with the idea that this is a state to be remembered per definition/<br>
&lt;astearns> zakim, close queue<br>
&lt;Zakim> ok, astearns, the speaker queue is closed<br>
&lt;astearns> q?<br>
&lt;TabAtkins> dbaron: I think some of these aren't much harder than today<br>
&lt;TabAtkins> dbaron: Dunno if we do them ideally today, but today if you declare margin and then margin-inline-start, should you serialize the margin shorthand?<br>
&lt;TabAtkins> dbaron: I think you shouldn't and that extends to this case<br>
&lt;TabAtkins> emilio: We do serialize it<br>
&lt;TabAtkins> dbaron: Think that's a mistake<br>
&lt;TabAtkins> emilio: That's how they all work, they're separate properties with separate values<br>
&lt;TabAtkins> dbaron: Back when we were doing logical props as huge array of expanded props, we would not ahve serialized it<br>
&lt;TabAtkins> dbaron: When we did it to depend on the order, we should have depended on some of the properties of the older solution that we dropped.<br>
&lt;astearns> ack miriam<br>
&lt;addison> that sounds like you (emilio) are arguing for the ! syntax?<br>
&lt;emilio> ?<br>
&lt;emilio> quite the opposite<br>
&lt;TabAtkins> miriam: I get it that -logical is easier to impl and more consistent, but if there's not a plan for how it becomes a first-class citizen, I don't like it<br>
&lt;florian> q+<br>
&lt;TabAtkins> miriam: That's why I like the ! solution, it's easy to toggle which is the default.<br>
&lt;astearns> ack emeyer<br>
&lt;TabAtkins> miriam: Concerned we just do the simple-to-implemenht and leave it that way, second class<br>
&lt;TabAtkins> emeyer: I'm not a particular fan of the ! either<br>
&lt;TabAtkins> emilio: We ahve already "not important" jokes, and this'll look like "not logical"<br>
&lt;TabAtkins> s/emilio/emeyer/<br>
&lt;TabAtkins> emeyer: Wonder if we can just add a keyword to the value<br>
&lt;TabAtkins> fantasai: Can't do it, that interferes with some property syntaxes, but we need something that's completely consistent. Has to be outside the property space.<br>
&lt;TabAtkins> iank_: Are there that many props...<br>
&lt;TabAtkins> iank_: As david said there are some we want to make physical.<br>
&lt;TabAtkins> iank_: What's the list?<br>
&lt;addison> has someone written the list?<br>
&lt;emilio> q+<br>
&lt;TabAtkins> fantasai: It's pretty long, but some that you might *usually* want physical you want logical sometimes<br>
&lt;TabAtkins> iank_: This does make me skeptical of the switch<br>
&lt;TabAtkins> fremy: What about a logical() function fo rthe top-level property syntax?<br>
&lt;TabAtkins> astearns: We're out of time. I think the appraoch of figuring out what we *can* do prop-by-prop, with the switch as an eventual goal, is the way to go.<br>
&lt;TabAtkins> astearns: Kicking things up a levle, I'm frustrated we couldn't do all the issues. Want to find a way out of this, can't always wait for tpac<br>
&lt;TabAtkins> [skipping some scheduling talk]<br>
&lt;chris> sad in particular we didn't get to https://github.com/w3c/csswg-drafts/issues/4497#issuecomment-763459971<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1282#issuecomment-1249685175 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 16 September 2022 18:35:57 UTC