feat: settings sliders (#120)

Co-authored-by: Ven <vendicated@riseup.net>
This commit is contained in:
megumin 2022-10-19 20:57:27 +01:00 committed by GitHub
parent efab399309
commit 1f50f78912
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 123 additions and 40 deletions

View file

@ -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<V = any> = { ok: true; value: V; } | { ok: false, error: any; };