Skip to content

Commit

Permalink
feat(tags): support removable (#1266)
Browse files Browse the repository at this point in the history
* feat(tags): support removable

* set connotation outline

* icon color

* ui

* revert

* Update components/tags/src/vwc-tag.scss

Co-authored-by: rachelbt <rachelbt@users.noreply.github.com>

Co-authored-by: rachelbt <rachelbt@users.noreply.github.com>
  • Loading branch information
yinonov and rachelbt committed May 30, 2022
1 parent 45f3063 commit 5b3cd3c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/tags/src/vwc-tag-base.ts
Expand Up @@ -8,6 +8,7 @@ import type { ClassInfo } from 'lit-html/directives/class-map.js';
import {
LitElement, html, property, TemplateResult, queryAsync, state, query, eventOptions
} from 'lit-element';
import { nothing } from 'lit-html';


type TagConnotation = Extract<
Expand Down Expand Up @@ -44,6 +45,9 @@ export class VWCTagBase extends LitElement {
@property({ type: Boolean, reflect: true })
selectable = false;

@property({ type: Boolean, reflect: true })
removable = false;

@state() protected shouldRenderRipple = false;

protected rippleHandlers = new RippleHandlers(() => {
Expand Down Expand Up @@ -120,11 +124,18 @@ export class VWCTagBase extends LitElement {
</span>`;
}

protected renderRemoveButton(): TemplateResult {
return html`<button class="remove-button" @click="${()=> this.remove()}">
${this.renderIcon('close-line')}
</button>`;
}

override render(): TemplateResult {
return this.selectable
? this.renderTagSelectable()
: html`<span class="vwc-tag ${classMap(this.getRenderClasses())}">
${this.text}
${this.removable ? this.renderRemoveButton() : nothing}
</span>`;
}

Expand Down
10 changes: 10 additions & 0 deletions components/tags/src/vwc-tag.scss
Expand Up @@ -83,6 +83,7 @@

&.vwc-tag--selected {
&.layout-outlined {
border-color: var(#{layout.$vvd-layout-color-outline});
background-color: var(#{connotation.$vvd-color-connotation}-soft);
color: var(#{connotation.$vvd-color-connotation}-contrast);
}
Expand All @@ -105,6 +106,7 @@
}

> .vwc-tag__icon {
#{connotation.$vvd-color-connotation}: initial;
block-size: var(#{tags-variables.$namespace-icon-checkmark--size});
inline-size: var(#{tags-variables.$namespace-icon-checkmark--size});

Expand All @@ -126,3 +128,11 @@
// }
// }

.remove-button {
all: unset;
margin-inline-start: 10px;

.vwc-tag__icon {
--vvd-icon-size: 12px;
}
}
3 changes: 3 additions & 0 deletions components/tags/stories/tag.stories.js
Expand Up @@ -25,3 +25,6 @@ Outlined.args = { text: 'Outlined', layout: 'outlined' };

export const Selected = Template.bind({});
Selected.args = { text: 'Selected', selectable: true, selected: true };

export const Removable = Template.bind({});
Removable.args = { text: 'Removable', Removable: true };
Binary file modified ui-tests/snapshots/vwc-tags.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5b3cd3c

Please sign in to comment.