diff --git a/src/components/User/User.tsx b/src/components/User/User.tsx index 27494bc83..ac093ec99 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 91ec59451..becc6aa2c 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 b2563fe15..c4efa01a1 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';