From 4c030afa7d4c90b2e3c7d2205f4550401418c603 Mon Sep 17 00:00:00 2001 From: Lungan Catalin Date: Fri, 22 Dec 2023 13:18:48 +0200 Subject: [PATCH 1/8] feat(Tag): introduce logic for assigning custom tag colors --- packages/beeq/src/components.d.ts | 8 ++++++++ .../src/components/tag/_storybook/bq-tag.stories.tsx | 3 +++ packages/beeq/src/components/tag/bq-tag.tsx | 9 ++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/beeq/src/components.d.ts b/packages/beeq/src/components.d.ts index f4371b08e..aff274880 100644 --- a/packages/beeq/src/components.d.ts +++ b/packages/beeq/src/components.d.ts @@ -1020,6 +1020,10 @@ export namespace Components { * The color style of the Tag */ "color": TTagColor; + /** + * The custom style color of the Tag + */ + "customColor"?: string; /** * If true, the Tag will be disabled (only if clickable = `true`, no interaction allowed) */ @@ -3036,6 +3040,10 @@ declare namespace LocalJSX { * The color style of the Tag */ "color"?: TTagColor; + /** + * The custom style color of the Tag + */ + "customColor"?: string; /** * If true, the Tag will be disabled (only if clickable = `true`, no interaction allowed) */ diff --git a/packages/beeq/src/components/tag/_storybook/bq-tag.stories.tsx b/packages/beeq/src/components/tag/_storybook/bq-tag.stories.tsx index ef57fd29e..df92acafc 100644 --- a/packages/beeq/src/components/tag/_storybook/bq-tag.stories.tsx +++ b/packages/beeq/src/components/tag/_storybook/bq-tag.stories.tsx @@ -20,6 +20,7 @@ const meta: Meta = { disabled: { control: 'boolean' }, hidden: { control: 'boolean' }, removable: { control: 'boolean' }, + 'custom-color': { control: 'text' }, selected: { control: 'boolean' }, size: { control: 'select', options: [...TAG_SIZE] }, variant: { control: 'select', options: [...TAG_VARIANT] }, @@ -37,6 +38,7 @@ const meta: Meta = { border: undefined, clickable: false, color: undefined, + 'custom-color': undefined, disabled: false, hidden: false, removable: false, @@ -54,6 +56,7 @@ const Template = (args: Args) => html` border=${ifDefined(args.border)} ?clickable=${args.clickable} color=${ifDefined(args.color)} + custom-color=${ifDefined(args['custom-color'])} ?disabled=${args.disabled} ?hidden=${args.hidden} ?removable=${args.removable} diff --git a/packages/beeq/src/components/tag/bq-tag.tsx b/packages/beeq/src/components/tag/bq-tag.tsx index 8c139938d..cbc45ff4d 100644 --- a/packages/beeq/src/components/tag/bq-tag.tsx +++ b/packages/beeq/src/components/tag/bq-tag.tsx @@ -45,6 +45,9 @@ export class BqTag { /** The color style of the Tag */ @Prop({ reflect: true }) color: TTagColor; + /** The custom style color of the Tag */ + @Prop({ reflect: true }) customColor?: string; + /** If true, the Tag will be disabled (only if clickable = `true`, no interaction allowed) */ @Prop({ reflect: true }) disabled?: boolean = false; @@ -193,13 +196,17 @@ export class BqTag { const style = { '--bq-tag--icon-prefix-size': `${iconSize(this.size)}px`, ...(this.border && { '--bq-tag--border-radius': `var(--bq-radius--${this.border})` }), + ...(this.customColor && { '--bq-tag--background-color': this.customColor }), + ...(this.customColor && { '--bq-text--primary': `var(--bq-text--primary-alt)` }), + ...(this.customColor && { '--bq-icon--color': `var(--bq-text--primary-alt)` }), }; return (