UNPKG

@reown/appkit-ui

Version:

The full stack toolkit to build onchain app UX.

84 lines 3.06 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { LitElement, html } 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 { customElement } from '../../utils/WebComponentsUtil.js'; import styles from './styles.js'; const TEXT_VARIANT_BY_SIZE = { lg: 'lg-regular-mono', md: 'md-regular-mono', sm: 'sm-regular-mono' }; const SPINNER_SIZE_BY_SIZE = { lg: 'md', md: 'md', sm: 'sm' }; let WuiButton = class WuiButton extends LitElement { constructor() { super(...arguments); this.size = 'lg'; this.disabled = false; this.fullWidth = false; this.loading = false; this.variant = 'accent-primary'; } render() { this.style.cssText = ` --local-width: ${this.fullWidth ? '100%' : 'auto'}; `; const textVariant = this.textVariant ?? TEXT_VARIANT_BY_SIZE[this.size]; return html ` <button data-variant=${this.variant} data-size=${this.size} ?disabled=${this.disabled}> ${this.loadingTemplate()} <slot name="iconLeft"></slot> <wui-text variant=${textVariant} color="inherit"> <slot></slot> </wui-text> <slot name="iconRight"></slot> </button> `; } loadingTemplate() { if (this.loading) { const size = SPINNER_SIZE_BY_SIZE[this.size]; const color = this.variant === 'neutral-primary' || this.variant === 'accent-primary' ? 'invert' : 'primary'; return html `<wui-loading-spinner color=${color} size=${size}></wui-loading-spinner>`; } return null; } }; WuiButton.styles = [resetStyles, elementStyles, styles]; __decorate([ property() ], WuiButton.prototype, "size", void 0); __decorate([ property({ type: Boolean }) ], WuiButton.prototype, "disabled", void 0); __decorate([ property({ type: Boolean }) ], WuiButton.prototype, "fullWidth", void 0); __decorate([ property({ type: Boolean }) ], WuiButton.prototype, "loading", void 0); __decorate([ property() ], WuiButton.prototype, "variant", void 0); __decorate([ property() ], WuiButton.prototype, "textVariant", void 0); WuiButton = __decorate([ customElement('wui-button') ], WuiButton); export { WuiButton }; //# sourceMappingURL=index.js.map