feat: add state to search story

This commit is contained in:
RadoslavDimchev 2023-10-19 10:54:16 +03:00
parent 8999f91a85
commit a998a38adb
2 changed files with 10 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import { useState } from 'react'
import type { Meta, StoryObj } from '@storybook/react' import type { Meta, StoryObj } from '@storybook/react'
import SearchInput from './SearchInput' import SearchInput from './SearchInput'
const meta = { const meta = {
@ -14,6 +14,12 @@ const meta = {
export default meta export default meta
type Story = StoryObj<typeof meta> type Story = StoryObj<typeof meta>
export const Default: Story = { export const Default: Story = (args: { value: string }) => {
args: { value: 'Search value' }, const [searchValue, setSearchValue] = useState(args.value)
return <SearchInput value={searchValue} changeSearchValue={setSearchValue} />
}
Default.args = {
value: '',
} }

View File

@ -26,8 +26,6 @@ const ValidatorListItem = ({
const handleMouseLeave = () => setIsHovered(false) const handleMouseLeave = () => setIsHovered(false)
const handleClick = () => setIsSelected(!isSelected) const handleClick = () => setIsSelected(!isSelected)
const backgroundColor = isSelected || isHovered ? 'rgba(42, 74, 245, 0.05)' : 'transparent'
return ( return (
<XStack <XStack
onMouseEnter={handleMouseEnter} onMouseEnter={handleMouseEnter}
@ -38,7 +36,7 @@ const ValidatorListItem = ({
style={{ style={{
padding: '6px 8px', padding: '6px 8px',
borderRadius: '12px', borderRadius: '12px',
backgroundColor, backgroundColor: (isSelected || isHovered) && 'rgba(42, 74, 245, 0.05)',
cursor: 'pointer', cursor: 'pointer',
}} }}
width="92%" width="92%"