From a5da4bf3adaacc50220a754194cc9122ad2545ae Mon Sep 17 00:00:00 2001 From: George Ashworth Date: Wed, 19 Nov 2025 15:47:35 +0000 Subject: [PATCH] DEV-1846 Summary Bar Tags Only Updating on Refresh | include tooltip option in chip component --- docs/pages/components/chip.md | 6 +- src/components/chip/chip.component.ts | 89 +++++++++++++++------------ 2 files changed, 52 insertions(+), 43 deletions(-) diff --git a/docs/pages/components/chip.md b/docs/pages/components/chip.md index 11cfebee2..f04eff7bb 100644 --- a/docs/pages/components/chip.md +++ b/docs/pages/components/chip.md @@ -50,9 +50,11 @@ layout: component ## Examples -### First Example +### Tooltip Example -TODO +```html:preview +Tooltip Test +``` ### Second Example diff --git a/src/components/chip/chip.component.ts b/src/components/chip/chip.component.ts index acb77e5fc..bf9e91d69 100644 --- a/src/components/chip/chip.component.ts +++ b/src/components/chip/chip.component.ts @@ -24,51 +24,58 @@ import styles from './chip.scss'; * @cssproperty --example - An example CSS custom property. */ export default class ZnChip extends ZincElement { - static styles: CSSResultGroup = unsafeCSS(styles); + static styles: CSSResultGroup = unsafeCSS(styles); - @property() icon: string = ''; + @property() icon: string = ''; + @property() tooltip: string = ''; - @property() type: 'info' | 'success' | 'warning' | 'error' | 'primary' | - 'transparent' | 'custom' | 'neutral' = 'neutral'; + @property() type: 'info' | 'success' | 'warning' | 'error' | 'primary' | + 'transparent' | 'custom' | 'neutral' = 'neutral'; - @property() size: 'small' | 'medium' | 'large'; // Defaults to base chip styling + @property() size: 'small' | 'medium' | 'large'; // Defaults to base chip styling - @property({attribute: 'flush', type: Boolean, reflect: true}) flush: boolean = false; - @property({attribute: 'flush-x', type: Boolean, reflect: true}) flushX: boolean = false; - @property({attribute: 'flush-y', type: Boolean, reflect: true}) flushY: boolean = false; + @property({attribute: 'flush', type: Boolean, reflect: true}) flush: boolean = false; + @property({attribute: 'flush-x', type: Boolean, reflect: true}) flushX: boolean = false; + @property({attribute: 'flush-y', type: Boolean, reflect: true}) flushY: boolean = false; - private readonly hasSlotController = new HasSlotController(this, '[default]', 'action'); + private readonly hasSlotController = new HasSlotController(this, '[default]', 'action'); - render() { - const hasContent = this.hasSlotController.test('[default]') - return html` -
- ${this.icon ? html` - ` : ''} - ${hasContent ? html` - ` : ''} - ${this.hasSlotController.test('action') ? html` - ` : ''} -
- `; - } + render() { + return html` + ${this.tooltip ? html` + ${this.getContent()}` : html`${this.getContent()}`} + `; + } + + getContent() { + const hasContent = this.hasSlotController.test('[default]'); + return html` +
+ ${this.icon ? html` + ` : ''} + ${hasContent ? html` + ` : ''} + ${this.hasSlotController.test('action') ? html` + ` : ''} +
` + } }