-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.component.ts
More file actions
53 lines (44 loc) · 1.49 KB
/
button.component.ts
File metadata and controls
53 lines (44 loc) · 1.49 KB
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
import { CSSResultGroup } from 'lit';
import { html, literal } from 'lit/static-html.js';
import { ifDefined } from 'lit/directives/if-defined.js';
import { property } from 'lit/decorators.js';
import { spread } from '@open-wc/lit-helpers';
import classNames from 'classnames';
import {
CZButtonProps,
CZButtonAppearance,
CZButtonSize,
} from './button.types.js';
import { CraftzingElement, createStyles } from '@design-system/common';
import { hostStyles } from '@design-system/styles';
import buttonStyle from './button.css?inline';
class CZButton extends CraftzingElement implements CZButtonProps {
static styles: CSSResultGroup = [hostStyles, createStyles(buttonStyle)];
@property({ reflect: true })
appearance: CZButtonAppearance = 'default';
@property({ type: String, reflect: true })
size: CZButtonSize = 'large';
@property({ type: String, reflect: true })
href = undefined;
@property({ type: Boolean, reflect: true })
disabled = false;
render() {
const tag = this.href ? literal`a` : literal`button`;
return html`<${tag}
${spread(this.undeclaredAttributes)}
class="${classNames([
'button',
`button--appearance-${this.appearance}`,
`button--size-${this.size}`,
])}"
href="${ifDefined(this.href && !this.disabled ? this.href : undefined)}"
?disabled="${this.disabled}"
part="base"
>
<span class="button__content" part="content">
<slot></slot>
</span>
</${tag}>`;
}
}
export { CZButton };