Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | 8x 4x 4x 4x 4x 8x 5x 2x 2x 1x 1x 8x | import { LitElement, css, html } from 'lit';
/** Position relative to the containing surface; inline lets a shared dock arrange several panels. */
export type PanelPosition =
| 'top'
| 'bottom'
| 'left'
| 'right'
| 'center'
| 'top-left'
| 'top-right'
| 'bottom-left'
| 'bottom-right'
| 'inline';
/** A reusable heading, keyboard-operable disclosure and scrollable content slot. */
export class CollapsiblePanelElement extends LitElement {
static override properties = {
heading: { type: String },
open: { type: Boolean, reflect: true },
position: { type: String, reflect: true },
};
declare heading: string;
declare open: boolean;
declare position: PanelPosition;
constructor() {
super();
this.heading = '';
this.open = true;
this.position = 'bottom';
}
static override styles = css`
:host {
position: absolute;
z-index: 40;
display: block;
width: min(420px, calc(100% - 16px));
color: var(--popover-foreground, #eee);
font: 13px/1.4 var(--font-sans, system-ui);
}
:host([hidden]) {
display: none;
}
:host([position='inline']) {
position: static;
width: 100%;
transform: none;
}
:host([position='top']) {
top: 0;
left: 50%;
transform: translateX(-50%);
}
:host([position='bottom']) {
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
:host([position='left']) {
left: 0;
top: 50%;
transform: translateY(-50%);
}
:host([position='right']) {
right: 0;
top: 50%;
transform: translateY(-50%);
}
:host([position='center']) {
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
:host([position='top-left']) {
top: 0;
left: 0;
}
:host([position='top-right']) {
top: 0;
right: 0;
}
:host([position='bottom-left']) {
bottom: 0;
left: 0;
}
:host([position='bottom-right']) {
bottom: 0;
right: 0;
}
details {
border: 1px solid var(--border, #333);
border-radius: 8px;
background: color-mix(in oklch, var(--popover, #171717) 92%, transparent);
box-shadow: 0 -4px 16px #0005;
backdrop-filter: blur(10px) saturate(140%);
-webkit-backdrop-filter: blur(10px) saturate(140%);
}
summary {
box-sizing: border-box;
min-height: 44px;
padding: 12px 16px;
cursor: pointer;
font-weight: 600;
}
summary:focus-visible {
outline: 2px solid var(--ring, #aaa);
outline-offset: -3px;
}
.content {
padding: 0 16px 16px;
max-height: min(320px, 40dvh);
overflow: auto;
}
details:not([open]) > .content {
display: none;
}
@media (prefers-reduced-transparency: reduce) {
details {
background: var(--popover, #171717);
backdrop-filter: none;
}
}
`;
private isolateKeys(this: void, event: KeyboardEvent): void {
if (event.key !== 'Escape') event.stopPropagation();
}
protected override render() {
return html`<details
@keydown=${this.isolateKeys}
@keyup=${this.isolateKeys}
.open=${this.open}
@toggle=${(event: Event) => {
const open = (event.currentTarget as HTMLDetailsElement).open;
if (this.open === open) return;
this.open = open;
this.dispatchEvent(new CustomEvent('panel-toggle', { detail: { open }, bubbles: true, composed: true }));
}}
>
<summary><span class="options-folder-title">${this.heading}</span></summary>
<div class="content"><slot></slot></div>
</details>`;
}
}
customElements.define('be-music-collapsible-panel', CollapsiblePanelElement);
declare global {
interface HTMLElementTagNameMap {
'be-music-collapsible-panel': CollapsiblePanelElement;
}
}
|