@@ -8,6 +8,7 @@ export const userProfileVariants = cva('flex flex-row items-center', {
88 variants : {
99 size : {
1010 l : 'h-[48px] gap-2' ,
11+ '40' : 'h-[40px] gap-2' ,
1112 m : 'h-[32px] gap-2' ,
1213 s : 'h-[24px] gap-1.5' ,
1314 } ,
@@ -21,6 +22,7 @@ export const userProfileTextVariants = cva('text-gray-100', {
2122 variants : {
2223 size : {
2324 l : 'text-[16px]' ,
25+ '40' : 'text-[14px]' ,
2426 m : 'text-[14px]' ,
2527 s : 'text-[12px]' ,
2628 } ,
@@ -34,6 +36,11 @@ export const userProfileTextVariants = cva('text-gray-100', {
3436 size : 'l' ,
3537 class : 'bg-gray-10 h-[16px] w-[96px] animate-pulse rounded-[2px]' ,
3638 } ,
39+ {
40+ loading : true ,
41+ size : '40' ,
42+ class : 'bg-gray-10 h-[14px] w-[96px] animate-pulse rounded-[2px]' ,
43+ } ,
3744 {
3845 loading : true ,
3946 size : 'm' ,
@@ -55,6 +62,7 @@ export const userProfileLabelVariants = cva('font-normal text-gray-60 mt-[-2px]'
5562 variants : {
5663 size : {
5764 l : 'text-[12px]' ,
65+ '40' : 'text-[11px]' ,
5866 m : 'text-[10px]' ,
5967 s : '' ,
6068 } ,
@@ -68,6 +76,11 @@ export const userProfileLabelVariants = cva('font-normal text-gray-60 mt-[-2px]'
6876 size : 'l' ,
6977 class : 'bg-gray-10 h-[12px] w-[64px] animate-pulse rounded-[2px]' ,
7078 } ,
79+ {
80+ loading : true ,
81+ size : '40' ,
82+ class : 'bg-gray-10 h-[11px] w-[64px] animate-pulse rounded-[2px]' ,
83+ } ,
7184 {
7285 loading : true ,
7386 size : 'm' ,
@@ -89,6 +102,7 @@ export const avatarVariants = cva('flex items-center justify-center font-semibol
89102 xxl : 'h-[128px] w-[128px] min-h-[128px] min-w-[128px] rounded-[64px] text-[48px]' ,
90103 xl : 'h-[64px] w-[64px] min-h-[64px] min-w-[64px] rounded-[32px] text-[24px]' ,
91104 l : 'h-[48px] w-[48px] min-h-[48px] min-w-[48px] rounded-[24px] text-[16px]' ,
105+ '40' : 'h-[40px] w-[40px] min-h-[40px] min-w-[40px] rounded-[20px] text-[14px]' ,
92106 m : 'h-[32px] w-[32px] min-h-[32px] min-w-[32px] rounded-[16px] text-[12px]' ,
93107 s : 'h-[24px] w-[24px] min-h-[24px] min-w-[24px] rounded-[12px] text-[10px]' ,
94108 } ,
@@ -100,7 +114,7 @@ export const avatarVariants = cva('flex items-center justify-center font-semibol
100114} ) ;
101115
102116export interface UserProfileProps extends React . HTMLAttributes < HTMLDivElement > {
103- size ?: 'l' | 'm' | 's' ;
117+ size ?: 'l' | '40' | ' m' | 's' ;
104118 src ?: string ;
105119 userId : number | null ;
106120 color ?: 'brand' ;
@@ -127,7 +141,15 @@ export const UserProfile = ({
127141 ...props
128142} : UserProfileProps ) => {
129143 return (
130- < div className = { cn ( userProfileVariants ( { size } ) , className ) } { ...props } >
144+ < div
145+ className = { cn (
146+ userProfileVariants ( { size } ) ,
147+ withOutText && 'gap-0' ,
148+ 'transition-[gap] duration-200 ease-linear' ,
149+ className ,
150+ ) }
151+ { ...props }
152+ >
131153 < Avatar size = { size } >
132154 < AvatarImage
133155 src = { src || `https://api.sovlium.ru/files/users/${ userId } /avatar.webp` }
@@ -139,18 +161,35 @@ export const UserProfile = ({
139161 < AvatarFallback size = { size } > { text [ 0 ] . toUpperCase ( ) } </ AvatarFallback >
140162 ) }
141163 </ Avatar >
142- { ! withOutText && (
143- < div className = { `flex flex-col ${ loading && 'gap-1' } ` } >
144- < span className = { cn ( userProfileTextVariants ( { size, loading } ) , classNameText ) } >
164+ < div
165+ className = { cn (
166+ 'min-w-0 overflow-hidden transition-[max-width,opacity] duration-200 ease-linear' ,
167+ withOutText ? 'max-w-0 opacity-0' : 'max-w-[16rem] opacity-100' ,
168+ ) }
169+ >
170+ < div className = { `flex min-w-0 flex-col overflow-hidden ${ loading && 'gap-1' } ` } >
171+ < span
172+ className = { cn (
173+ 'truncate whitespace-nowrap' ,
174+ userProfileTextVariants ( { size, loading } ) ,
175+ classNameText ,
176+ ) }
177+ >
145178 { ! loading && text }
146179 </ span >
147180 { size !== 's' && (
148- < span className = { cn ( userProfileLabelVariants ( { size, loading } ) , classNameLabel ) } >
181+ < span
182+ className = { cn (
183+ 'truncate whitespace-nowrap' ,
184+ userProfileLabelVariants ( { size, loading } ) ,
185+ classNameLabel ,
186+ ) }
187+ >
149188 { ! loading && label }
150189 </ span >
151190 ) }
152191 </ div >
153- ) }
192+ </ div >
154193 </ div >
155194 ) ;
156195} ;
0 commit comments