Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 53b29ca

Browse files
docs: add issue as an example
1 parent 36648c4 commit 53b29ca

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { Component, Input } from '@angular/core'
2+
import { render, screen } from '@testing-library/angular'
3+
4+
describe('TagComponent', () => {
5+
it('create a tag default primary', async () => {
6+
await render(`<hc-tag>primary</hc-tag>`, {
7+
declarations: [TagComponent],
8+
})
9+
10+
expect(screen.getByText(/primary/i)).toBeInTheDocument()
11+
expect(screen.getByRole('tag')).toHaveClass('hc-tag-primary')
12+
})
13+
})
14+
15+
16+
@Component({
17+
selector: 'hc-tag',
18+
template: `
19+
<span
20+
class="small2"
21+
role="tag"
22+
[ngClass]="classes"
23+
[attr.aria-label]="ariaLabel"
24+
>
25+
<ng-content></ng-content>
26+
</span>
27+
`,
28+
styles: [
29+
`
30+
.hc-tag {
31+
display: inline-flex;
32+
align-items: center;
33+
justify-content: center;
34+
color: var(--neutral-white);
35+
padding: 4px 10px;
36+
border-radius: 6px;
37+
}
38+
39+
.hc-tag-primary {
40+
background-color: var(--primary-default);
41+
}
42+
43+
.hc-tag-success {
44+
background-color: var(--green-default);
45+
}
46+
47+
.hc-tag-info {
48+
background-color: var(--primary-default);
49+
}
50+
51+
.hc-tag-warning {
52+
background-color: var(--yellow-default);
53+
}
54+
55+
.hc-tag-danger {
56+
background-color: var(--red-default);
57+
}
58+
59+
.hc-tag-rounded {
60+
border-radius: 10rem;
61+
}
62+
`,
63+
],
64+
})
65+
export class TagComponent {
66+
@Input() severity: 'success' | 'info' | 'warning' | 'danger' | 'primary' = 'primary'
67+
@Input() rounded = false
68+
@Input() ariaLabel?: string
69+
70+
get classes() {
71+
return {
72+
['hc-tag']: true,
73+
[`hc-tag-${this.severity}`]: true,
74+
['hc-tag-rounded']: this.rounded,
75+
}
76+
}
77+
}
78+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /