-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
index.ts
50 lines (42 loc) · 1.67 KB
/
index.ts
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
import { html, LitElement } from 'lit'
import { property } from 'lit/decorators.js'
import '../../components/wui-icon/index.js'
import '../../components/wui-image/index.js'
import '../../components/wui-text/index.js'
import '../../layout/wui-flex/index.js'
import { elementStyles, resetStyles } from '../../utils/ThemeUtil.js'
import { customElement } from '../../utils/WebComponentsUtil.js'
import styles from './styles.js'
@customElement('wui-list-content')
export class WuiListContent extends LitElement {
public static override styles = [resetStyles, elementStyles, styles]
// -- State & Properties -------------------------------- //
@property() public imageSrc?: string = undefined
@property() public textTitle = ''
@property() public textValue?: string = undefined
// -- Render -------------------------------------------- //
public override render() {
return html`
<wui-flex justifyContent="space-between" alignItems="center">
<wui-text variant="paragraph-500" color=${this.textValue ? 'fg-200' : 'fg-100'}>
${this.textTitle}
</wui-text>
${this.templateContent()}
</wui-flex>
`
}
// -- Private ------------------------------------------- //
private templateContent() {
if (this.imageSrc) {
return html`<wui-image src=${this.imageSrc} alt=${this.textTitle}></wui-image>`
} else if (this.textValue) {
return html` <wui-text variant="paragraph-400" color="fg-100"> ${this.textValue} </wui-text>`
}
return html`<wui-icon size="inherit" color="fg-200" name="networkPlaceholder"></wui-icon>`
}
}
declare global {
interface HTMLElementTagNameMap {
'wui-list-content': WuiListContent
}
}