mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
refactor(control): better indentation in ui_behavior
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { writable, type Writable } from "svelte/store";
|
import { writable, type Writable } from 'svelte/store';
|
||||||
|
|
||||||
export const dnd_flip_duration_ms = 300;
|
export const dnd_flip_duration_ms = 300;
|
||||||
|
|
||||||
@@ -6,27 +6,25 @@ const heights_options: Record<string, { min: number; max: number; step: number }
|
|||||||
display: {
|
display: {
|
||||||
min: 15,
|
min: 15,
|
||||||
max: 40,
|
max: 40,
|
||||||
step: 5,
|
step: 5
|
||||||
},
|
},
|
||||||
file: {
|
file: {
|
||||||
min: 10,
|
min: 10,
|
||||||
max: 20,
|
max: 20,
|
||||||
step: 5,
|
step: 5
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const current_height: Writable<Record<string, number>> = writable<Record<string, number>>({
|
export const current_height: Writable<Record<string, number>> = writable<Record<string, number>>({
|
||||||
display: 25,
|
display: 25,
|
||||||
file: 10,
|
file: 10
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export const is_group_drag: Writable<boolean> = writable<boolean>(false);
|
export const is_group_drag: Writable<boolean> = writable<boolean>(false);
|
||||||
export const is_display_drag: Writable<boolean> = writable<boolean>(false);
|
export const is_display_drag: Writable<boolean> = writable<boolean>(false);
|
||||||
|
|
||||||
export const pinned_display_id: Writable<string | null> = writable<string | null>(null);
|
export const pinned_display_id: Writable<string | null> = writable<string | null>(null);
|
||||||
|
|
||||||
|
|
||||||
export function change_height(key: 'display' | 'file', factor: number) {
|
export function change_height(key: 'display' | 'file', factor: number) {
|
||||||
current_height.update((height) => {
|
current_height.update((height) => {
|
||||||
height[key] = next_height_step_size(key, height, factor) || height[key];
|
height[key] = next_height_step_size(key, height, factor) || height[key];
|
||||||
@@ -34,8 +32,12 @@ export function change_height(key: 'display' | 'file', factor: number) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function next_height_step_size(key: 'display' | 'file', current_height_array: Record<string, number>, factor: number): number {
|
export function next_height_step_size(
|
||||||
const new_size = current_height_array[key] + (factor * heights_options[key].step);
|
key: 'display' | 'file',
|
||||||
|
current_height_array: Record<string, number>,
|
||||||
|
factor: number
|
||||||
|
): number {
|
||||||
|
const new_size = current_height_array[key] + factor * heights_options[key].step;
|
||||||
if (new_size > heights_options[key].max || new_size < heights_options[key].min) {
|
if (new_size > heights_options[key].max || new_size < heights_options[key].min) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -43,9 +45,6 @@ export function next_height_step_size(key: 'display' | 'file', current_height_ar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function get_selectable_color_classes(
|
export function get_selectable_color_classes(
|
||||||
selected: boolean,
|
selected: boolean,
|
||||||
returning_classes: { bg?: boolean; hover?: boolean; active?: boolean; text?: boolean } = {},
|
returning_classes: { bg?: boolean; hover?: boolean; active?: boolean; text?: boolean } = {},
|
||||||
|
|||||||
Reference in New Issue
Block a user