Skip to content

Commit

Permalink
Improve control types with discriminated union
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Mar 14, 2024
1 parent 46defba commit 17be521
Showing 1 changed file with 41 additions and 29 deletions.
70 changes: 41 additions & 29 deletions src/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,47 @@ export interface InputType {
control?:
| ControlType
| {
/**
* @see https://storybook.js.org/docs/api/arg-types#controltype
*/
type: ControlType;
/**
* @see https://storybook.js.org/docs/api/arg-types#controlaccept
*/
accept?: string;
/**
* @see https://storybook.js.org/docs/api/arg-types#controllabels
*/
labels?: { [options: string]: string };
/**
* @see https://storybook.js.org/docs/api/arg-types#controlmax
*/
max?: number;
/**
* @see https://storybook.js.org/docs/api/arg-types#controlmin
*/
min?: number;
/**
* @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors
*/
presetColors?: string[];
/**
* @see https://storybook.js.org/docs/api/arg-types#controlstep
*/
step?: number;
}
/**
* @see https://storybook.js.org/docs/api/arg-types#controltype
*/
type: ControlType;
}
| {
type: 'color';
/**
* @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors
*/
presetColors?: string[];
}
| {
type: 'file';
/**
* @see https://storybook.js.org/docs/api/arg-types#controlaccept
*/
accept?: string;
}
| {
type: 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select';
/**
* @see https://storybook.js.org/docs/api/arg-types#controllabels
*/
labels?: { [options: string]: string };
}
| {
type: 'number' | 'range';
/**
* @see https://storybook.js.org/docs/api/arg-types#controlmax
*/
max?: number;
/**
* @see https://storybook.js.org/docs/api/arg-types#controlmin
*/
min?: number;
/**
* @see https://storybook.js.org/docs/api/arg-types#controlstep
*/
step?: number;
}
| false;
/**
* @see https://storybook.js.org/docs/api/arg-types#description
Expand Down

0 comments on commit 17be521

Please sign in to comment.