Open drwpow opened 1 year ago
Yeah, the options are usually to expose the classes as you have above, use css properties / variables to allow certain things to be overridden (which may be enough - there's probably a limited number of things that likely need to be overridden as you listed) or, for ultimate flexibility, switch to a "headless" approach (but with a default implementation provided). I guess it could also provide some slots to allow overriding some things (like providing your own SVG element)
Yeah a headless approach would be neat! Personally I really only need tiny styling tweaks that CSS could pull off—I like having all the elements there and hooked up—but a headless approach could allow for customizations like aligning the hue wheel horizontally under the square, etc.
Yes, you should be able to make it look like any other color select component with a headless approach, which would be neat. It could still provide a default implementation (or two) for people who just want the ready-baked approach.
Problem
Wanted to open up an issue to discuss rather than a PR. When this component is rendered, it has hardcoded
fill
stylings on the SVG elements, and doesn’t expose predictable CSS classnames to select anything:I’d like some selector to override default styles from the parent component if possible. Some examples would include, but not limited to:
#000
/#fff
to match other elements on page)Of course, all of these are opinionated and there’s no default styling that would make everyone happy. So just allowing for style overrides would be helpful.
Solution
One solution would possibly be to use global styling which would make selection easier. Elements could have some classname prefix such as
scs-*
(for svelte-color-select, but I don’t care what the prefix is). For example:No opinion on the actual prefix name, names of elements, or syntax (BEM/OOCSS/SMACCS/etc). Just as long as elements are exposed by some predictable class name (even if there are no default styles) that’d be ideal.
Also classnames would be preferred over IDs for the main reason there may be more than one of these colorpickers per page (would be rare, but possible nonetheless)
Open to thoughts / feedback! As well as other alternatives.