Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions packages/uui-color-slider/lib/uui-color-slider.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class UUIColorSliderElement extends LabelMixin('label', LitElement) {
if (this.color) {
const colord = new Colord(this.color);
const { h, s, l } = colord.toHsl();
const { r, g, b } = colord.toRgb();

const gradient =
this.type === 'saturation'
Expand All @@ -129,7 +130,13 @@ export class UUIColorSliderElement extends LabelMixin('label', LitElement) {
? `linear-gradient(to ${this.vertical ? 'top' : 'right'}, hsl(${h}, ${s}%, 0%), hsl(${h}, ${s}%, 100%))`
: null;

const hueColor =
this.type === 'opacity'
? `linear-gradient(to ${this.vertical ? 'top' : 'right'}, transparent 0%, rgba(${r}, ${g}, ${b}, ${this.max}%) 100%)`
: null;

this.style.setProperty('--uui-slider-background-image', gradient);
this.style.setProperty('--uui-slider-hue-color', hueColor);
}
}
}
Expand Down Expand Up @@ -275,12 +282,7 @@ export class UUIColorSliderElement extends LabelMixin('label', LitElement) {
? html`<div
id="current-hue"
style=${styleMap({
backgroundImage: `linear-gradient(to ${
this.vertical ? 'top' : 'right'
},
transparent 0%,
${this.color} 100%
)`,
backgroundImage: `var(--uui-slider-hue-color)`,
})}></div>`
: ''}
<!-- <slot name="detail"> </slot> -->
Expand Down
23 changes: 21 additions & 2 deletions packages/uui-color-slider/lib/uui-color-slider.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,35 @@ export const Readonly: Story = {
},
};

export const Hue: Story = {
args: {
type: 'hue',
value: 180,
},
};

export const Opacity: Story = {
args: {
type: 'opacity',
color: '#0075ff',
},
};

export const Vertical: Story = {
export const OpacityMin50: Story = {
args: {
type: 'opacity',
color: '#0075ff',
min: 50,
value: 75,
},
};

export const OpacityMax50: Story = {
args: {
vertical: true,
type: 'opacity',
color: '#0075ff',
max: 50,
value: 25,
},
};

Expand Down
Loading