elem-go icon indicating copy to clipboard operation
elem-go copied to clipboard

Add ` ClassNames` util to `attrs` package

Open chasefleming opened this issue 3 months ago • 2 comments

Closes: https://github.com/chasefleming/elem-go/issues/165

chasefleming avatar Oct 02 '25 13:10 chasefleming

@whisk what do you think about this? Do you mind reviewing?

chasefleming avatar Oct 02 '25 16:10 chasefleming

hi @chasefleming, I think that your point about missing spaces is valid. Concatenation of strings with + is error prone, and that's why I usually use something like

strings.Join([]string{"btn", elem.If(isPrimary, "primary", "")}, " ")

This is not exactly neat and may add redundant spaces, but it's safe.

Can ClassNames be generalized for other attrs which may need multiple values separated by spaces? I can't think of any right now.

Otherwise the PR looks good ~~with one minor comment~~ with no comments :)

whisk avatar Oct 06 '25 21:10 whisk