Simplify design
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
export interface DialogAction {
|
||||
label: string;
|
||||
variant?: 'primary' | 'secondary' | 'accent' | 'danger';
|
||||
onclick?: () => void;
|
||||
}
|
||||
|
||||
export interface DialogOptions {
|
||||
title: string;
|
||||
description?: string;
|
||||
tone?: 'neutral' | 'danger';
|
||||
actions?: DialogAction[];
|
||||
}
|
||||
|
||||
class DialogStore {
|
||||
current = $state<DialogOptions | null>(null);
|
||||
|
||||
show(options: DialogOptions) {
|
||||
this.current = options;
|
||||
}
|
||||
|
||||
error(title: string, description?: string, actions?: DialogAction[]) {
|
||||
this.show({ title, description, tone: 'danger', actions });
|
||||
}
|
||||
|
||||
close() {
|
||||
this.current = null;
|
||||
}
|
||||
|
||||
run(action: DialogAction) {
|
||||
this.close();
|
||||
action.onclick?.();
|
||||
}
|
||||
}
|
||||
|
||||
export const dialog = new DialogStore();
|
||||
@@ -1,4 +1,7 @@
|
||||
import { contextMenuPosition, type MenuPosition } from '$lib/components/ui/overlay/ContextMenu.svelte';
|
||||
import {
|
||||
contextMenuPosition,
|
||||
type MenuPosition
|
||||
} from '$lib/components/ui/overlay/ContextMenu.svelte';
|
||||
import { player, toQueueItem, type ApiTrackLike } from '../player/player.svelte';
|
||||
|
||||
export type TrackMenuState = { track: ApiTrackLike } & MenuPosition;
|
||||
|
||||
Reference in New Issue
Block a user