Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
266e7032dd |
@@ -2,6 +2,7 @@ import { LitElement, html, css, nothing } from 'lit';
|
|||||||
import { customElement, property, state, query } from 'lit/decorators.js';
|
import { customElement, property, state, query } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { designTokens } from '../../styles/tokens.css';
|
import { designTokens } from '../../styles/tokens.css';
|
||||||
|
import { srOnly } from '../../styles/sr-only.css';
|
||||||
import {
|
import {
|
||||||
LookupReleaseGroup,
|
LookupReleaseGroup,
|
||||||
BrowseReleases,
|
BrowseReleases,
|
||||||
@@ -289,6 +290,7 @@ export class ExploreAlbumDetails extends LitElement implements ContextMenuHost {
|
|||||||
designTokens,
|
designTokens,
|
||||||
exploreLinkStyles,
|
exploreLinkStyles,
|
||||||
contextMenuStyles,
|
contextMenuStyles,
|
||||||
|
srOnly,
|
||||||
css`
|
css`
|
||||||
:host {
|
:host {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -662,21 +664,34 @@ export class ExploreAlbumDetails extends LitElement implements ContextMenuHost {
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The request control is offered on every row that has
|
/* The request control is only offered where there is
|
||||||
* something to request, and is not revealed on hover.
|
* something to request, and only when the row is being
|
||||||
|
* attended to — a column of plus signs down a mostly-owned
|
||||||
|
* album is the clutter the green ticks were.
|
||||||
*
|
*
|
||||||
* It used to be transparent until the row was hovered or
|
* Hidden with opacity, never display:none or visibility,
|
||||||
* focused, on the reasoning that a column of plus signs
|
* so it keeps its place in the layout (rows do not reflow
|
||||||
* down a mostly-owned album is clutter. That reasoning was
|
* as the pointer moves) and stays in the tab order and the
|
||||||
* inherited from the green ticks it replaced and does not
|
* accessibility tree. focus-within is what makes it
|
||||||
* survive the rule those were removed for: a tick marked
|
* reachable without a mouse: tabbing to the button reveals
|
||||||
* the *common* case, while this marks the rows that are
|
* it, and the row's own focus reveals it before you get
|
||||||
* **not** here. A mark on the exception is the information
|
* there. */
|
||||||
* on this page — and one that appears only under the
|
|
||||||
* pointer cannot be seen, counted, or reached by anyone
|
|
||||||
* driving this with a finger. */
|
|
||||||
.track-row .track-request {
|
.track-row .track-request {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.12s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.track-row:hover .track-request,
|
||||||
|
.track-row:focus-within .track-request,
|
||||||
|
.track-row .track-request:focus-visible {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.track-row .track-request {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
];
|
];
|
||||||
@@ -3020,11 +3035,21 @@ export class ExploreAlbumDetails extends LitElement implements ContextMenuHost {
|
|||||||
|
|
||||||
/* ── Tracklist ── */
|
/* ── Tracklist ── */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The heading is there and is not drawn.
|
||||||
|
*
|
||||||
|
* A list of numbered titles with durations under an album's cover
|
||||||
|
* does not need a word above it saying what it is — it was the
|
||||||
|
* only thing on this page labelling something already obvious. But
|
||||||
|
* the section is a landmark and the page's heading structure runs
|
||||||
|
* through it, so what goes is the *ink*, not the element: a reader
|
||||||
|
* jumping by heading still finds the tracklist.
|
||||||
|
*/
|
||||||
private renderTracklist() {
|
private renderTracklist() {
|
||||||
if (this.loadingReleases) {
|
if (this.loadingReleases) {
|
||||||
return html`
|
return html`
|
||||||
<section>
|
<section>
|
||||||
<h3 class="section-header">Tracklist</h3>
|
<h3 class="sr-only">Tracklist</h3>
|
||||||
<div class="section-loading">Loading tracks\u2026</div>
|
<div class="section-loading">Loading tracks\u2026</div>
|
||||||
</section>
|
</section>
|
||||||
`;
|
`;
|
||||||
@@ -3037,7 +3062,7 @@ export class ExploreAlbumDetails extends LitElement implements ContextMenuHost {
|
|||||||
if (!current) {
|
if (!current) {
|
||||||
return html`
|
return html`
|
||||||
<section>
|
<section>
|
||||||
<h3 class="section-header">Tracklist</h3>
|
<h3 class="sr-only">Tracklist</h3>
|
||||||
<div class="section-error">
|
<div class="section-error">
|
||||||
<wa-icon name="triangle-exclamation"></wa-icon>
|
<wa-icon name="triangle-exclamation"></wa-icon>
|
||||||
No release data available.
|
No release data available.
|
||||||
@@ -3050,7 +3075,7 @@ export class ExploreAlbumDetails extends LitElement implements ContextMenuHost {
|
|||||||
if (tracks.length === 0) {
|
if (tracks.length === 0) {
|
||||||
return html`
|
return html`
|
||||||
<section>
|
<section>
|
||||||
<h3 class="section-header">Tracklist</h3>
|
<h3 class="sr-only">Tracklist</h3>
|
||||||
<div
|
<div
|
||||||
style="color: var(--yj-text-tertiary, #888); font-size: var(--yj-text-md)"
|
style="color: var(--yj-text-tertiary, #888); font-size: var(--yj-text-md)"
|
||||||
>
|
>
|
||||||
@@ -3066,7 +3091,7 @@ export class ExploreAlbumDetails extends LitElement implements ContextMenuHost {
|
|||||||
|
|
||||||
return html`
|
return html`
|
||||||
<section>
|
<section>
|
||||||
<h3 class="section-header">Tracklist</h3>
|
<h3 class="sr-only">Tracklist</h3>
|
||||||
<div class="tracklist">
|
<div class="tracklist">
|
||||||
${discNumbers.map((discNum) => {
|
${discNumbers.map((discNum) => {
|
||||||
const discTracks = discMap.get(discNum) ?? [];
|
const discTracks = discMap.get(discNum) ?? [];
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
/**
|
|
||||||
* The request badge on an unowned row is there without being hovered.
|
|
||||||
*
|
|
||||||
* It used to be transparent until the row was hovered or focused, on
|
|
||||||
* the reasoning that a column of plus signs down a mostly-owned album
|
|
||||||
* is clutter. That reasoning came from the green ticks it replaced and
|
|
||||||
* does not survive the rule those were removed for: a tick marked the
|
|
||||||
* **common** case, while this marks the rows that are *not* here. A
|
|
||||||
* mark on the exception is the information on this page, and one that
|
|
||||||
* exists only under the pointer cannot be seen, counted, or reached by
|
|
||||||
* anyone driving the app with a finger.
|
|
||||||
*
|
|
||||||
* That the badge *repaints* when clicked is the other half of #33 and
|
|
||||||
* is covered by `album-track-request.test.ts`.
|
|
||||||
*/
|
|
||||||
import { describe, expect, it, beforeEach } from 'vitest';
|
|
||||||
import type { LitElement } from 'lit';
|
|
||||||
|
|
||||||
import '@components/explore-album-details/explore-album-details';
|
|
||||||
import { stub, flush, resetHarness } from '@test/support/harness';
|
|
||||||
import { fixture, shadowAll } from '@test/support/render';
|
|
||||||
|
|
||||||
function track(n: number, owned: boolean) {
|
|
||||||
return {
|
|
||||||
position: n,
|
|
||||||
discNumber: 1,
|
|
||||||
title: `Track ${n}`,
|
|
||||||
length: 200000,
|
|
||||||
mbid: `mbid-${n}`,
|
|
||||||
inLibrary: owned,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/** An album with one owned track and one that is not here. */
|
|
||||||
async function albumWithAnUnownedTrack(): Promise<LitElement> {
|
|
||||||
const el = await fixture<LitElement>('explore-album-details', {
|
|
||||||
albumName: 'Glass Harbour',
|
|
||||||
releaseGroupMBID: 'rg-1',
|
|
||||||
});
|
|
||||||
|
|
||||||
stub('library.Library.GetFilePathsByRecordingMBIDs', {
|
|
||||||
'mbid-1': ['/music/mbid-1.mp3'],
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.assign(el, {
|
|
||||||
versionEntries: [
|
|
||||||
{
|
|
||||||
key: 'v1',
|
|
||||||
label: '2019',
|
|
||||||
sublabel: '2 tracks',
|
|
||||||
tracks: [track(1, true), track(2, false)],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
selectedVersionKey: 'v1',
|
|
||||||
loadingReleases: false,
|
|
||||||
loadingInfo: false,
|
|
||||||
});
|
|
||||||
el.requestUpdate();
|
|
||||||
await flush();
|
|
||||||
await el.updateComplete;
|
|
||||||
|
|
||||||
return el;
|
|
||||||
}
|
|
||||||
|
|
||||||
const badges = (el: LitElement) =>
|
|
||||||
shadowAll(el, 'library-status-indicator.track-request');
|
|
||||||
|
|
||||||
describe('the tracklist’s request badge', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
resetHarness();
|
|
||||||
stub('library.Library.GetFilePathsByRecordingMBIDs', {});
|
|
||||||
stub('library.Library.GetFilePathsByAlbums', {});
|
|
||||||
stub('library.Library.GetAlbumTracks', []);
|
|
||||||
stub('library.Library.GetAllLibrariesWithTrackCounts', []);
|
|
||||||
stub('download.Service.ProviderKinds', []);
|
|
||||||
stub('download.Service.ListProviders', []);
|
|
||||||
stub('download.Service.ListDownloads', []);
|
|
||||||
stub('download.Service.ListRequests', []);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('is visible without a pointer anywhere near it', async () => {
|
|
||||||
const el = await albumWithAnUnownedTrack();
|
|
||||||
const [badge] = badges(el);
|
|
||||||
|
|
||||||
expect(badge).toBeTruthy();
|
|
||||||
// Computed opacity rather than the absence of a rule, because the
|
|
||||||
// rule could come back under a different selector.
|
|
||||||
expect(getComputedStyle(badge!).opacity).toBe('1');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('is still only on the rows with something to request', async () => {
|
|
||||||
// Always-visible is not the same as everywhere: an owned track has
|
|
||||||
// nothing left to ask for, and a badge on it would be the column of
|
|
||||||
// green ticks this page deliberately stopped drawing.
|
|
||||||
expect(badges(await albumWithAnUnownedTrack())).toHaveLength(1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* The tracklist's own heading.
|
||||||
|
*
|
||||||
|
* A list of numbered titles with durations, under the album's cover, is
|
||||||
|
* the one thing on this page that did not need a word above it saying
|
||||||
|
* what it was — "TRACKLIST" labelled the only thing already obvious.
|
||||||
|
*
|
||||||
|
* What goes is the *ink*, not the element. The section is a landmark
|
||||||
|
* and the page's heading structure runs through it, so a reader moving
|
||||||
|
* by heading still has to be able to find it, and it is hidden the way
|
||||||
|
* `sr-only` hides things: `clip-path`, never `display: none`, which
|
||||||
|
* would take it out of the accessibility tree along with the layout.
|
||||||
|
*/
|
||||||
|
import { describe, expect, it, beforeEach } from 'vitest';
|
||||||
|
import type { LitElement } from 'lit';
|
||||||
|
|
||||||
|
import '@components/explore-album-details/explore-album-details';
|
||||||
|
import { stub, flush, resetHarness } from '@test/support/harness';
|
||||||
|
import { fixture, shadowAll } from '@test/support/render';
|
||||||
|
|
||||||
|
function track(n: number) {
|
||||||
|
return {
|
||||||
|
position: n,
|
||||||
|
discNumber: 1,
|
||||||
|
title: `Track ${n}`,
|
||||||
|
length: 200000,
|
||||||
|
mbid: `mbid-${n}`,
|
||||||
|
inLibrary: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function albumPage(): Promise<LitElement> {
|
||||||
|
const el = await fixture<LitElement>('explore-album-details', {
|
||||||
|
albumName: 'Glass Harbour',
|
||||||
|
releaseGroupMBID: 'rg-1',
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.assign(el, {
|
||||||
|
versionEntries: [
|
||||||
|
{
|
||||||
|
key: 'v1',
|
||||||
|
label: '2019',
|
||||||
|
sublabel: '2 tracks',
|
||||||
|
tracks: [track(1), track(2)],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
selectedVersionKey: 'v1',
|
||||||
|
loadingReleases: false,
|
||||||
|
loadingInfo: false,
|
||||||
|
});
|
||||||
|
el.requestUpdate();
|
||||||
|
await flush();
|
||||||
|
await el.updateComplete;
|
||||||
|
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tracklistHeading = (el: LitElement) =>
|
||||||
|
shadowAll(el, 'h3').find((h) => h.textContent?.trim() === 'Tracklist');
|
||||||
|
|
||||||
|
describe('the album tracklist heading', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
resetHarness();
|
||||||
|
stub('library.Library.GetFilePathsByRecordingMBIDs', {});
|
||||||
|
stub('library.Library.GetFilePathsByAlbums', {});
|
||||||
|
stub('library.Library.GetAlbumTracks', []);
|
||||||
|
stub('library.Library.GetAllLibrariesWithTrackCounts', []);
|
||||||
|
stub('download.Service.ProviderKinds', []);
|
||||||
|
stub('download.Service.ListProviders', []);
|
||||||
|
stub('download.Service.ListDownloads', []);
|
||||||
|
stub('download.Service.ListRequests', []);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is still in the tree', async () => {
|
||||||
|
expect(tracklistHeading(await albumPage())).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('takes up no room on the page', async () => {
|
||||||
|
const heading = tracklistHeading(await albumPage())!;
|
||||||
|
const box = heading.getBoundingClientRect();
|
||||||
|
|
||||||
|
expect(box.width).toBeLessThanOrEqual(1);
|
||||||
|
expect(box.height).toBeLessThanOrEqual(1);
|
||||||
|
// Hidden by clipping, not by removal: display:none and
|
||||||
|
// visibility:hidden both take it out of the accessibility tree.
|
||||||
|
expect(getComputedStyle(heading).display).not.toBe('none');
|
||||||
|
expect(getComputedStyle(heading).visibility).not.toBe('hidden');
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user