import { LitElement, html, css, nothing } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; import '@awesome.me/webawesome/dist/components/icon/icon.js'; import { toggleRequest } from '@utils/library-status'; import { notificationStore } from '@store/notification-store'; import { describeError } from '@utils/describe-error'; import { ICON_CAN_REQUEST, ICON_IN_LIBRARY, ICON_REQUESTED, } from '@utils/icon-language'; /** * Library status for an entity (artist, album, or track). * * - `in-library`: the entity is already in the user's local library. * - `partial`: some of it is here and the rest is known to be missing * — an album whose files declare twelve tracks where nine are held. * Only ever correct when that total is *known*; see `owned` / * `expected` below. * - `queued`: the entity has been handed off to a download client but * hasn't arrived yet. Reserved for future download-client plumbing. * - `not-in-library` (default): the entity is not owned and has not * been requested. */ export type LibraryStatus = | 'in-library' | 'partial' | 'queued' | 'not-in-library'; /** * Tri-state library status indicator: a small circular badge embedded * in track rows, album cards, and artist cards. * * **It is a button only where it can act, and a badge everywhere * else.** It used to be a ` `; } return html` ${glyph} `; } /** * The progress arc. Drawn as a stroked circle rather than a conic * gradient so the ring keeps a constant width at every `size` and * the arc's ends stay round. */ private renderRing() { const radius = 8; const circumference = 2 * Math.PI * radius; const offset = circumference * (1 - this.fraction()); return html` `; } } function capitalize(s: string): string { return s.length > 0 ? (s[0] ?? '').toUpperCase() + s.slice(1) : s; } declare global { interface HTMLElementTagNameMap { 'library-status-indicator': LibraryStatusIndicator; } }