Update Avatar component (#385)

* revert text changes

* check 'none'

* rm cloneElement

* use 'none' as val
This commit is contained in:
Felicio Mununga 2023-04-26 12:04:07 +02:00 committed by GitHub
parent 1df8c16091
commit 0b6badac48
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
2 changed files with 10 additions and 15 deletions

View File

@ -203,16 +203,10 @@ const Avatar = (props: AvatarProps) => {
<Fallback borderRadius={radius} backgroundColor={backgroundColor}>
{/* todo?: contrasting color to background */}
{props.type === 'group' ? (
cloneElement(
<MembersIcon
size={
groupMembersIconSizes[props.size] as IconProps['size']
}
/>,
{
color: '$white-100',
}
)
<MembersIcon
size={groupMembersIconSizes[props.size] as IconProps['size']}
color="$white-100"
/>
) : (
<Text
size={textSizes[props.size]}
@ -285,13 +279,15 @@ const Avatar = (props: AvatarProps) => {
const renderBadge = () => {
switch (props.type) {
case 'user': {
if (!props.indicator) {
const { indicator = 'none', size } = props
if (!indicator || indicator === 'none') {
return
}
return (
<Unspaced>
<Indicator size={props.size} state={props.indicator} />
<Indicator size={size} state={indicator} />
</Unspaced>
)
}

View File

@ -12,7 +12,6 @@ type Weight = NonNullable<Variants['weight']>
type Props = {
children: React.ReactNode
size?: 27 | 19 | 15 | 13 | 11 | undefined
color?: ColorTokens
truncate?: boolean
wrap?: false
@ -27,8 +26,8 @@ type Props = {
// TODO: monospace should be used only for variant. Extract to separate <Address> component?
// TODO: Ubuntu Mono should be used only for code snippets. Extract to separate <Code> component?
const Text = (props: Props, ref: Ref<RNText>) => {
const { color = '$neutral-100', size = 13, ...rest } = props
return <Base {...rest} ref={ref} color={color} size={size} />
const { color = '$neutral-100', ...rest } = props
return <Base {...rest} ref={ref} color={color} />
}
const Base = styled(BaseText, {