Skip to content

Advanced color slider story #1076

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

Open
wants to merge 6 commits into
base: v1/contrib
Choose a base branch
from

Conversation

bjarnef
Copy link
Contributor

@bjarnef bjarnef commented Apr 20, 2025

Description

I added a more advanced story for uui-color-slider to see how the sliders would work as RGBA/HSLA/HSBA and connect each other.
I was inspired by these examples: https://everycolorpicker.com/pickers/slider-color-picker/

https://react.fluentui.dev/?path=/docs/components-colorpicker--docs#color-slider-channels

The logic is still missing a bit to update input value when slider change, and the other way around.
It also add the saturation and lightness options.

While investigating I found that uui-color-slider didn't respect min and max value, mainly the opacity slider which always expect a max or 100, even though I set max to 1.

I re-used to getHexString(), but perhaps we can move this and some other functions to color utils and may depend on Colord library or we can consider another #938

We could probably also have some other functions here. e.g. parseColor from a color string returning the h, s, l, a values.

I also think perhaps we should remove the output value below slider or an option to hide it? It can always be rendered below and in vertical slider is collide with the handle.

We can eventually consider some input field for this similar to color picker in Chrome depending on shown format.

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Motivation and context

How to test?

Screenshots (if appropriate)

chrome_xBM04VTxjW.mp4

The saturation and lightness sliders would ideally use color similar the opacity slider, so it may not be necessary to set --uui-slider-background-image in story if set in uui-color-slider when parsing color property.

Checklist

  • If my change requires a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@Copilot Copilot AI review requested due to automatic review settings April 20, 2025 09:12
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces an advanced story for the uui-color-slider component to demonstrate its capability for RGBA/HSLA/HSBA manipulation and updates the slider defaults to respect user-defined min and max values.

  • Added an “Advanced” story that supports multiple slider types (hue, saturation, lightness, and opacity) and real-time color updates.
  • Modified the uui-color-slider element to conditionally apply default max values based on the slider type.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/uui-color-slider/lib/uui-color-slider.story.ts Introduces the advanced color slider story with dynamic slider behavior and live color preview.
packages/uui-color-slider/lib/uui-color-slider.element.ts Updates default property handling to allow custom min/max values for different slider types.
Comments suppressed due to low confidence (2)

packages/uui-color-slider/lib/uui-color-slider.story.ts:192

  • For the opacity slider, the background color is generated without taking the current opacity value into account. Consider passing 'value.a * 100' (or a similar calculation) as the alpha parameter to getHexString to accurately reflect the slider's opacity.
.color=${slider.type === 'opacity' ? getHexString(value.h, value.s, value.l) : undefined}

packages/uui-color-slider/lib/uui-color-slider.story.ts:67

  • [nitpick] The 'slider' object used in event handlers is currently typed as 'any'. Consider defining an interface for slider objects to improve type safety and maintainability.
const sliders = [

Copy link

Hi there @bjarnef, thank you for this contribution! 👍

While we wait for the team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@bjarnef bjarnef changed the title Add advanced color slider story Advanced color slider story Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant