-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
index.ts
47 lines (39 loc) · 1.53 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
import { html, LitElement } from 'lit'
import { property } from 'lit/decorators.js'
import '../../components/wui-icon/index.js'
import '../../components/wui-loading-spinner/index.js'
import '../../components/wui-text/index.js'
import { elementStyles, resetStyles } from '../../utils/ThemeUtil.js'
import type { SizeType } from '../../utils/TypeUtil.js'
import { customElement } from '../../utils/WebComponentsUtil.js'
import styles from './styles.js'
@customElement('wui-connect-button')
export class WuiConnectButton extends LitElement {
public static override styles = [resetStyles, elementStyles, styles]
// -- State & Properties -------------------------------- //
@property() public size: Exclude<SizeType, 'inherit' | 'xl' | 'lg' | 'xs' | 'xxs'> = 'md'
@property({ type: Boolean }) public loading = false
// -- Render -------------------------------------------- //
public override render() {
const textVariant = this.size === 'md' ? 'paragraph-600' : 'small-600'
return html`
<button data-size=${this.size} ?disabled=${this.loading} ontouchstart>
${this.loadingTemplate()}
<wui-text variant=${textVariant} color=${this.loading ? 'accent-100' : 'inherit'}>
<slot></slot>
</wui-text>
</button>
`
}
public loadingTemplate() {
if (!this.loading) {
return null
}
return html`<wui-loading-spinner size=${this.size} color="accent-100"></wui-loading-spinner>`
}
}
declare global {
interface HTMLElementTagNameMap {
'wui-connect-button': WuiConnectButton
}
}