Skip to content

Commit d19fa5f

Browse files
authored
feat(ui5-token): provide closeIcon slot (#2193)
1 parent 3427f35 commit d19fa5f

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

packages/main/src/Token.hbs

+13-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
<span class="ui5-token--text">{{this.text}}</span>
1111

1212
{{#unless readonly}}
13-
<ui5-icon
14-
@click="{{_delete}}"
15-
name="{{iconURI}}"
16-
accessible-name="{{tokenDeletableText}}"
17-
show-tooltip
13+
<div
1814
class="ui5-token--icon"
19-
></ui5-icon>
15+
@click="{{_delete}}"
16+
>
17+
{{#if closeIcon.length}}
18+
<slot name="closeIcon"></slot>
19+
{{else}}
20+
<ui5-icon
21+
name="{{iconURI}}"
22+
accessible-name="{{tokenDeletableText}}"
23+
show-tooltip
24+
></ui5-icon>
25+
{{/if}}
26+
</div>
2027
{{/unless}}
2128
</div>

packages/main/src/Token.js

+17
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import styles from "./generated/themes/Token.css.js";
2323
const metadata = {
2424
tag: "ui5-token",
2525
languageAware: true,
26+
managedSlots: true,
2627
properties: /** @lends sap.ui.webcomponents.main.Token.prototype */ {
2728

2829
/**
@@ -67,6 +68,22 @@ const metadata = {
6768
_tabIndex: { type: String, defaultValue: "-1", noAttribute: true },
6869
},
6970

71+
slots: /** @lends sap.ui.webcomponents.main.Token.prototype */ {
72+
73+
/**
74+
* Defines the close icon for the token. If nothing is provided to this slot, the default close icon will be used.
75+
* Accepts <code>ui5-icon</code>
76+
*
77+
* @type {HTMLElement[]}
78+
* @slot
79+
* @public
80+
* @since 1.0.0-rc.9
81+
*/
82+
closeIcon: {
83+
type: HTMLElement,
84+
},
85+
},
86+
7087
events: /** @lends sap.ui.webcomponents.main.Token.prototype */ {
7188

7289
/**

packages/main/src/themes/Token.css

+8-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,17 @@
6666
white-space: nowrap;
6767
}
6868

69-
:host([selected]) .ui5-token--icon {
69+
.ui5-token--icon {
70+
display: flex;
71+
}
72+
73+
:host([selected]) .ui5-token--icon > ui5-icon,
74+
:host([selected]) ::slotted(ui5-icon) {
7075
color: var(--sapButton_Selected_TextColor);
7176
}
7277

73-
.ui5-token--icon {
78+
.ui5-token--icon > ui5-icon,
79+
::slotted(ui5-icon) {
7480
color: inherit;
7581
cursor: pointer;
7682
width: var(--_ui5_token_icon_size);

packages/main/test/pages/MultiInput.html

+11
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,17 @@ <h1>Test value-help-trigger with F4 and Alt + ArrowUp/Down</h1>
187187
<ui5-input id="value-help-trigger-counter" placeholder="event count.."></ui5-input>
188188
</div>
189189

190+
<div>
191+
<ui5-title>MultiInput with tokesn with custom icon</ui5-title>
192+
<ui5-multi-input style="width: 500px;">
193+
<ui5-token slot="tokens" text="Menu">
194+
<ui5-icon name="menu" accessible-name="Menu here" slot="closeIcon"></ui5-icon>
195+
</ui5-token>
196+
<ui5-token slot="tokens" text="Not a menu">
197+
</ui5-token>
198+
</ui5-multi-input>
199+
</div>
200+
190201
<script>
191202

192203
var createTokenFromText = function (text) {

0 commit comments

Comments
 (0)