Skip to content

Commit 43bce63

Browse files
authored
Merge branch 'master' into feature/criteria
2 parents 363713a + 60899c8 commit 43bce63

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

hwproj.front/package-lock.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hwproj.front/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"@types/remarkable": "^1.7.4",
2727
"@uiw/react-markdown-preview": "4.2.2",
2828
"@uiw/react-md-editor": "3.25.6",
29+
"avatarka": "^1.0.1",
30+
"avatarka-react": "^1.0.1",
2931
"axios": "^0.30.2",
3032
"bootstrap": "^4.3.1",
3133
"classnames": "^2.3.1",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {AccountDataDto} from "@/api";
2+
import {FC} from "react";
3+
import AvatarUtils from "@/components/Utils/AvatarUtils";
4+
import {Avatar} from "@mui/material";
5+
import {Avatar as Avatarka, generateParams, getThemeNames} from 'avatarka-react';
6+
7+
const themes = getThemeNames().filter(x => x !== "geometric")
8+
9+
export const UserAvatar: FC<{ user: AccountDataDto }> = ({user}) => {
10+
if (user.githubId) return <Avatar {...AvatarUtils.stringAvatar(user)}/>
11+
12+
const hash = [...user.userId!].reduce((h, c) => Math.imul(h, 31) + c.charCodeAt(0) | 0, 0) >>> 0
13+
const index = hash % themes.length
14+
const theme = themes[index]
15+
const params = generateParams(theme, user.userId);
16+
return <Avatarka params={{...params, backgroundShape: "circle"}} theme={theme} size={40}/>;
17+
}

hwproj.front/src/components/Solutions/TaskSolutionComponent.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
CriterionViewModel
1414
} from '@/api'
1515
import ApiSingleton from "../../api/ApiSingleton";
16-
import { Alert, Avatar, Rating, Stack, Tooltip, Card, CardContent, CardActions, IconButton, Chip, Box } from "@mui/material";
16+
import { Alert, Avatar, Rating, Stack, Tooltip, Card, CardContent, CardActions, IconButton, Chip, Box, } from "@mui/material";
1717
import AvatarUtils from "../Utils/AvatarUtils";
1818
import Utils from "../../services/Utils";
1919
import {RatingStorage} from "../Storages/RatingStorage";
@@ -30,6 +30,7 @@ import KeyboardCommandKeyIcon from '@mui/icons-material/KeyboardCommandKey';
3030
import MouseOutlinedIcon from '@mui/icons-material/MouseOutlined';
3131
import BlurOnIcon from '@mui/icons-material/BlurOn';
3232
import BlurOffIcon from '@mui/icons-material/BlurOff';
33+
import {UserAvatar} from "../Common/UserAvatar";
3334

3435
type Criterion = CriterionViewModel;
3536

@@ -1056,7 +1057,7 @@ const TaskSolutionComponent: FC<ISolutionProps> = (props) => {
10561057
alignItems={students.length === 1 ? "center" : "normal"} spacing={1}>
10571058
<Stack direction={"row"} spacing={1}>
10581059
{students && students.map(t => <Tooltip title={t.surname + " " + t.name}>
1059-
<Avatar {...AvatarUtils.stringAvatar(t)} />
1060+
<span><UserAvatar user={t} key={t.userId}/></span>
10601061
</Tooltip>)}
10611062
</Stack>
10621063
<Grid item spacing={1} container direction="column">

hwproj.front/src/components/Utils/AvatarUtils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AccountDataDto} from "../../api";
1+
import {AccountDataDto} from "@/api";
22

33
export default class AvatarUtils {
44

0 commit comments

Comments
 (0)