diff --git a/packages/grafana-ui/src/components/Forms/FieldArray.mdx b/packages/grafana-ui/src/components/Forms/FieldArray.mdx index 465b68acc4f..92a9deb27d8 100644 --- a/packages/grafana-ui/src/components/Forms/FieldArray.mdx +++ b/packages/grafana-ui/src/components/Forms/FieldArray.mdx @@ -12,21 +12,21 @@ import { FieldArray } from './FieldArray'; ```jsx import { Form, FieldArray } from '@grafana/ui'; -
; ``` diff --git a/packages/grafana-ui/src/components/Forms/FieldArray.story.tsx b/packages/grafana-ui/src/components/Forms/FieldArray.story.tsx index 9fd1a782294..88404a3d08b 100644 --- a/packages/grafana-ui/src/components/Forms/FieldArray.story.tsx +++ b/packages/grafana-ui/src/components/Forms/FieldArray.story.tsx @@ -4,6 +4,7 @@ import { withStoryContainer } from '../../utils/storybook/withStoryContainer'; import { Form, Input, Button, HorizontalGroup } from '@grafana/ui'; import { FieldArray } from './FieldArray'; import mdx from './FieldArray.mdx'; +import { Meta, Story } from '@storybook/react'; export default { title: 'Forms/FieldArray', @@ -13,10 +14,17 @@ export default { docs: { page: mdx, }, + controls: { + exclude: ['name', 'keyName', 'control', 'shouldUnregister'], + }, }, -}; + argTypes: { + containerWidth: { control: { type: 'range', min: 100, max: 500, step: 10 } }, + containerHeight: { control: { type: 'range', min: 100, max: 500, step: 10 } }, + }, +} as Meta; -export const simple = () => { +export const Simple: Story = (args) => { const defaultValues: any = { people: [{ firstName: 'Janis', lastName: 'Joplin' }], }; @@ -58,3 +66,8 @@ export const simple = () => { ); }; +Simple.args = { + containerWidth: 300, + containerHeight: 0, + showBoundaries: false, +}; diff --git a/packages/grafana-ui/src/components/Layout/Layout.story.tsx b/packages/grafana-ui/src/components/Layout/Layout.story.tsx index 498c3e564a3..c20f008707f 100644 --- a/packages/grafana-ui/src/components/Layout/Layout.story.tsx +++ b/packages/grafana-ui/src/components/Layout/Layout.story.tsx @@ -15,9 +15,6 @@ export default { docs: { page: mdx, }, - knobs: { - disabled: true, - }, controls: { exclude: ['orientation'], }, @@ -28,8 +25,13 @@ export default { align: 'center', wrap: false, width: '100%', + containerWidth: 300, + containerHeight: 0, + showBoundaries: false, }, argTypes: { + containerWidth: { control: { type: 'range', min: 100, max: 500, step: 10 } }, + containerHeight: { control: { type: 'range', min: 100, max: 500, step: 10 } }, justify: { control: { type: 'select', diff --git a/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx b/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx index de85f0de507..b13c0ecd42a 100644 --- a/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx +++ b/packages/grafana-ui/src/utils/storybook/withStoryContainer.tsx @@ -1,7 +1,7 @@ import React from 'react'; -import { boolean, number } from '@storybook/addon-knobs'; import { css, cx } from '@emotion/css'; import { RenderFunction } from '../../types'; +import { StoryContext } from '@storybook/react'; const StoryContainer: React.FC<{ width?: number; height?: number; showBoundaries: boolean }> = ({ children, @@ -43,38 +43,12 @@ const StoryContainer: React.FC<{ width?: number; height?: number; showBoundaries ); }; -export const withStoryContainer = (story: RenderFunction) => { - const CONTAINER_GROUP = 'Container options'; - // --- - const containerBoundary = boolean('Show container boundary', false, CONTAINER_GROUP); - const fullWidthContainer = boolean('Full width container', false, CONTAINER_GROUP); - const containerWidth = number( - 'Container width', - 300, - { - range: true, - min: 100, - max: 500, - step: 10, - }, - CONTAINER_GROUP - ); - const containerHeight = number( - 'Container height', - 0, - { - range: true, - min: 100, - max: 500, - step: 10, - }, - CONTAINER_GROUP - ); +export const withStoryContainer = (story: RenderFunction, context: StoryContext) => { return (