Skip to content

Commit

Permalink
chore: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
king8fisher committed Nov 15, 2024
1 parent fb9b281 commit 75709dc
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 45 deletions.
5 changes: 1 addition & 4 deletions src/components/atoms/Navbar/Patch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ export const Patch = () => {
title={`Age of Empires II: Definitive Edition - Patch ${patch.DE}`}
>
<span>DE</span>
<span>
{patch.DE}
</span>
<span>{patch.DE}</span>
</span>
</>
);
};

22 changes: 12 additions & 10 deletions src/components/atoms/Navbar/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

import { z } from "zod";

export const PatchSchema = z.array(z.object({
number: z.number(),
label: z.string(),
release_date: z.date(),
published: z.boolean(),
url: z.string(),
description: z.string(),
total_games: z.number()
}));
export const PatchSchema = z.array(
z.object({
number: z.number(),
label: z.string(),
release_date: z.date(),
published: z.boolean(),
url: z.string(),
description: z.string(),
total_games: z.number(),
})
);

export type PatchSchema = z.infer<typeof PatchSchema>;
export type PatchSchema = z.infer<typeof PatchSchema>;
42 changes: 18 additions & 24 deletions src/components/atoms/SingleCivIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,35 @@ interface SingleCivIconProps {
civData: ICivData;
}

const SingleCivIcon = (
{ highlight, civData, disablePopup, ...props }: SingleCivIconProps
& HTMLAttributes<HTMLDivElement>) => {
const SingleCivIcon = ({
highlight,
civData,
disablePopup,
...props
}: SingleCivIconProps & HTMLAttributes<HTMLDivElement>) => {
const imgClassName = highlight ? undefined : "opacity-20";
return (
<SingleCivIconWrap {...props}>
{disablePopup && <img src={getCivImgUrl(civData.key)} className={imgClassName} />}
{!disablePopup &&
<ContentWithTooltip
tooltip={
<TooltipContent civData={civData} />
}
>

{!disablePopup && (
<ContentWithTooltip tooltip={<TooltipContent civData={civData} />}>
<img src={getCivImgUrl(civData.key)} className={imgClassName} />
</ContentWithTooltip>
}
)}
</SingleCivIconWrap>
);
};

export default SingleCivIcon;

export const TooltipContent = ({ civData }: { civData: ICivData }) => {
return (<div className="flex flex-col gap-1 text-sm">
<div className="flex flex-row items-start">
<span className="font-bold leading-6 grow">{civData.value}</span>
<SingleCivIcon
highlight
disablePopup
civData={civData}
className="place-self-end"
/>
return (
<div className="flex flex-col gap-1 text-sm">
<div className="flex flex-row items-start">
<span className="font-bold leading-6 grow">{civData.value}</span>
<SingleCivIcon highlight disablePopup civData={civData} className="place-self-end" />
</div>
<span className="text-wrap" dangerouslySetInnerHTML={{ __html: civData.help }} />
</div>
<span className="text-wrap" dangerouslySetInnerHTML={{ __html: civData.help }} />
</div>
)
}
);
};
21 changes: 14 additions & 7 deletions src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ import SingleCivIcon, { TooltipContent } from "../../components/atoms/SingleCivI
import { ButtonGroup, IFilterStats } from "../../components/molecules/ButtonGroup";
import { CivView } from "../../components/molecules/CivView";
import GenericUnitsView from "../../components/molecules/GenericUnitsView";
import { ICivData, IGroupByUnitData, IUnitCivData, getAllCivs, groupByUnitType, searchCivs, searchUnits } from "../../data/model";
import {
ICivData,
IGroupByUnitData,
IUnitCivData,
getAllCivs,
groupByUnitType,
searchCivs,
searchUnits,
} from "../../data/model";
import { DataFilter } from "../../helpers/constants";
import { useDebounce } from "../../helpers/debouncers";
import { Container } from "../../styles";
Expand Down Expand Up @@ -66,8 +74,7 @@ const Home = () => {
{filter === DataFilter.units && <GenericUnitsView genericUnitsData={searchResult} />}
{filter === DataFilter.civs && searchResult?.civs.map((civ) => <CivView key={civ.key} civ={civ} />)}
<div className="flex flex-row flex-wrap md:flex-nowrap gap-1 items-start pb-8">
{
filter === DataFilter.civs &&
{filter === DataFilter.civs && (
<div className="grid grid-cols-8 gap-1 p-1 mt-1 max-w-[300px] shrink-0">
{getAllCivs().map((civData) => (
<SingleCivIcon
Expand All @@ -76,7 +83,7 @@ const Home = () => {
civData={civData}
key={civData.key}
onMouseOver={() => {
setCivTip(civData)
setCivTip(civData);
}}
onMouseLeave={() => {
// We want to keep the last still visible.
Expand All @@ -85,12 +92,12 @@ const Home = () => {
/>
))}
</div>
}
{ (filter === DataFilter.civs && civTip) &&
)}
{filter === DataFilter.civs && civTip && (
<div className="grow flex flex-col gap-2 p-2 rounded bg-black/20">
<TooltipContent civData={civTip} />
</div>
}
)}
</div>
</Container>
);
Expand Down

0 comments on commit 75709dc

Please sign in to comment.