Skip to content

Commit

Permalink
Merge pull request #1607 from decentdao/update-blockie-avatar
Browse files Browse the repository at this point in the history
Update deterministic avatar generation library
  • Loading branch information
adamgall authored Apr 26, 2024
2 parents 00e880b + 0a1305e commit a3aa7ea
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 71 deletions.
74 changes: 9 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
"@shutter-network/shutter-crypto": "^1.0.1",
"@snapshot-labs/snapshot.js": "^0.7.3",
"@tanstack/react-query": "^5.28.4",
"@ukstv/jazzicon-react": "^1.0.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"@web3modal/wagmi": "^4.1.1",
"axios": "^0.27.2",
"blo": "^1.2.0",
"classnames": "^2.3.1",
"date-fns": "^2.29.3",
"date-fns-tz": "^2.0.1",
Expand Down
15 changes: 10 additions & 5 deletions src/components/ui/page/Header/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Box, Image } from '@chakra-ui/react';
import { Jazzicon } from '@ukstv/jazzicon-react';
import { blo } from 'blo';
import { Suspense } from 'react';
import { useImage } from 'react-image';
import { getAddress } from 'viem';

type AvatarSize = 'icon' | 'lg' | 'sm';
const avatarSizes: { [size: string]: string } = {
Expand All @@ -10,13 +11,17 @@ const avatarSizes: { [size: string]: string } = {
lg: '2rem',
};

function JazziconAvatar({ address, size }: { size: AvatarSize; address: string }) {
function BlockieAvatar({ address, size }: { size: AvatarSize; address: string }) {
return (
<Box
h={avatarSizes[size]}
w={avatarSizes[size]}
>
<Jazzicon address={address} />
<Image
borderRadius="full"
src={blo(getAddress(address))}
alt={address}
/>
</Box>
);
}
Expand Down Expand Up @@ -48,7 +53,7 @@ function Avatar({
}) {
if (!url) {
return (
<JazziconAvatar
<BlockieAvatar
size={size}
address={address}
/>
Expand All @@ -58,7 +63,7 @@ function Avatar({
return (
<Suspense
fallback={
<JazziconAvatar
<BlockieAvatar
size={size}
address={address}
/>
Expand Down

0 comments on commit a3aa7ea

Please sign in to comment.