Three corrections to the Discover album card:
- Overlay meta: the genre is one point larger and bold, and the year
now sits a single line below it (conditional `if` rows with explicit
heights, instead of `visible` toggles that left a phantom gap)
- Award ribbon: width hugs its label (capped at 200px, below the card
width) instead of spanning the full card — it reads as a ribbon again
- Quality badge: extracted to a QualityBadge primitive that reveals
the exact quality ("Hi-Res: 24-bit / 96 kHz") on hover, mirroring the
Tauri QualityBadge; home.rs derives the label from the discover
audio info
cc
225 lines
7.7 KiB
Plaintext
225 lines
7.7 KiB
Plaintext
// Album card for the Discover sections.
|
|
//
|
|
// Mirrors the Svelte AlbumCardLite: 220px column, 220px square artwork
|
|
// with a bottom-left award ribbon and a hover overlay (dark scrim,
|
|
// genre/year meta, and play / favorite / more action buttons), then a
|
|
// tight title / artist stack alongside an icon-only quality badge.
|
|
// Deterministic 266px height.
|
|
|
|
import { Theme } from "../foundation/semantic-colors.slint";
|
|
import { Typography } from "../foundation/typography.slint";
|
|
import { Radius } from "../foundation/radius.slint";
|
|
import { Spacing } from "../foundation/spacing.slint";
|
|
import { AlbumCardItem } from "../state.slint";
|
|
import { QbzIcon } from "../primitives/QbzIcon.slint";
|
|
import { QualityBadge } from "../primitives/QualityBadge.slint";
|
|
|
|
// Circular hover-overlay action button.
|
|
component OverlayButton inherits Rectangle {
|
|
in property <image> icon;
|
|
in property <bool> primary: false;
|
|
in property <length> diameter: 36px;
|
|
in property <length> icon-size: 16px;
|
|
|
|
width: root.diameter;
|
|
height: root.diameter;
|
|
border-radius: root.diameter / 2;
|
|
background: root.primary ? #ffffff : transparent;
|
|
border-width: root.primary ? 0px : 1.5px;
|
|
border-color: #ffffffe6;
|
|
|
|
QbzIcon {
|
|
source: root.icon;
|
|
width: root.icon-size;
|
|
height: root.icon-size;
|
|
x: (parent.width - self.width) / 2;
|
|
y: (parent.height - self.height) / 2;
|
|
tint: root.primary ? #000000 : #ffffff;
|
|
}
|
|
}
|
|
|
|
export component AlbumCard inherits Rectangle {
|
|
in property <AlbumCardItem> album;
|
|
callback clicked(string);
|
|
|
|
// Fully deterministic height: artwork 220 + 6 spacer + 40 meta.
|
|
width: 220px;
|
|
height: 266px;
|
|
|
|
VerticalLayout {
|
|
alignment: start;
|
|
spacing: 0px;
|
|
|
|
// --- Artwork + hover overlay -------------------------------------
|
|
Rectangle {
|
|
width: 220px;
|
|
height: 220px;
|
|
border-radius: Radius.sm;
|
|
background: Theme.surface-elevated;
|
|
clip: true;
|
|
|
|
// Cover art. Empty until the artwork pipeline resolves it,
|
|
// leaving the elevated placeholder visible underneath.
|
|
Image {
|
|
width: 100%;
|
|
height: 100%;
|
|
source: root.album.artwork;
|
|
image-fit: cover;
|
|
}
|
|
|
|
// Hover scrim.
|
|
Rectangle {
|
|
width: 100%;
|
|
height: 100%;
|
|
background: #000000;
|
|
opacity: hover.has-hover ? 0.6 : 0.0;
|
|
animate opacity { duration: 150ms; }
|
|
}
|
|
|
|
// Hover meta — genre + year, top-left. The year sits one
|
|
// single line below the genre.
|
|
VerticalLayout {
|
|
x: 12px;
|
|
y: 12px;
|
|
spacing: 2px;
|
|
opacity: hover.has-hover ? 1.0 : 0.0;
|
|
animate opacity { duration: 150ms; }
|
|
|
|
if root.album.genre != "": Text {
|
|
text: root.album.genre;
|
|
height: 20px;
|
|
color: #ffffffeb;
|
|
font-size: 15px;
|
|
font-weight: Typography.bold;
|
|
vertical-alignment: center;
|
|
}
|
|
if root.album.year != "": Text {
|
|
text: root.album.year;
|
|
height: 17px;
|
|
color: #ffffffcc;
|
|
font-size: 13px;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
|
|
// Hover action buttons — favorite / play / more.
|
|
HorizontalLayout {
|
|
x: 0px;
|
|
y: 132px;
|
|
width: 220px;
|
|
height: 44px;
|
|
alignment: center;
|
|
spacing: 12px;
|
|
opacity: hover.has-hover ? 1.0 : 0.0;
|
|
animate opacity { duration: 150ms; }
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
OverlayButton { icon: @image-url("../assets/icons/heart.svg"); }
|
|
}
|
|
OverlayButton {
|
|
icon: @image-url("../assets/icons/play.svg");
|
|
primary: true;
|
|
diameter: 44px;
|
|
icon-size: 18px;
|
|
}
|
|
VerticalLayout {
|
|
alignment: center;
|
|
OverlayButton { icon: @image-url("../assets/icons/ellipsis.svg"); }
|
|
}
|
|
}
|
|
|
|
// Award ribbon — content-width only (it is a ribbon, not a
|
|
// full-width band), capped so long labels still elide.
|
|
if root.album.ribbon != "": Rectangle {
|
|
x: 0px;
|
|
y: parent.height - self.height - 8px;
|
|
height: 20px;
|
|
// Hug the label; cap below the card width so a runaway
|
|
// label elides instead of spanning the whole card.
|
|
width: Math.min(ribbon-row.preferred-width, 200px);
|
|
background: root.album.ribbon-kind == "press"
|
|
? #d49511
|
|
: #000000e0;
|
|
border-top-right-radius: 3px;
|
|
border-bottom-right-radius: 3px;
|
|
clip: true;
|
|
|
|
// Left accent stripe (not on the gold press ribbon).
|
|
Rectangle {
|
|
x: 0px;
|
|
width: root.album.ribbon-kind == "press" ? 0px : 3px;
|
|
background: root.album.ribbon-kind == "qobuzissime"
|
|
? #8b5cf6
|
|
: #eab308;
|
|
}
|
|
ribbon-row := HorizontalLayout {
|
|
padding-left: 10px;
|
|
padding-right: 10px;
|
|
Text {
|
|
text: root.album.ribbon;
|
|
color: root.album.ribbon-kind == "press"
|
|
? #1f1407
|
|
: #ffffff;
|
|
font-size: 10px;
|
|
font-weight: Typography.semibold;
|
|
vertical-alignment: center;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Hover + click detector — topmost so it owns the pointer.
|
|
hover := TouchArea {
|
|
width: 100%;
|
|
height: 100%;
|
|
mouse-cursor: pointer;
|
|
clicked => {
|
|
root.clicked(root.album.id);
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle { height: 6px; }
|
|
|
|
// --- Title / artist + quality badge ------------------------------
|
|
HorizontalLayout {
|
|
height: 40px;
|
|
spacing: Spacing.sm;
|
|
|
|
VerticalLayout {
|
|
alignment: center;
|
|
spacing: 2px;
|
|
horizontal-stretch: 1;
|
|
|
|
Text {
|
|
text: root.album.title;
|
|
height: 20px;
|
|
color: Theme.text-primary;
|
|
font-size: Typography.body;
|
|
font-weight: Typography.medium;
|
|
vertical-alignment: center;
|
|
overflow: elide;
|
|
}
|
|
Text {
|
|
text: root.album.artist;
|
|
height: 18px;
|
|
color: Theme.text-muted;
|
|
font-size: Typography.link;
|
|
vertical-alignment: center;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
|
|
// Icon-only quality badge with an exact-quality hover tooltip.
|
|
VerticalLayout {
|
|
alignment: center;
|
|
QualityBadge {
|
|
tier: root.album.quality-tier;
|
|
label: root.album.quality-label;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|