Open AmeliaBR opened 5 years ago
Since I'm going to be sending people to this issue to give feedback, let's do it via a GitHub reactions poll:
React to this comment with the following symbols to express a vote:
❤️ (heart) for the outline-shape vs filled-shape system with different syntax for different properties
🎉 (tada/hooray/party) for the auto vs override system, where keywords are allowed in any of the properties, and override the existing SVG properties
👍 (+1/thumbs up) for "I don't care which option, just please pick it & ship it!"
Of course, if you have detailed use cases, other alternatives, or any other constructive comments, please feel free to leave them below!
Agenda+ to decide on a final answer. It looks like people are okay with the proposal to:
Thanks for adding this to the agenda, @tabatkins! Based on the current schedule, I won't be on the call but I think the summary above still covers everything.
Once we pick the final syntax, other things to consider:
auto
keyword in polygon()
?)clip-path
, shape-outside
, and offset-path
?(For now, I'm assuming that d
will continue to only accept path()
. But I myself wouldn't mind if it accepted other functions if that's easier to implement!)
The CSS Working Group just discussed Motion - Final approach for shapes
, and agreed to the following:
RESOLVED: make an optional keyword with just the two values, and default to even-odd or "lookup depending on context"
In order to close this issue, it seems that defining how to handle <'fill-rule'>
in some contexts still needs to be defined.
People may be confused without a clarification in the related specs for these contexts (see https://github.com/w3c/fxtf-drafts/issues/512 and #7390), now that path()
and polygon()
are defined to accept an optional <'fill-rule'>
in CSS Shapes, whose default value is nonzero
instead of evenodd
, as noted in the above resolution, which I assume is intentional.
If I am not mistaken, it boils down to defining that:
<'fill-rule'>
must be ignored and omitted in the serialization when the context is offset-path
(Motion 1)<'fill-rule'>
must take precedence over fill-rule
and clip-rule
when the context is d
(SVG 2), assuming its value definition is none | <path()>
(as currently implemented in browsers) instead of none | <string>
Added the omitted default handling in https://github.com/w3c/csswg-drafts/commit/5ebf7dfe2a58093065c9b88d1e828944753e132d
(As Chris Coyier has regularly noted on CSS-Tricks, our current specs and implementation of CSS Shapes functions are a bit of a mess, with certain shapes functions working in some properties but not others. I started writing an explanation of why it's a mess, and ended up with good summaries of two possible solutions. Copying that comment here, in the hopes of finally coming to a decision & getting everything spec'd and shipped!)
The tricky part is fill-rule. The
polygon()
function includes fill-rule keywords as an optional first parameter:https://codepen.io/AmeliaBR/pen/GgWBOy
But a
<path>
element uses the keywords set by thefill-rule
ORclip-rule
properties, depending on the shape's context. So having a keyword inside thed
property would create a conflict.The
path()
function as currently spec'd foroffset-path
doesn't include a keyword parameter, because motion only uses the outline, not the fill.We have agreed to use that syntax for
d
(<path>
shape) as a property.But for
clip-path
(and future stuff likeshape-inside
to define the text wrapping area as a shape), we need to know which fill rule to use.One idea I mused about (but never wrote down) is to define two different CSS data types, one of which is a super class of the other:
<outline-shape>
doesn't have fill-rule keywords<filled-shape>
=<outline-shape>
(with default fill-rule) |polygon()
andpath()
with keywordsSo, with this option, the
d
property would take an<outline-shape>
function, no keywords allowed, and would still use thefill-rule
/clip-rule
properties with no conflict.Another option is to define an
auto
value for the keyword inside the functions, and make that the default. Inclip-path
, anauto
value would behave just like the current default (nonzero
), But ind
, it would behave as "check thefill-rule
orclip-rule
property according to context and use that". If you did specify a different keyword in a function insided
, it would override the other properties:A side benefit, in my opinion, is that this means we could long-term plan to deprecate usage of the
fill-rule
/clip-rule
properties, which are already super annoying in the way they depend on context. If you want context-specific keyword values in the CSS function notation, you could use inherited CSS variable values.But the most important benefit of either of these approaches is that they would allow all the shape functions (possibly minus fill-rule keywords) to be used in all the shape-related properties!!!