-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbutton.tsx
More file actions
41 lines (36 loc) · 1.26 KB
/
button.tsx
File metadata and controls
41 lines (36 loc) · 1.26 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
import type { EventEmitter } from '@stencil/core';
import { Component, Event, h, Prop } from '@stencil/core';
import { Button as ButtonComponent } from 'common/Button/Button';
import type { ButtonSizeEnum, ButtonVariantEnum } from '../../../common/Button/button.types';
@Component({
tag: 'mvx-button',
styleUrl: 'button.scss',
shadow: true,
})
export class Button {
@Event() buttonClick: EventEmitter<MouseEvent>;
@Prop() class?: string = '';
// Accept `data-testid` without reflecting it on the host element,
// so only the inner `<button>` ends up with this attribute.
@Prop({ attribute: 'data-testid', reflect: false }) dataTestId?: string = '';
@Prop() disabled?: boolean = false;
@Prop() size?: `${ButtonSizeEnum}` = 'large';
@Prop() variant?: `${ButtonVariantEnum}` = 'primary';
private readonly handleClick = (event: MouseEvent) => {
this.buttonClick.emit(event);
};
render() {
return (
<ButtonComponent
class={this.class}
// data-testid={this.internalDataTestId} // This is handled by the `data-testid` prop with `reflect: false`
disabled={this.disabled}
size={this.size}
variant={this.variant}
onClick={this.handleClick}
>
<slot />
</ButtonComponent>
);
}
}