From 1f50f78912caeeff1c65182d61b72e6ec95b9899 Mon Sep 17 00:00:00 2001 From: megumin Date: Wed, 19 Oct 2022 20:57:27 +0100 Subject: feat: settings sliders (#120) Co-authored-by: Ven --- src/utils/types.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/utils') diff --git a/src/utils/types.ts b/src/utils/types.ts index 5ed95e4..1318799 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -70,13 +70,15 @@ export enum OptionType { BIGINT, BOOLEAN, SELECT, + SLIDER, } export type PluginOptionsItem = | PluginOptionString | PluginOptionNumber | PluginOptionBoolean - | PluginOptionSelect; + | PluginOptionSelect + | PluginOptionSlider; export interface PluginOptionBase { description: string; @@ -132,4 +134,24 @@ export interface PluginOptionSelectOption { default?: boolean; } +export interface PluginOptionSlider extends PluginOptionBase { + type: OptionType.SLIDER; + /** + * All the possible values in the slider. Needs at least two values. + */ + markers: number[]; + /** + * Default value to use + */ + default: number; + /** + * If false, allow users to select values in-between your markers. + */ + stickToMarkers?: boolean; + /** + * Prevents the user from saving settings if this is false or a string + */ + isValid?(value: number): number; +} + export type IpcRes = { ok: true; value: V; } | { ok: false, error: any; }; -- cgit