mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
feat: improve friends playing game box
This commit is contained in:
parent
cf39b426e1
commit
e02875ad56
@ -2,7 +2,7 @@ import { userProfileContext } from "@renderer/context";
|
|||||||
import { useFormat } from "@renderer/hooks";
|
import { useFormat } from "@renderer/hooks";
|
||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import SteamLogo from "@renderer/assets/steam-logo.svg?react";
|
||||||
import * as styles from "./profile-content.css";
|
import * as styles from "./profile-content.css";
|
||||||
import { Avatar, Link } from "@renderer/components";
|
import { Avatar, Link } from "@renderer/components";
|
||||||
|
|
||||||
@ -13,6 +13,21 @@ export function FriendsBox() {
|
|||||||
|
|
||||||
const { numberFormatter } = useFormat();
|
const { numberFormatter } = useFormat();
|
||||||
|
|
||||||
|
const getGameImage = (game: { iconUrl: string | null; title: string }) => {
|
||||||
|
if (game.iconUrl) {
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
alt={game.title}
|
||||||
|
width={16}
|
||||||
|
style={{ borderRadius: 4 }}
|
||||||
|
src={game.iconUrl}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <SteamLogo width={16} height={16} />;
|
||||||
|
};
|
||||||
|
|
||||||
if (!userProfile?.friends.length) return null;
|
if (!userProfile?.friends.length) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -27,7 +42,14 @@ export function FriendsBox() {
|
|||||||
<div className={styles.box}>
|
<div className={styles.box}>
|
||||||
<ul className={styles.list}>
|
<ul className={styles.list}>
|
||||||
{userProfile?.friends.map((friend) => (
|
{userProfile?.friends.map((friend) => (
|
||||||
<li key={friend.id}>
|
<li
|
||||||
|
key={friend.id}
|
||||||
|
title={
|
||||||
|
friend.currentGame
|
||||||
|
? t("playing", { game: friend.currentGame.title })
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
<Link to={`/profile/${friend.id}`} className={styles.listItem}>
|
<Link to={`/profile/${friend.id}`} className={styles.listItem}>
|
||||||
<Avatar
|
<Avatar
|
||||||
size={32}
|
size={32}
|
||||||
@ -35,12 +57,17 @@ export function FriendsBox() {
|
|||||||
alt={friend.displayName}
|
alt={friend.displayName}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div>
|
<div
|
||||||
|
style={{ display: "flex", flexDirection: "column", gap: 4 }}
|
||||||
|
>
|
||||||
<span className={styles.friendName}>
|
<span className={styles.friendName}>
|
||||||
{friend.displayName}
|
{friend.displayName}
|
||||||
</span>
|
</span>
|
||||||
{friend.currentGame && (
|
{friend.currentGame && (
|
||||||
<p>{t("playing", { game: friend.currentGame.title })}</p>
|
<div style={{ display: "flex", gap: 4 }}>
|
||||||
|
{getGameImage(friend.currentGame)}
|
||||||
|
<small>{friend.currentGame.title}</small>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
|
Loading…
Reference in New Issue
Block a user