generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #815 from amitamrutiya/update-cell
feat: add AuthorCell component and integrate it into CatalogDesignTable
- Loading branch information
Showing
4 changed files
with
80 additions
and
51 deletions.
There are no files selected for viewing
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,66 @@ | ||
import React from 'react'; | ||
import { Avatar, Box, Grid, Typography } from '../../base'; | ||
import { CLOUD_URL } from '../../constants/constants'; | ||
import { PersonIcon } from '../../icons'; | ||
import { CustomTooltip } from '../CustomTooltip'; | ||
|
||
interface AuthorCellProps { | ||
firstName: string; | ||
lastName: string; | ||
avatarUrl: string; | ||
userId: string; | ||
maxWidth?: boolean; | ||
} | ||
|
||
const AuthorCell: React.FC<AuthorCellProps> = ({ | ||
firstName, | ||
lastName, | ||
avatarUrl, | ||
userId, | ||
maxWidth = true | ||
}) => { | ||
const displayName = | ||
firstName && lastName | ||
? `${firstName} ${lastName}` | ||
: firstName | ||
? firstName | ||
: lastName | ||
? lastName | ||
: ''; | ||
|
||
return ( | ||
<Box sx={{ '& > img': { mr: 2, flexShrink: 0 } }}> | ||
<Grid | ||
container | ||
alignItems="center" | ||
style={maxWidth ? { width: 'max-content' } : { width: '' }} | ||
> | ||
<Grid item> | ||
<Box sx={{ color: 'text.secondary', mr: 1 }}> | ||
<CustomTooltip title={`View ${displayName}'s Profile`}> | ||
<div> | ||
<Avatar | ||
style={{ cursor: 'pointer' }} | ||
alt={displayName} | ||
src={avatarUrl} | ||
onClick={() => { | ||
window.open(`${CLOUD_URL}/user/${userId}`, '_blank'); | ||
}} | ||
> | ||
{!avatarUrl && <PersonIcon />} | ||
</Avatar> | ||
</div> | ||
</CustomTooltip> | ||
</Box> | ||
</Grid> | ||
{maxWidth && ( | ||
<Grid item> | ||
<Typography variant="body2">{displayName}</Typography> | ||
</Grid> | ||
)} | ||
</Grid> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default AuthorCell; |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import AuthorCell from './AuthorCell'; | ||
import CatalogDesignsTable from './CatalogDesignTable'; | ||
import { colViews, createDesignColumns } from './columnConfig'; | ||
export { TableVisibilityControl } from './TableVisibilityControl'; | ||
export { ViewSwitch } from './ViewSwitch'; | ||
export { CatalogDesignsTable, colViews, createDesignColumns }; | ||
export { AuthorCell, CatalogDesignsTable, colViews, createDesignColumns }; |