UNPKG

@puzzleitc/puzzle-shell

Version:

The standard design for Puzzle tools

89 lines (87 loc) 2.9 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, css, html } from "lit"; import { customElement } from "lit/decorators/custom-element.js"; import { property } from "lit/decorators/property.js"; import { theme } from "../utils/theme"; /** * Dropdown menu item with icon and text. * * @slot - Slot for the icon and the text */ let MenuDropdownItem = class MenuDropdownItem extends LitElement { constructor() { super(...arguments); this.href = "#"; } focus(options) { this.shadowRoot?.querySelector("a")?.focus(options); } render() { return html `<a href="${this.href}" role="menuitem"> <slot></slot> </a>`; } }; MenuDropdownItem.styles = [ theme, css ` :host { display: block; } a { display: flex; align-items: center; font-family: var(--pzsh-font-family); margin-top: var(--pzsh-menu-item-gap); padding: var(--pzsh-menu-item-padding-vertical) var(--pzsh-menu-item-padding-horizontal) var(--pzsh-menu-item-padding-vertical) calc( var(--pzsh-icon-size) + var(--pzsh-spacer) / 2 +var(--pzsh-menu-item-padding-horizontal) ); color: var(--pzsh-menu-fg); background-color: var(--pzsh-menu-bg-alt); text-decoration: none; white-space: nowrap; } :host(:focus) a, a:hover, a:active, a:focus { color: var(--pzsh-menu-active); } ::slotted(pzsh-icon), ::slotted(svg) { margin-right: calc(var(--pzsh-spacer) / 2); } @media (min-width: ${theme.breakpoint}px) { a { margin: 0; padding: var(--pzsh-menu-item-padding-vertical) var(--pzsh-menu-item-padding-horizontal); color: var(--pzsh-menu-dropdown-item-fg); background-color: transparent; } :host(:focus) a, a:hover, a:active, a:focus { color: var(--pzsh-menu-dropdown-item-fg); background-color: var(--pzsh-menu-dropdown-item-bg-alt); } } `, ]; __decorate([ property({ type: String }) ], MenuDropdownItem.prototype, "href", void 0); MenuDropdownItem = __decorate([ customElement("pzsh-menu-dropdown-item") ], MenuDropdownItem); export { MenuDropdownItem };