diff --git a/src/components/User/User.tsx b/src/components/User/User.tsx index 27494bc830..ac093ec999 100644 --- a/src/components/User/User.tsx +++ b/src/components/User/User.tsx @@ -3,18 +3,13 @@ import React from 'react'; import {Avatar} from '../Avatar'; import {block} from '../utils/cn'; -import {COMPACT_SIZES, DEFAULT_SIZE} from './constants'; +import {COMPACT_SIZES, DEFAULT_SIZE, UserQa} from './constants'; import type {UserProps} from './types'; import './User.scss'; const b = block('user'); -export const UserQa = { - NAME: 'user-name', - DESCRIPTION: 'user-description', -}; - export const User = React.forwardRef( ( { @@ -30,7 +25,10 @@ export const User = React.forwardRef( }, ref, ) => { - const showDescription = Boolean(description && !COMPACT_SIZES.includes(size)); + const showDescription = Boolean(description && !COMPACT_SIZES.has(size)); + + const nameTitle = typeof name === 'string' ? name : undefined; + const descriptionTitle = typeof description === 'string' ? description : undefined; return (
( > {avatar ? (
- {React.isValidElement(avatar) ? avatar : } + {React.isValidElement(avatar) ? ( + avatar + ) : ( + + )}
) : null} {name || showDescription ? (
{name ? ( - + {name} ) : null} {showDescription ? ( - + {description} ) : null} diff --git a/src/components/User/constants.ts b/src/components/User/constants.ts index 91ec59451f..becc6aa2ca 100644 --- a/src/components/User/constants.ts +++ b/src/components/User/constants.ts @@ -1,4 +1,9 @@ import type {UserSize} from './types'; -export const COMPACT_SIZES: UserSize[] = ['xs', '2xs']; +export const COMPACT_SIZES: Set = new Set(['xs', '2xs']); export const DEFAULT_SIZE: UserSize = 'm'; + +export const UserQa = { + NAME: 'user-name', + DESCRIPTION: 'user-description', +}; diff --git a/src/components/User/index.ts b/src/components/User/index.ts index b2563fe154..c4efa01a1b 100644 --- a/src/components/User/index.ts +++ b/src/components/User/index.ts @@ -1,2 +1,3 @@ export type {UserSize, UserProps} from './types'; +export {UserQa} from './constants'; export {User} from './User';