From 5085b5c1aaf60c42e9d1d8fd5c9a5b9fd99a6420 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sat, 19 Apr 2025 16:51:31 +0200 Subject: [PATCH 1/2] Allow color gradient in color swatch --- .../lib/uui-color-swatch.element.ts | 2 +- .../lib/uui-color-swatches.story.ts | 58 +++++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/packages/uui-color-swatch/lib/uui-color-swatch.element.ts b/packages/uui-color-swatch/lib/uui-color-swatch.element.ts index aa52fa2f2..c6d48d09f 100644 --- a/packages/uui-color-swatch/lib/uui-color-swatch.element.ts +++ b/packages/uui-color-swatch/lib/uui-color-swatch.element.ts @@ -129,7 +129,7 @@ export class UUIColorSwatchElement extends LabelMixin(
html` ${repeat(args.swatches, (swatch: any) => { + label="My color palette">${repeat(args.swatches, (swatch: any) => { const label = typeof swatch === 'string' ? swatch : swatch.label; const value = typeof swatch === 'string' ? swatch : swatch.value; + const color = typeof swatch === 'string' ? swatch : swatch.color; return html` `; + .color="${color}" + .value=${value}> + `; })} `, @@ -72,3 +114,11 @@ export const ShowLabel: Story = { showLabel: true, }, }; + +export const Gradient: Story = { + args: { + swatches: gradients, + showLabel: true, + value: 'lemon-twist', + }, +}; From 855b992dd671c7f35efa39f0c72ba8cbe56a8066 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sat, 19 Apr 2025 17:15:44 +0200 Subject: [PATCH 2/2] Add story --- packages/uui-color-swatch/lib/uui-color-swatch.story.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/uui-color-swatch/lib/uui-color-swatch.story.ts b/packages/uui-color-swatch/lib/uui-color-swatch.story.ts index 7c8df43a9..a89055394 100644 --- a/packages/uui-color-swatch/lib/uui-color-swatch.story.ts +++ b/packages/uui-color-swatch/lib/uui-color-swatch.story.ts @@ -114,3 +114,12 @@ export const Transparent: Story = { value: 'rgba(209, 2, 26, 0.4)', }, }; + +export const Gradient: Story = { + args: { + value: 'sun', + color: 'radial-gradient(orange, red)', + label: 'Sun', + showLabel: true, + }, +};