feat: add new server icons

This commit is contained in:
dvelo 2024-11-06 21:38:36 -06:00
parent c728d2030a
commit c699c32c95
3 changed files with 68 additions and 8 deletions

@ -32,13 +32,19 @@
import { getCommunityServerFavorites, getCustomization } from "@/lib/api"; import { getCommunityServerFavorites, getCustomization } from "@/lib/api";
import { MHSF } from "@/lib/mhsf"; import { MHSF } from "@/lib/mhsf";
import { ServerResponse } from "@/lib/types/mh-server"; import { ServerResponse } from "@/lib/types/mh-server";
import { MinehutIcon, getMinehutIcons } from "@/lib/types/server-icon"; import {
MinehutIcon,
getIndexFromRarity,
getMinehutIcons,
rarityIndex,
} from "@/lib/types/server-icon";
import { Copy, Info } from "lucide-react"; import { Copy, Info } from "lucide-react";
import { useTheme } from "next-themes"; import { useTheme } from "next-themes";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import FadeIn from "react-fade-in/lib/FadeIn"; import FadeIn from "react-fade-in/lib/FadeIn";
import toast, { CheckmarkIcon } from "react-hot-toast"; import toast, { CheckmarkIcon } from "react-hot-toast";
import Markdown from "react-markdown"; import Markdown from "react-markdown";
import IconDisplay from "./IconDisplay";
import AchievementList from "./feat/AchievementList"; import AchievementList from "./feat/AchievementList";
import { Button } from "./ui/button"; import { Button } from "./ui/button";
import { import {
@ -74,13 +80,13 @@ export default function AfterServerView({ server }: { server: string }) {
getCommunityServerFavorites(server).then((c) => { getCommunityServerFavorites(server).then((c) => {
mhsf.setFavorites(c); mhsf.setFavorites(c);
}); });
getMinehutIcons().then((i) => {
setIcons(i);
});
} }
fetch("https://api.minehut.com/server/" + server + "?byName=true").then( fetch("https://api.minehut.com/server/" + server + "?byName=true").then(
(c) => c.json().then((n) => setServerObject(n.server)), (c) => c.json().then((n) => setServerObject(n.server)),
); );
getMinehutIcons().then((i) => {
setIcons(i);
});
setLoading(false); setLoading(false);
}); });
}, []); }, []);
@ -411,16 +417,47 @@ export default function AfterServerView({ server }: { server: string }) {
</div> </div>
)} )}
{view == "icons" && ( {view == "icons" && (
<div> <div className="col-span-4">
<p> <p>
Purchased Icons are icons that are under the server's Purchased Icons are icons that are under the server's
ownership, they may or may not available at that certain ownership, they may or may not available at that certain
moment either. moment either.
</p> </p>
{serverObject?.purchased_icons.map((icon) => ( {serverObject?.purchased_icons.map((icon) => (
<div key={icon}> <Card key={icon} className="my-4">
{icons?.find((c) => c._id === icon)?.icon_name} <CardContent
</div> className="pt-4"
style={{
color: getIndexFromRarity(
icons
?.find((c) => c._id === icon)
?.rank.toLowerCase(),
).text,
}}
>
<IconDisplay
server={{
icon: icons?.find((c) => c._id === icon)?.icon_name,
}}
className="mr-2"
/>
{icons?.find((c) => c._id === icon)?.display_name}
<span
className="mx-2 p-1 pr-2 rounded italic font-bold"
style={{
backgroundColor: getIndexFromRarity(
icons
?.find((c) => c._id === icon)
?.rank.toLowerCase(),
).bg,
}}
>
{icons
?.find((c) => c._id === icon)
?.rank.toLocaleUpperCase()}
</span>
</CardContent>
</Card>
))} ))}
</div> </div>
)} )}

@ -54,6 +54,20 @@ const FeatureList = ({
export const version = "1.4.0"; export const version = "1.4.0";
export const changelog: { name: string; id: string; changelog: ReactNode }[] = [ export const changelog: { name: string; id: string; changelog: ReactNode }[] = [
{
id: "ywvhtcs4k9rqjfp57x",
name: "v1.4.5",
changelog: (
<FeatureList
features={["Add server icons"]}
title={
<strong className="flex items-center">
Version 1.4.5 (November 6th 2024)
</strong>
}
/>
),
},
{ {
id: "amq4suhgcfwrb7y5j6", id: "amq4suhgcfwrb7y5j6",
name: "v1.4.0", name: "v1.4.0",

@ -56,3 +56,12 @@ export const rarityIndex = {
epic: { bg: "#4c1a7b", text: "#ce59ff" }, epic: { bg: "#4c1a7b", text: "#ce59ff" },
legendary: { bg: "#de6e0d", text: "#fce8cf" }, legendary: { bg: "#de6e0d", text: "#fce8cf" },
}; };
export const getIndexFromRarity = (rank: string | undefined) => {
if (rank === undefined) {
return rarityIndex.common;
}
return rarityIndex[
rank as "common" | "uncommon" | "rare" | "epic" | "legendary"
];
};