Skip to content

Commit

Permalink
Add info button + default black theme (#244)
Browse files Browse the repository at this point in the history
* Add info button + default black theme

* Disable codecov comments
  • Loading branch information
petrvecera authored Aug 31, 2023
1 parent af78b4d commit 4850284
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 56 deletions.
2 changes: 2 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
codecov:
comment: false
29 changes: 0 additions & 29 deletions components/icon/info.tsx

This file was deleted.

8 changes: 8 additions & 0 deletions components/icon/relic-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import relic_icon from "../../public/icons/general/relic_icon.png";
import Image from "next/image";

const RelicIcon = ({ size = 20 }: { size?: number }) => {
return <Image src={relic_icon} alt={`$Relic icon`} width={size} height={size} unoptimized />;
};

export default RelicIcon;
33 changes: 33 additions & 0 deletions components/screens/players/components/player-id-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ActionIcon, Code, Group, HoverCard, Text } from "@mantine/core";
import { IconBrandSteam, IconInfoCircle } from "@tabler/icons-react";
import React from "react";
import RelicIcon from "../../../icon/relic-icon";

const PlayerIdIcon = ({ relicID, steamID }: { relicID: number; steamID?: string }) => {
return (
<HoverCard width={260} shadow="md">
<HoverCard.Target>
<ActionIcon size="lg" variant="default" radius="md">
<IconInfoCircle size={25} />
</ActionIcon>
</HoverCard.Target>
<HoverCard.Dropdown>
<Group spacing={"xs"}>
<RelicIcon size={17} />
<Text size="sm">Relic ID &nbsp;</Text>

<Code>{relicID}</Code>
</Group>
{steamID && (
<Group spacing={"xs"}>
<IconBrandSteam size={15} />
<Text size="sm">Steam ID</Text>
<Code>{steamID}</Code>
</Group>
)}
</HoverCard.Dropdown>
</HoverCard>
);
};

export default PlayerIdIcon;
5 changes: 5 additions & 0 deletions components/screens/players/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import PlayerSummary from "./components/player-summary";
import PlayerStandings from "./components/player-standings";
import PlayerRecentMatches from "./components/player-recent-matches";
import ErrorCard from "../../error-card";
import PlayerIdIcon from "./components/player-id-icon";

const createPlayerHeadDescription = (
playerData: PlayerCardDataType,
Expand Down Expand Up @@ -158,6 +159,10 @@ const PlayerCard = ({
)}
{platform === "psn" && <PSNIcon label="Play Station player" />}
{platform === "xbox" && <XboxIcon label="XBOX player" />}
<PlayerIdIcon
relicID={playerData.info.relicID}
steamID={playerData.info.steamID || undefined}
/>
</Group>
</Stack>
</Group>
Expand Down
2 changes: 1 addition & 1 deletion components/screens/stats/game/charts/maps-played-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const MapsPlayedBarChart: React.FC<IProps> = ({ data }) => {
tickSize: 5,
tickPadding: 5,
legend: "Number of games",
tickRotation: -45,
tickRotation: -55,
legendPosition: "middle",
legendOffset: 38,
}}
Expand Down
2 changes: 1 addition & 1 deletion components/screens/stats/maps/charts/maps-played-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const MapsPlayedBarChart: React.FC<IProps> = ({ data }) => {
tickSize: 5,
tickPadding: 5,
legend: "Number of games",
tickRotation: -35,
tickRotation: -45,
legendPosition: "middle",
legendOffset: 38,
}}
Expand Down
46 changes: 23 additions & 23 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useColorScheme, useLocalStorage } from "@mantine/hooks";
import Script from "next/script";
import webFirebase from "../src/firebase/web-firebase";
import { BetaVersion } from "../components/other/beta-version";
import { useEffect, useRef } from "react";
import { useEffect } from "react";
import NProgress from "nprogress";
import "../components/other/nprogress.css";
import ContentContainer from "../components/Content-container";
Expand All @@ -25,14 +25,14 @@ export default function App(props: AppProps & { colorScheme: ColorScheme }) {

// get system colorscheme
const systemColorScheme = useColorScheme("dark");
const prevSystemColorSchemeRef = useRef(systemColorScheme);

// create a cookie on browser to store if the user is visiting the site for the first time
const [firstVisit, setFirstVisit] = useLocalStorage<boolean>({
key: "first-visit",
defaultValue: true,
getInitialValueInEffect: true,
});
// const prevSystemColorSchemeRef = useRef(systemColorScheme);
//
// // create a cookie on browser to store if the user is visiting the site for the first time
// const [firstVisit, setFirstVisit] = useLocalStorage<boolean>({
// key: "first-visit",
// defaultValue: true,
// getInitialValueInEffect: true,
// });

// create a cookie on browser to store colorscheme starting out with system colorscheme as default
const [colorScheme, setColorScheme] = useLocalStorage<ColorScheme>({
Expand All @@ -41,20 +41,20 @@ export default function App(props: AppProps & { colorScheme: ColorScheme }) {
getInitialValueInEffect: true,
});

// useColorScheme returns an incorrect initial value due to serverside rendering
// when on the client for the first time set the colorscheme to system preferences
useEffect(() => {
if (typeof document !== "undefined") {
// only run on client side
if (prevSystemColorSchemeRef.current !== systemColorScheme) {
if (firstVisit) {
setColorScheme(systemColorScheme);
setFirstVisit(false);
}
}
prevSystemColorSchemeRef.current = systemColorScheme;
}
}, [systemColorScheme]);
// // useColorScheme returns an incorrect initial value due to serverside rendering
// // when on the client for the first time set the colorscheme to system preferences
// useEffect(() => {
// if (typeof document !== "undefined") {
// // only run on client side
// if (prevSystemColorSchemeRef.current !== systemColorScheme) {
// if (firstVisit) {
// setColorScheme(systemColorScheme);
// setFirstVisit(false);
// }
// }
// prevSystemColorSchemeRef.current = systemColorScheme;
// }
// }, [systemColorScheme]);

// switch colorscheme
const toggleColorScheme = (value?: ColorScheme) =>
Expand Down
Binary file added public/icons/general/relic_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/coh3/coh3-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ export type PlayerCardDataType = {
COH3PlayTime: null;
standings: InternalStandings;
info: {
relicID: number;
country: string;
level: number;
name: string;
xp: number | undefined;
steamID: string | undefined;
steamID: string | null;
};
};

Expand Down
3 changes: 2 additions & 1 deletion src/players/standings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ const getPlayerInfo = (statGroup: RawStatGroup) => {
const possibleSteamId = convertSteamNameToID(playerData.name);

return {
relicID: playerData.profile_id,
name: playerData.alias,
country: playerData.country,
level: playerData.level,
xp: playerData.xp,
steamID: possibleSteamId !== "" ? possibleSteamId : undefined,
steamID: possibleSteamId !== "" ? possibleSteamId : null,
};
};

Expand Down

0 comments on commit 4850284

Please sign in to comment.