import { DeesElement, property, html, customElement, type TemplateResult, cssManager, css, } from '@design.estate/dees-element'; import * as domtools from '@design.estate/dees-domtools'; import { SioCombox } from './sio-combox.js'; import { SioIcon } from './sio-icon.js'; import { state } from '@design.estate/dees-element'; SioCombox; SioIcon; // Import design tokens import { colors, bdTheme } from './00colors.js'; import { spacing, radius, shadows, transitions, sizes } from './00tokens.js'; import { fontFamilies, typography } from './00fonts.js'; declare global { interface HTMLElementTagNameMap { 'sio-fab': SioFab; } } @customElement('sio-fab') export class SioFab extends DeesElement { @property({ type: Boolean }) public showCombox = false; @state() private hasShownOnce = false; @state() private shouldPulse = false; public static demo = () => html` `; constructor() { super(); domtools.DomTools.setupDomTools(); } public render(): TemplateResult { return html` ${domtools.elementBasic.styles}
{ this.shouldPulse = false; }} >
${this.showCombox || this.hasShownOnce ? html` this.showCombox = false}> ` : ''}
`; } /** * toggles the combox */ public async toggleCombox() { console.log('toggle combox'); const wasOpen = this.showCombox; this.showCombox = !this.showCombox; if (this.showCombox) { this.hasShownOnce = true; if (!wasOpen) { this.shouldPulse = true; } } } public async firstUpdated(args: any) { super.firstUpdated(args); const domtools = await this.domtoolsPromise; // Set up keyboard shortcut domtools.keyboard .on([domtools.keyboard.keyEnum.Ctrl, domtools.keyboard.keyEnum.S]) .subscribe(() => { this.toggleCombox(); }); } public async updated(changedProperties: Map) { super.updated(changedProperties); // Set reference object when combox is rendered if ((changedProperties.has('showCombox') || changedProperties.has('hasShownOnce')) && (this.showCombox || this.hasShownOnce)) { const sioCombox: SioCombox = this.shadowRoot.querySelector('sio-combox'); const mainBox: HTMLElement = this.shadowRoot.querySelector('#mainbox'); if (sioCombox && mainBox && !sioCombox.referenceObject) { sioCombox.referenceObject = mainBox; } } } }