Skip to content
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

feat(core/chip+pill): add property to display ix-tooltip with customizable text #1697

Merged
merged 29 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0652c31
feat(chip+pill): add tooltipText property to chip and pill componentsโ€ฆ
AndreasBerliner Feb 14, 2025
af81c5f
refactor(pill): rename test directory from 'tests' to 'test'
AndreasBerliner Feb 14, 2025
2b2d885
test(chip+pill): add component tests for title attribute (tooltip) onโ€ฆ
AndreasBerliner Feb 14, 2025
b8606ec
chore(chip+pill): change since annotation for tooltipText property frโ€ฆ
AndreasBerliner Feb 17, 2025
5235ed8
chore(chip+pill): add changeset
AndreasBerliner Feb 17, 2025
1fceb41
docs(chip+pill): change tooltipText property docs
AndreasBerliner Feb 17, 2025
67e2762
docs(chip+pill): add guideline docs for tooltipText, fix typo in pillโ€ฆ
AndreasBerliner Feb 17, 2025
c541b23
docs(chip+pill): formatting of test app examples (remove blanks and lโ€ฆ
AndreasBerliner Feb 17, 2025
399c0c5
docs(chip+pill): add tooltip-text with custom text and none to previeโ€ฆ
AndreasBerliner Feb 17, 2025
4b2753d
Merge branch 'main' into tooltip-chip-pill
AndreasBerliner Feb 17, 2025
aa904b6
Apply suggestions from code review
nuke-ellington Feb 17, 2025
f360798
feat(chip+pill): change logic to add ix-tooltip on chip and pill compโ€ฆ
AndreasBerliner Feb 24, 2025
20024ac
test(chip+pill): change component tests according to new implementatiโ€ฆ
AndreasBerliner Feb 24, 2025
d0c728f
docs(chip+pill): Change documentation styleguides according to new imโ€ฆ
AndreasBerliner Feb 24, 2025
72a02b8
docs(chip+pill): adjust test app examples according to new implementaโ€ฆ
AndreasBerliner Feb 24, 2025
41dd399
chore(chip+pill): adjust changeset description
AndreasBerliner Feb 24, 2025
3d0a54a
Merge branch 'main' into tooltip-chip-pill
AndreasBerliner Feb 24, 2025
a5a4172
Update .changeset/curvy-meals-deliver.md
AndreasBerliner Feb 25, 2025
0feb67f
test(chip+pill): fix component test by adding missing awaits
AndreasBerliner Feb 25, 2025
d60ab26
Merge branch 'tooltip-chip-pill' of github.com:siemens/ix into tooltiโ€ฆ
AndreasBerliner Feb 25, 2025
b2b7542
refactor(chip): refactor logic to determine tooltip
AndreasBerliner Feb 25, 2025
0af6d3c
refactor(pill): refactor logic to determine tooltip
AndreasBerliner Feb 25, 2025
c385ecc
fix(chip+pill): sonar changes - add readonly to containerElementRef
AndreasBerliner Feb 25, 2025
7233c94
test(chip+pill): review changes - remove unnecessary component tests
AndreasBerliner Feb 25, 2025
296ac7a
Merge branch 'main' into tooltip-chip-pill
jul-lam Feb 25, 2025
02f6627
refactor(chip+pill): rename determineTooltip to getTooltip
AndreasBerliner Feb 25, 2025
34c2db8
chore(chip+pill): apply changeset review suggestion
AndreasBerliner Feb 25, 2025
6ab98a2
docs(chip+pill): reformat test app examples according to review
AndreasBerliner Feb 25, 2025
9a8831f
fix(chip+pill): add trim function to remove leading and trailing whitโ€ฆ
AndreasBerliner Feb 25, 2025
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
7 changes: 7 additions & 0 deletions .changeset/curvy-meals-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@siemens/ix-angular': minor
'@siemens/ix': minor
'@siemens/ix-vue': minor
---

`ix-chip` and `ix-pill`: Add property `tooltip-text` to display an `ix-tooltip` with customizable text.
14 changes: 9 additions & 5 deletions packages/angular-test-app/src/preview-examples/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import { Component } from '@angular/core';
selector: 'app-example',
template: `
<div class="chip">
<ix-chip closable outline> Primary </ix-chip>
<ix-chip icon="print">Primary with icon</ix-chip>
<ix-chip icon="print" style="width: 10rem" closable> Primary </ix-chip>
<ix-chip closable outline>Primary</ix-chip>
<ix-chip icon="print" tooltip-text="Custom tooltip text">
Primary with icon
</ix-chip>
<ix-chip icon="print" tooltip-text style="width: 10rem" closable>
Primary
</ix-chip>

<ix-chip variant="critical" closable outline> Alarm </ix-chip>
<ix-chip variant="alarm" icon="print"> Alarm with icon </ix-chip>
<ix-chip variant="critical" closable outline>Alarm</ix-chip>
<ix-chip variant="alarm" icon="print">Alarm with icon</ix-chip>
<ix-chip variant="alarm" icon="print" style="width: 10rem" closable>
Alarm
</ix-chip>
Expand Down
6 changes: 3 additions & 3 deletions packages/angular-test-app/src/preview-examples/pill.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
-->
<ix-pill variant="custom" color="white" background="purple"> Label </ix-pill>
<ix-pill variant="custom" color="white" background="purple">Label</ix-pill>

<ix-pill>Label</ix-pill>
<ix-pill outline>Label</ix-pill>
<ix-pill tooltip-text="Custom tooltip text">Label</ix-pill>
<ix-pill tooltip-text outline>Label</ix-pill>
<ix-pill class="styled">Label</ix-pill>

<ix-pill icon="star">Label</ix-pill>
Expand Down
8 changes: 4 additions & 4 deletions packages/angular/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,14 @@ export declare interface IxCheckboxGroup extends Components.IxCheckboxGroup {}


@ProxyCmp({
inputs: ['active', 'background', 'chipColor', 'closable', 'color', 'icon', 'outline', 'variant']
inputs: ['active', 'background', 'chipColor', 'closable', 'color', 'icon', 'outline', 'tooltipText', 'variant']
})
@Component({
selector: 'ix-chip',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['active', 'background', 'chipColor', 'closable', 'color', 'icon', 'outline', 'variant'],
inputs: ['active', 'background', 'chipColor', 'closable', 'color', 'icon', 'outline', 'tooltipText', 'variant'],
})
export class IxChip {
protected el: HTMLElement;
Expand Down Expand Up @@ -2087,14 +2087,14 @@ export declare interface IxPaneLayout extends Components.IxPaneLayout {}


@ProxyCmp({
inputs: ['alignLeft', 'background', 'color', 'icon', 'outline', 'pillColor', 'variant']
inputs: ['alignLeft', 'background', 'color', 'icon', 'outline', 'pillColor', 'tooltipText', 'variant']
})
@Component({
selector: 'ix-pill',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['alignLeft', 'background', 'color', 'icon', 'outline', 'pillColor', 'variant'],
inputs: ['alignLeft', 'background', 'color', 'icon', 'outline', 'pillColor', 'tooltipText', 'variant'],
})
export class IxPill {
protected el: HTMLElement;
Expand Down
90 changes: 86 additions & 4 deletions packages/core/component-doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3122,14 +3122,19 @@
"encapsulation": "shadow",
"dependents": [],
"dependencies": [
"ix-icon-button"
"ix-icon-button",
"ix-tooltip"
],
"dependencyGraph": {
"ix-chip": [
"ix-icon-button"
"ix-icon-button",
"ix-tooltip"
],
"ix-icon-button": [
"ix-spinner"
],
"ix-tooltip": [
"ix-typography"
]
},
"props": [
Expand Down Expand Up @@ -3301,6 +3306,36 @@
"optional": false,
"required": false
},
{
"name": "tooltipText",
"type": "boolean | string",
"complexType": {
"original": "string | boolean",
"resolved": "boolean | string",
"references": {}
},
"mutable": false,
"attr": "tooltip-text",
"reflectToAttr": false,
"docs": "Display a tooltip. By default, no tooltip will be displayed.\nAdd the attribute to display the text content of the component as a tooltip or use a string to display a custom text.",
"docsTags": [
{
"name": "since",
"text": "3.0.0"
}
],
"default": "false",
"values": [
{
"type": "boolean"
},
{
"type": "string"
}
],
"optional": false,
"required": false
},
{
"name": "variant",
"type": "\"alarm\" | \"critical\" | \"custom\" | \"info\" | \"neutral\" | \"primary\" | \"success\" | \"warning\"",
Expand Down Expand Up @@ -16015,8 +16050,17 @@
"docsTags": [],
"encapsulation": "shadow",
"dependents": [],
"dependencies": [],
"dependencyGraph": {},
"dependencies": [
"ix-tooltip"
],
"dependencyGraph": {
"ix-pill": [
"ix-tooltip"
],
"ix-tooltip": [
"ix-typography"
]
},
"props": [
{
"name": "alignLeft",
Expand Down Expand Up @@ -16164,6 +16208,36 @@
"optional": false,
"required": false
},
{
"name": "tooltipText",
"type": "boolean | string",
"complexType": {
"original": "string | boolean",
"resolved": "boolean | string",
"references": {}
},
"mutable": false,
"attr": "tooltip-text",
"reflectToAttr": false,
"docs": "Display a tooltip. By default, no tooltip will be displayed.\nAdd the attribute to display the text content of the component as a tooltip or use a string to display a custom text.",
"docsTags": [
{
"name": "since",
"text": "3.0.0"
}
],
"default": "false",
"values": [
{
"type": "boolean"
},
{
"type": "string"
}
],
"optional": false,
"required": false
},
{
"name": "variant",
"type": "\"alarm\" | \"critical\" | \"custom\" | \"info\" | \"neutral\" | \"primary\" | \"success\" | \"warning\"",
Expand Down Expand Up @@ -21270,8 +21344,10 @@
],
"encapsulation": "shadow",
"dependents": [
"ix-chip",
"ix-field-wrapper",
"ix-menu-item",
"ix-pill",
"ix-slider"
],
"dependencies": [
Expand All @@ -21281,12 +21357,18 @@
"ix-tooltip": [
"ix-typography"
],
"ix-chip": [
"ix-tooltip"
],
"ix-field-wrapper": [
"ix-tooltip"
],
"ix-menu-item": [
"ix-tooltip"
],
"ix-pill": [
"ix-tooltip"
],
"ix-slider": [
"ix-tooltip"
]
Expand Down
20 changes: 20 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,11 @@ export namespace Components {
* Show chip with outline style
*/
"outline": boolean;
/**
* Display a tooltip. By default, no tooltip will be displayed. Add the attribute to display the text content of the component as a tooltip or use a string to display a custom text.
* @since 3.0.0
*/
"tooltipText": string | boolean;
/**
* Chip variant
*/
Expand Down Expand Up @@ -2348,6 +2353,11 @@ export namespace Components {
* Custom font color for pill. Only working for `variant='custom'`
*/
"pillColor": string | undefined;
/**
* Display a tooltip. By default, no tooltip will be displayed. Add the attribute to display the text content of the component as a tooltip or use a string to display a custom text.
* @since 3.0.0
*/
"tooltipText": string | boolean;
/**
* Pill variant
*/
Expand Down Expand Up @@ -5691,6 +5701,11 @@ declare namespace LocalJSX {
* Show chip with outline style
*/
"outline"?: boolean;
/**
* Display a tooltip. By default, no tooltip will be displayed. Add the attribute to display the text content of the component as a tooltip or use a string to display a custom text.
* @since 3.0.0
*/
"tooltipText"?: string | boolean;
/**
* Chip variant
*/
Expand Down Expand Up @@ -7634,6 +7649,11 @@ declare namespace LocalJSX {
* Custom font color for pill. Only working for `variant='custom'`
*/
"pillColor"?: string | undefined;
/**
* Display a tooltip. By default, no tooltip will be displayed. Add the attribute to display the text content of the component as a tooltip or use a string to display a custom text.
* @since 3.0.0
*/
"tooltipText"?: string | boolean;
/**
* Pill variant
*/
Expand Down
30 changes: 29 additions & 1 deletion packages/core/src/components/chip/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Host,
Prop,
} from '@stencil/core';
import { makeRef } from '../utils/make-ref';

@Component({
tag: 'ix-chip',
Expand Down Expand Up @@ -80,13 +81,22 @@ export class Chip {
*/
@Prop() outline = false;

/**
* Display a tooltip. By default, no tooltip will be displayed.
* Add the attribute to display the text content of the component as a tooltip or use a string to display a custom text.
* @since 3.0.0
*/
@Prop() tooltipText: string | boolean = false;

/**
* Fire event if close button is clicked
*
* @since 1.5.0
*/
@Event() closeChip!: EventEmitter;

private readonly containerElementRef = makeRef<HTMLElement>();

private getCloseButton() {
return (
<div class="close-button-container">
Expand All @@ -112,6 +122,23 @@ export class Chip {
);
}

private getTooltip() {
if (!this.tooltipText && !this.hostElement.hasAttribute('tooltip-text')) {
return null;
}

const text =
typeof this.tooltipText === 'string' && this.tooltipText.trim()
? this.tooltipText
: this.hostElement.textContent?.trim();

return (
<ix-tooltip for={this.containerElementRef.waitForCurrent()}>
{text}
</ix-tooltip>
);
}

render() {
const isInactive = this.active === false;

Expand All @@ -127,7 +154,6 @@ export class Chip {
return (
<Host
tabIndex="-1"
title={this.hostElement.textContent}
class={{
inactive: isInactive,
}}
Expand All @@ -140,6 +166,7 @@ export class Chip {
}
>
<div
ref={this.containerElementRef}
style={{ ...customStyle }}
class={{
container: true,
Expand Down Expand Up @@ -170,6 +197,7 @@ export class Chip {
</span>
{isInactive === false && this.closable ? this.getCloseButton() : null}
</div>
{this.getTooltip()}
</Host>
);
}
Expand Down
Loading
Loading