@storybook/addon-knobs#object TypeScript Examples
The following examples show how to use
@storybook/addon-knobs#object.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserTableView.stories.tsx From bouncecode-cms with GNU General Public License v3.0 | 6 votes |
UserTable = () => {
const data: ITableDataCallback = async query => {
return {
data: object('data', [
{
id: 1,
email: '[email protected]',
isAdmin: true,
payload: {displayName: '홍길동'},
createdDate: new Date(),
updatedDate: new Date(),
},
]),
page: number('page', 1),
totalCount: number('totalCount', 100), // TODO: totalCount
};
};
return (
<SnackbarProvider>
<UserTableView data={data} />
</SnackbarProvider>
);
}
Example #2
Source File: Field.stories.tsx From react-js-tutorial with MIT License | 6 votes |
emptyField = () => [
<Field
key="jsx"
onClick={elementClicked}
field={object("field", [
["", "", ""],
["", "", ""],
["", "", ""],
])}
/>,
]
Example #3
Source File: Field.stories.tsx From react-js-tutorial with MIT License | 6 votes |
nonEmptyField = () => [
<Field
key="jsx"
onClick={elementClicked}
field={object("field", [
["x", "o", ""],
["", "o", ""],
["", "", ""],
])}
/>,
]
Example #4
Source File: ButtonCascader.story.tsx From grafana-chinese with Apache License 2.0 | 6 votes |
getKnobs = () => {
return {
disabled: boolean('Disabled', false),
text: text('Button Text', 'Click me!'),
options: object('Options', [
{
label: 'A',
value: 'A',
children: [
{ label: 'B', value: 'B' },
{ label: 'C', value: 'C' },
],
},
{ label: 'D', value: 'D' },
]),
};
}
Example #5
Source File: PieChart.story.tsx From grafana-chinese with Apache License 2.0 | 6 votes |
getKnobs = () => {
return {
datapoints: object('datapoints', [
{
value: 100,
name: '100',
color: '#7EB26D',
},
{
value: 200,
name: '200',
color: '#6ED0E0',
},
]),
pieType: text('pieType', PieChartType.PIE),
strokeWidth: number('strokeWidth', 1),
unit: text('unit', 'ms'),
};
}
Example #6
Source File: ButtonSelect.story.tsx From grafana-chinese with Apache License 2.0 | 6 votes |
ButtonSelectStories.add('default', () => {
const intialState: SelectableValue<string> = { label: 'A label', value: 'A value' };
const value = object<SelectableValue<string>>('Selected Value:', intialState);
const options = object<Array<SelectableValue<string>>>('Options:', [
intialState,
{ label: 'Another label', value: 'Another value' },
]);
return (
<UseState initialState={value}>
{(value, updateValue) => {
return (
<ButtonSelect
value={value}
options={options}
onChange={value => {
action('onChanged fired')(value);
updateValue(value);
}}
label={value.label ? value.label : ''}
className="refresh-select"
iconClass={text('iconClass', 'fa fa-clock-o fa-fw')}
/>
);
}}
</UseState>
);
});
Example #7
Source File: Select.story.tsx From grafana-chinese with Apache License 2.0 | 6 votes |
options = object<Array<SelectableValue<string>>>('Options:', [
intialState,
{ label: 'Another label', value: 'Another value 1' },
{ label: 'Another label', value: 'Another value 2' },
{ label: 'Another label', value: 'Another value 3' },
{ label: 'Another label', value: 'Another value 4' },
{ label: 'Another label', value: 'Another value 5' },
{ label: 'Another label', value: 'Another value ' },
])
Example #8
Source File: Select.story.tsx From grafana-chinese with Apache License 2.0 | 6 votes |
basic = () => {
const value = object<SelectableValue<string>>('Selected Value:', intialState);
return (
<UseState initialState={value}>
{(value, updateValue) => {
return (
<Select
placeholder="Choose..."
options={options}
width={20}
onChange={value => {
action('onChanged fired')(value);
updateValue(value);
}}
/>
);
}}
</UseState>
);
}
Example #9
Source File: Select.story.tsx From grafana-chinese with Apache License 2.0 | 6 votes |
withAllowCustomValue = () => {
// @ts-ignore
const value = object<SelectableValue<string>>('Selected Value:', null);
return (
<UseState initialState={value}>
{(value, updateValue) => {
return (
<Select
// value={value}
placeholder="Choose..."
options={options}
width={20}
allowCustomValue={true}
onChange={value => {
action('onChanged fired')(value);
updateValue(value);
}}
/>
);
}}
</UseState>
);
}
Example #10
Source File: Test.stories.ts From IOT-Map-Component with MIT License | 5 votes |
Clusters = () => {
markersList = object('markersList', MARKER_LIST);
addEventListener('DOMContentLoaded', init);
return iotMapTemplate;
}
Example #11
Source File: TestView.stories.tsx From bouncecode-cms with GNU General Public License v3.0 | 5 votes |
Test = () => {
const data = object('data', {test: 'message'});
return <TestView data={data} />;
}