-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathau-label.gts
70 lines (63 loc) · 1.5 KB
/
au-label.gts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import Component from '@glimmer/component';
import AuBadge from './au-badge';
import AuPill from './au-pill';
export interface AuLabelSignature {
Args: {
error?: boolean;
inline?: boolean;
required?: boolean;
requiredLabel?: string;
warning?: boolean;
};
Blocks: {
default: [];
};
Element: HTMLLabelElement;
}
export default class AuLabel extends Component<AuLabelSignature> {
get inline() {
if (this.args.inline) return 'au-c-label--inline';
else return '';
}
get error() {
if (this.args.error) return 'au-c-label--error';
else return '';
}
get warning() {
if (this.args.warning) return 'au-c-label--warning';
else return '';
}
<template>
<label
class="au-c-label {{this.error}} {{this.warning}} {{this.inline}}"
...attributes
>
{{#if this.warning}}
<AuBadge
@icon="alert-triangle"
@size="small"
@skin="warning"
class="au-u-margin-right-tiny"
/>
{{/if}}
{{#if this.error}}
<AuBadge
@icon="cross"
@size="small"
@skin="error"
class="au-u-margin-right-tiny"
/>
{{/if}}
{{yield}}
{{#if @required}}
{{#if @inline}}
<span class="au-c-label__addendum">
{{~if @requiredLabel @requiredLabel "*"~}}
</span>
{{else}}
<AuPill>{{if @requiredLabel @requiredLabel "Verplicht"}}</AuPill>
{{/if}}
{{/if}}
</label>
</template>
}