Skip to content

Instantly share code, notes, and snippets.

@postspectacular
Created April 26, 2023 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save postspectacular/aa41d876e0b7e2f02bc427b4cc0ddeaf to your computer and use it in GitHub Desktop.
Save postspectacular/aa41d876e0b7e2f02bc427b4cc0ddeaf to your computer and use it in GitHub Desktop.
export type FxParamType =
| "number"
| "bigint"
| "boolean"
| "color"
| "string"
| "select";
interface FxParamBigintOpts {
min?: number | bigint;
max?: number | bigint;
}
interface FxParamNumberOpts {
min?: number;
max?: number;
step?: number;
}
interface FxParamStringOpts {
minLength?: number;
maxLength?: number;
}
interface FxParamSelectOpts {
options: string[];
}
export interface FxParamOptionsMap {
number: FxParamNumberOpts;
bigint: FxParamBigintOpts;
boolean: never;
color: never;
string: FxParamStringOpts;
select: FxParamSelectOpts;
}
export interface FxParamTypeMap {
number: number;
bigint: bigint;
boolean: boolean;
color: string;
string: string;
select: string;
}
export interface FxParamDefinition<Type extends FxParamType> {
id: string;
name?: string;
type: Type;
default?: FxParamTypeMap[Type];
options: FxParamOptionsMap[Type];
version?: string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment