matthewp / corset

Declarative data bindings, bring your own backend.
https://corset.dev/
BSD 2-Clause "Simplified" License
277 stars 2 forks source link

[Parity] text property is currently adding commas between items #105

Closed JaneOri closed 2 years ago

JaneOri commented 2 years ago

v0.8.10

text: "hello" var(--c) "world";

if --c isn't set, that results in "hello,,world" being inserted

in CSS, content would concatenate them directly without the comma joiner so "helloworld" would ideally be the result instead

It could be interesting to have a separate text-joiner property that specifies what the joiner string is though, defaulting to empty string

matthewp commented 2 years ago

Thanks! I think this makes sense, if that's what content does we should have parity there.

I also like the text-joiner idea. That would mean that text and text-joiner would be longhand properties for a shorthand (I guess?). Don't know if I want to go there just yet but something worth tracking for sure.

JaneOri commented 2 years ago

Maybe we could say if text is set to a list longer than 2 items, the last item is the joiner? So text is the shorthand

Then text-content is the list longhand for the individual text items and text-joiner is the joiner longhand, defaulting to empty string

As for parity of that idea: Many shorthand CSS properties have some degree of order-is-important. As an extreme case, the font shorthand specifically has order-is-important paired with specific types being a sort of required landmark in the middle to help with parsing of it, which is much more complicated than this idea (and probably part of why font shorthand is rare-ish). I imagine text-content will be used more than text in Corset if this idea moves forward too but there is an intuitive assumption I get just from seeing text: var(--a) var(--b) var(--c) ", "; and I think maybe others would too :)

matthewp commented 2 years ago

An example of this working with content: https://codepen.io/matthewp/pen/zYPmpNZ

matthewp commented 2 years ago

Fixed here: https://github.com/matthewp/corset/releases/tag/v0.8.11