feat: testing new achievements page ui

This commit is contained in:
Zamitto 2024-10-16 23:06:21 -03:00
parent 108b2552b5
commit ea5b07a1ec
7 changed files with 48 additions and 63 deletions

View File

@ -63,7 +63,6 @@ jobs:
with: with:
name: Build-${{ matrix.os }} name: Build-${{ matrix.os }}
path: | path: |
dist/win-unpacked/**
dist/*-portable.exe dist/*-portable.exe
dist/*.zip dist/*.zip
dist/*.dmg dist/*.dmg

View File

@ -110,7 +110,7 @@ const getAchievementsRemoteUser = async (
...achievementData, ...achievementData,
unlocked: false, unlocked: false,
unlockTime: null, unlockTime: null,
icon: icongray, icongray: icongray,
} as UserAchievement; } as UserAchievement;
}) })
.sort((a, b) => { .sort((a, b) => {

View File

@ -64,7 +64,13 @@ export const mergeAchievements = async (
localGameAchievement?.unlockedAchievements || "[]" localGameAchievement?.unlockedAchievements || "[]"
).filter((achievement) => achievement.name) as UnlockedAchievement[]; ).filter((achievement) => achievement.name) as UnlockedAchievement[];
const newAchievements = achievements const newAchievementsMap = new Map(
achievements.reverse().map((achievement) => {
return [achievement.name.toUpperCase(), achievement];
})
);
const newAchievements = [...newAchievementsMap.values()]
.filter((achievement) => { .filter((achievement) => {
return !unlockedAchievements.some((localAchievement) => { return !unlockedAchievements.some((localAchievement) => {
return ( return (

View File

@ -37,6 +37,7 @@ interface AchievementPanelProps {
function AchievementPanel({ user, otherUser }: AchievementPanelProps) { function AchievementPanel({ user, otherUser }: AchievementPanelProps) {
const { t } = useTranslation("achievement"); const { t } = useTranslation("achievement");
const { userDetails } = useUserDetails();
const getProfileImage = (imageUrl: string | null | undefined) => { const getProfileImage = (imageUrl: string | null | undefined) => {
return ( return (
@ -121,35 +122,29 @@ function AchievementPanel({ user, otherUser }: AchievementPanelProps) {
const otherUserTotalAchievementCount = otherUser.achievements.length; const otherUserTotalAchievementCount = otherUser.achievements.length;
return ( return (
<> <div
<div style={{
style={{ display: "grid",
display: "flex", gridTemplateColumns: "3fr 1fr 1fr",
flexDirection: "row", gap: `${SPACING_UNIT * 2}px`,
width: "100%", padding: `${SPACING_UNIT}px`,
padding: `0 ${SPACING_UNIT * 2}px`, }}
gap: `${SPACING_UNIT * 2}px`, >
}} <div style={{ display: "flex", flexDirection: "column" }}>
>
{getProfileImage(otherUser.profileImageUrl)}
<div <div
style={{ style={{
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
width: "100%",
}} }}
> >
<h1 style={{ fontSize: "1.2em", marginBottom: "8px" }}> <h1 style={{ fontSize: "1.2em", marginBottom: "8px" }}>
{t("user_achievements", { {otherUser.displayName}
displayName: otherUser.displayName,
})}
</h1> </h1>
<div <div
style={{ style={{
display: "flex", display: "flex",
justifyContent: "space-between", justifyContent: "space-between",
marginBottom: 8, marginBottom: 8,
width: "100%",
color: vars.color.muted, color: vars.color.muted,
}} }}
> >
@ -182,26 +177,14 @@ function AchievementPanel({ user, otherUser }: AchievementPanelProps) {
className={styles.achievementsProgressBar} className={styles.achievementsProgressBar}
/> />
</div> </div>
</div>
<div
style={{
display: "flex",
flexDirection: "row-reverse",
width: "100%",
padding: `0 ${SPACING_UNIT * 2}px`,
gap: `${SPACING_UNIT * 2}px`,
}}
>
{getProfileImage(user.profileImageUrl)}
<div <div
style={{ style={{
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
width: "100%",
}} }}
> >
<h1 style={{ fontSize: "1.2em", marginBottom: "8px" }}> <h1 style={{ fontSize: "1.2em", marginBottom: "8px" }}>
{t("your_achievements")} {userDetails?.displayName}
</h1> </h1>
<div <div
style={{ style={{
@ -238,7 +221,9 @@ function AchievementPanel({ user, otherUser }: AchievementPanelProps) {
/> />
</div> </div>
</div> </div>
</> <div>{getProfileImage(otherUser.profileImageUrl)}</div>
<div>{getProfileImage(user.profileImageUrl)}</div>
</div>
); );
} }
@ -288,7 +273,7 @@ function AchievementList({
<li <li
key={index} key={index}
className={styles.listItem} className={styles.listItem}
style={{ display: "grid", gridTemplateColumns: "1fr auto 1fr" }} style={{ display: "grid", gridTemplateColumns: "3fr 1fr 1fr" }}
> >
<div <div
style={{ style={{
@ -306,41 +291,31 @@ function AchievementList({
alt={otherUserAchievement.displayName} alt={otherUserAchievement.displayName}
loading="lazy" loading="lazy"
/> />
{otherUserAchievement.unlockTime && ( <div>
<h4>{otherUserAchievement.displayName}</h4>
<p>{otherUserAchievement.description}</p>
</div>
</div>
<div>
{otherUserAchievement.unlockTime ? (
<div style={{ whiteSpace: "nowrap" }}> <div style={{ whiteSpace: "nowrap" }}>
<small>{t("unlocked_at")}</small> <small>{t("unlocked_at")}</small>
<p>{formatDateTime(otherUserAchievement.unlockTime)}</p> <p>{formatDateTime(otherUserAchievement.unlockTime)}</p>
</div> </div>
) : (
"Não desbloqueada"
)} )}
</div> </div>
<div style={{ textAlign: "center" }}> <div>
<h4>{otherUserAchievement.displayName}</h4> {achievements[index].unlockTime ? (
<p>{otherUserAchievement.description}</p>
</div>
<div
style={{
display: "flex",
flexDirection: "row-reverse",
alignItems: "center",
gap: `${SPACING_UNIT}px`,
textAlign: "right",
}}
>
<img
className={styles.listItemImage({
unlocked: achievements[index].unlocked,
})}
src={achievements[index].icon}
alt={achievements[index].displayName}
loading="lazy"
/>
{achievements[index].unlockTime && (
<div style={{ whiteSpace: "nowrap" }}> <div style={{ whiteSpace: "nowrap" }}>
<small>{t("unlocked_at")}</small> <small>{t("unlocked_at")}</small>
<p>{formatDateTime(achievements[index].unlockTime)}</p> <p>{formatDateTime(achievements[index].unlockTime)}</p>
</div> </div>
) : (
"Não desbloqueada"
)} )}
</div> </div>
</li> </li>

View File

@ -72,12 +72,10 @@ export const container = style({
export const panel = recipe({ export const panel = recipe({
base: { base: {
width: "100%", width: "100%",
height: "100px", height: "180px",
minHeight: "100px", minHeight: "180px",
padding: `${SPACING_UNIT * 2}px 0`, padding: `${SPACING_UNIT * 2}px`,
backgroundColor: vars.color.darkBackground, backgroundColor: vars.color.darkBackground,
display: "flex",
flexDirection: "row",
transition: "all ease 0.2s", transition: "all ease 0.2s",
borderBottom: `solid 1px ${vars.color.border}`, borderBottom: `solid 1px ${vars.color.border}`,
position: "sticky", position: "sticky",

View File

@ -24,6 +24,8 @@ const fakeAchievements: UserAchievement[] = [
hidden: false, hidden: false,
description: "Chop down your first tree.", description: "Chop down your first tree.",
icon: "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/105600/0fbb33098c9da39d1d4771d8209afface9c46e81.jpg", icon: "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/105600/0fbb33098c9da39d1d4771d8209afface9c46e81.jpg",
icongray:
"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/105600/0fbb33098c9da39d1d4771d8209afface9c46e81.jpg",
unlocked: true, unlocked: true,
unlockTime: Date.now(), unlockTime: Date.now(),
}, },
@ -32,6 +34,8 @@ const fakeAchievements: UserAchievement[] = [
name: "", name: "",
hidden: false, hidden: false,
icon: "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/105600/0a6ff6a36670c96ceb4d30cf6fd69d2fdf55f38e.jpg", icon: "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/105600/0a6ff6a36670c96ceb4d30cf6fd69d2fdf55f38e.jpg",
icongray:
"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/105600/0a6ff6a36670c96ceb4d30cf6fd69d2fdf55f38e.jpg",
unlocked: false, unlocked: false,
unlockTime: null, unlockTime: null,
}, },
@ -40,6 +44,8 @@ const fakeAchievements: UserAchievement[] = [
name: "", name: "",
hidden: false, hidden: false,
icon: "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/105600/2d10311274fe7c92ab25cc29afdca86b019ad472.jpg", icon: "https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/105600/2d10311274fe7c92ab25cc29afdca86b019ad472.jpg",
icongray:
"https://cdn.akamai.steamstatic.com/steamcommunity/public/images/apps/105600/2d10311274fe7c92ab25cc29afdca86b019ad472.jpg",
unlocked: false, unlocked: false,
unlockTime: null, unlockTime: null,
}, },

View File

@ -45,6 +45,7 @@ export interface UserAchievement {
unlocked: boolean; unlocked: boolean;
unlockTime: number | null; unlockTime: number | null;
icon: string; icon: string;
icongray: string;
} }
export interface RemoteUnlockedAchievement { export interface RemoteUnlockedAchievement {