tweak avatars
This commit is contained in:
parent
f20db30062
commit
c8b8daeb29
@ -22,7 +22,7 @@ const ProxyImgComponent = forwardRef<HTMLImageElement, ProxyImgProps>(function P
|
|||||||
const { proxy } = useImgProxy();
|
const { proxy } = useImgProxy();
|
||||||
const [loadFailed, setLoadFailed] = useState(false);
|
const [loadFailed, setLoadFailed] = useState(false);
|
||||||
const [bypass, setBypass] = useState(CONFIG.media.bypassImgProxyError);
|
const [bypass, setBypass] = useState(CONFIG.media.bypassImgProxyError);
|
||||||
const [imgSrc, setImgSrc] = useState<string>(proxy(src, size, sha256));
|
const [imgSrc, setImgSrc] = useState<string | undefined>(src ? proxy(src, size, sha256) : undefined);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoadFailed(false);
|
setLoadFailed(false);
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
.avatar {
|
.avatar {
|
||||||
border-radius: 50%;
|
@apply rounded-full;
|
||||||
height: 210px;
|
height: 210px;
|
||||||
width: 210px;
|
width: 210px;
|
||||||
background-image: var(--img-url);
|
|
||||||
border: 1px solid transparent;
|
|
||||||
background-origin: border-box;
|
|
||||||
background-clip: content-box, border-box;
|
|
||||||
background-size: cover;
|
|
||||||
box-sizing: border-box;
|
|
||||||
background-position: center;
|
|
||||||
background-color: var(--gray);
|
background-color: var(--gray);
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,11 @@ const Avatar = ({
|
|||||||
className,
|
className,
|
||||||
showTitle = true,
|
showTitle = true,
|
||||||
}: AvatarProps) => {
|
}: AvatarProps) => {
|
||||||
|
const defaultImg = defaultAvatar(pubkey);
|
||||||
const url = useMemo(() => {
|
const url = useMemo(() => {
|
||||||
return image ?? user?.picture ?? defaultAvatar(pubkey);
|
if((image?.length ?? 0) > 0) return image;
|
||||||
|
if((user?.picture?.length ?? 0) > 0) return user?.picture;
|
||||||
|
return defaultImg;
|
||||||
}, [user, image, pubkey]);
|
}, [user, image, pubkey]);
|
||||||
|
|
||||||
const s = size ?? 120;
|
const s = size ?? 120;
|
||||||
@ -42,6 +45,7 @@ const Avatar = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const domain = user?.nip05 && user.nip05.split("@")[1];
|
const domain = user?.nip05 && user.nip05.split("@")[1];
|
||||||
|
const isDefault = url === defaultImg;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
@ -49,6 +53,7 @@ const Avatar = ({
|
|||||||
className={classNames(
|
className={classNames(
|
||||||
"avatar relative flex items-center justify-center",
|
"avatar relative flex items-center justify-center",
|
||||||
{ "with-overlay": imageOverlay },
|
{ "with-overlay": imageOverlay },
|
||||||
|
{ "outline outline-2 outline-nostr-purple m-[2px]": isDefault },
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
data-domain={domain?.toLowerCase()}
|
data-domain={domain?.toLowerCase()}
|
||||||
|
@ -15,6 +15,7 @@ import ProfileImage from "@/Components/User/ProfileImage";
|
|||||||
import ZapModal from "@/Components/ZapModal/ZapModal";
|
import ZapModal from "@/Components/ZapModal/ZapModal";
|
||||||
import { hexToBech32 } from "@/Utils";
|
import { hexToBech32 } from "@/Utils";
|
||||||
import { LoginSessionType, LoginStore } from "@/Utils/Login";
|
import { LoginSessionType, LoginStore } from "@/Utils/Login";
|
||||||
|
import { ZapTarget } from "@/Utils/Zapper";
|
||||||
|
|
||||||
const AvatarSection = ({
|
const AvatarSection = ({
|
||||||
user,
|
user,
|
||||||
@ -100,8 +101,8 @@ const AvatarSection = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="avatar-wrapper w-max">
|
<div className="flex justify-between w-full">
|
||||||
<Avatar pubkey={id ?? ""} user={user} onClick={() => setModalImage(user?.picture || "")} className="pointer" />
|
<Avatar pubkey={id ?? ""} user={user} onClick={() => setModalImage(user?.picture || "")} className="pointer" size={100} />
|
||||||
<div className="profile-actions">
|
<div className="profile-actions">
|
||||||
{renderButtons()}
|
{renderButtons()}
|
||||||
{!isMe && id && <FollowButton pubkey={id} />}
|
{!isMe && id && <FollowButton pubkey={id} />}
|
||||||
@ -111,14 +112,14 @@ const AvatarSection = ({
|
|||||||
targets={
|
targets={
|
||||||
lnurl?.lnurl && id
|
lnurl?.lnurl && id
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
type: "lnurl",
|
type: "lnurl",
|
||||||
value: lnurl?.lnurl,
|
value: lnurl.lnurl,
|
||||||
weight: 1,
|
weight: 1,
|
||||||
name: user?.display_name || user?.name,
|
name: user?.display_name || user?.name,
|
||||||
zap: { pubkey: id },
|
zap: { pubkey: id, anon: false }
|
||||||
},
|
} as ZapTarget,
|
||||||
]
|
]
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
show={showLnQr}
|
show={showLnQr}
|
||||||
|
@ -70,14 +70,14 @@ const ProfileDetails = ({
|
|||||||
targets={
|
targets={
|
||||||
lnurl?.lnurl && id
|
lnurl?.lnurl && id
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
type: "lnurl",
|
type: "lnurl",
|
||||||
value: lnurl?.lnurl,
|
value: lnurl?.lnurl,
|
||||||
weight: 1,
|
weight: 1,
|
||||||
name: user?.display_name || user?.name,
|
name: user?.display_name || user?.name,
|
||||||
zap: { pubkey: id },
|
zap: { pubkey: id, anon: false },
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
show={showLnQr}
|
show={showLnQr}
|
||||||
|
@ -66,19 +66,6 @@
|
|||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile-wrapper > .avatar-wrapper {
|
|
||||||
z-index: 1;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile-wrapper > .avatar-wrapper .avatar {
|
|
||||||
width: 100px;
|
|
||||||
height: 100px;
|
|
||||||
background-image: var(--img-url);
|
|
||||||
border: 3px solid #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.profile .name {
|
.profile .name {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable max-lines */
|
||||||
import * as utils from "@noble/curves/abstract/utils";
|
import * as utils from "@noble/curves/abstract/utils";
|
||||||
import * as secp from "@noble/curves/secp256k1";
|
import * as secp from "@noble/curves/secp256k1";
|
||||||
import { hmac } from "@noble/hashes/hmac";
|
import { hmac } from "@noble/hashes/hmac";
|
||||||
@ -459,7 +460,7 @@ export function kvToObject<T>(o: string, sep?: string) {
|
|||||||
export function defaultAvatar(input?: string) {
|
export function defaultAvatar(input?: string) {
|
||||||
if (isOffline()) return Nostrich;
|
if (isOffline()) return Nostrich;
|
||||||
const key = (input?.length ?? 0) === 0 ? "missing" : input;
|
const key = (input?.length ?? 0) === 0 ? "missing" : input;
|
||||||
return `https://robohash.v0l.io/${key}.png${isHalloween() ? "?set=set2" : ""}`;
|
return `https://nostr.api.v0l.io/api/v1/avatar/${isHalloween() ? "zombies" : "cyberpunks"}/${key}.webp`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isFormElement(target: HTMLElement): boolean {
|
export function isFormElement(target: HTMLElement): boolean {
|
||||||
|
@ -10,8 +10,6 @@ module.exports = {
|
|||||||
highlight: "var(--highlight)",
|
highlight: "var(--highlight)",
|
||||||
"bg-color": "var(--bg-color)",
|
"bg-color": "var(--bg-color)",
|
||||||
"bg-secondary": "var(--bg-secondary)",
|
"bg-secondary": "var(--bg-secondary)",
|
||||||
},
|
|
||||||
textColor: {
|
|
||||||
"nostr-blue": "var(--repost)",
|
"nostr-blue": "var(--repost)",
|
||||||
"nostr-green": "var(--success)",
|
"nostr-green": "var(--success)",
|
||||||
"nostr-orange": "var(--zap)",
|
"nostr-orange": "var(--zap)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user