-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
232 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
import { | ||
cn, | ||
BookIcon, | ||
DoveIcon, | ||
} from "@cartridge/ui-next"; | ||
import { Achievement } from "./achievement"; | ||
import { Item } from "."; | ||
import { useMemo } from "react"; | ||
|
||
export function Achievements() { | ||
export function Achievements({ achievements }: { achievements: Item[] }) { | ||
const { completed, total } = useMemo(() => ({ completed: achievements.filter(item => item.completed).length, total: achievements.length }), [achievements]); | ||
|
||
return ( | ||
<div className="flex flex-col gap-y-px"> | ||
<div className="bg-secondary p-3 rounded-t-md"> | ||
<p className="uppercase text-xs text-muted-foreground font-semibold tracking-wider">Progression</p> | ||
</div> | ||
<div className="bg-secondary p-2 flex gap-4"> | ||
<div className="bg-secondary py-2 px-3 flex gap-4"> | ||
<div className="grow flex flex-col justify-center items-start bg-accent rounded-xl p-1"> | ||
<div style={{ width: `${Math.floor(100 * 4 / 9)}%` }} className={cn("grow bg-primary rounded-xl", )} /> | ||
<div style={{ width: `${Math.floor(100 * completed / total)}%` }} className={cn("grow bg-primary rounded-xl", )} /> | ||
</div> | ||
<p className="text-xs text-muted-foreground"> | ||
4 of 9 | ||
{`${completed} of ${total}`} | ||
</p> | ||
</div> | ||
<Achievement Icon={BookIcon} title="rogue scholar" description="finish a run without killing any monsters" percentage={12} earning={50} timestamp={1729318800} /> | ||
<Achievement Icon={DoveIcon} title="pacifist path" description="lorem ipsum dolor sit amet" percentage={24} earning={10} timestamp={1729328800} /> | ||
<Achievement Icon={DoveIcon} title="pacifist path" description="lorem ipsum dolor sit amet" percentage={24} earning={10} timestamp={1729328800} /> | ||
<Achievement Icon={DoveIcon} title="pacifist path" description="lorem ipsum dolor sit amet" percentage={24} earning={10} timestamp={1729328800} /> | ||
<Achievement Icon={DoveIcon} title="pacifist path" description="lorem ipsum dolor sit amet" percentage={24} earning={10} timestamp={1729328800} /> | ||
<Achievement Icon={DoveIcon} title="pacifist path" description="lorem ipsum dolor sit amet" percentage={24} earning={10} timestamp={1729328800} /> | ||
{achievements.map((achievement, index) => ( | ||
<Achievement | ||
key={index} | ||
Icon={achievement.Icon} | ||
title={achievement.hidden ? achievement.hidden_title : achievement.title} | ||
description={achievement.hidden ? achievement.hidden_description : achievement.description} | ||
percentage={achievement.percentage} | ||
earning={achievement.earning} | ||
timestamp={achievement.timestamp} | ||
completed={achievement.completed} | ||
last={index === achievements.length - 1} | ||
/> | ||
))} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Item } from "./index"; | ||
import { Pinned, Empty } from "./pinned"; | ||
|
||
export function Pinneds({ achievements }: { achievements: Item[] }) { | ||
return ( | ||
<div className="grid grid-cols-3 gap-4"> | ||
{achievements.map((achievement, index) => ( | ||
<Pinned key={index} Icon={achievement.Icon} title={achievement.title} /> | ||
))} | ||
{Array.from({ length: 3 - achievements.length }).map((_, index) => ( | ||
<Empty key={index} /> | ||
))} | ||
</div> | ||
); | ||
} |