From ddea87ccf8cf3cf5ef548794a67a7b751686eb02 Mon Sep 17 00:00:00 2001 From: dvelo <52332868+DeveloLongScript@users.noreply.github.com> Date: Sat, 16 Nov 2024 15:01:14 -0600 Subject: [PATCH] feat: add new embeds --- .idea/.gitignore | 8 + .idea/codeStyles/Project.xml | 7 + .idea/codeStyles/codeStyleConfig.xml | 5 + .vscode/.gitignore | 6 + .vscode/extensions.json | 5 + .vscode/settings.json | 3 + package.json | 3 +- src/app/(embeds)/embed/[server]/page.tsx | 39 + src/app/(embeds)/layout.tsx | 58 ++ src/app/(main)/server/[server]/page.tsx | 203 +++--- src/components/AfterServerView.tsx | 878 ++++++++++++----------- src/components/CommandBar.tsx | 1 - src/components/ServerView.tsx | 6 +- src/components/feat/Embed.tsx | 168 +++++ src/components/feat/EmbedSelector.tsx | 306 ++++++++ src/components/misc/TabServer.tsx | 31 +- src/components/ui/select.tsx | 158 ++++ src/config/docs.ts | 1 + src/config/version.tsx | 712 +++++++++--------- src/lib/single.ts | 3 + yarn.lock | 118 ++- 21 files changed, 1789 insertions(+), 930 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .vscode/.gitignore create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 src/app/(embeds)/embed/[server]/page.tsx create mode 100644 src/app/(embeds)/layout.tsx create mode 100644 src/components/feat/Embed.tsx create mode 100644 src/components/feat/EmbedSelector.tsx create mode 100644 src/components/ui/select.tsx diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..88bf7a7 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Ignore everything for IntelliJ except for project essential code-styles +* + +!copyright/* +!codeStyles/* +!.gitignore + +!*/ \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..5dcac8f --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.vscode/.gitignore b/.vscode/.gitignore new file mode 100644 index 0000000..95d594d --- /dev/null +++ b/.vscode/.gitignore @@ -0,0 +1,6 @@ +# Ignore everything for VSCode except for project essential code-styles +* + +!extensions.json +!settings.json +!.gitignore \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..9e91c17 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "sarfrajansari.copyright-header-injector" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e4ad59b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "copyright-header-injector.copyrightText": "/*\n * MHSF, Minehut Server List\n * All external content is rather licensed under the ECA Agreement\n * located here: https://mhsf.app/docs/legal/external-content-agreement\n *\n * All code under MHSF is licensed under the MIT License\n * by open source contributors\n *\n * Copyright (c) 2024 dvelo\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */" +} \ No newline at end of file diff --git a/package.json b/package.json index 6e4bba6..1c09685 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-menubar": "^1.1.1", "@radix-ui/react-primitive": "^2.0.0", + "@radix-ui/react-select": "^2.1.2", "@radix-ui/react-switch": "^1.1.0", "@unocss/eslint-plugin": "^0.61.5", "@unocss/postcss": "^0.61.5", @@ -105,7 +106,7 @@ "react-markdown": "^9.0.1", "react-resizable-panels": "^2.0.23", "recharts": "^2.12.7", - "shiki": "^1.22.2", + "shiki": "^1.23.0", "tailwindcss": "^3.4.1", "typescript": "^5", "vaul": "^0.9.1", diff --git a/src/app/(embeds)/embed/[server]/page.tsx b/src/app/(embeds)/embed/[server]/page.tsx new file mode 100644 index 0000000..b2a739e --- /dev/null +++ b/src/app/(embeds)/embed/[server]/page.tsx @@ -0,0 +1,39 @@ +/* + * MHSF, Minehut Server List + * All external content is rather licensed under the ECA Agreement + * located here: https://mhsf.app/docs/legal/external-content-agreement + * + * All code under MHSF is licensed under the MIT License + * by open source contributors + * + * Copyright (c) 2024 dvelo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +import Embed from "@/components/feat/Embed"; + +export default function EmbedPage({ + params, +}: { + params: { server: string }; +}) { + return ; +} diff --git a/src/app/(embeds)/layout.tsx b/src/app/(embeds)/layout.tsx new file mode 100644 index 0000000..cc0b9eb --- /dev/null +++ b/src/app/(embeds)/layout.tsx @@ -0,0 +1,58 @@ +/* + * MHSF, Minehut Server List + * All external content is rather licensed under the ECA Agreement + * located here: https://mhsf.app/docs/legal/external-content-agreement + * + * All code under MHSF is licensed under the MIT License + * by open source contributors + * + * Copyright (c) 2024 dvelo + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +"use client"; + +import { TooltipProvider } from "@/components/ui/tooltip"; +import "../globals.css"; +import { ThemeProvider } from "@/components/ThemeProvider"; +import { useSearchParams } from "next/navigation"; + +export default function RootLayout({ + children, +}: { + children: React.ReactNode; +}) { + const searchParams = useSearchParams(); + const search = searchParams?.get("theme") || "light"; + return ( + + + + {children} + + + + ); +} diff --git a/src/app/(main)/server/[server]/page.tsx b/src/app/(main)/server/[server]/page.tsx index dd16f18..6921cf3 100644 --- a/src/app/(main)/server/[server]/page.tsx +++ b/src/app/(main)/server/[server]/page.tsx @@ -33,123 +33,114 @@ import Banner from "@/components/Banner"; import ColorProvider from "@/components/ColorProvider"; import ServerView from "@/components/ServerView"; import TabServer from "@/components/misc/TabServer"; -import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; -import { CornerDownLeft } from "lucide-react"; import type { Metadata, ResolvingMetadata } from "next"; -import Link from "next/link"; type Props = { - params: { server: string }; + params: { server: string }; }; export async function generateMetadata( - { params }: Props, - parent: ResolvingMetadata, + { params }: Props, + parent: ResolvingMetadata ): Promise { - // read route params - const { server } = params; - const json = await ( - await fetch("https://api.minehut.com/server/" + server + "?byName=true") - ).json(); + // read route params + const { server } = params; + const json = await ( + await fetch("https://api.minehut.com/server/" + server + "?byName=true") + ).json(); - return { - themeColor: "#000000", - title: - json.server == null - ? "Server doesn't exist | MHSF" - : json.server.name + - ", " + - (json.server.online - ? json.server.playerCount + - (json.server.maxPlayers != 10 - ? "/" + json.server.maxPlayers - : "") + - " online" - : "Offline") + - " | MHSF", - description: - json.server == null - ? `The server ${server} doesn't exist.` - : `View ${server} on Minehut Server Finder!`, - authors: json.server == null ? undefined : { name: json.server.owner }, - applicationName: "MHSF (Minehut Server Finder)", - icons: - json.server == null - ? undefined - : "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + - (json.server.icon == undefined ? "OAK_SIGN" : json.server.icon) + - ".png", - twitter: { - title: - json.server == null - ? "Server doesn't exist | MHSF" - : json.server.name + - ", " + - (json.server.online - ? json.server.playerCount + - (json.server.maxPlayers != 10 - ? "/" + json.server.maxPlayers - : "") + - " online" - : "Offline") + - " | MHSF", - description: - json.server == null - ? `The server ${server} doesn't exist.` - : `View ${server} on Minehut Server Finder!`, - images: [ - { - url: - "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + - json.server.icon + - ".png", - }, - { - url: "/public/imgs/icon-cf.png", - }, - ], - }, - openGraph: { - type: "profile", - siteName: "MHSF (Minehut Server Finder)", + return { + themeColor: "#000000", + title: + json.server == null + ? "Server doesn't exist | MHSF" + : json.server.name + + ", " + + (json.server.online + ? json.server.playerCount + + (json.server.maxPlayers != 10 + ? "/" + json.server.maxPlayers + : "") + + " online" + : "Offline") + + " | MHSF", + description: + json.server == null + ? `The server ${server} doesn't exist.` + : `View ${server} on Minehut Server Finder!`, + authors: json.server == null ? undefined : { name: json.server.owner }, + applicationName: "MHSF (Minehut Server Finder)", + icons: + json.server == null + ? undefined + : "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + + (json.server.icon == undefined ? "OAK_SIGN" : json.server.icon) + + ".png", + twitter: { + title: + json.server == null + ? "Server doesn't exist | MHSF" + : json.server.name + + ", " + + (json.server.online + ? json.server.playerCount + + (json.server.maxPlayers != 10 + ? "/" + json.server.maxPlayers + : "") + + " online" + : "Offline") + + " | MHSF", + description: + json.server == null + ? `The server ${server} doesn't exist.` + : `View ${server} on Minehut Server Finder!`, + images: [ + { + url: + "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + + json.server.icon + + ".png", + }, + { + url: "/public/imgs/icon-cf.png", + }, + ], + }, + openGraph: { + type: "profile", + siteName: "MHSF (Minehut Server Finder)", - images: [ - { - url: - "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + - json.server.icon + - ".png", - }, - { - url: "/public/imgs/icon-cf.png", - }, - ], - }, - }; + images: [ + { + url: + "https://minehut-server-icons-live.s3.us-west-2.amazonaws.com/" + + json.server.icon + + ".png", + }, + { + url: "/public/imgs/icon-cf.png", + }, + ], + }, + }; } export default function ServerPage({ params }: { params: { server: string } }) { - return ( -
- -
- - - - - -
- -
- -
- -
-
-
- ); + return ( +
+ +
+ + +
+ +
+ +
+ +
+
+
+ ); } diff --git a/src/components/AfterServerView.tsx b/src/components/AfterServerView.tsx index a8a42bd..1989357 100644 --- a/src/components/AfterServerView.tsx +++ b/src/components/AfterServerView.tsx @@ -33,12 +33,11 @@ import { getCommunityServerFavorites, getCustomization } from "@/lib/api"; import { MHSF } from "@/lib/mhsf"; import { ServerResponse } from "@/lib/types/mh-server"; import { - MinehutIcon, - getIndexFromRarity, - getMinehutIcons, - rarityIndex, + MinehutIcon, + getIndexFromRarity, + getMinehutIcons, } from "@/lib/types/server-icon"; -import { Copy, Info } from "lucide-react"; +import { Copy, ExternalLink, Info } from "lucide-react"; import { useTheme } from "next-themes"; import { useEffect, useState } from "react"; import FadeIn from "react-fade-in/lib/FadeIn"; @@ -48,441 +47,458 @@ import IconDisplay from "./IconDisplay"; import AchievementList from "./feat/AchievementList"; import { Button } from "./ui/button"; import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, } from "./ui/card"; import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; +import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from "./ui/drawer"; +import EmbedSelector from "./feat/EmbedSelector"; export default function AfterServerView({ server }: { server: string }) { - const [description, setDescription] = useState(""); - const [discord, setDiscord] = useState(""); - const [mhsf, setMHSF] = useState(new MHSF()); - const [icons, setIcons] = useState(); - const { resolvedTheme } = useTheme(); - const [loading, setLoading] = useState(true); - const [view, setView] = useState( - description !== "" || discord !== "" ? "desc" : "extra", - ); - const [serverObject, setServerObject] = useState( - undefined, - ); - const [copied, setCopied] = useState(false); + const [description, setDescription] = useState(""); + const [discord, setDiscord] = useState(""); + const [mhsf, setMHSF] = useState(new MHSF()); + const [icons, setIcons] = useState(); + const { resolvedTheme } = useTheme(); + const [loading, setLoading] = useState(true); + const [view, setView] = useState( + description !== "" || discord !== "" ? "desc" : "extra" + ); + const [serverObject, setServerObject] = useState( + undefined + ); + const [embedOpened, setEmbedOpened] = useState(false); + const [copied, setCopied] = useState(false); - useEffect(() => { - getCustomization(server).then((b) => { - if (b != null) { - setDescription(b.description == null ? "" : b.description); - setDiscord(b.discord == null ? "" : b.discord); - mhsf.setCustomizations(b); - getCommunityServerFavorites(server).then((c) => { - mhsf.setFavorites(c); - }); - } - 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); - }); - }, []); - if (loading) return <>; + useEffect(() => { + getCustomization(server).then((b) => { + if (b != null) { + setDescription(b.description == null ? "" : b.description); + setDiscord(b.discord == null ? "" : b.discord); + mhsf.setCustomizations(b); + getCommunityServerFavorites(server).then((c) => { + mhsf.setFavorites(c); + }); + } + 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); + }); + }, []); + if (loading) return <>; - return ( - <> - -
-
- {(description != "" || discord != "") && ( - - )} - - - -
-
-
- {(description != "" || discord != "") && ( - - )} - - - -
-
+ return ( + <> + + + + Embed Creator + + + + + +
+
+ {(description != "" || discord != "") && ( + + )} + + + + +
+
+
+ {(description != "" || discord != "") && ( + + )} + + + + +
+
-
- {description != "" && view == "desc" && ( - - - - ); - }, - }} - > - {description} - - - - )} - {discord != "" && view == "desc" && ( - - - Discord Server - - `); + + useEffect(() => { + setHtmlCode(``); + setJsxCode(`