-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathindex.ts
51 lines (43 loc) · 1.37 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
51
import { LitElement, html } from 'lit'
import { property } from 'lit/decorators.js'
import '../../components/wui-image/index.js'
import '../../components/wui-text/index.js'
import { elementStyles, resetStyles } from '../../utils/ThemeUtil.js'
import { customElement } from '../../utils/WebComponentsUtil.js'
import '../wui-icon-box/index.js'
import styles from './styles.js'
@customElement('wui-token-button')
export class WuiTokenButton extends LitElement {
public static override styles = [resetStyles, elementStyles, styles]
// -- State & Properties -------------------------------- //
@property() public imageSrc?: string
@property() public text = ''
// -- Render -------------------------------------------- //
public override render() {
return html`
<button>
${this.tokenTemplate()}
<wui-text variant="paragraph-600" color="fg-100">${this.text}</wui-text>
</button>
`
}
// -- Private ------------------------------------------- //
private tokenTemplate() {
if (this.imageSrc) {
return html`<wui-image src=${this.imageSrc}></wui-image>`
}
return html`
<wui-icon-box
size="sm"
iconColor="fg-200"
backgroundColor="fg-300"
icon="networkPlaceholder"
></wui-icon-box>
`
}
}
declare global {
interface HTMLElementTagNameMap {
'wui-token-button': WuiTokenButton
}
}