-
Notifications
You must be signed in to change notification settings - Fork 201
Slider with gradient background styling. #521
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
Comments
If |
Another alternative would be keeping the current HTML structure, applying the gradient via |
That's really nice @mischnic! Managing |
Looking deeper at this, the approach does require a little bit more of the actual CSS that is being generated, but a good amount less overall. The changes looks like:
And the following addition:
With the sample HTML being updated to include
All with the added benefit of maintaining the browser support matrix (IE11 and Edge live to fight another day...). If this makes sense to everyone, I can take a look at what would be needed to get a PR together for this. |
One thing unaddressed in either of these solutions is support for
|
Here's how I've implemented this for React Spectrum: adobe/react-spectrum@c702d55 (Missing RTL support, I didn't even think of that when writing this 😄 ) |
Does someone from the Spectrum CSS team have thoughts on this? |
Description
With the current slider track DOM structure:
[===Left Track===] (Knob) [===Right Track===]
The ability to create a gradient slider, a la https://spectrum.adobe.com/page/slider/#Gradient, is pretty difficult. Particularly because both
.spectrum-Slider-track
elements are assigned the same--spectrum-slider-track-color
custom property to manage their background. As solid color, this is fine, but for a gradient that should uniformly span the width of the slider element the hacks to work around that are dubious.I'd like to suggest the possibility of addressing this UI by altering the
clip-path
of the.spectrum-Slider-track
elements, rather than theirwidth
.It's a pretty heavy lift to have all of that
clip-path
rule in the inline styles, but this could be translated to a single--spectrum-slider-track-percentage
property that hid all of that complexity inside of the delivered styles.The main alteration that is needed from Spectrum CSS is to ensure
.spectrum-Slider-track { width: 100%; }
and then the same track color (e.g.--spectrum-slider-track-color: linear-gradient(to right, red, green 100%)
) would be applicable to both tracks and allow the UI desired. Doing the same to.spectrum-Slider-fill
would similarly allow the--spectrum-slider-fill-track-color
custom property to support the same when thefilled
variant is used.The Spectrum Web Components team has previously prototyped this in the following PR: adobe/spectrum-web-components#456

Why do you need this feature or component?
Cleaner support for Spectrum specification for usage in our applications.
Possible issues:
clip-path
has mixed browser support in the long tail, so I'm not sure how it intersection with your browser support matrix; needs checking in Edge/IE 11 as clip-path is listed as "only supporting url()" in those browsers depending on which Can I Use you rely on: https://caniuse.com/#search=clip-pathsynced to jira: https://jira.corp.adobe.com/browse/CSS-215
The text was updated successfully, but these errors were encountered: