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

View File

@ -2,11 +2,13 @@ import { useState } from 'react'
import { XStack, YStack } from 'tamagui'
import { Avatar, Text } from '@status-im/components'
import { ReactionIcon } from '@status-im/icons'
import './CreateAvatar.css'
import LabelInputField from '../LabelInputField'
import ColorPicker from '../ColorPicker/ColorPicker'
import EmojiPickerDialog from '../EmojiPickerDialog'
const CreateAvatar = () => {
const [chosenColor, setChosenColor] = useState('#2A4AF5')
const [isEmojiDialogOpen, setIsEmojiDialogOpen] = useState(false)
return (
<YStack my={16}>
@ -14,12 +16,14 @@ const CreateAvatar = () => {
<LabelInputField labelText="Device Name" placeholderText="Stake and chips" />
</XStack>
<XStack my={10} justifyContent={'space-between'}>
<YStack mr={30}>
<YStack mr={60}>
<Text size={13} weight="regular" color={'#647084'}>
Device Avatar
</Text>
<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
type="icon"
size={32}
@ -38,7 +42,7 @@ const CreateAvatar = () => {
<Text size={13} weight="regular" color={'#647084'}>
Highlight Color
</Text>
<ColorPicker />
<ColorPicker setChosenColor={setChosenColor} />
</YStack>
</XStack>
</YStack>