-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
index.ts
44 lines (35 loc) · 1.45 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
import { html, LitElement } from 'lit'
import { property } from 'lit/decorators.js'
import '../../components/wui-icon/index.js'
import { colorStyles, elementStyles, resetStyles } from '../../utils/ThemeUtil.js'
import type { ColorType, IconType, SizeType } from '../../utils/TypeUtil.js'
import { customElement } from '../../utils/WebComponentsUtil.js'
import styles from './styles.js'
@customElement('wui-icon-link')
export class WuiIconLink extends LitElement {
public static override styles = [resetStyles, elementStyles, colorStyles, styles]
// -- State & Properties -------------------------------- //
@property() public size: SizeType = 'md'
@property({ type: Boolean }) public disabled = false
@property() public icon: IconType = 'copy'
@property() public iconColor: ColorType = 'inherit'
// -- Render -------------------------------------------- //
public override render() {
const borderRadius = this.size === 'lg' ? '--wui-border-radius-xs' : '--wui-border-radius-xxs'
const padding = this.size === 'lg' ? '--wui-spacing-1xs' : '--wui-spacing-2xs'
this.style.cssText = `
--local-border-radius: var(${borderRadius});
--local-padding: var(${padding});
`
return html`
<button ?disabled=${this.disabled} ontouchstart>
<wui-icon color=${this.iconColor} size=${this.size} name=${this.icon}></wui-icon>
</button>
`
}
}
declare global {
interface HTMLElementTagNameMap {
'wui-icon-link': WuiIconLink
}
}