From afdfbfb08f5d4e53b15d21cd2d89b95a6dc9f16a Mon Sep 17 00:00:00 2001 From: Aram Limpens Date: Wed, 6 Dec 2023 19:49:05 +0100 Subject: [PATCH] Add subcomponent controls --- .../src/SearchField/SearchField.docs.mdx | 4 ++- .../src/SearchField/SearchField.stories.tsx | 36 +++++++++++++------ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/storybook/storybook-react/src/SearchField/SearchField.docs.mdx b/storybook/storybook-react/src/SearchField/SearchField.docs.mdx index 82922af902..3926f212fa 100644 --- a/storybook/storybook-react/src/SearchField/SearchField.docs.mdx +++ b/storybook/storybook-react/src/SearchField/SearchField.docs.mdx @@ -1,4 +1,4 @@ -import { Canvas, Markdown, Meta, Primary } from "@storybook/blocks"; +import { Canvas, Controls, Markdown, Meta, Primary } from "@storybook/blocks"; import * as SearchFieldStories from "./SearchField.stories.tsx"; import README from "../../../../packages/css/src/components/search-field/README.md?raw"; @@ -8,6 +8,8 @@ import README from "../../../../packages/css/src/components/search-field/README. + + ### Met placeholder Een zoekveld kan een placeholder hebben. diff --git a/storybook/storybook-react/src/SearchField/SearchField.stories.tsx b/storybook/storybook-react/src/SearchField/SearchField.stories.tsx index f0a4db11e6..49bfc890d9 100644 --- a/storybook/storybook-react/src/SearchField/SearchField.stories.tsx +++ b/storybook/storybook-react/src/SearchField/SearchField.stories.tsx @@ -3,33 +3,46 @@ * Copyright (c) 2023 Gemeente Amsterdam */ -import { SearchField } from '@amsterdam/design-system-react' +import { SearchField, SearchFieldProps } from '@amsterdam/design-system-react' import { useArgs } from '@storybook/preview-api' import { Meta, StoryObj } from '@storybook/react' +type InputProps = { label?: string; placeholder?: string } +type StoryProps = SearchFieldProps & InputProps + const meta = { title: 'Forms/Search Field', component: SearchField, args: { - children: [, ], onSubmit: (e) => { e.preventDefault() }, }, argTypes: { - // TODO: add label and placeholder controls once we figure out an approach for subcomponent controls children: { table: { disable: true, }, }, + label: { + control: 'text', + }, onSubmit: { table: { disable: true, }, }, + placeholder: { + control: 'text', + }, }, -} satisfies Meta + render: ({ label, placeholder, ...args }) => ( + + + + + ), +} satisfies Meta export default meta @@ -39,10 +52,7 @@ export const Default: Story = {} export const WithPlaceholder: Story = { args: { - children: [ - , - , - ], + placeholder: 'Wat kunnen we voor u vinden?', }, } @@ -50,7 +60,7 @@ export const Controlled: any = { args: { value: '', }, - render: function Component() { + render: function Component({ label, placeholder }: InputProps) { const [args, setArgs] = useArgs() const onValueChange = (event: any) => { @@ -70,7 +80,13 @@ export const Controlled: any = { } }} > - + )