add color picker state and changing color of avatar

This commit is contained in:
Ivana Andersson 2023-08-25 11:56:56 +03:00
parent 14df1b1d90
commit db5ad33b0e
2 changed files with 13 additions and 7 deletions

View File

@ -1,10 +1,12 @@
import { useState } from 'react'
import { XStack } from 'tamagui' import { XStack } from 'tamagui'
import { CustomPicker } from 'react-color' import { CustomPicker } from 'react-color'
import './ColorPicker.css' import './ColorPicker.css'
const ColorPicker = () => { type ColorPickerProps = {
const [chosenColor, setChosenColor] = useState('#2A4AF5') setChosenColor: (a: string) => void
}
const ColorPicker = ({ setChosenColor }: ColorPickerProps) => {
const colors = [ const colors = [
'#2A4AF5', '#2A4AF5',
'#F6B03C', '#F6B03C',
@ -27,7 +29,7 @@ const ColorPicker = () => {
key={i} key={i}
type="button" type="button"
className="color-picker-button" className="color-picker-button"
onClick={_e => setChosenColor(color)} onClick={() => setChosenColor(color)}
style={{ background: color, color: color }} style={{ background: color, color: color }}
></button> ></button>
))} ))}

View File

@ -2,11 +2,13 @@ import { useState } from 'react'
import { XStack, YStack } from 'tamagui' import { XStack, YStack } from 'tamagui'
import { Avatar, Text } from '@status-im/components' import { Avatar, Text } from '@status-im/components'
import { ReactionIcon } from '@status-im/icons' import { ReactionIcon } from '@status-im/icons'
import './CreateAvatar.css'
import LabelInputField from '../LabelInputField' import LabelInputField from '../LabelInputField'
import ColorPicker from '../ColorPicker/ColorPicker' import ColorPicker from '../ColorPicker/ColorPicker'
import EmojiPickerDialog from '../EmojiPickerDialog' import EmojiPickerDialog from '../EmojiPickerDialog'
const CreateAvatar = () => { const CreateAvatar = () => {
const [chosenColor, setChosenColor] = useState('#2A4AF5')
const [isEmojiDialogOpen, setIsEmojiDialogOpen] = useState(false) const [isEmojiDialogOpen, setIsEmojiDialogOpen] = useState(false)
return ( return (
<YStack my={16}> <YStack my={16}>
@ -14,12 +16,14 @@ const CreateAvatar = () => {
<LabelInputField labelText="Device Name" placeholderText="Stake and chips" /> <LabelInputField labelText="Device Name" placeholderText="Stake and chips" />
</XStack> </XStack>
<XStack my={10} justifyContent={'space-between'}> <XStack my={10} justifyContent={'space-between'}>
<YStack mr={30}> <YStack mr={60}>
<Text size={13} weight="regular" color={'#647084'}> <Text size={13} weight="regular" color={'#647084'}>
Device Avatar Device Avatar
</Text> </Text>
<XStack my={10} alignItems={'end'}> <XStack my={10} alignItems={'end'}>
<Avatar type="user" size={80} name="Device Avatar" /> <div className="device-avatar" style={{ background: chosenColor }}>
<img src="./icons/nodes-app-icon.png" alt="" />
</div>
<Avatar <Avatar
type="icon" type="icon"
size={32} size={32}
@ -38,7 +42,7 @@ const CreateAvatar = () => {
<Text size={13} weight="regular" color={'#647084'}> <Text size={13} weight="regular" color={'#647084'}>
Highlight Color Highlight Color
</Text> </Text>
<ColorPicker /> <ColorPicker setChosenColor={setChosenColor} />
</YStack> </YStack>
</XStack> </XStack>
</YStack> </YStack>