Created
April 26, 2023 11:39
-
-
Save postspectacular/aa41d876e0b7e2f02bc427b4cc0ddeaf to your computer and use it in GitHub Desktop.
Preliminary fx(params) type defs (based on: https://github.com/fxhash/fxlens/blob/master/src/components/FxParams/types.ts)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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