re-added virtualizer to cover grid, dropdown uses phantom-row method, minor user friendly resizing/focusing tweaks
This commit is contained in:
@@ -45,10 +45,13 @@ export class AlbumDropdown extends LitElement {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
selectedTracks: Set<string> = new Set();
|
selectedTracks: Set<string> = new Set();
|
||||||
|
|
||||||
|
/** Number of phantom grid rows allocated by the parent. */
|
||||||
|
@property({ type: Number, attribute: 'phantom-rows' })
|
||||||
|
phantomRows = 1;
|
||||||
|
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
display: block;
|
display: block;
|
||||||
grid-column: 1 / -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.album-dropdown {
|
.album-dropdown {
|
||||||
@@ -73,12 +76,6 @@ export class AlbumDropdown extends LitElement {
|
|||||||
column-count: 3;
|
column-count: 3;
|
||||||
column-fill: auto;
|
column-fill: auto;
|
||||||
column-gap: 24px;
|
column-gap: 24px;
|
||||||
height: 206px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dropdown-tracks.overflow {
|
|
||||||
height: auto;
|
|
||||||
min-height: 206px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.track-row {
|
.track-row {
|
||||||
@@ -168,22 +165,21 @@ export class AlbumDropdown extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the multi-column track layout
|
* Compute the track container height from the number
|
||||||
* overflows 3 columns at the base height.
|
* of phantom grid rows allocated by the parent.
|
||||||
*
|
*
|
||||||
* Heuristic: each track row is ~28px tall, the base
|
* Grid constants: itemHeight=230, gap=16.
|
||||||
* dropdown content height is 206px, each column fits
|
* Dropdown chrome: 12+12 padding + 2+2 border = 28px.
|
||||||
* ~7 tracks, and with 3 columns that is ~21 tracks.
|
|
||||||
*/
|
*/
|
||||||
private tracksOverflow(): boolean {
|
private get tracksHeight(): number {
|
||||||
const rowHeight = 28;
|
const gridItemHeight = 230;
|
||||||
const containerHeight = 206;
|
const gridGap = 16;
|
||||||
const perColumn = Math.floor(
|
const chrome = 28;
|
||||||
containerHeight / rowHeight,
|
const total =
|
||||||
);
|
this.phantomRows * gridItemHeight +
|
||||||
const maxTracks = perColumn * 3;
|
(this.phantomRows - 1) * gridGap;
|
||||||
|
|
||||||
return this.tracks.length > maxTracks;
|
return total - chrome;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================================
|
/* ================================================================
|
||||||
@@ -326,15 +322,12 @@ export class AlbumDropdown extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const overflow = this.tracksOverflow();
|
|
||||||
|
|
||||||
const tracksClass = overflow
|
|
||||||
? 'dropdown-tracks overflow'
|
|
||||||
: 'dropdown-tracks';
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div class="album-dropdown">
|
<div class="album-dropdown">
|
||||||
<div class=${tracksClass}>
|
<div
|
||||||
|
class="dropdown-tracks"
|
||||||
|
style="height:${this.tracksHeight}px"
|
||||||
|
>
|
||||||
${this.tracks.map(
|
${this.tracks.map(
|
||||||
(track, i) =>
|
(track, i) =>
|
||||||
this.renderTrackRow(track, i),
|
this.renderTrackRow(track, i),
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user