-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update stories to use hook and update controls (#7)
- Loading branch information
Showing
11 changed files
with
73 additions
and
80 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
43 changes: 18 additions & 25 deletions
43
packages/react-front-kit/src/3-custom/Components/HeaderSearch/HeaderSearch.stories.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,34 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import type { ChangeEvent, ReactElement } from 'react'; | ||
|
||
import { useState } from 'react'; | ||
import { useStorybookArgsConnect } from '../../../hooks/useStorybookArgsConnect'; | ||
|
||
import { HeaderSearch as Cmp } from './HeaderSearch'; | ||
|
||
const meta = { | ||
component: Cmp, | ||
decorators: [ | ||
function Component(Story, ctx) { | ||
const args = useStorybookArgsConnect(ctx.args, { | ||
onChange: 'value', | ||
}); | ||
return ( | ||
<div style={{ position: 'relative' }}> | ||
<Story args={{ ...args }} /> | ||
</div> | ||
); | ||
}, | ||
], | ||
tags: ['autodocs'], | ||
title: '3-custom/Components/HeaderSearch', | ||
} satisfies Meta<typeof Cmp>; | ||
|
||
export default meta; | ||
type IStory = StoryObj<typeof meta>; | ||
|
||
function Render(props: Record<string, unknown>): ReactElement { | ||
const [search, setSearch] = useState(''); | ||
function handleSearchChange(event: ChangeEvent<HTMLInputElement>): void { | ||
setSearch(event.target.value); | ||
} | ||
|
||
function handleSearchClear(): void { | ||
setSearch(''); | ||
} | ||
return ( | ||
<div style={{ position: 'relative' }}> | ||
<Cmp | ||
{...props} | ||
onChange={handleSearchChange} | ||
onClear={handleSearchClear} | ||
value={search} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export const HeaderSearch: IStory = { | ||
args: {}, | ||
render: Render, | ||
args: { | ||
clearButtonAriaLabel: 'Clear', | ||
opened: false, | ||
value: '', | ||
}, | ||
}; |
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
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