feat: moving friends request button to sidebar

This commit is contained in:
Zamitto 2024-07-12 19:38:39 -03:00
parent 198a283752
commit 49fd34c3c0
5 changed files with 109 additions and 41 deletions

View File

@ -40,6 +40,7 @@
"@reduxjs/toolkit": "^2.2.3", "@reduxjs/toolkit": "^2.2.3",
"@sentry/electron": "^5.1.0", "@sentry/electron": "^5.1.0",
"@vanilla-extract/css": "^1.14.2", "@vanilla-extract/css": "^1.14.2",
"@vanilla-extract/dynamic": "^2.1.1",
"@vanilla-extract/recipes": "^0.5.2", "@vanilla-extract/recipes": "^0.5.2",
"aria2": "^4.1.2", "aria2": "^4.1.2",
"auto-launch": "^5.0.6", "auto-launch": "^5.0.6",

View File

@ -1,7 +1,18 @@
import { style } from "@vanilla-extract/css"; import { createVar, style } from "@vanilla-extract/css";
import { SPACING_UNIT, vars } from "../../theme.css"; import { SPACING_UNIT, vars } from "../../theme.css";
export const profileContainerBackground = createVar();
export const profileContainer = style({
background: profileContainerBackground,
position: "relative",
cursor: "pointer",
":hover": {
backgroundColor: "rgba(255, 255, 255, 0.15)",
},
});
export const profileButton = style({ export const profileButton = style({
display: "flex", display: "flex",
cursor: "pointer", cursor: "pointer",
@ -10,9 +21,8 @@ export const profileButton = style({
color: vars.color.muted, color: vars.color.muted,
borderBottom: `solid 1px ${vars.color.border}`, borderBottom: `solid 1px ${vars.color.border}`,
boxShadow: "0px 0px 15px 0px rgb(0 0 0 / 70%)", boxShadow: "0px 0px 15px 0px rgb(0 0 0 / 70%)",
":hover": { width: "100%",
backgroundColor: "rgba(255, 255, 255, 0.15)", zIndex: "10",
},
}); });
export const profileButtonContent = style({ export const profileButtonContent = style({
@ -64,3 +74,25 @@ export const profileButtonTitle = style({
textOverflow: "ellipsis", textOverflow: "ellipsis",
whiteSpace: "nowrap", whiteSpace: "nowrap",
}); });
export const friendRequestContainer = style({
position: "absolute",
padding: "8px",
right: `${SPACING_UNIT}px`,
display: "flex",
top: 0,
bottom: 0,
alignItems: "center",
});
export const friendRequestButton = style({
color: vars.color.success,
cursor: "pointer",
borderRadius: "50%",
overflow: "hidden",
width: "40px",
height: "40px",
":hover": {
color: vars.color.body,
},
});

View File

@ -1,10 +1,11 @@
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { PersonIcon } from "@primer/octicons-react"; import { PersonAddIcon, PersonIcon } from "@primer/octicons-react";
import * as styles from "./sidebar-profile.css"; import * as styles from "./sidebar-profile.css";
import { assignInlineVars } from "@vanilla-extract/dynamic";
import { useAppSelector, useUserDetails } from "@renderer/hooks"; import { useAppSelector, useUserDetails } from "@renderer/hooks";
import { useMemo } from "react"; import { useMemo } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { profileContainerBackground } from "./sidebar-profile.css";
export function SidebarProfile() { export function SidebarProfile() {
const navigate = useNavigate(); const navigate = useNavigate();
@ -30,45 +31,66 @@ export function SidebarProfile() {
}, [profileBackground]); }, [profileBackground]);
return ( return (
<button <div
type="button" className={styles.profileContainer}
className={styles.profileButton} style={assignInlineVars({
style={{ background: profileButtonBackground }} [profileContainerBackground]: profileButtonBackground,
onClick={handleButtonClick} })}
> >
<div className={styles.profileButtonContent}> <button
<div className={styles.profileAvatar}> type="button"
{userDetails?.profileImageUrl ? ( className={styles.profileButton}
<img onClick={handleButtonClick}
src={userDetails.profileImageUrl} >
alt={userDetails.displayName} <div className={styles.profileButtonContent}>
/> <div className={styles.profileAvatar}>
) : ( {userDetails?.profileImageUrl ? (
<PersonIcon size={24} /> <img
)} className={styles.profileAvatar}
</div> src={userDetails.profileImageUrl}
alt={userDetails.displayName}
/>
) : (
<PersonIcon size={24} />
)}
</div>
<div className={styles.profileButtonInformation}> <div className={styles.profileButtonInformation}>
<p className={styles.profileButtonTitle}> <p className={styles.profileButtonTitle}>
{userDetails ? userDetails.displayName : t("sign_in")} {userDetails ? userDetails.displayName : t("sign_in")}
</p> </p>
{userDetails && gameRunning && (
<div>
<small>{gameRunning.title}</small>
</div>
)}
</div>
{userDetails && gameRunning && ( {userDetails && gameRunning && (
<div> <img
<small>{gameRunning.title}</small> alt={gameRunning.title}
</div> width={24}
style={{ borderRadius: 4 }}
src={gameRunning.iconUrl}
/>
)} )}
</div> </div>
</button>
{userDetails && gameRunning && ( {userDetails && !gameRunning && (
<img <div className={styles.friendRequestContainer}>
alt={gameRunning.title} <button
width={24} type="button"
style={{ borderRadius: 4 }} className={styles.friendRequestButton}
src={gameRunning.iconUrl} onClick={() => {
/> console.log("alshdaksjhdskajhd");
)} }}
</div> >
</button> <PersonAddIcon size={24} />
30
</button>
</div>
)}
</div>
); );
} }

View File

@ -355,10 +355,11 @@ export function UserContent({
{isMe && ( {isMe && (
<button <button
type="button" type="button"
style={{ color: vars.color.body, cursor: "pointer" }} style={{ color: vars.color.success, cursor: "pointer" }}
onClick={() => setShowAddFriendsModal(true)} onClick={() => setShowAddFriendsModal(true)}
> >
<PersonAddIcon size={24} /> <PersonAddIcon size={24} />
30
</button> </button>
)} )}
</div> </div>

View File

@ -2433,6 +2433,13 @@
modern-ahocorasick "^1.0.0" modern-ahocorasick "^1.0.0"
picocolors "^1.0.0" picocolors "^1.0.0"
"@vanilla-extract/dynamic@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@vanilla-extract/dynamic/-/dynamic-2.1.1.tgz#bc93a577b127a7dcb6f254973d13a863029a7faf"
integrity sha512-iqf736036ujEIKsIq28UsBEMaLC2vR2DhwKyrG3NDb/fRy9qL9FKl1TqTtBV4daU30Uh3saeik4vRzN8bzQMbw==
dependencies:
"@vanilla-extract/private" "^1.0.5"
"@vanilla-extract/integration@^7.1.3": "@vanilla-extract/integration@^7.1.3":
version "7.1.4" version "7.1.4"
resolved "https://registry.npmjs.org/@vanilla-extract/integration/-/integration-7.1.4.tgz" resolved "https://registry.npmjs.org/@vanilla-extract/integration/-/integration-7.1.4.tgz"
@ -2456,6 +2463,11 @@
resolved "https://registry.npmjs.org/@vanilla-extract/private/-/private-1.0.4.tgz" resolved "https://registry.npmjs.org/@vanilla-extract/private/-/private-1.0.4.tgz"
integrity sha512-8FGD6AejeC/nXcblgNCM5rnZb9KXa4WNkR03HCWtdJBpANjTgjHEglNLFnhuvdQ78tC6afaxBPI+g7F2NX3tgg== integrity sha512-8FGD6AejeC/nXcblgNCM5rnZb9KXa4WNkR03HCWtdJBpANjTgjHEglNLFnhuvdQ78tC6afaxBPI+g7F2NX3tgg==
"@vanilla-extract/private@^1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@vanilla-extract/private/-/private-1.0.5.tgz#8c08ac4851f4cc89a3dcdb858d8938e69b1481c4"
integrity sha512-6YXeOEKYTA3UV+RC8DeAjFk+/okoNz/h88R+McnzA2zpaVqTR/Ep+vszkWYlGBcMNO7vEkqbq5nT/JMMvhi+tw==
"@vanilla-extract/recipes@^0.5.2": "@vanilla-extract/recipes@^0.5.2":
version "0.5.2" version "0.5.2"
resolved "https://registry.npmjs.org/@vanilla-extract/recipes/-/recipes-0.5.2.tgz" resolved "https://registry.npmjs.org/@vanilla-extract/recipes/-/recipes-0.5.2.tgz"