Add handler on each sidebar button
This commit is contained in:
parent
89ad2ecb73
commit
395f28219d
|
@ -1,40 +1,47 @@
|
||||||
import { IconButton } from '@status-im/components'
|
import { IconButton } from '@status-im/components'
|
||||||
|
import { useDispatch } from 'react-redux'
|
||||||
import { Stack } from 'tamagui'
|
import { Stack } from 'tamagui'
|
||||||
|
import { toggleButtonSelection } from '../../redux/Sidebars/slice'
|
||||||
|
|
||||||
type IconButtonWithDotProps = {
|
type IconButtonWithDotProps = {
|
||||||
iconEl: any
|
iconEl: any
|
||||||
variant: 'ghost' | 'outline'
|
variant: 'ghost' | 'outline'
|
||||||
isDotOn: boolean
|
isDotOn: boolean
|
||||||
selected?: boolean
|
selected?: boolean
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const IconButtonWithDot = ({
|
const IconButtonWithDot = ({
|
||||||
iconEl,
|
iconEl,
|
||||||
variant,
|
variant,
|
||||||
isDotOn,
|
isDotOn,
|
||||||
selected,
|
selected,
|
||||||
disabled,
|
disabled,
|
||||||
|
id
|
||||||
}: IconButtonWithDotProps) => {
|
}: IconButtonWithDotProps) => {
|
||||||
return (
|
const dispatch = useDispatch()
|
||||||
<Stack style={{ position: 'relative', display: 'inline-block' }}>
|
const onClickHandler = (id) => { if (!disabled) dispatch(toggleButtonSelection(id)) }
|
||||||
<IconButton icon={iconEl} variant={variant} selected={selected} disabled={disabled} />
|
|
||||||
{isDotOn && (
|
return (
|
||||||
<Stack
|
<Stack style={{ position: 'relative', display: 'inline-block' }}>
|
||||||
style={{
|
<IconButton icon={iconEl} variant={variant} selected={selected} disabled={disabled} onPress={() => onClickHandler(id)} />
|
||||||
position: 'absolute',
|
{isDotOn && (
|
||||||
right: 7,
|
<Stack
|
||||||
top: 5,
|
style={{
|
||||||
width: '9px',
|
position: 'absolute',
|
||||||
height: '9px',
|
right: 7,
|
||||||
borderRadius: '50%',
|
top: 5,
|
||||||
backgroundColor: '#1992D7',
|
width: '9px',
|
||||||
border: '1.5px solid #fff',
|
height: '9px',
|
||||||
}}
|
borderRadius: '50%',
|
||||||
/>
|
backgroundColor: '#1992D7',
|
||||||
)}
|
border: '1.5px solid #fff',
|
||||||
</Stack>
|
}}
|
||||||
)
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default IconButtonWithDot
|
export default IconButtonWithDot
|
||||||
|
|
Loading…
Reference in New Issue