Files
qbz/crates/qbz-slint/ui/myqbz/CreateMyQbzModal.slint
T
vicrodh 16e6232220 refactor(myqbz): button audit — app primitives + fix glyph centering
Phase-2 Slice 12c (user directive: use the app's circular controls, no invented
buttons; fix the glyph-stuck-left bug).
- Hero §3.6: deleted the local ActionCircle; the 4 hero controls are now the
  shared CircleAction (Play primary = filled white disc + black glyph; the loading
  spinner is now available = more 1:1). Added `enabled` to CircleAction (additive).
- All MyQBZ modal footers (Create / Edit / Mix / AddTo / Discography) now use the
  shared QbzPrimaryButton (+ a new `destructive` variant for Delete) and a new
  shared SecondaryButton (promoted from AppearanceSettings' inline copy).
  QbzPrimaryButton auto-sizes as a footer chip while staying full-width in login
  (verified: login stretches it in a VerticalLayout; footers take preferred width).
- Kept legitimately-local icon+label controls (grid "+ New" CTA, AddToMixtape
  picker chips, toolbar sort/filter/view-mode pills) but verified every glyph is
  centered.
- Fixed 3 glyph-stuck-left bugs (DiscographyBuilder checkboxes used non-snapped
  centering -> the Math.round(.../1px)*1px crisp idiom).

Backend crates untouched. cargo check -p qbz-slint green.

cc
2026-06-09 08:29:11 -06:00

195 lines
7.7 KiB
Plaintext

// "Create Mixtape / Collection" modal — 1:1 with Tauri's inline create
// modal in `+page.svelte` (spec 30 §3). A Name field, a Kind radio toggle
// (Mixtape / Collection — artist_collection is built via the Discography
// Builder, not here), and Cancel / Create buttons. The title and the Create
// button label switch on `kind` ("Create Mixtape" + "+ New Mixtape" vs
// "Create Collection" + "+ New Collection").
//
// Opened from either grid's "+ New" CTA / empty-state button
// (MyQbzCreateState.open). Backdrop click and Cancel close without creating;
// Enter / Create submit. Create is disabled while busy or the name is blank.
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { MyQbzCreateState, MyQbzCreateActions } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { QbzPrimaryButton } from "../primitives/QbzPrimaryButton.slint";
import { SecondaryButton } from "../primitives/SecondaryButton.slint";
import { LineEdit } from "std-widgets.slint";
// A single labelled radio option in the Kind toggle.
component KindRadio inherits TouchArea {
in property <string> label;
in property <bool> selected;
mouse-cursor: pointer;
horizontal-stretch: 0;
HorizontalLayout {
spacing: 6px;
// Radio dot.
Rectangle {
width: 18px;
height: 18px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: 9px;
border-width: root.selected ? 0px : 1.5px;
border-color: Theme.text-muted;
background: root.selected ? Theme.accent : transparent;
Rectangle {
width: 7px;
height: 7px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: 3.5px;
background: #ffffff;
visible: root.selected;
}
}
Text {
text: root.label;
color: Theme.text-primary;
font-size: Typography.body;
vertical-alignment: center;
}
}
}
export component CreateMyQbzModal inherits Rectangle {
visible: MyQbzCreateState.open;
property <bool> is-mixtape: MyQbzCreateState.kind == "mixtape";
property <bool> can-create: MyQbzCreateState.name != "" && !MyQbzCreateState.creating;
if MyQbzCreateState.open: Rectangle {
background: #000000bf;
TouchArea {
mouse-cursor: default;
clicked => {
MyQbzCreateActions.close();
}
}
Rectangle {
width: Math.min(root.width - 80px, 420px);
height: panel.preferred-height;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
border-radius: Radius.md;
background: Theme.surface-card;
border-width: 1px;
border-color: Theme.border-subtle;
drop-shadow-blur: 32px;
drop-shadow-color: #00000080;
TouchArea { }
panel := VerticalLayout {
padding: 24px;
spacing: 16px;
HorizontalLayout {
Text {
text: root.is-mixtape ? @tr("Create Mixtape") : @tr("Create Collection");
color: Theme.text-primary;
font-size: Typography.heading;
font-weight: Typography.bold;
horizontal-stretch: 1;
vertical-alignment: center;
}
close-x := TouchArea {
width: 28px;
height: 28px;
mouse-cursor: pointer;
clicked => {
MyQbzCreateActions.close();
}
QbzIcon {
source: @image-url("../assets/icons/x.svg");
width: 17px;
height: 17px;
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: close-x.has-hover ? Theme.text-primary : Theme.text-muted;
}
}
}
// Name.
VerticalLayout {
spacing: 8px;
Text {
// Uppercase eyebrow (Tauri .field-label text-transform).
text: @tr("NAME");
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: Typography.semibold;
letter-spacing: 1.5px;
}
name-input := LineEdit {
text <=> MyQbzCreateState.name;
accepted => {
MyQbzCreateActions.submit();
}
}
}
// Kind toggle (Mixtape / Collection).
VerticalLayout {
spacing: 8px;
Text {
text: @tr("KIND");
color: Theme.text-muted;
font-size: Typography.legal;
font-weight: Typography.semibold;
letter-spacing: 1.5px;
}
HorizontalLayout {
spacing: 12px;
alignment: start;
KindRadio {
label: @tr("Mixtapes");
selected: root.is-mixtape;
clicked => {
if (!MyQbzCreateState.creating) {
MyQbzCreateState.kind = "mixtape";
}
}
}
KindRadio {
label: @tr("Collections");
selected: !root.is-mixtape;
clicked => {
if (!MyQbzCreateState.creating) {
MyQbzCreateState.kind = "collection";
}
}
}
}
}
// Cancel + Create — the app's shared labeled primitives
// (auto-width, 38px footer chips).
HorizontalLayout {
alignment: end;
spacing: 8px;
// Cancel (secondary).
SecondaryButton {
label: @tr("Cancel");
height: 38px;
clicked => {
MyQbzCreateActions.close();
}
}
// Create (primary) — label reuses the empty-state CTA.
QbzPrimaryButton {
label: root.is-mixtape ? @tr("+ New Mixtape") : @tr("+ New Collection");
height: 38px;
enabled: root.can-create;
clicked => {
MyQbzCreateActions.submit();
}
}
}
}
}
}
}