Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 085273d

Browse files
committed
feat(chip): add tag closing and finish styling
1 parent 3b73225 commit 085273d

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

src/chip-input/ux-tag-theme.css

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,36 @@ styles.tag {
44

55
font-size: 14px;
66

7-
padding: 2px 6px;
7+
height: 24px;
88

99
border-radius: 2px;
1010

1111
background-color: ${background || $design.accent};
1212
color: ${foreground || $design.accentForeground};
1313
}
14+
15+
styles.tag > span {
16+
margin: 0 8px;
17+
}
18+
19+
styles.tag > span.close {
20+
display:none;
21+
}
22+
23+
styles.tag[deletable] > span {
24+
margin-right: 0;
25+
}
26+
27+
styles.tag[deletable] > span.close {
28+
display: inline-flex;
29+
justify-content: center;
30+
align-items: center;
31+
margin: 0 4px;
32+
cursor: pointer;
33+
}
34+
35+
styles.tag[deletable] > span.close::before {
36+
content: '+';
37+
font-size: 24px;
38+
transform: rotate(45deg);
39+
}

src/chip-input/ux-tag.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<template role="textbox" styles.tag>
22
<require from="./ux-tag-theme"></require>
33

4-
<slot></slot>
4+
<span>
5+
<slot></slot>
6+
</span>
57

8+
<span class="close" click.delegate="closeTag()">
9+
</span>
610
</template>

src/chip-input/ux-tag.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { customElement, bindable, ViewResources, View, processAttributes } from 'aurelia-templating';
2+
import { DOM } from 'aurelia-pal';
23
import { bindingMode } from 'aurelia-binding';
34
import { inject } from 'aurelia-dependency-injection';
45
import { StyleEngine } from '../styles/style-engine';
@@ -18,7 +19,7 @@ export class UxTag implements Themable {
1819
public view: View;
1920

2021
constructor(
21-
/*private element: HTMLInputElement,*/
22+
private element: HTMLInputElement,
2223
public resources: ViewResources,
2324
private styleEngine: StyleEngine) { }
2425

@@ -35,4 +36,10 @@ export class UxTag implements Themable {
3536
public themeChanged(newValue: any) {
3637
this.styleEngine.applyTheme(this, newValue);
3738
}
39+
40+
public closeTag() {
41+
const closeEvent = DOM.createCustomEvent('close', { bubbles: false });
42+
43+
this.element.dispatchEvent(closeEvent);
44+
}
3845
}

0 commit comments

Comments
 (0)