Skip to content

Commit

Permalink
feat(ui5-token): provide closeIcon slot (#2193)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifoosid committed Sep 14, 2020
1 parent 3427f35 commit d19fa5f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
19 changes: 13 additions & 6 deletions packages/main/src/Token.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@
<span class="ui5-token--text">{{this.text}}</span>

{{#unless readonly}}
<ui5-icon
@click="{{_delete}}"
name="{{iconURI}}"
accessible-name="{{tokenDeletableText}}"
show-tooltip
<div
class="ui5-token--icon"
></ui5-icon>
@click="{{_delete}}"
>
{{#if closeIcon.length}}
<slot name="closeIcon"></slot>
{{else}}
<ui5-icon
name="{{iconURI}}"
accessible-name="{{tokenDeletableText}}"
show-tooltip
></ui5-icon>
{{/if}}
</div>
{{/unless}}
</div>
17 changes: 17 additions & 0 deletions packages/main/src/Token.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import styles from "./generated/themes/Token.css.js";
const metadata = {
tag: "ui5-token",
languageAware: true,
managedSlots: true,
properties: /** @lends sap.ui.webcomponents.main.Token.prototype */ {

/**
Expand Down Expand Up @@ -67,6 +68,22 @@ const metadata = {
_tabIndex: { type: String, defaultValue: "-1", noAttribute: true },
},

slots: /** @lends sap.ui.webcomponents.main.Token.prototype */ {

/**
* Defines the close icon for the token. If nothing is provided to this slot, the default close icon will be used.
* Accepts <code>ui5-icon</code>
*
* @type {HTMLElement[]}
* @slot
* @public
* @since 1.0.0-rc.9
*/
closeIcon: {
type: HTMLElement,
},
},

events: /** @lends sap.ui.webcomponents.main.Token.prototype */ {

/**
Expand Down
10 changes: 8 additions & 2 deletions packages/main/src/themes/Token.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@
white-space: nowrap;
}

:host([selected]) .ui5-token--icon {
.ui5-token--icon {
display: flex;
}

:host([selected]) .ui5-token--icon > ui5-icon,
:host([selected]) ::slotted(ui5-icon) {
color: var(--sapButton_Selected_TextColor);
}

.ui5-token--icon {
.ui5-token--icon > ui5-icon,
::slotted(ui5-icon) {
color: inherit;
cursor: pointer;
width: var(--_ui5_token_icon_size);
Expand Down
11 changes: 11 additions & 0 deletions packages/main/test/pages/MultiInput.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ <h1>Test value-help-trigger with F4 and Alt + ArrowUp/Down</h1>
<ui5-input id="value-help-trigger-counter" placeholder="event count.."></ui5-input>
</div>

<div>
<ui5-title>MultiInput with tokesn with custom icon</ui5-title>
<ui5-multi-input style="width: 500px;">
<ui5-token slot="tokens" text="Menu">
<ui5-icon name="menu" accessible-name="Menu here" slot="closeIcon"></ui5-icon>
</ui5-token>
<ui5-token slot="tokens" text="Not a menu">
</ui5-token>
</ui5-multi-input>
</div>

<script>

var createTokenFromText = function (text) {
Expand Down

0 comments on commit d19fa5f

Please sign in to comment.