mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-15 04:32:13 +00:00
feat: adding background to profile
This commit is contained in:
parent
d048d562a3
commit
524bfe91ef
2 changed files with 20 additions and 4 deletions
|
@ -1,5 +1,8 @@
|
||||||
import { UserGame, UserProfile } from "@types";
|
import { UserGame, UserProfile } from "@types";
|
||||||
import cn from "classnames";
|
import cn from "classnames";
|
||||||
|
import { average } from "color.js";
|
||||||
|
import Color from "color";
|
||||||
|
|
||||||
import * as styles from "./user.css";
|
import * as styles from "./user.css";
|
||||||
import { SPACING_UNIT, vars } from "@renderer/theme.css";
|
import { SPACING_UNIT, vars } from "@renderer/theme.css";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
|
@ -58,18 +61,30 @@ export const UserContent = ({ userProfile }: ProfileContentProps) => {
|
||||||
navigate("/");
|
navigate("/");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAvatarLoad = async () => {
|
||||||
|
console.log(userProfile.profileImageUrl);
|
||||||
|
const output = await average(userProfile.profileImageUrl!, {
|
||||||
|
amount: 1,
|
||||||
|
format: "hex",
|
||||||
|
});
|
||||||
|
|
||||||
|
const backgroundColor = output
|
||||||
|
? (new Color(output).darken(0.7).toString() as string)
|
||||||
|
: "";
|
||||||
|
|
||||||
|
console.log(backgroundColor);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<section
|
<section className={styles.profileContentBox}>
|
||||||
className={styles.profileContentBox}
|
|
||||||
style={{ padding: `${SPACING_UNIT * 2}px ${SPACING_UNIT * 2}px` }}
|
|
||||||
>
|
|
||||||
<div className={styles.profileAvatarContainer}>
|
<div className={styles.profileAvatarContainer}>
|
||||||
{userProfile.profileImageUrl ? (
|
{userProfile.profileImageUrl ? (
|
||||||
<img
|
<img
|
||||||
className={styles.profileAvatar}
|
className={styles.profileAvatar}
|
||||||
alt={userProfile.displayName}
|
alt={userProfile.displayName}
|
||||||
src={userProfile.profileImageUrl}
|
src={userProfile.profileImageUrl}
|
||||||
|
onLoad={handleAvatarLoad}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<PersonIcon size={72} />
|
<PersonIcon size={72} />
|
||||||
|
|
|
@ -12,6 +12,7 @@ export const wrapper = style({
|
||||||
export const profileContentBox = style({
|
export const profileContentBox = style({
|
||||||
display: "flex",
|
display: "flex",
|
||||||
gap: `${SPACING_UNIT + SPACING_UNIT / 2}px`,
|
gap: `${SPACING_UNIT + SPACING_UNIT / 2}px`,
|
||||||
|
padding: `${SPACING_UNIT * 4}px ${SPACING_UNIT * 2}px`,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
borderRadius: "4px",
|
borderRadius: "4px",
|
||||||
border: `solid 1px ${vars.color.border}`,
|
border: `solid 1px ${vars.color.border}`,
|
||||||
|
|
Loading…
Reference in a new issue