feat: cloud ui

This commit is contained in:
Zamitto 2024-12-22 21:21:05 -03:00
parent 7b724d4185
commit d6b5fd1b9f
5 changed files with 51 additions and 21 deletions

View File

@ -387,7 +387,8 @@
"hidden_achievement_tooltip": "This is a hidden achievement", "hidden_achievement_tooltip": "This is a hidden achievement",
"achievement_earn_points": "Earn {{points}} points with this achievement", "achievement_earn_points": "Earn {{points}} points with this achievement",
"earned_points": "Earned points:", "earned_points": "Earned points:",
"available_points": "Available points:" "available_points": "Available points:",
"how_to_earn_achievements_points": "How to earn achievements points?"
}, },
"hydra_cloud": { "hydra_cloud": {
"subscription_tour_title": "Hydra Cloud Subscription", "subscription_tour_title": "Hydra Cloud Subscription",
@ -397,6 +398,8 @@
"animated_profile_picture": "Animated profile pictures", "animated_profile_picture": "Animated profile pictures",
"premium_support": "Premium Support", "premium_support": "Premium Support",
"show_and_compare_achievements": "Show and compare your achievements to other users", "show_and_compare_achievements": "Show and compare your achievements to other users",
"animated_profile_banner": "Animated profile banner" "animated_profile_banner": "Animated profile banner",
"hydra_cloud": "Hydra Cloud",
"hydra_cloud_feature_found": "You've just discovered a Hydra Cloud feature!"
} }
} }

View File

@ -384,16 +384,19 @@
"hidden_achievement_tooltip": "Está é uma conquista oculta", "hidden_achievement_tooltip": "Está é uma conquista oculta",
"achievement_earn_points": "Ganhe {{points}} pontos com essa conquista", "achievement_earn_points": "Ganhe {{points}} pontos com essa conquista",
"earned_points": "Pontos ganhos:", "earned_points": "Pontos ganhos:",
"available_points": "Pontos disponíveis:" "available_points": "Pontos disponíveis:",
"how_to_earn_achievements_points": "Como desbloquear pontos nas conquistas?"
}, },
"hydra_cloud": { "hydra_cloud": {
"subscription_tour_title": "Assinatura Hydra Cloud", "subscription_tour_title": "Assinatura Hydra Cloud",
"hydra_cloud": "Hydra Cloud",
"subscribe_now": "Inscreva-se agora", "subscribe_now": "Inscreva-se agora",
"cloud_achievements": "Salvamento de conquistas em nuvem", "cloud_achievements": "Salvamento de conquistas em nuvem",
"animated_profile_picture": "Fotos de perfil animadas", "animated_profile_picture": "Fotos de perfil animadas",
"premium_support": "Suporte Premium", "premium_support": "Suporte Premium",
"show_and_compare_achievements": "Exiba e compare suas conquistas com outros usuários", "show_and_compare_achievements": "Exiba e compare suas conquistas com outros usuários",
"animated_profile_banner": "Banner animado no perfil", "animated_profile_banner": "Banner animado no perfil",
"cloud_saving": "Saves de jogos em nuvem" "cloud_saving": "Saves de jogos em nuvem",
"hydra_cloud_feature_found": "Você descobriu uma funcionalidade Hydra Cloud!"
} }
} }

View File

@ -8,7 +8,8 @@ export const panel = style({
padding: `${SPACING_UNIT * 2}px ${SPACING_UNIT * 3}px`, padding: `${SPACING_UNIT * 2}px ${SPACING_UNIT * 3}px`,
backgroundColor: vars.color.background, backgroundColor: vars.color.background,
display: "flex", display: "flex",
alignItems: "center", flexDirection: "column",
alignItems: "start",
justifyContent: "space-between", justifyContent: "space-between",
borderBottom: `solid 1px ${vars.color.border}`, borderBottom: `solid 1px ${vars.color.border}`,
}); });
@ -59,3 +60,12 @@ export const progressBar = recipe({
}, },
}, },
}); });
export const link = style({
textAlign: "start",
color: vars.color.body,
":hover": {
textDecoration: "underline",
cursor: "pointer",
},
});

View File

@ -1,10 +1,10 @@
import { useContext } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { gameDetailsContext } from "@renderer/context";
import * as styles from "./achievement-panel.css";
import HydraIcon from "@renderer/assets/icons/hydra.svg?react"; import HydraIcon from "@renderer/assets/icons/hydra.svg?react";
import { UserAchievement } from "@types"; import { UserAchievement } from "@types";
import { useSubscription } from "@renderer/hooks/use-subscription";
import { useUserDetails } from "@renderer/hooks";
import { vars } from "@renderer/theme.css";
import * as styles from "./achievement-panel.css";
export interface AchievementPanelProps { export interface AchievementPanelProps {
achievements: UserAchievement[]; achievements: UserAchievement[];
@ -12,6 +12,8 @@ export interface AchievementPanelProps {
export function AchievementPanel({ achievements }: AchievementPanelProps) { export function AchievementPanel({ achievements }: AchievementPanelProps) {
const { t } = useTranslation("achievement"); const { t } = useTranslation("achievement");
const { hasActiveSubscription } = useUserDetails();
const { showHydraCloudModal } = useSubscription();
const achievementsPointsTotal = achievements.reduce( const achievementsPointsTotal = achievements.reduce(
(acc, achievement) => acc + (achievement.points ?? 0), (acc, achievement) => acc + (achievement.points ?? 0),
@ -24,16 +26,32 @@ export function AchievementPanel({ achievements }: AchievementPanelProps) {
0 0
); );
const {} = useContext(gameDetailsContext); if (!hasActiveSubscription) {
return (
<div className={styles.panel}>
<div className={styles.content}>
{t("earned_points")} <HydraIcon width={20} height={20} />
??? / ???
</div>
<button
type="button"
onClick={showHydraCloudModal}
className={styles.link}
>
<small style={{ color: vars.color.warning }}>
{t("how_to_earn_achievements_points")}
</small>
</button>
</div>
);
}
return ( return (
<>
<div className={styles.panel}> <div className={styles.panel}>
<div className={styles.content}> <div className={styles.content}>
{t("earned_points")} <HydraIcon width={20} height={20} /> {t("earned_points")} <HydraIcon width={20} height={20} />
{achievementsPointsEarnedSum} / {achievementsPointsTotal} {achievementsPointsEarnedSum} / {achievementsPointsTotal}
</div> </div>
</div> </div>
</>
); );
} }

View File

@ -15,11 +15,7 @@ export const HydraCloudModal = ({ visible, onClose }: HydraCloudModalProps) => {
}; };
return ( return (
<Modal <Modal visible={visible} title={t("hydra_cloud")} onClose={onClose}>
visible={visible}
title={t("subscription_tour_title")}
onClose={onClose}
>
<div <div
style={{ style={{
display: "flex", display: "flex",
@ -28,7 +24,7 @@ export const HydraCloudModal = ({ visible, onClose }: HydraCloudModalProps) => {
gap: `${SPACING_UNIT * 2}px`, gap: `${SPACING_UNIT * 2}px`,
}} }}
> >
Você descobriu uma funcionalidade Hydra Cloud! {t("hydra_cloud_feature_found")}
<Button onClick={handleClickOpenCheckout}>Saiba mais</Button> <Button onClick={handleClickOpenCheckout}>Saiba mais</Button>
</div> </div>
</Modal> </Modal>