Skip to content

Commit bae5c4e

Browse files
committed
chore: improve author box rendering
1 parent 6c9f52e commit bae5c4e

File tree

2 files changed

+32
-47
lines changed

2 files changed

+32
-47
lines changed
Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
11
import { RelativeTimeWithTooltip } from '../RelativeTimeWithTooltip';
22
import { UserLink } from '../Links';
33
import { useUserInfo } from '../../hooks/useEntityAuthor';
4-
import { Avatar, Box, Grid, makeStyles, Typography } from '@material-ui/core';
4+
import { Avatar, Box, makeStyles, Typography } from '@material-ui/core';
55
import { ExpertIcon } from '../Icons/ExpertIcon.tsx';
66

77
const useStyles = makeStyles(
88
theme => ({
99
authorBox: {
1010
padding: theme.spacing(0, 1.5, 0, 0),
1111
textAlign: 'right',
12-
width: 220,
13-
background: theme.palette.background.paper,
14-
borderRadius: theme.shape.borderRadius,
1512
display: 'flex',
1613
flexDirection: 'column',
17-
justifyContent: 'flex-start',
1814
gap: theme.spacing(0.5),
15+
marginLeft: theme.spacing(2),
16+
maxWidth: '200px',
1917
},
20-
authorRow: {
18+
timeRow: {
2119
display: 'flex',
2220
alignItems: 'center',
23-
width: '100%',
24-
marginTop: theme.spacing(0.5),
25-
marginBottom: theme.spacing(0.5),
2621
},
2722
avatar: {
28-
width: theme.spacing(3),
29-
height: theme.spacing(3),
30-
marginRight: theme.spacing(1),
23+
width: '20px',
24+
height: '20px',
3125
},
32-
authorLink: {
26+
authorInfo: {
3327
textOverflow: 'ellipsis',
3428
overflow: 'hidden',
3529
whiteSpace: 'nowrap',
36-
fontWeight: 600,
3730
color: theme.palette.text.primary,
3831
display: 'flex',
3932
alignItems: 'center',
4033
gap: theme.spacing(0.5),
4134
},
35+
authorLink: {
36+
textOverflow: 'ellipsis',
37+
overflow: 'hidden',
38+
whiteSpace: 'nowrap',
39+
color: theme.palette.text.primary,
40+
},
4241
expertIcon: {
4342
marginLeft: theme.spacing(0.5),
4443
verticalAlign: 'middle',
@@ -65,39 +64,25 @@ export const AuthorBox = (props: {
6564

6665
return (
6766
<Box className={`qetaAuthorBox ${styles.authorBox}`}>
68-
<Grid container alignItems="center" justifyContent="flex-end" spacing={0}>
69-
<Grid item xs={12} style={{ paddingBottom: 0 }}>
70-
<Typography className="qetaAuthorBoxCreated" variant="caption">
71-
{label} <RelativeTimeWithTooltip value={time} />
72-
</Typography>
73-
</Grid>
74-
75-
<Grid item style={{ paddingTop: 0 }}>
76-
<Avatar
77-
src={user?.spec?.profile?.picture}
78-
className="qetaAuthorBoxAvatar avatar"
79-
alt={name}
80-
variant="rounded"
81-
style={{ width: '1.2em', height: '1.2em' }}
82-
>
83-
{initials}
84-
</Avatar>
85-
</Grid>
86-
<Grid
87-
item
88-
style={{
89-
paddingTop: 0,
90-
textOverflow: 'ellipsis',
91-
overflow: 'hidden',
92-
whiteSpace: 'nowrap',
93-
}}
67+
<Box className={styles.timeRow}>
68+
<Typography className="qetaAuthorBoxCreated" variant="caption">
69+
{label} <RelativeTimeWithTooltip value={time} />
70+
</Typography>
71+
</Box>
72+
<Box className={styles.authorInfo}>
73+
<Avatar
74+
src={user?.spec?.profile?.picture}
75+
className={`qetaAuthorBoxAvatar ${styles.avatar}`}
76+
alt={name}
77+
variant="rounded"
9478
>
95-
<Box style={{ paddingLeft: '0.3em' }}>
96-
<UserLink entityRef={userEntityRef} anonymous={anonymous} />
97-
{expert && <ExpertIcon />}
98-
</Box>
99-
</Grid>
100-
</Grid>
79+
{initials}
80+
</Avatar>
81+
<Box className={styles.authorLink}>
82+
<UserLink entityRef={userEntityRef} anonymous={anonymous} />
83+
{expert && <ExpertIcon className={styles.expertIcon} />}
84+
</Box>
85+
</Box>
10186
</Box>
10287
);
10388
};

plugins/qeta-react/src/components/TagsAndEntities/UserChip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const UserTooltip = (props: {
4343
src={user?.spec?.profile?.picture}
4444
alt={name}
4545
variant="rounded"
46-
style={{ width: '0.9em', height: '0.9em' }}
46+
style={{ width: '20px', height: '20px' }}
4747
>
4848
{initials}
4949
</Avatar>

0 commit comments

Comments
 (0)