/** * Width Selector Component * * Dropdown menu for selecting terminal width constraints. * Includes common presets and custom width input with font size controls. */ import { html, LitElement } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { Z_INDEX } from '../../utils/constants.js'; import { COMMON_TERMINAL_WIDTHS } from '../../utils/terminal-preferences.js'; @customElement('width-selector') export class WidthSelector extends LitElement { // Disable shadow DOM to use Tailwind createRenderRoot() { return this; } @property({ type: Boolean }) visible = false; @property({ type: Number }) terminalMaxCols = 0; @property({ type: Number }) terminalFontSize = 14; @property({ type: String }) customWidth = ''; @property({ type: Function }) onWidthSelect?: (width: number) => void; @property({ type: Function }) onFontSizeChange?: (size: number) => void; @property({ type: Function }) onClose?: () => void; @property({ type: Boolean }) isMobile = false; private handleCustomWidthInput(e: Event) { const input = e.target as HTMLInputElement; this.customWidth = input.value; this.requestUpdate(); } private handleCustomWidthSubmit() { const width = Number.parseInt(this.customWidth, 10); if (!Number.isNaN(width) && width >= 20 && width <= 500) { this.onWidthSelect?.(width); this.customWidth = ''; } } private handleCustomWidthKeydown(e: KeyboardEvent) { if (e.key === 'Enter') { this.handleCustomWidthSubmit(); } else if (e.key === 'Escape') { this.customWidth = ''; this.onClose?.(); } } render() { if (!this.visible) return null; return html`
this.onClose?.()} >
Terminal Width
${COMMON_TERMINAL_WIDTHS.map( (width) => html` ` )}
Custom (20-500)
e.stopPropagation()} class="flex-1 bg-dark-bg-secondary border border-dark-border rounded-md px-3 py-2 text-sm font-mono text-dark-text placeholder:text-dark-text-dim focus:border-accent-primary focus:shadow-glow-primary-sm transition-all" />
Font Size
${this.terminalFontSize}px
`; } }