-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Radix base and topnav Co-authored-by: Guy Langford-Lee <guy@growthbook.io> Co-authored-by: Jeremy Dorn <jeremy@jeremydorn.com>
- Loading branch information
1 parent
11aced8
commit 36691d5
Showing
19 changed files
with
1,275 additions
and
274 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
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,28 +1,39 @@ | ||
import { FC } from "react"; | ||
import md5 from "md5"; | ||
import clsx from "clsx"; | ||
import { violet } from "@radix-ui/colors"; | ||
|
||
const Avatar: FC<{ | ||
email: string; | ||
name: string; | ||
size?: number; | ||
className?: string; | ||
name?: string; | ||
}> = ({ email, size = 40, className, name }) => { | ||
const hash = md5(email?.trim()?.toLowerCase() || ""); | ||
const url = `https://www.gravatar.com/avatar/${hash}?d=identicon&s=${size}`; | ||
|
||
const firstNameLetter = name?.charAt(0) || email.charAt(0); | ||
const lastNameLetter = name?.split(" ")[1]?.charAt(0); | ||
const title = name ? `${name} <${email}>` : email; | ||
|
||
const copy = | ||
name.toLowerCase() === "api" | ||
? name.toUpperCase() | ||
: `${firstNameLetter.toUpperCase()}${lastNameLetter?.toUpperCase()}`; | ||
return ( | ||
<img | ||
className={clsx("border rounded-circle", className)} | ||
src={url} | ||
//round avatar with initals in the middle | ||
<div | ||
className={clsx( | ||
"align-items-center justify-content-center border rounded-circle d-flex", | ||
className | ||
)} | ||
title={title} | ||
style={{ | ||
width: size + 2, | ||
height: size + 2, | ||
height: size, | ||
width: size, | ||
backgroundColor: violet?.violet3, | ||
color: violet?.violet11, | ||
fontSize: size / 2.7, | ||
fontWeight: 600, | ||
}} | ||
/> | ||
> | ||
{copy} | ||
</div> | ||
); | ||
}; | ||
export default Avatar; |
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
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
Oops, something went wrong.
36691d5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for docs ready!
✅ Preview
https://docs-mo72zasob-growthbook.vercel.app
Built with commit 36691d5.
This pull request is being automatically deployed with vercel-action