-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f9b2d1
commit e4a540e
Showing
17 changed files
with
226 additions
and
166 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { css } from '@rocket.chat/css-in-js'; | ||
import { Box, ActionButton, Skeleton } from '@rocket.chat/fuselage'; | ||
import React, { forwardRef, ReactNode, ComponentProps } from 'react'; | ||
|
||
import { useTranslation } from '../../contexts/TranslationContext'; | ||
import MarkdownText from '../MarkdownText'; | ||
import * as Status from '../UserStatus'; | ||
import UserAvatar from '../avatar/UserAvatar'; | ||
import UserCardContainer from './UserCardContainer'; | ||
import UserCardInfo from './UserCardInfo'; | ||
import UserCardRoles from './UserCardRoles'; | ||
import UserCardUsername from './UserCardUsername'; | ||
|
||
const clampStyle = css` | ||
display: -webkit-box; | ||
overflow: hidden; | ||
-webkit-line-clamp: 3; | ||
-webkit-box-orient: vertical; | ||
word-break: break-all; | ||
`; | ||
|
||
type UserCardProps = { | ||
className?: string; | ||
style?: ComponentProps<typeof Box>['style']; | ||
open?: () => void; | ||
name?: string; | ||
username?: string; | ||
etag?: string; | ||
customStatus?: ReactNode; | ||
roles?: ReactNode; | ||
bio?: ReactNode; | ||
status?: ReactNode; | ||
actions?: ReactNode; | ||
localTime?: ReactNode; | ||
onClose?: () => void; | ||
nickname?: string; | ||
}; | ||
|
||
const UserCard = forwardRef(function UserCard( | ||
{ | ||
className, | ||
style, | ||
open, | ||
name, | ||
username, | ||
etag, | ||
customStatus = <Skeleton width='100%' />, | ||
roles = ( | ||
<> | ||
<Skeleton width='32%' mi='x2' /> | ||
<Skeleton width='32%' mi='x2' /> | ||
<Skeleton width='32%' mi='x2' /> | ||
</> | ||
), | ||
bio = ( | ||
<> | ||
<Skeleton width='100%' /> | ||
<Skeleton width='100%' /> | ||
<Skeleton width='100%' /> | ||
</> | ||
), | ||
status = <Status.Offline />, | ||
actions, | ||
localTime = <Skeleton width='100%' />, | ||
onClose, | ||
nickname, | ||
}: UserCardProps, | ||
ref, | ||
) { | ||
const t = useTranslation(); | ||
|
||
return ( | ||
<UserCardContainer className={className} ref={ref} style={style}> | ||
<Box> | ||
{!username ? <Skeleton width='x124' height='x124' variant='rect' /> : <UserAvatar username={username} etag={etag} size='x124' />} | ||
{actions && ( | ||
<Box flexGrow={0} display='flex' mb='x12' alignItems='center' justifyContent='center'> | ||
{actions} | ||
</Box> | ||
)} | ||
</Box> | ||
<Box display='flex' flexDirection='column' flexGrow={1} flexShrink={1} mis='x24' width='1px'> | ||
<Box mbe='x4' withTruncatedText display='flex'> | ||
{!name ? <Skeleton width='100%' /> : <UserCardUsername status={status} name={name} />} | ||
{nickname && ( | ||
<Box flexGrow={1} flexShrink={1} flexBasis={0} title={t('Nickname')} color='hint' mis='x4' fontScale='p2' withTruncatedText> | ||
({nickname}) | ||
</Box> | ||
)} | ||
</Box> | ||
{customStatus && ( | ||
<UserCardInfo> | ||
{typeof customStatus === 'string' ? ( | ||
<MarkdownText withTruncatedText variant='inlineWithoutBreaks' content={customStatus} parseEmoji={true} /> | ||
) : ( | ||
customStatus | ||
)} | ||
</UserCardInfo> | ||
)} | ||
<UserCardRoles>{roles}</UserCardRoles> | ||
<UserCardInfo>{localTime}</UserCardInfo> | ||
{bio && ( | ||
<UserCardInfo withTruncatedText={false} className={clampStyle} height='x60'> | ||
{typeof bio === 'string' ? <MarkdownText variant='inline' content={bio} /> : bio} | ||
</UserCardInfo> | ||
)} | ||
{open && <a onClick={open}>{t('See_full_profile')}</a>} | ||
</Box> | ||
{onClose && ( | ||
<Box> | ||
<ActionButton small ghost title={t('Close')} icon='cross' onClick={onClose} /> | ||
</Box> | ||
)} | ||
</UserCardContainer> | ||
); | ||
}); | ||
|
||
export default UserCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ActionButton, Icon } from '@rocket.chat/fuselage'; | ||
import React, { ReactElement, ComponentProps } from 'react'; | ||
|
||
type UserCardActionProps = { | ||
label?: string; | ||
icon: ComponentProps<typeof Icon>['name']; | ||
}; | ||
|
||
const UserCardAction = ({ label, icon, ...props }: UserCardActionProps): ReactElement => ( | ||
<ActionButton icon={icon} small title={label} {...props} mi='x2' /> | ||
); | ||
|
||
export default UserCardAction; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import React, { forwardRef, ComponentProps } from 'react'; | ||
|
||
const UserCardContainer = forwardRef(function UserCardContainer(props: ComponentProps<typeof Box>, ref) { | ||
return <Box ref={ref} rcx-user-card bg='surface' elevation='2' p='x24' display='flex' borderRadius='x2' width='439px' {...props} />; | ||
}); | ||
|
||
export default UserCardContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import React, { ReactElement, ComponentProps } from 'react'; | ||
|
||
const UserCardInfo = (props: ComponentProps<typeof Box>): ReactElement => ( | ||
<Box mbe='x8' is='span' fontScale='p2' color='hint' withTruncatedText {...props} /> | ||
); | ||
|
||
export default UserCardInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Box, Tag } from '@rocket.chat/fuselage'; | ||
import React, { ReactNode, ReactElement } from 'react'; | ||
|
||
const UserCardRole = ({ children }: { children: ReactNode }): ReactElement => ( | ||
<Box m='x2' fontScale='c2'> | ||
<Tag disabled children={children} /> | ||
</Box> | ||
); | ||
|
||
export default UserCardRole; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import React, { ReactNode, ReactElement } from 'react'; | ||
|
||
import UserCardInfo from './UserCardInfo'; | ||
|
||
const UserCardRoles = ({ children }: { children: ReactNode }): ReactElement => ( | ||
<Box m='neg-x2'> | ||
<UserCardInfo flexWrap='wrap' display='flex' flexShrink={0}> | ||
{children} | ||
</UserCardInfo> | ||
</Box> | ||
); | ||
|
||
export default UserCardRoles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Box } from '@rocket.chat/fuselage'; | ||
import React, { ReactElement, ReactNode, ComponentProps } from 'react'; | ||
|
||
import * as UserStatus from '../UserStatus'; | ||
|
||
type UserCardUsernameProps = ComponentProps<typeof Box> & { | ||
name: ReactNode; | ||
status: ReactNode; | ||
}; | ||
|
||
const UserCardUsername = ({ name, status = <UserStatus.Offline />, ...props }: UserCardUsernameProps): ReactElement => ( | ||
<Box | ||
display='flex' | ||
title={name} | ||
flexGrow={2} | ||
flexShrink={1} | ||
flexBasis={0} | ||
alignItems='center' | ||
fontScale='h4' | ||
color='default' | ||
withTruncatedText | ||
{...props} | ||
> | ||
{status}{' '} | ||
<Box mis='x8' flexGrow={1} withTruncatedText> | ||
{name} | ||
</Box> | ||
</Box> | ||
); | ||
|
||
export default UserCardUsername; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.