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

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

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: Flow-relative syntax for 'margin'-like shorthands<br>
&lt;emilio> Github: https://github.com/w3c/csswg-drafts/issues/1282<br>
&lt;r12a> s/multiple languages as a single language/multiple languages for a single font/<br>
&lt;emilio> fantasai: currently css assign values in shorthands to the physical longhands<br>
&lt;emilio> fantasai: it seems useful to make logical shorthands similarly convenient, which is useful for i18n<br>
&lt;emilio> fantasai: but we don't have a proposal for which kind of syntax we want to have for this<br>
&lt;emilio> fantasai: one's relative keyword, other is a bang keyword, others is a different property<br>
&lt;astearns> !no<br>
&lt;emilio> fantasai: one of the main restrictions is try to keep it sufficiently easy to type<br>
&lt;dbaron> I would be pretty strongly against a ! syntax for something that's part of the property (i.e., not changing cascading).<br>
&lt;emilio> fantasai: nothing on the thread seems to have stuck<br>
&lt;emilio> fantasai: can we come up with some idea?<br>
&lt;emilio> fantasai: other proposals were like global mode switchs, etc...<br>
&lt;emilio> fantasai: we could do some or multiple<br>
&lt;emilio> fantasai: [enumerates other solutions from the thread]<br>
&lt;emilio> addison: one of the challenges is when you go to make a rtl page layout you need to edit your stylesheet to flip your margins, ideally it'd be default<br>
&lt;myles_> q+<br>
&lt;emilio> TabAtkins: Something in the value space is maybe the best, like keywords<br>
&lt;emilio> TabAtkins: I'd be against punctuation, no precedent and hard to google, plus not compatible with CSSOM<br>
&lt;emilio> TabAtkins: similarly for the bang<br>
&lt;emilio> TabAtkins: nor mode switches, dbaron argued against it, serialization is also harder that way<br>
&lt;emilio> q+<br>
&lt;r12a> q+<br>
&lt;emilio> fantasai: typing relative is too long<br>
&lt;astearns> ack myles_<br>
&lt;dbaron> +1 to tab saying it should be in the regular value space<br>
&lt;emilio> myles_: Will the bang keyword be applicable on every property<br>
&lt;emilio> *?<br>
&lt;iank_> q+<br>
&lt;emilio> fantasai: only to some<br>
&lt;astearns> +1 to dbaron's +1 on regular value space<br>
&lt;dbaron> q+<br>
&lt;emilio> myles_: so part of the grammar of the specific properties, right?<br>
&lt;emilio> fantasai: yes<br>
&lt;emilio> myles_: it'd be cool if it works with variables<br>
&lt;emilio> fantasai: that'd be terrifying<br>
&lt;astearns> ack emilio<br>
&lt;emilio> TabAtkins: you should be able to drop a whole relative margin value in a variable<br>
&lt;TabAtkins> TabAtkins: And you *cannot* put bang values into variables.<br>
&lt;myles_> emilio: expanding shorthand into mulitple lonahands dpeending on syntax, like overflow, is not something that any othe rproperty has righ tnow. So it's goig to require specifying how yous erialize when you have all of th e8 logical and physical margins. IF you want the solution that peoplw ill implement fast, the best option is different properties. Then, all the machinery is there already.<br>
&lt;myles_> fantasai: how do we come up with a systematic way of coming up with a new property that is consistent, short, easy<br>
&lt;myles_> emilio: yes<br>
&lt;myles_> TabAtkins: we do "margin-se"<br>
&lt;myles_> emilio: or "logical-margin"<br>
&lt;myles_> fantasai: it's way too long. some peopl will put all of their stylesheets all of the time, and will stop using physical properties. It needs to be ergonomic enough that it's possible<br>
&lt;dbaron> 'margins', 'paddings' :-P<br>
&lt;myles_> florian: will we push back against tab here about puctuation? ~padding ~margin?<br>
&lt;jensimmons> it might be faster to implement, but if we hate the choice 10 years from now, it’s not a good idea<br>
&lt;myles_> TabAtkins: if its property names, my objection is different. The only thing is that would not be an ident anymore.<br>
&lt;myles_> florian: can we fix it?<br>
&lt;myles_> TabAtkins: potentially but its a syntax change. It would be better for it to fit kn the syntax.<br>
&lt;myles_> florian: if somebody is using a property that uses idents, this would break.<br>
&lt;myles_> TabAtkins: we try to not change syntax<br>
&lt;myles_> florian: this may warrant an exception<br>
&lt;myles_> TabAtkins: yes. I think we can come up with a prefix in alphabumeric that's short<br>
&lt;emilio> astearns: do we have anything more on that?<br>
&lt;astearns> ack r12a<br>
&lt;emilio> r12a: I agree with that fantasai and TabAtkins that it needs to be easy to type, I'd suggest `lmargin`<br>
&lt;jensimmons> q+<br>
&lt;myles_> +1 to not using "relative"<br>
&lt;emilio> r12a: I think `logical` is a much better word than `relative`<br>
&lt;cbiesinger> +1 for not using relative<br>
&lt;astearns> ack iank_<br>
&lt;emilio> iank_: Any of the bang syntax will probably have very funky interactions with CSSOM<br>
&lt;TabAtkins> I think `l` as a prefix works okay. I think we can reasonably prefix any word with that.<br>
&lt;emilio> iank_: setProperty has a different argument for `!important` and such<br>
&lt;astearns> ack dbaron<br>
&lt;fantasai> I don't like prefixing with alphanumeric because it's less obvious what's going on and it won't sort correctly.<br>
&lt;TabAtkins> *post*fixing with `l`?<br>
&lt;fantasai> we use prefixes for the real name of the property, and prefix relationships are about shorthands<br>
&lt;fantasai> postfixing makes it look like a different longhand of the physical shorthand<br>
&lt;astearns> q?<br>
&lt;emilio> dbaron: So I think we all don't like the various bang things. I guess I'm not 100% convinced we want different property names, I think having it in the value would be slightly nicer even if we need to sort out a bunch of CSSOM issues, though it might depend on whether we find appropriate names for the properties<br>
&lt;astearns> ack jensimmons<br>
&lt;emilio> dbaron: different properties is probably faster<br>
&lt;cbiesinger> q+<br>
&lt;emilio> jensimmons: some of the things suggested where the good syntax is the old thing that nobody uses 10 years from now<br>
&lt;emilio> jensimmons: so even if might be more efficient or easier to implement we should peek a name that is a good name<br>
&lt;majidvp> q+<br>
&lt;emilio> heycam: I feel like all of the syntax proposed so far is going to be a bit different and awkward, so I'm not sure the goal of finding a clean word is feasible<br>
&lt;emilio> jensimmons: I think lmargin is a bit more awkward than relative on the value<br>
&lt;dbaron> I guess another option is using a delimiter within the 'margin' value like 1em / 2em / 3em / 4em.<br>
&lt;emilio> jensimmons: Some of them feels smoother than others<br>
&lt;r12a> q+<br>
&lt;rachelandrew> q+<br>
&lt;emilio> fantasai: can you give us your opinion on the different proposal?<br>
&lt;emilio> jensimmons: I think -new is better than a new name, and keyword is better than a bang, but I can look at the list as we goo<br>
&lt;astearns> ack fantasai<br>
&lt;emilio> jensimmons: how does it look in 10 years is something to look into<br>
&lt;TabAtkins> schmlinss<br>
&lt;myles_> jensimmons: sticking a random letter in front of iframe hasn't seemed to hinder its adoption, it seems most people colloquially speak of iframes instead of frames<br>
&lt;emilio> fantasai: prefixing breaks the sort order, margin-something feels like a longhand analogous to margin-left or such<br>
&lt;jensimmons> iMargin? lol<br>
&lt;emilio> fantasai: I'm a little skeptical about prefixing / suffixing has the issue of making it relate to properties it doesn't relate to<br>
&lt;dbaron> q+<br>
&lt;emilio> *seem to relate<br>
&lt;astearns> ack cbiesinger<br>
&lt;TabAtkins> Allowed postfix punctuators in ident syntax: - or _ ^_^<br>
&lt;TabAtkins> margin-, margin_<br>
&lt;myles_> margin: ➡️<br>
&lt;emilio> cbiesinger: I think lmargin and such are a huge concern, we have some other messy margin<br>
&lt;emilio> majidvp: I think mode switch is the easiest. Is the concern about serialization really a problem? When do you have the problem?<br>
&lt;jensimmons> imargin = international margin<br>
&lt;cbiesinger> @mode "logical"; at the top?<br>
&lt;fantasai> cbiesinger, yes that's one option<br>
&lt;emilio> florian: we have some of that problem with box-sizing and such<br>
&lt;fantasai> cbiesinger, the other is a block like @media<br>
&lt;cbiesinger> block seems worse to me<br>
&lt;fantasai> cbiesinger, yeah I agree<br>
&lt;emilio> dbaron: I think we consider it a design mistake<br>
&lt;fantasai> cbiesinger, if we have a mode switch we might want to have a way to put a specific declaration into the other mode, though<br>
&lt;astearns> ack r12a<br>
&lt;emilio> s/it/box-sizing<br>
&lt;astearns> ack majidvp<br>
&lt;fantasai> s/consider it/consider box-sizing/<br>
&lt;emilio> r12a: dbaron proposed separators instead, maybe we should consider that?<br>
&lt;cbiesinger> fantasai: maybe but your escape hatch is margin-left<br>
&lt;astearns> ack rachelandrew<br>
&lt;fantasai> s/fantasai:/fantasai,/<br>
&lt;emilio> rachelandrew: From the POV of teaching this a keyword means that you can look at your code and know what I'm using here, seems to infer the intent best<br>
&lt;emilio> dbaron: I suggested using separators, assuming we do want to move everyone to that, so that you can do something like `margin: 1em / 2em / 3em / 4em`<br>
&lt;emilio> dbaron: It's somewhat obscure so it makes the distinction less obvious, but if it becomes the way to do it it may not be a problem/<br>
&lt;jensimmons> What Rachel just said makes me think that `margin: 10px 5px 15px 25px relative;` is more of a “equal” to `margin` today… changing to a different property infers that it’s a different thing<br>
&lt;emilio> fantasai: we use slashes on some places already, so not sure we could switch everyhwere<br>
&lt;r12a> q+<br>
&lt;astearns> ack dbaron<br>
&lt;emilio> dbaron: it doesn't need to be a slash, there are probably a number of those we haven't used yet<br>
&lt;cbiesinger> +1 for dbaron's suggestion<br>
&lt;emilio> dbaron: the other reason it sort of makes sense to me is that the delimiter indicates a different relationship between the different values<br>
&lt;jensimmons> also, should we go the other way — to match Grid — …. ???? Crazy. but also....<br>
&lt;emilio> myles_: looks like if you don't use slashes code work and it'd look just wrong in RTL<br>
&lt;fantasai> yes, jensimmons, we will go the other way to match Grid<br>
&lt;astearns> ack r12a<br>
&lt;emilio> TabAtkins: Since the direction is different it at least sometimes will look wrong<br>
&lt;fantasai> Grid is using the direction we picked out for logical 4-value syntaxes in general, we just never solved this particular syntax issue to have them :)<br>
&lt;emilio> r12a: So you still have to deal with serialization and such<br>
&lt;emilio> dbaron: yeah, that was emilio's concern, we need to solve that if we handle margins<br>
&lt;fantasai> It's interesting to note that the grid-area shorthand already uses slashes (and is logical)<br>
&lt;emilio> emilio: You also need to handle compressing and serializing when you specify all the 8 margins<br>
&lt;emilio> dbaron: you could condense those to two occurences to the margin shorthand, but it's a bunch of CSSOM work<br>
&lt;rachelandrew> there is an example of individual properties here for padding: https://codepen.io/rachelandrew/pen/OQrorW<br>
&lt;emilio> dbaron: that's the 'this will take longer to get done'<br>
&lt;rachelandrew> from https://www.smashingmagazine.com/2018/03/understanding-logical-properties-values/<br>
&lt;emilio> emilio: note that you also need to figure out how that interacts with the other sub-shorthands like margin-block / margin-inline<br>
&lt;emilio> TabAtkins: yeah I think finding something using property names would be maybe the better idea<br>
&lt;Bert> q+<br>
&lt;emilio> fantasai: I think you still need a switch to change to physical in specific cases, and whatever solution we choose needs to be workable for that<br>
&lt;fantasai> myles_: Mode switch at the top of the file, many CSS authors don't know CSS that well and just copy-paste, so mode switches would end up being problematic for them<br>
&lt;astearns> ack Bert<br>
&lt;emilio> myles_: It's harder for authors to understand mode-switches, and they'll just get it wrong<br>
&lt;fantasai> Bert: Said earlier that it might be a problem if margin expands to different properties based on whether there's a keyword or not. Is that true? Wouldn't it expand to all of them all the time.<br>
&lt;emilio> fantasai: thanks, I had missed it :-)<br>
&lt;fantasai> florian: Depending on the values, they are propagated to different values, but always expand out to the same set of longhands (all of them)<br>
&lt;fantasai> dbaron: At the specified value it is, but at the computed value level, the two sets of properties compute the same values<br>
&lt;fantasai> dbaron: The way we've added logical properties, they are distinct properties at the specified value level nd they both exist in the object model<br>
&lt;fantasai> Bert: If you set margin-start, it goes to margin-start<br>
&lt;fantasai> Bert: If you set 'margin, does it also set margin-start or only go to margin-top<br>
&lt;fantasai> dbaron: We're rying to find a syntax that sets the margin-start property<br>
&lt;fantasai> Bert: Is it necessary?<br>
&lt;fantasai> florian: ...<br>
&lt;fantasai> florian: We don't have a logical shorthand. If we want logical to be the default way to write style sheets, we need that.<br>
&lt;fantasai> astearns: Short answer is no the shrothand doesn't expand to all 8<br>
&lt;fantasai> dbaron: Having the shorthand somehow set margin-top so that it sets the logical thing, could be doable, but would have some very confusing results<br>
&lt;fantasai> florian: I didn't understnad that<br>
&lt;fantasai> Bert: Problem is that the 'margin' property doesn't reset the logical margins. Can that be changed?<br>
&lt;fantasai> Bert: Like font resets font-size-adjust even tough it's not mentioned<br>
&lt;fantasai> fremy: I'm not sure why it doesn't set<br>
&lt;fantasai> fremy: These values would never be used<br>
&lt;fantasai> fremy: It doesn't matter if margin resets them or doesn't<br>
&lt;fantasai> fremy: If the orde rin which you reset them is such that you have the logical ones after the other ones its fine.<br>
&lt;fantasai> dbaron: That would be one solution to part of the object model issues.<br>
&lt;fantasai> dbaron: others around serialization<br>
&lt;fantasai> fremy: Somewhere we have to find principles of doing this, and need algorithm for this<br>
&lt;fantasai> fremy: I ddin't find it yet<br>
&lt;fantasai> dbaron: Might be in a GH issue somewhere<br>
&lt;fantasai> dbaron: probably don't want to dig too far into CSSOM issues right now<br>
&lt;fantasai> astearns: This was a good background on all solutions we could consider, but doesn't sound like we'll resolve today<br>
&lt;fantasai> TabAtkins: Sounds like we're interested in a declaration-based syntax<br>
&lt;TabAtkins> More specific than declaration-level. Property-name or value-level. (So not declaration glyphs, or ! values, etc.)<br>
&lt;florian> fantasai: I think whether or not we need a mode switch, we will have a syntax ???<br>
&lt;myles_> "use logical;"<br>
&lt;myles_> (instead of "use strict")<br>
&lt;emilio> lol<br>
&lt;florian> fantasai: the reason the shorthand resets 4 or 8 of the longhands is actually still an open issue<br>
&lt;florian> s/the reason/whether/<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-432184161 using your GitHub account

Received on Tuesday, 23 October 2018 10:06:19 UTC