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 SearchInput from './SearchInput'
const meta = {
@ -14,6 +14,12 @@ const meta = {
export default meta
type Story = StoryObj<typeof meta>
export const Default: Story = {
args: { value: 'Search value' },
export const Default: Story = (args: { value: string }) => {
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 handleClick = () => setIsSelected(!isSelected)
const backgroundColor = isSelected || isHovered ? 'rgba(42, 74, 245, 0.05)' : 'transparent'
return (
<XStack
onMouseEnter={handleMouseEnter}
@ -38,7 +36,7 @@ const ValidatorListItem = ({
style={{
padding: '6px 8px',
borderRadius: '12px',
backgroundColor,
backgroundColor: (isSelected || isHovered) && 'rgba(42, 74, 245, 0.05)',
cursor: 'pointer',
}}
width="92%"