Skip to content

Commit

Permalink
feat: add new server icons
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloLongScript committed Nov 7, 2024
1 parent c728d20 commit c699c32
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 8 deletions.
53 changes: 45 additions & 8 deletions src/components/AfterServerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@
import { getCommunityServerFavorites, getCustomization } from "@/lib/api";
import { MHSF } from "@/lib/mhsf";
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 { useTheme } from "next-themes";
import { useEffect, useState } from "react";
import FadeIn from "react-fade-in/lib/FadeIn";
import toast, { CheckmarkIcon } from "react-hot-toast";
import Markdown from "react-markdown";
import IconDisplay from "./IconDisplay";
import AchievementList from "./feat/AchievementList";
import { Button } from "./ui/button";
import {
Expand Down Expand Up @@ -74,13 +80,13 @@ export default function AfterServerView({ server }: { server: string }) {
getCommunityServerFavorites(server).then((c) => {
mhsf.setFavorites(c);
});
getMinehutIcons().then((i) => {
setIcons(i);
});
}
fetch("https://api.minehut.com/server/" + server + "?byName=true").then(
(c) => c.json().then((n) => setServerObject(n.server)),
);
getMinehutIcons().then((i) => {
setIcons(i);
});
setLoading(false);
});
}, []);
Expand Down Expand Up @@ -411,16 +417,47 @@ export default function AfterServerView({ server }: { server: string }) {
</div>
)}
{view == "icons" && (
<div>
<div className="col-span-4">
<p>
Purchased Icons are icons that are under the server's
ownership, they may or may not available at that certain
moment either.
</p>
{serverObject?.purchased_icons.map((icon) => (
<div key={icon}>
{icons?.find((c) => c._id === icon)?.icon_name}
</div>
<Card key={icon} className="my-4">
<CardContent
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>
)}
Expand Down
14 changes: 14 additions & 0 deletions src/config/version.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ const FeatureList = ({

export const version = "1.4.0";
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",
name: "v1.4.0",
Expand Down
9 changes: 9 additions & 0 deletions src/lib/types/server-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ export const rarityIndex = {
epic: { bg: "#4c1a7b", text: "#ce59ff" },
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"
];
};

0 comments on commit c699c32

Please sign in to comment.