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(ui5-token): provide closeIcon slot #2193

Merged
merged 2 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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