-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove Jazzicons & Add default pfps (#2233)
remove Jazzicons update pfps
- Loading branch information
1 parent
5f477e0
commit 86f4466
Showing
6 changed files
with
64 additions
and
60 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
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,35 +1,42 @@ | ||
import React, { useRef, useEffect } from "react"; | ||
import JAZZ from "@metamask/jazzicon"; | ||
import React, { memo } from "react"; | ||
import usePfp from "../../hooks/usePfp"; | ||
import UserDefaultPfp from "./user.svg"; | ||
import WorkspaceDefaultPfp from "./workspace.svg"; | ||
|
||
export default function UserIcon({ size = 36, user, role }) { | ||
const UserIcon = memo(({ role }) => { | ||
const { pfp } = usePfp(); | ||
const divRef = useRef(null); | ||
const seed = user?.uid | ||
? toPseudoRandomInteger(user.uid) | ||
: Math.floor(100000 + Math.random() * 900000); | ||
|
||
useEffect(() => { | ||
if (!divRef.current || (role === "user" && pfp)) return; | ||
|
||
const result = JAZZ(size, seed); | ||
divRef.current.appendChild(result); | ||
}, [pfp, role, seed, size]); | ||
|
||
return ( | ||
<div className="relative w-[35px] h-[35px] rounded-full flex-shrink-0 overflow-hidden"> | ||
<div ref={divRef} /> | ||
{role === "user" && pfp && ( | ||
{role === "user" && <RenderUserPfp pfp={pfp} />} | ||
{role !== "user" && ( | ||
<img | ||
src={pfp} | ||
alt="User profile picture" | ||
className="absolute top-0 left-0 w-full h-full object-cover rounded-full bg-white" | ||
src={WorkspaceDefaultPfp} | ||
alt="system profile picture" | ||
className="flex items-center justify-center rounded-full border border-white/40" | ||
/> | ||
)} | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
function RenderUserPfp({ pfp }) { | ||
if (!pfp) | ||
return ( | ||
<img | ||
src={UserDefaultPfp} | ||
alt="User profile picture" | ||
className="rounded-full border-none" | ||
/> | ||
); | ||
|
||
function toPseudoRandomInteger(uidString = "") { | ||
return uidString.split("").reduce((acc, char) => acc + char.charCodeAt(0), 0); | ||
return ( | ||
<img | ||
src={pfp} | ||
alt="User profile picture" | ||
className="absolute top-0 left-0 w-full h-full object-cover rounded-full border-none" | ||
/> | ||
); | ||
} | ||
|
||
export default UserIcon; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -483,14 +483,6 @@ | |
"@jridgewell/resolve-uri" "^3.1.0" | ||
"@jridgewell/sourcemap-codec" "^1.4.14" | ||
|
||
"@metamask/jazzicon@^2.0.0": | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/@metamask/jazzicon/-/jazzicon-2.0.0.tgz#5615528e91c0fc5c9d79202d1f0954a7922525a0" | ||
integrity sha512-7M+WSZWKcQAo0LEhErKf1z+D3YX0tEDAcGvcKbDyvDg34uvgeKR00mFNIYwAhdAS9t8YXxhxZgsrRBBg6X8UQg== | ||
dependencies: | ||
color "^0.11.3" | ||
mersenne-twister "^1.1.0" | ||
|
||
"@microsoft/fetch-event-source@^2.0.1": | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/@microsoft/fetch-event-source/-/fetch-event-source-2.0.1.tgz#9ceecc94b49fbaa15666e38ae8587f64acce007d" | ||
|
@@ -1097,11 +1089,6 @@ cliui@^8.0.1: | |
strip-ansi "^6.0.1" | ||
wrap-ansi "^7.0.0" | ||
|
||
clone@^1.0.2: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" | ||
integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg== | ||
|
||
clsx@^1.1.1: | ||
version "1.2.1" | ||
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.2.1.tgz#0ddc4a20a549b59c93a4116bb26f5294ca17dc12" | ||
|
@@ -1112,7 +1099,7 @@ clsx@^2.0.0: | |
resolved "https://registry.yarnpkg.com/clsx/-/clsx-2.1.1.tgz#eed397c9fd8bd882bfb18deab7102049a2f32999" | ||
integrity sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA== | ||
|
||
color-convert@^1.3.0, color-convert@^1.9.0: | ||
color-convert@^1.9.0: | ||
version "1.9.3" | ||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" | ||
integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== | ||
|
@@ -1131,27 +1118,11 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" | ||
integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== | ||
|
||
color-name@^1.0.0, color-name@~1.1.4: | ||
color-name@~1.1.4: | ||
version "1.1.4" | ||
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" | ||
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== | ||
|
||
color-string@^0.3.0: | ||
version "0.3.0" | ||
resolved "https://registry.yarnpkg.com/color-string/-/color-string-0.3.0.tgz#27d46fb67025c5c2fa25993bfbf579e47841b991" | ||
integrity sha512-sz29j1bmSDfoAxKIEU6zwoIZXN6BrFbAMIhfYCNyiZXBDuU/aiHlN84lp/xDzL2ubyFhLDobHIlU1X70XRrMDA== | ||
dependencies: | ||
color-name "^1.0.0" | ||
|
||
color@^0.11.3: | ||
version "0.11.4" | ||
resolved "https://registry.yarnpkg.com/color/-/color-0.11.4.tgz#6d7b5c74fb65e841cd48792ad1ed5e07b904d764" | ||
integrity sha512-Ajpjd8asqZ6EdxQeqGzU5WBhhTfJ/0cA4Wlbre7e5vXfmDSmda7Ov6jeKoru+b0vHcb1CqvuroTHp5zIWzhVMA== | ||
dependencies: | ||
clone "^1.0.2" | ||
color-convert "^1.3.0" | ||
color-string "^0.3.0" | ||
|
||
commander@^4.0.0: | ||
version "4.1.1" | ||
resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" | ||
|
@@ -2545,11 +2516,6 @@ merge2@^1.3.0: | |
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" | ||
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== | ||
|
||
mersenne-twister@^1.1.0: | ||
version "1.1.0" | ||
resolved "https://registry.yarnpkg.com/mersenne-twister/-/mersenne-twister-1.1.0.tgz#f916618ee43d7179efcf641bec4531eb9670978a" | ||
integrity sha512-mUYWsMKNrm4lfygPkL3OfGzOPTR2DBlTkBNHM//F6hGp8cLThY897crAlk3/Jo17LEOOjQUrNAx6DvgO77QJkA== | ||
|
||
micromatch@^4.0.4, micromatch@^4.0.5: | ||
version "4.0.7" | ||
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.7.tgz#33e8190d9fe474a9895525f5618eee136d46c2e5" | ||
|