Skip to content
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

Stroke style type feedback #98

Open
c1rrus opened this issue Jan 13, 2022 · 3 comments
Open

Stroke style type feedback #98

c1rrus opened this issue Jan 13, 2022 · 3 comments

Comments

@c1rrus
Copy link
Member

c1rrus commented Jan 13, 2022

Is the stroke style composite type fit for purpose? Does it need more sub-values (e.g. equivalents to SVG's stroke-linejoin, stroke-miterlimit and stroke-dashoffset attributes)?

Please share your feedback, thoughts and ideas in this issue.

@c1rrus c1rrus added the dtcg-format All issues related to the format specification. label Jan 13, 2022
@c1rrus c1rrus changed the title Stroke style type Stroke style type feedback Jan 13, 2022
@TravisSpomer
Copy link

One additional property that could be useful is stroke alignment: whether it draws inside the edge of the object on top of the fill, or outside of the object.

Figma CSS WinUI
Inner background-clip: border-box BackgroundSizing="OuterBorderEdge"
Outer background-clip: padding-box BackgroundSizing="InnerBorderEdge"

@drwpow
Copy link
Contributor

drwpow commented Feb 28, 2022

I think there’s a unique problem with the string | object polymorphism here which doesn’t exist on other tokens.

font, for example, may be a string | string[]. But if string is passed, you could normalize that by simply placing that in an array, and it would be equivalent (in other words, you can “expand” one type into another). This form of polymorphism is easy to deal with because they aren’t necessarily distinct types; one is simply a shorthand for another.

I would expect for strokeStyle the string value should be “expandable” to the object value, but that doesn’t seem to be the case. If I’m reading this right, the object value would always be the dashed style? If so, I’d suggest the following:

{
  "alert-border-style": {
    "$type": "strokeStyle",
    "$value": {
      "style": "dashed",
      "dashArray": ["0.5rem", "0.25rem"],
      "lineCap": "round"
    }
  }
}

Having a "style" that corresponds to the string value (feel free to bikeshed the name; I’m not opinionated about “style”) allows the two types to be interchangeable. So "$value": "dashed" and "$value": { "style": "dashed" } are two ways to write the same thing.

Of course, that begs the question of whether or not other styles ("$value": { "style": "solid" }) also have attributes that could be set. I’d probably lean toward simply letting the implementor decide which additional attributes apply and which don’t (e.g. say dashArray was set on a solid stroke and the tool author decided to ignore that attribute without throwing an error). But I could realistically see a core set of attributes applying to multiple styles and not being mutually-exclusive to one.


Alternate suggestion: if each different stroke type needs different values and there is little to no overlap, (i.e. there are “sub-types,”) I’d argue those are actually not the same type and need to be split apart.

In that instance, splitting apart one stroke into multiple e.g. $type: "solidStroke", $type: "dashedStroke", etc., would make it easier both on the author and the tool implementor than dealing with complex polymorphic types where one part of $value has implications on the rest of the shape (hidden types).

@c1rrus c1rrus added the Needs Feedback/Review Open for feedback from the community, and may require a review from editors. label Mar 21, 2022
@kevinmpowell kevinmpowell added this to the Next Draft Priority milestone Oct 3, 2022
@kevinmpowell kevinmpowell removed Needs Feedback/Review Open for feedback from the community, and may require a review from editors. dtcg-format All issues related to the format specification. labels Oct 3, 2022
@PavelLaptev
Copy link
Contributor

I think if we're coping dashArray or lineCap. Because we're also referring here to SVG. There should also be other values like:

  • lineJoin: "round" | "bevel" | "miter"
  • miterLimit: number
  • dashOffset: number

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants