Nuke the shit outta next

This commit is contained in:
MotorTruck1221
2025-03-17 21:55:38 -06:00
parent 10e1516540
commit 67b2a2a1ab
152 changed files with 0 additions and 8830 deletions
-43
View File
@@ -1,43 +0,0 @@
"use client";
import { useState, useEffect } from "react";
import App from "@/components/game";
interface AppData {
title: string;
image: string;
url: string;
}
export default function Apps() {
const [Apps, setApps] = useState<AppData[]>([]);
useEffect(() => {
async function fetchApps() {
try {
const response = await fetch("/apps.json");
if (!response.ok) {
throw new Error("Failed to fetch data");
}
const data: AppData[] = await response.json();
setApps(data);
} catch (error) {
console.error("Error fetching data:", error);
}
}
fetchApps();
}, []);
return (
<div>
<h1 className="text-6xl font-semibold py-8 text-center">Apps</h1>
<div className="flex flex-wrap justify-center px-24">
{Apps.map((app, index) => (
<div className="p-2" key={index}>
<App title={app.title} image={app.image} url={app.url} />
</div>
))}
</div>
</div>
);
}
-43
View File
@@ -1,43 +0,0 @@
"use client";
import { useState, useEffect } from "react";
import Game from "@/components/game";
interface GameData {
title: string;
image: string;
url: string;
}
export default function Games() {
const [games, setGames] = useState<GameData[]>([]);
useEffect(() => {
async function fetchGames() {
try {
const response = await fetch("/games.json");
if (!response.ok) {
throw new Error("Failed to fetch data");
}
const data: GameData[] = await response.json();
setGames(data);
} catch (error) {
console.error("Error fetching data:", error);
}
}
fetchGames();
}, []);
return (
<div>
<h1 className="text-6xl font-semibold py-8 text-center">Games</h1>
<div className="flex flex-wrap justify-center px-24">
{games.map((game, index) => (
<div className="p-2" key={index}>
<Game title={game.title} image={game.image} url={game.url} />
</div>
))}
</div>
</div>
);
}
-166
View File
@@ -1,166 +0,0 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: 214 27.37% 7.55%;
--foreground: 212 16% 82%;
--muted: 214 12% 16%;
--muted-foreground: 214 12% 66%;
--popover: 214 27% 9%;
--popover-foreground: 212 16% 92%;
--card: 214 23.58% 9.03%;
--card-foreground: 212 16% 87%;
--border: 214 17% 17%;
--input: 214 17% 20%;
--primary: 194.72 85% 45%;
--primary-foreground: 189 85% 5%;
--secondary: 221.89 18.13% 22.46%;
--secondary-foreground: 189 30% 85%;
--accent: 221.89 18.13% 22.46%;
--accent-foreground: 214 27% 87%;
--destructive: 6 96% 59%;
--destructive-foreground: 0 0% 100%;
--ring: 215.09 100% 98.03%;
--radius: 0.4rem;
}
.bluelight {
--background: 230 8% 85%;
--foreground: 229 26% 28%;
--muted: 230 12% 81%;
--muted-foreground: 230 12% 21%;
--popover: 230 8% 82%;
--popover-foreground: 229 26% 18%;
--card: 230 8% 83%;
--card-foreground: 229 26% 23%;
--border: 0 0% 80%;
--input: 0 0% 77%;
--primary: 223 42% 57%;
--primary-foreground: 0 0% 100%;
--secondary: 223 30% 75%;
--secondary-foreground: 223 30% 15%;
--accent: 230 8% 70%;
--accent-foreground: 230 8% 10%;
--destructive: 2 82% 30%;
--destructive-foreground: 2 82% 90%;
--ring: 223 42% 57%;
}
.cyberpunk {
--background: 253 41% 19%;
--foreground: 157 100% 50%;
--muted: 253 12% 23%;
--muted-foreground: 253 12% 73%;
--popover: 253 41% 16%;
--popover-foreground: 157 100% 60%;
--card: 253 41% 17%;
--card-foreground: 157 100% 55%;
--border: 253 31% 24%;
--input: 253 31% 27%;
--primary: 167 100% 50%;
--primary-foreground: 167 100% 10%;
--secondary: 167 30% 25%;
--secondary-foreground: 167 30% 85%;
--accent: 253 41% 34%;
--accent-foreground: 254 41% 94%;
--destructive: 5 92% 45%;
--destructive-foreground: 0 0% 100%;
--ring: 167 100% 50%;
}
.catppuccin {
--background: 240 21% 15%;
--foreground: 226 64% 88%;
--muted: 240 21% 12%;
--muted-foreground: 228 17% 64%;
--popover: 240 21% 12%;
--popover-foreground: 227 35% 80%;
--card: 240 21% 12%;
--card-foreground: 228 24% 72%;
--border: 234 13% 31%;
--input: 234 13% 31%;
--primary: 115 54% 76%;
--primary-foreground: 240 21% 15%;
--secondary: 240 21% 12%;
--secondary-foreground: 228 17% 64%;
--accent: 237 16% 23%;
--accent-foreground: 227 35% 80%;
--destructive: 343 81% 75%;
--destructive-foreground: 226 64% 88%;
--ring: 228 24% 72%;
}
.midnight {
--background: 0 0% 0%;
--foreground: 0 0% 100%;
--muted: 0 0% 0%;
--muted-foreground: 0 0% 50%;
--popover: 0 0% 0%;
--popover-foreground: 0 0% 95%;
--card: 0 0% 5%;
--card-foreground: 0 0% 90%;
--border: 0 0% 25%;
--input: 0 0% 20%;
--primary: 158 97% 53%;
--primary-foreground: 0 0% 0%;
--secondary: 0 0% 8%;
--secondary-foreground: 167 0% 85%;
--accent: 0 0% 12%;
--accent-foreground: 0 0% 90%;
--destructive: 360 100% 65%;
--destructive-foreground: 0 0% 100%;
--ring: 0 0% 70%;
--radius: 0.4rem;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
@layer base {
.loader {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.loader div {
box-sizing: border-box;
display: block;
position: absolute;
width: 64px;
height: 64px;
margin: 8px;
border: 8px solid #fff;
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: #fff transparent transparent transparent;
}
.loader div:nth-child(1) {
animation-delay: -0.45s;
}
.loader div:nth-child(2) {
animation-delay: -0.3s;
}
.loader div:nth-child(3) {
animation-delay: -0.15s;
}
@keyframes lds-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
}
-198
View File
@@ -1,198 +0,0 @@
"use client";
import Sidebar from "@/components/sidebar";
import { Button } from "@/components/ui/button";
import { encodeXor } from "@/lib/utils";
import { useEffect, useRef, useState } from "react";
import store from "store2";
import * as Lucide from "lucide-react";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
interface ContentWindow extends Window {
__uv$location: Location;
}
declare global {
interface Window {
chemical: any;
}
}
export default function Route({ params }: { params: { route: string[] } }) {
const ref = useRef<HTMLIFrameElement>(null);
const contentWindow = ref.current?.contentWindow as ContentWindow;
const [open, setOpen] = useState(false);
const route = params.route.join("/");
const [tabIcon, setTabIcon] = useState("");
const [tabName, setTabName] = useState("");
const [shortcutted, setShortcutted] = useState(false);
useEffect(() => {
async function go() {
if (ref.current) {
ref.current.src = await window.chemical.encode(
atob(decodeURIComponent(route)),
{
service: window.chemical.getStore("service"),
autoHttps: true,
searchEngine:
window.chemical.getStore("searchEngine") ||
"https://www.google.com/search?q=%s",
}
);
}
}
go();
}, []);
function triggerShortcut() {
store.set("shortcuts", [], false);
const contentWindow = ref.current?.contentWindow as ContentWindow;
if (!("__uv$location" in contentWindow)) return;
const shortcuts: any[] = store("shortcuts");
if (
shortcuts.some((value) => value.url == contentWindow.__uv$location.href)
) {
store(
"shortcuts",
shortcuts.filter(
(value) => value.url !== contentWindow.__uv$location.href
)
);
setShortcutted(false);
} else {
store("shortcuts", [
...store("shortcuts"),
{
image:
(
contentWindow.document.querySelector(
"link[rel*='icon']"
) as HTMLLinkElement
)?.href || `${contentWindow.__uv$location.origin}/favicon.ico`,
title: contentWindow.document.title,
url: contentWindow.__uv$location.href,
},
]);
setShortcutted(true);
}
}
function handleLoad() {
const contentWindow = ref.current?.contentWindow as ContentWindow;
setTabName(contentWindow.document.title);
setTabIcon(
(
contentWindow.document.querySelector(
"link[rel*='icon']"
) as HTMLLinkElement
)?.href || `${contentWindow.__uv$location.origin}/favicon.ico`
);
store.set("shortcuts", [], false);
const shortcuts: any[] = store("shortcuts");
if (
shortcuts.some((value) => value.url == contentWindow.__uv$location.href)
) {
setShortcutted(true);
} else {
setShortcutted(false);
}
}
return (
<div>
<div className="w-screen fixed top-0 h-14 border-b flex items-center justify-between px-4 pr-8">
<div className="flex items-center gap-3">
<Button onClick={() => setOpen(true)} size="icon" variant="ghost">
<Lucide.Menu className="h-7 w-7" />
</Button>
<div className="flex items-center gap-2">
{tabIcon ? (
<img src={tabIcon} className="h-8 w-8" />
) : (
<Lucide.Radius className="h-8 w-8 rotate-180" />
)}
<h1 className="text-xl font-bold">
{tabName ? tabName : "Radius"}
</h1>
</div>
</div>
<div className="flex items-center gap-2 z-50">
<TooltipProvider delayDuration={0}>
<Tooltip>
<TooltipTrigger asChild>
<Button onClick={() => contentWindow.history.back()} variant="ghost" size="icon">
<Lucide.ArrowLeft />
</Button>
</TooltipTrigger>
<TooltipContent>Back</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button onClick={() => contentWindow.history.forward()} variant="ghost" size="icon">
<Lucide.ArrowRight />
</Button>
</TooltipTrigger>
<TooltipContent>Forward</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button onClick={() => contentWindow.location.reload()} variant="ghost" size="icon">
<Lucide.RotateCw />
</Button>
</TooltipTrigger>
<TooltipContent>Reload</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" onClick={triggerShortcut}>
<Lucide.Star
className={shortcutted ? "fill-foreground" : "fill-none"}
/>
</Button>
</TooltipTrigger>
<TooltipContent>Shortcut</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
<Sidebar open={open} onOpenChange={setOpen} />
</div>
<iframe
ref={ref}
onLoad={handleLoad}
className="h-[calc(100vh-3.5rem)] w-full"
></iframe>
<div className="flex items-center justify-center fixed h-full w-full pointer-events-none -z-10">
<svg
aria-hidden="true"
className="w-20 h-20 animate-spin text-gray-600 fill-primary"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
</div>
</div>
);
}
-33
View File
@@ -1,33 +0,0 @@
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";
import Navbar from "@/components/navbar";
import { Themes } from "./providers";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "Radius",
description: "",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<head>
<link rel="icon" href="/icon.png" />
<script data-wisp-store data-transport-store src="/chemical.js"></script>
</head>
<body className={inter.className}>
<Themes>
<Navbar />
<div className="pt-14">{children}</div>
</Themes>
</body>
</html>
);
}
-46
View File
@@ -1,46 +0,0 @@
"use client";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardTitle } from "@/components/ui/card";
import { ShieldX } from "lucide-react";
import Image from "next/image";
export default function PageNotFound() {
return (
<div className="flex h-screen items-center justify-center">
{/* Container for mobile and desktop layouts */}
<div className="flex flex-col lg:flex-row items-center justify-center space-y-6 lg:space-y-0 lg:space-x-8">
{/* Cat gif on top for mobile, on the left for larger screens */}
<div className="flex-shrink-0">
<Image
src="/kitty.gif"
width={300} // dont adjust unless you're weird
height={300}
alt="kitty"
className="rounded-lg" // rounded corner for kitty
/>
</div>
{/* the error card */}
<Card className="flex h-96 w-96 flex-col items-center justify-center">
<CardTitle className="mx-auto mb-2 flex flex-col items-center justify-center">
<ShieldX className="h-14 w-14" />
<h2 className="mt-2 text-3xl font-semibold">404 Error</h2>
</CardTitle>
<CardContent className="mt-4 text-center text-base">
Click below to go to the home page.
<br /> 404 - Page not found
</CardContent>
<CardContent className="mt-4">
<Button
type="button"
onClick={() => (window.location.href = "/")}
className="text-muted-background text-black"
>
Go Home
</Button>
</CardContent>
</Card>
</div>
</div>
);
}
-75
View File
@@ -1,75 +0,0 @@
"use client";
import Shortcut from "@/components/shortcut";
import { Input } from "@/components/ui/input";
import { Flame, Radius, Search } from "lucide-react";
import { useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import { Item } from "@/lib/types";
import store from "store2";
export default function Home() {
const router = useRouter();
const [shortcuts, setShortcuts] = useState<Item[]>([]);
const [splashText, setSplashText] = useState<string>("");
useEffect(() => {
fetch("/splash.json")
.then((response) => response.json())
.then((data) => {
const randomIndex = Math.floor(Math.random() * data.length);
setSplashText(data[randomIndex].splash);
})
.catch((error) => console.error("Error fetching splash text:", error));
store.set("shortcuts", [], false);
const data: Item[] = store("shortcuts");
setShortcuts(data);
}, []);
return (
<div>
<div className="fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex flex-col items-center gap-6">
<div className="flex items-center gap-2">
<Radius className="h-16 w-16 rotate-180" />
<h1 className="text-6xl font-semibold">Radius</h1>
</div>
<div className="flex items-center gap-2">
<div className="relative">
<Input
className="w-[26rem] px-9 h-12 rounded-lg"
placeholder="Search the web"
onKeyDown={(e) => {
if (e.key !== "Enter") return;
router.push(`/go/${btoa(e.currentTarget.value)}`);
}}
/>
<Search className="h-4 w-4 text-muted-foreground absolute top-1/2 -translate-y-1/2 left-3" />
</div>
</div>
<p
style={{
fontSize: "1rem",
fontWeight: "normal",
marginTop: "0.4rem",
}}
>
{splashText}
</p>
{shortcuts.length > 0 && (
<div className="py-2 flex flex-wrap gap-2 justify-center">
{shortcuts.map((shortcut: Item) => {
return (
<Shortcut
key={shortcut.title}
image={shortcut.image}
title={shortcut.title}
url={shortcut.url}
/>
);
})}
</div>
)}
</div>
</div>
);
}
-7
View File
@@ -1,7 +0,0 @@
"use client";
import { ThemeProvider } from "next-themes";
export function Themes({ children }: { children: React.ReactNode }) {
return <ThemeProvider attribute="class">{children}</ThemeProvider>;
}
-94
View File
@@ -1,94 +0,0 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { ModeToggle } from "@/components/ThemeSwitch";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import { Save, RotateCcw } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";
const formSchema = z.object({
backgroundImage: z.string().url("Please provide a valid URL"),
description: z.string().optional(),
});
export default function Settings() {
const [submitting, setSubmitting] = useState(false);
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
backgroundImage: "",
},
});
function onSubmit(values: z.infer<typeof formSchema>) {
setSubmitting(true);
document.body.style.backgroundImage = `url(${values.backgroundImage})`;
document.body.style.backgroundSize = "cover";
document.body.style.backgroundPosition = "center";
setTimeout(() => {
setSubmitting(false);
toast.success("Settings saved");
}, 1000);
}
function onReset() {
form.reset();
document.body.style.backgroundImage = "";
toast("Settings reset");
}
return (
<div className="space-y-4">
<h1 className="text-4xl font-semibold">Appearance</h1>
<Separator />
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="w-1/2 space-y-4"
>
<FormField
control={form.control}
name="backgroundImage"
render={({ field }) => (
<FormItem>
<FormLabel>Background Image</FormLabel>
<FormControl>
<Input placeholder="Background Image URL" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{}
<div className="flex space-x-4">
<Button type="submit" disabled={submitting}>
<Save className="mr-2 h-5 w-5" /> Save Changes
</Button>
<Button type="button" onClick={onReset}>
<RotateCcw className="mr-2 h-5 w-5" /> Reset
</Button>
</div>
</form>
</Form>
<ModeToggle />
</div>
);
}
-24
View File
@@ -1,24 +0,0 @@
"use client";
import { Separator } from "@/components/ui/separator";
export default function Credits() {
return (
<div>
<h1 className="text-4xl font-semibold">Credits</h1>
<Separator />
<div className="mt-4">
<p>Radius contributors!</p>
<ul className="list-disc pl-5 mt-2 space-y-1">
<li>Owski09</li>
<li>proudparrot2</li>
<li>Sparkzil</li>
<li>Scaratek</li>
<li>fwxe</li>
<li>Nebelung</li>
<li>anshnk</li>
</ul>
</div>
</div>
);
}
-60
View File
@@ -1,60 +0,0 @@
"use client";
import { Button } from "@/components/ui/button";
import { Users, Link, Palette, LockIcon } from "lucide-react";
import NextLink from "next/link";
import { usePathname } from "next/navigation";
export default function SettingsLayout({
children,
}: Readonly<{ children: React.ReactNode }>) {
const pathname = usePathname();
return (
<div className="flex">
<div className="flex w-1/4 flex-col gap-2 p-4 pl-8 pt-8">
<NextLink href="/settings/proxy/">
<Button
variant={
pathname?.includes("/settings/proxy/") ? "secondary" : "ghost"
}
className="w-full items-center justify-start gap-2"
>
<LockIcon className="h-5 w-5" /> Proxy
</Button>
</NextLink>
<NextLink href="/settings/appearance/">
<Button
variant={
pathname?.includes("/settings/appearance") ? "secondary" : "ghost"
}
className="w-full items-center justify-start gap-2"
>
<Palette className="h-5 w-5" /> Appearance
</Button>
</NextLink>
<NextLink href="/settings/credits/">
<Button
variant={
pathname?.includes("/settings/credits") ? "secondary" : "ghost"
}
className="w-full items-center justify-start gap-2"
>
<Users className="h-5 w-5" /> Credits
</Button>
</NextLink>
<NextLink href="/settings/links/">
<Button
variant={
pathname?.includes("/settings/links") ? "secondary" : "ghost"
}
className="w-full items-center justify-start gap-2"
>
<Link className="h-5 w-5" /> Social Links
</Button>
</NextLink>
</div>
<div className="w-3/4 px-12 py-8">{children}</div>
</div>
);
}
-30
View File
@@ -1,30 +0,0 @@
"use client";
import NextLink from "next/link";
import { Separator } from "@/components/ui/separator";
export default function SocialLinks() {
return (
<div>
<h1 className="text-4xl font-semibold">Socials</h1>
<Separator />
<div className="mt-4">
<p>Follow us on other platforms!</p>
<ul className="list-disc pl-5 mt-2 space-y-1">
<li>TikTok: @radiusproxy</li>
<li>YouTube: @RadiusProxy</li>
<li>
Discord:{" "}
<NextLink
href="https://discord.gg/JrAxQz7Qkw"
target="_blank"
className="text-blue-500 underline"
>
Join Now!
</NextLink>
</li>
</ul>
</div>
</div>
);
}
-208
View File
@@ -1,208 +0,0 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Separator } from "@/components/ui/separator";
import { Save, RotateCcw } from "lucide-react";
import { useEffect, useState } from "react";
import { toast } from "sonner";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
const formSchema = z.object({
wispServer: z.string().url("Please provide a valid URL"),
description: z.string().optional(),
});
export default function ProxyOptions() {
const [submitting, setSubmitting] = useState(false);
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
wispServer: "",
},
});
useEffect(() => {
const wispServer: string = window.chemical.getStore("wisp");
const defaultWisp: string =
(location.protocol === "https:" ? "wss" : "ws") +
"://" +
location.host +
"/wisp/";
form.setValue("wispServer", wispServer !== defaultWisp ? wispServer : "");
}, []);
function onSubmit(values: z.infer<typeof formSchema>) {
setSubmitting(true);
window.chemical.setStore("wisp", values.wispServer);
setTimeout(() => {
setSubmitting(false);
toast.success("Settings saved");
}, 1000);
}
function onReset() {
form.reset();
window.chemical.setStore("wisp", "");
toast("Settings reset");
}
const [proxy, setProxy] = useState("");
useEffect(() => {
setProxy(window.chemical.getStore("service"));
}, []);
const proxyChanged = (service: string) => {
setProxy(service);
window.chemical.setStore("service", service);
};
const [searchEngine, setSearchEngine] = useState("");
useEffect(() => {
setSearchEngine(
window.chemical.getStore("searchEngine") ||
"https://www.google.com/search?q=%s"
);
}, []);
const searchEngineChanged = (service: string) => {
setSearchEngine(service);
window.chemical.setStore("searchEngine", service);
};
const [transport, setTransport] = useState("");
useEffect(() => {
setTransport(window.chemical.getStore("transport"));
}, []);
const transportChanged = (service: string) => {
setTransport(service);
window.chemical.setStore("transport", service);
};
return (
<div>
<h1 className="text-4xl font-semibold">Proxy</h1>
<Separator />
<div className="mt-4">
<p>Proxy Switcher</p>
<Select value={proxy} onValueChange={proxyChanged}>
<SelectTrigger className="w-[180px]">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem value="uv">Ultraviolet</SelectItem>
<SelectItem value="rammerhead">Rammerhead</SelectItem>
<SelectItem value="scramjet">
Scramjet (old broken version)
</SelectItem>
<SelectItem value="meteor">Meteor</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<p>Transport</p>
<Select value={transport} onValueChange={transportChanged}>
<SelectTrigger className="w-[180px]">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem value="libcurl">Libcurl</SelectItem>
<SelectItem value="epoxy">Epoxy</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<p>Search Engine</p>
<Select value={searchEngine} onValueChange={searchEngineChanged}>
<SelectTrigger className="w-[180px]">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem value="https://www.google.com/search?q=%s">
Google
</SelectItem>
<SelectItem value="https://duckduckgo.com/?q=%s&ia=web">
DuckDuckGo
</SelectItem>
<SelectItem value="https://www.bing.com/search?q=%s">
Bing
</SelectItem>
<SelectItem value="https://search.yahoo.com/search?p=%s">
Yahoo
</SelectItem>
<SelectItem value="https://search.brave.com/search?q=%s">
Brave
</SelectItem>
<SelectItem value="https://www.qwant.com/?q=%s&t=web">
Qwant
</SelectItem>
<SelectItem value="https://searx.si/search?q=%s">
SearXNG
</SelectItem>
<SelectItem value="https://www.ecosia.org/search?method=index&q=%s">
Ecosia
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="w-1/2 space-y-4"
>
<FormField
control={form.control}
name="wispServer"
render={({ field }) => (
<FormItem>
<FormLabel>Wisp Server Switcher</FormLabel>
<FormControl>
<Input placeholder="Wisp Server URL" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{}
<div className="flex space-x-4">
<Button type="submit" disabled={submitting}>
<Save className="mr-2 h-5 w-5" /> Save Changes
</Button>
<Button type="button" onClick={onReset}>
<RotateCcw className="mr-2 h-5 w-5" /> Reset
</Button>
</div>
</form>
</Form>
</div>
</div>
);
}
-50
View File
@@ -1,50 +0,0 @@
"use client";
import * as React from "react";
import { Moon, Sun } from "lucide-react";
import { useTheme } from "next-themes";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
export function ModeToggle() {
const { setTheme } = useTheme();
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline">
<Sun className="h-5 w-5 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 mr-1" />
<Moon className="absolute h-5 w-5 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100 mr-[60px]" />
<p>Themes</p>
<span className="sr-only">Toggle theme</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setTheme("radius")}>
Radius
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("cyberpunk")}>
Cyberpunk
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("bluelight")}>
Bluelight
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("midnight")}>
Midnight
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("catppuccin")}>
Catppuccin
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("midnight")}>
System
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
}
-21
View File
@@ -1,21 +0,0 @@
'use client'
import { useRouter } from 'next/navigation'
import { Item } from '@/lib/types'
export default function App({ title, image, url }: Item) {
const router = useRouter()
return (
<div
className="relative group cursor-pointer hover:scale-105 duration-100 transition-all"
onClick={() => {
router.push(`/go/${btoa(url)}`)
}}
>
<img src={image} className="h-36 aspect-square object-cover rounded-md" />
<div className="absolute inset-0 h-full w-full opacity-0 group-hover:opacity-100 bg-gradient-to-t from-accent to-transparent rounded-b-md duration-100 flex items-end p-2 px-4 font-semibold">
<p>{title}</p>
</div>
</div>
)
}
-20
View File
@@ -1,20 +0,0 @@
'use client'
import { useRouter } from 'next/navigation'
import { Item } from '@/lib/types'
export default function Game({ title, image, url }: Item) {
const router = useRouter()
return (
<div
className="relative group cursor-pointer hover:scale-105 duration-100 transition-all"
onClick={() => {
router.push(`/go/${btoa(url)}`)
}}
>
<img src={image} className="h-36 aspect-square object-cover rounded-md" />
<div className="absolute inset-0 h-full w-full opacity-0 group-hover:opacity-100 bg-gradient-to-t from-accent to-transparent rounded-b-md duration-100 flex items-end p-2 px-4 font-semibold">
<p>{title}</p>
</div>
</div>
)
}
-33
View File
@@ -1,33 +0,0 @@
'use client'
import * as Lucide from 'lucide-react'
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './ui/tooltip'
import { usePathname } from 'next/navigation'
import { Button } from './ui/button'
import { useState } from 'react'
import Sidebar from './sidebar'
import Link from 'next/link' // Import the Link component
import { ModeToggle } from "./ThemeSwitch";
export default function Navbar() {
const [open, setOpen] = useState(false)
const pathname = usePathname()
if (pathname && pathname.includes('/go/')) return null
return (
<div className="w-screen fixed h-14 border-b flex items-center px-4 bg-background z-10">
<div className="flex items-center gap-3">
<Button onClick={() => setOpen(true)} size="icon" variant="ghost">
<Lucide.Menu className="h-7 w-7" />
</Button>
{/* Wrap the logo and text in a Link */}
<Link href="/" className="flex items-center gap-2">
<Lucide.Radius className="h-8 w-8 rotate-180" />
<h1 className="text-xl font-bold">Radius</h1>
</Link>
</div>
<Sidebar open={open} onOpenChange={setOpen} />
</div>
)
}
-31
View File
@@ -1,31 +0,0 @@
import { Item } from '@/lib/types'
import { Ellipsis, Pen, Pencil, SquarePen, X } from 'lucide-react'
import { useRouter } from 'next/navigation'
import store from 'store2'
export default function Shortcut({ image, title, url }: Item) {
function removeShortcut() {
const shortcuts: Item[] = store('shortcuts')
store(
'shortcuts',
shortcuts.filter((value) => value.url !== url)
)
location.reload()
}
const router = useRouter()
return (
<div
className="group flex flex-col relative items-center justify-center gap-3 border h-32 w-32 rounded-md bg-card hover:bg-accent duration-200 cursor-pointer"
onClick={() => {
router.push(`/go/${btoa(url)}`)
}}
>
<img src={image} className="h-8 w-8" />
{title && <p className="truncate w-full px-2">{title}</p>}
<div className="absolute bottom-2 right-2 opacity-0 group-hover:opacity-100 duration-200 transition-opacity">
<X size={16} onClick={removeShortcut} />
</div>
</div>
)
}
-48
View File
@@ -1,48 +0,0 @@
'use client'
import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sheet'
import * as Lucide from 'lucide-react'
import { Button } from './ui/button'
import { usePathname } from 'next/navigation'
import Link from 'next/link'
import { Separator } from './ui/separator'
export default function Sidebar({ open, onOpenChange }: { open: boolean; onOpenChange: (open: boolean) => void }) {
const pathname = usePathname()
return (
<Sheet open={open} onOpenChange={onOpenChange}>
<SheetContent side="left" className="w-72">
<SheetHeader>
<SheetTitle>
<Lucide.Radius className="rotate-180 h-10 w-10 ml-2"></Lucide.Radius>
</SheetTitle>
</SheetHeader>
<div className="py-6 flex flex-col gap-2">
<Link href="/" onClick={() => onOpenChange(false)}>
<Button variant={pathname == '/' ? 'secondary' : 'ghost'} className="justify-start gap-2 w-full hover:scale-105 duration-200 transition-all">
<Lucide.Home /> Home
</Button>
</Link>
<Link href="/games" onClick={() => onOpenChange(false)}>
<Button variant={pathname?.includes('/games') ? 'secondary' : 'ghost'} className="justify-start gap-2 w-full hover:scale-105 duration-200 transition-all">
<Lucide.Gamepad /> Games
</Button>
</Link>
<Link href="/apps" onClick={() => onOpenChange(false)}>
<Button variant={pathname?.includes('/apps') ? 'secondary' : 'ghost'} className="justify-start gap-2 w-full hover:scale-105 duration-200 transition-all">
<Lucide.LayoutGrid /> Apps
</Button>
</Link>
<Separator />
<Link href="/settings" onClick={() => onOpenChange(false)}>
<Button variant={pathname?.includes('/settings') ? 'secondary' : 'ghost'} className="justify-start gap-2 w-full hover:scale-105 duration-200 transition-all">
<Lucide.Settings2 /> Settings
</Button>
</Link>
</div>
</SheetContent>
</Sheet>
)
}
-88
View File
@@ -1,88 +0,0 @@
import { createContext, useContext, useEffect, useState } from 'react';
type Theme =
| 'radius'
| 'cyberpunk'
| 'bluelight'
| 'midnight'
| 'catppuccin'
| 'system';
const themes: Theme[] = [
'radius',
'cyberpunk',
'bluelight',
'midnight',
'catppuccin',
'system',
];
type ThemeProviderProps = {
children: React.ReactNode;
defaultTheme?: Theme;
storageKey?: string;
};
type ThemeProviderState = {
themes: Theme[];
theme: Theme;
setTheme: (theme: Theme) => void;
};
const initialState: ThemeProviderState = {
themes: themes,
theme: 'system',
setTheme: () => null,
};
const ThemeProviderContext = createContext<ThemeProviderState>(initialState);
export function ThemeProvider({
children,
defaultTheme = 'system',
storageKey = 'theme',
...props
}: ThemeProviderProps) {
const [theme, setTheme] = useState<Theme>(
() => (localStorage.getItem(storageKey) as Theme) || defaultTheme,
);
useEffect(() => {
const root = window.document.documentElement;
root.classList.remove(...themes);
if (theme === 'system') {
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)')
.matches
? 'midnight'
: 'bluelight';
root.classList.add(systemTheme);
return;
}
root.classList.add(theme);
}, [theme]);
const value = {
theme,
themes,
setTheme: (theme: Theme) => {
localStorage.setItem(storageKey, theme);
setTheme(theme);
},
};
return (
<ThemeProviderContext.Provider {...props} value={value}>
{children}
</ThemeProviderContext.Provider>
);
}
// eslint-disable-next-line
export const useTheme = () => {
const context = useContext(ThemeProviderContext);
if (context === undefined)
throw new Error('useTheme must be used within a ThemeProvider');
return context;
};
-40
View File
@@ -1,40 +0,0 @@
import * as React from 'react'
import { Slot } from '@radix-ui/react-slot'
import { cva, type VariantProps } from 'class-variance-authority'
import { cn } from '@/lib/utils'
const buttonVariants = cva('inline-flex items-center justify-center whitespace-nowrap rounded-lg text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', {
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline'
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'h-10 w-10'
}
},
defaultVariants: {
variant: 'default',
size: 'default'
}
})
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
asChild?: boolean
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'button'
return <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} />
})
Button.displayName = 'Button'
export { Button, buttonVariants }
-79
View File
@@ -1,79 +0,0 @@
import * as React from "react"
import { cn } from "@/lib/utils"
const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"rounded-lg border bg-card text-card-foreground shadow-sm",
className
)}
{...props}
/>
))
Card.displayName = "Card"
const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
{...props}
/>
))
CardHeader.displayName = "CardHeader"
const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn(
"text-2xl font-semibold leading-none tracking-tight",
className
)}
{...props}
/>
))
CardTitle.displayName = "CardTitle"
const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
CardDescription.displayName = "CardDescription"
const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
))
CardContent.displayName = "CardContent"
const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex items-center p-6 pt-0", className)}
{...props}
/>
))
CardFooter.displayName = "CardFooter"
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
-200
View File
@@ -1,200 +0,0 @@
"use client"
import * as React from "react"
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
import { Check, ChevronRight, Circle } from "lucide-react"
import { cn } from "@/lib/utils"
const DropdownMenu = DropdownMenuPrimitive.Root
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
const DropdownMenuGroup = DropdownMenuPrimitive.Group
const DropdownMenuPortal = DropdownMenuPrimitive.Portal
const DropdownMenuSub = DropdownMenuPrimitive.Sub
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
const DropdownMenuSubTrigger = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
inset?: boolean
}
>(({ className, inset, children, ...props }, ref) => (
<DropdownMenuPrimitive.SubTrigger
ref={ref}
className={cn(
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
inset && "pl-8",
className
)}
{...props}
>
{children}
<ChevronRight className="ml-auto h-4 w-4" />
</DropdownMenuPrimitive.SubTrigger>
))
DropdownMenuSubTrigger.displayName =
DropdownMenuPrimitive.SubTrigger.displayName
const DropdownMenuSubContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
>(({ className, ...props }, ref) => (
<DropdownMenuPrimitive.SubContent
ref={ref}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
))
DropdownMenuSubContent.displayName =
DropdownMenuPrimitive.SubContent.displayName
const DropdownMenuContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<DropdownMenuPrimitive.Portal>
<DropdownMenuPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
</DropdownMenuPrimitive.Portal>
))
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
const DropdownMenuItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
inset?: boolean
}
>(({ className, inset, ...props }, ref) => (
<DropdownMenuPrimitive.Item
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
inset && "pl-8",
className
)}
{...props}
/>
))
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
const DropdownMenuCheckboxItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
>(({ className, children, checked, ...props }, ref) => (
<DropdownMenuPrimitive.CheckboxItem
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className
)}
checked={checked}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<Check className="h-4 w-4" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
</DropdownMenuPrimitive.CheckboxItem>
))
DropdownMenuCheckboxItem.displayName =
DropdownMenuPrimitive.CheckboxItem.displayName
const DropdownMenuRadioItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
>(({ className, children, ...props }, ref) => (
<DropdownMenuPrimitive.RadioItem
ref={ref}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className
)}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<Circle className="h-2 w-2 fill-current" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
</DropdownMenuPrimitive.RadioItem>
))
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
const DropdownMenuLabel = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
inset?: boolean
}
>(({ className, inset, ...props }, ref) => (
<DropdownMenuPrimitive.Label
ref={ref}
className={cn(
"px-2 py-1.5 text-sm font-semibold",
inset && "pl-8",
className
)}
{...props}
/>
))
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
const DropdownMenuSeparator = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
>(({ className, ...props }, ref) => (
<DropdownMenuPrimitive.Separator
ref={ref}
className={cn("-mx-1 my-1 h-px bg-muted", className)}
{...props}
/>
))
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
const DropdownMenuShortcut = ({
className,
...props
}: React.HTMLAttributes<HTMLSpanElement>) => {
return (
<span
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
{...props}
/>
)
}
DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
export {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuCheckboxItem,
DropdownMenuRadioItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuGroup,
DropdownMenuPortal,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuRadioGroup,
}
-176
View File
@@ -1,176 +0,0 @@
import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { Slot } from "@radix-ui/react-slot"
import {
Controller,
ControllerProps,
FieldPath,
FieldValues,
FormProvider,
useFormContext,
} from "react-hook-form"
import { cn } from "@/lib/utils"
import { Label } from "@/components/ui/label"
const Form = FormProvider
type FormFieldContextValue<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
> = {
name: TName
}
const FormFieldContext = React.createContext<FormFieldContextValue>(
{} as FormFieldContextValue
)
const FormField = <
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
>({
...props
}: ControllerProps<TFieldValues, TName>) => {
return (
<FormFieldContext.Provider value={{ name: props.name }}>
<Controller {...props} />
</FormFieldContext.Provider>
)
}
const useFormField = () => {
const fieldContext = React.useContext(FormFieldContext)
const itemContext = React.useContext(FormItemContext)
const { getFieldState, formState } = useFormContext()
const fieldState = getFieldState(fieldContext.name, formState)
if (!fieldContext) {
throw new Error("useFormField should be used within <FormField>")
}
const { id } = itemContext
return {
id,
name: fieldContext.name,
formItemId: `${id}-form-item`,
formDescriptionId: `${id}-form-item-description`,
formMessageId: `${id}-form-item-message`,
...fieldState,
}
}
type FormItemContextValue = {
id: string
}
const FormItemContext = React.createContext<FormItemContextValue>(
{} as FormItemContextValue
)
const FormItem = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
const id = React.useId()
return (
<FormItemContext.Provider value={{ id }}>
<div ref={ref} className={cn("space-y-2", className)} {...props} />
</FormItemContext.Provider>
)
})
FormItem.displayName = "FormItem"
const FormLabel = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
>(({ className, ...props }, ref) => {
const { error, formItemId } = useFormField()
return (
<Label
ref={ref}
className={cn(error && "text-destructive", className)}
htmlFor={formItemId}
{...props}
/>
)
})
FormLabel.displayName = "FormLabel"
const FormControl = React.forwardRef<
React.ElementRef<typeof Slot>,
React.ComponentPropsWithoutRef<typeof Slot>
>(({ ...props }, ref) => {
const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
return (
<Slot
ref={ref}
id={formItemId}
aria-describedby={
!error
? `${formDescriptionId}`
: `${formDescriptionId} ${formMessageId}`
}
aria-invalid={!!error}
{...props}
/>
)
})
FormControl.displayName = "FormControl"
const FormDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => {
const { formDescriptionId } = useFormField()
return (
<p
ref={ref}
id={formDescriptionId}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
)
})
FormDescription.displayName = "FormDescription"
const FormMessage = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, children, ...props }, ref) => {
const { error, formMessageId } = useFormField()
const body = error ? String(error?.message) : children
if (!body) {
return null
}
return (
<p
ref={ref}
id={formMessageId}
className={cn("text-sm font-medium text-destructive", className)}
{...props}
>
{body}
</p>
)
})
FormMessage.displayName = "FormMessage"
export {
useFormField,
Form,
FormItem,
FormLabel,
FormControl,
FormDescription,
FormMessage,
FormField,
}
-12
View File
@@ -1,12 +0,0 @@
import * as React from 'react'
import { cn } from '@/lib/utils'
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
const Input = React.forwardRef<HTMLInputElement, InputProps>(({ className, type, ...props }, ref) => {
return <input type={type} className={cn('flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50', className)} ref={ref} {...props} />
})
Input.displayName = 'Input'
export { Input }
-26
View File
@@ -1,26 +0,0 @@
"use client"
import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
)
const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
{...props}
/>
))
Label.displayName = LabelPrimitive.Root.displayName
export { Label }
-160
View File
@@ -1,160 +0,0 @@
"use client"
import * as React from "react"
import * as SelectPrimitive from "@radix-ui/react-select"
import { Check, ChevronDown, ChevronUp } from "lucide-react"
import { cn } from "@/lib/utils"
const Select = SelectPrimitive.Root
const SelectGroup = SelectPrimitive.Group
const SelectValue = SelectPrimitive.Value
const SelectTrigger = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Trigger
ref={ref}
className={cn(
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
className
)}
{...props}
>
{children}
<SelectPrimitive.Icon asChild>
<ChevronDown className="h-4 w-4 opacity-50" />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
))
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
const SelectScrollUpButton = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
>(({ className, ...props }, ref) => (
<SelectPrimitive.ScrollUpButton
ref={ref}
className={cn(
"flex cursor-default items-center justify-center py-1",
className
)}
{...props}
>
<ChevronUp className="h-4 w-4" />
</SelectPrimitive.ScrollUpButton>
))
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
const SelectScrollDownButton = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
>(({ className, ...props }, ref) => (
<SelectPrimitive.ScrollDownButton
ref={ref}
className={cn(
"flex cursor-default items-center justify-center py-1",
className
)}
{...props}
>
<ChevronDown className="h-4 w-4" />
</SelectPrimitive.ScrollDownButton>
))
SelectScrollDownButton.displayName =
SelectPrimitive.ScrollDownButton.displayName
const SelectContent = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
>(({ className, children, position = "popper", ...props }, ref) => (
<SelectPrimitive.Portal>
<SelectPrimitive.Content
ref={ref}
className={cn(
"relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
position === "popper" &&
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
className
)}
position={position}
{...props}
>
<SelectScrollUpButton />
<SelectPrimitive.Viewport
className={cn(
"p-1",
position === "popper" &&
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
)}
>
{children}
</SelectPrimitive.Viewport>
<SelectScrollDownButton />
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
))
SelectContent.displayName = SelectPrimitive.Content.displayName
const SelectLabel = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Label>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
>(({ className, ...props }, ref) => (
<SelectPrimitive.Label
ref={ref}
className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
{...props}
/>
))
SelectLabel.displayName = SelectPrimitive.Label.displayName
const SelectItem = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
>(({ className, children, ...props }, ref) => (
<SelectPrimitive.Item
ref={ref}
className={cn(
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className
)}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<SelectPrimitive.ItemIndicator>
<Check className="h-4 w-4" />
</SelectPrimitive.ItemIndicator>
</span>
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
</SelectPrimitive.Item>
))
SelectItem.displayName = SelectPrimitive.Item.displayName
const SelectSeparator = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
>(({ className, ...props }, ref) => (
<SelectPrimitive.Separator
ref={ref}
className={cn("-mx-1 my-1 h-px bg-muted", className)}
{...props}
/>
))
SelectSeparator.displayName = SelectPrimitive.Separator.displayName
export {
Select,
SelectGroup,
SelectValue,
SelectTrigger,
SelectContent,
SelectLabel,
SelectItem,
SelectSeparator,
SelectScrollUpButton,
SelectScrollDownButton,
}
-31
View File
@@ -1,31 +0,0 @@
"use client"
import * as React from "react"
import * as SeparatorPrimitive from "@radix-ui/react-separator"
import { cn } from "@/lib/utils"
const Separator = React.forwardRef<
React.ElementRef<typeof SeparatorPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
>(
(
{ className, orientation = "horizontal", decorative = true, ...props },
ref
) => (
<SeparatorPrimitive.Root
ref={ref}
decorative={decorative}
orientation={orientation}
className={cn(
"shrink-0 bg-border",
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
className
)}
{...props}
/>
)
)
Separator.displayName = SeparatorPrimitive.Root.displayName
export { Separator }
-140
View File
@@ -1,140 +0,0 @@
"use client"
import * as React from "react"
import * as SheetPrimitive from "@radix-ui/react-dialog"
import { cva, type VariantProps } from "class-variance-authority"
import { X } from "lucide-react"
import { cn } from "@/lib/utils"
const Sheet = SheetPrimitive.Root
const SheetTrigger = SheetPrimitive.Trigger
const SheetClose = SheetPrimitive.Close
const SheetPortal = SheetPrimitive.Portal
const SheetOverlay = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Overlay
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className
)}
{...props}
ref={ref}
/>
))
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName
const sheetVariants = cva(
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
{
variants: {
side: {
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
bottom:
"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
right:
"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm",
},
},
defaultVariants: {
side: "right",
},
}
)
interface SheetContentProps
extends React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
VariantProps<typeof sheetVariants> {}
const SheetContent = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Content>,
SheetContentProps
>(({ side = "right", className, children, ...props }, ref) => (
<SheetPortal>
<SheetOverlay />
<SheetPrimitive.Content
ref={ref}
className={cn(sheetVariants({ side }), className)}
{...props}
>
{children}
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</SheetPrimitive.Close>
</SheetPrimitive.Content>
</SheetPortal>
))
SheetContent.displayName = SheetPrimitive.Content.displayName
const SheetHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-2 text-center sm:text-left",
className
)}
{...props}
/>
)
SheetHeader.displayName = "SheetHeader"
const SheetFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className
)}
{...props}
/>
)
SheetFooter.displayName = "SheetFooter"
const SheetTitle = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Title
ref={ref}
className={cn("text-lg font-semibold text-foreground", className)}
{...props}
/>
))
SheetTitle.displayName = SheetPrimitive.Title.displayName
const SheetDescription = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>
>(({ className, ...props }, ref) => (
<SheetPrimitive.Description
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
))
SheetDescription.displayName = SheetPrimitive.Description.displayName
export {
Sheet,
SheetPortal,
SheetOverlay,
SheetTrigger,
SheetClose,
SheetContent,
SheetHeader,
SheetFooter,
SheetTitle,
SheetDescription,
}
-31
View File
@@ -1,31 +0,0 @@
"use client"
import { useTheme } from "next-themes"
import { Toaster as Sonner } from "sonner"
type ToasterProps = React.ComponentProps<typeof Sonner>
const Toaster = ({ ...props }: ToasterProps) => {
const { theme = "system" } = useTheme()
return (
<Sonner
theme={theme as ToasterProps["theme"]}
className="toaster group"
toastOptions={{
classNames: {
toast:
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
description: "group-[.toast]:text-muted-foreground",
actionButton:
"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
cancelButton:
"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
},
}}
{...props}
/>
)
}
export { Toaster }
-55
View File
@@ -1,55 +0,0 @@
"use client"
import * as React from "react"
import * as TabsPrimitive from "@radix-ui/react-tabs"
import { cn } from "@/lib/utils"
const Tabs = TabsPrimitive.Root
const TabsList = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.List>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
>(({ className, ...props }, ref) => (
<TabsPrimitive.List
ref={ref}
className={cn(
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
className
)}
{...props}
/>
))
TabsList.displayName = TabsPrimitive.List.displayName
const TabsTrigger = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
>(({ className, ...props }, ref) => (
<TabsPrimitive.Trigger
ref={ref}
className={cn(
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
className
)}
{...props}
/>
))
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
const TabsContent = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
>(({ className, ...props }, ref) => (
<TabsPrimitive.Content
ref={ref}
className={cn(
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
className
)}
{...props}
/>
))
TabsContent.displayName = TabsPrimitive.Content.displayName
export { Tabs, TabsList, TabsTrigger, TabsContent }
-24
View File
@@ -1,24 +0,0 @@
import * as React from "react"
import { cn } from "@/lib/utils"
export interface TextareaProps
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
({ className, ...props }, ref) => {
return (
<textarea
className={cn(
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className
)}
ref={ref}
{...props}
/>
)
}
)
Textarea.displayName = "Textarea"
export { Textarea }
-129
View File
@@ -1,129 +0,0 @@
"use client"
import * as React from "react"
import * as ToastPrimitives from "@radix-ui/react-toast"
import { cva, type VariantProps } from "class-variance-authority"
import { X } from "lucide-react"
import { cn } from "@/lib/utils"
const ToastProvider = ToastPrimitives.Provider
const ToastViewport = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Viewport>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
>(({ className, ...props }, ref) => (
<ToastPrimitives.Viewport
ref={ref}
className={cn(
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
className
)}
{...props}
/>
))
ToastViewport.displayName = ToastPrimitives.Viewport.displayName
const toastVariants = cva(
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
{
variants: {
variant: {
default: "border bg-background text-foreground",
destructive:
"destructive group border-destructive bg-destructive text-destructive-foreground",
},
},
defaultVariants: {
variant: "default",
},
}
)
const Toast = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Root>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
VariantProps<typeof toastVariants>
>(({ className, variant, ...props }, ref) => {
return (
<ToastPrimitives.Root
ref={ref}
className={cn(toastVariants({ variant }), className)}
{...props}
/>
)
})
Toast.displayName = ToastPrimitives.Root.displayName
const ToastAction = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Action>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
>(({ className, ...props }, ref) => (
<ToastPrimitives.Action
ref={ref}
className={cn(
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
className
)}
{...props}
/>
))
ToastAction.displayName = ToastPrimitives.Action.displayName
const ToastClose = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Close>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
>(({ className, ...props }, ref) => (
<ToastPrimitives.Close
ref={ref}
className={cn(
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
className
)}
toast-close=""
{...props}
>
<X className="h-4 w-4" />
</ToastPrimitives.Close>
))
ToastClose.displayName = ToastPrimitives.Close.displayName
const ToastTitle = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Title>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
>(({ className, ...props }, ref) => (
<ToastPrimitives.Title
ref={ref}
className={cn("text-sm font-semibold", className)}
{...props}
/>
))
ToastTitle.displayName = ToastPrimitives.Title.displayName
const ToastDescription = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Description>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
>(({ className, ...props }, ref) => (
<ToastPrimitives.Description
ref={ref}
className={cn("text-sm opacity-90", className)}
{...props}
/>
))
ToastDescription.displayName = ToastPrimitives.Description.displayName
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>
type ToastActionElement = React.ReactElement<typeof ToastAction>
export {
type ToastProps,
type ToastActionElement,
ToastProvider,
ToastViewport,
Toast,
ToastTitle,
ToastDescription,
ToastClose,
ToastAction,
}
-35
View File
@@ -1,35 +0,0 @@
"use client"
import {
Toast,
ToastClose,
ToastDescription,
ToastProvider,
ToastTitle,
ToastViewport,
} from "@/components/ui/toast"
import { useToast } from "@/components/ui/use-toast"
export function Toaster() {
const { toasts } = useToast()
return (
<ToastProvider>
{toasts.map(function ({ id, title, description, action, ...props }) {
return (
<Toast key={id} {...props}>
<div className="grid gap-1">
{title && <ToastTitle>{title}</ToastTitle>}
{description && (
<ToastDescription>{description}</ToastDescription>
)}
</div>
{action}
<ToastClose />
</Toast>
)
})}
<ToastViewport />
</ToastProvider>
)
}
-30
View File
@@ -1,30 +0,0 @@
"use client"
import * as React from "react"
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
import { cn } from "@/lib/utils"
const TooltipProvider = TooltipPrimitive.Provider
const Tooltip = TooltipPrimitive.Root
const TooltipTrigger = TooltipPrimitive.Trigger
const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
)}
{...props}
/>
))
TooltipContent.displayName = TooltipPrimitive.Content.displayName
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
-194
View File
@@ -1,194 +0,0 @@
"use client"
// Inspired by react-hot-toast library
import * as React from "react"
import type {
ToastActionElement,
ToastProps,
} from "@/components/ui/toast"
const TOAST_LIMIT = 1
const TOAST_REMOVE_DELAY = 1000000
type ToasterToast = ToastProps & {
id: string
title?: React.ReactNode
description?: React.ReactNode
action?: ToastActionElement
}
const actionTypes = {
ADD_TOAST: "ADD_TOAST",
UPDATE_TOAST: "UPDATE_TOAST",
DISMISS_TOAST: "DISMISS_TOAST",
REMOVE_TOAST: "REMOVE_TOAST",
} as const
let count = 0
function genId() {
count = (count + 1) % Number.MAX_SAFE_INTEGER
return count.toString()
}
type ActionType = typeof actionTypes
type Action =
| {
type: ActionType["ADD_TOAST"]
toast: ToasterToast
}
| {
type: ActionType["UPDATE_TOAST"]
toast: Partial<ToasterToast>
}
| {
type: ActionType["DISMISS_TOAST"]
toastId?: ToasterToast["id"]
}
| {
type: ActionType["REMOVE_TOAST"]
toastId?: ToasterToast["id"]
}
interface State {
toasts: ToasterToast[]
}
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()
const addToRemoveQueue = (toastId: string) => {
if (toastTimeouts.has(toastId)) {
return
}
const timeout = setTimeout(() => {
toastTimeouts.delete(toastId)
dispatch({
type: "REMOVE_TOAST",
toastId: toastId,
})
}, TOAST_REMOVE_DELAY)
toastTimeouts.set(toastId, timeout)
}
export const reducer = (state: State, action: Action): State => {
switch (action.type) {
case "ADD_TOAST":
return {
...state,
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
}
case "UPDATE_TOAST":
return {
...state,
toasts: state.toasts.map((t) =>
t.id === action.toast.id ? { ...t, ...action.toast } : t
),
}
case "DISMISS_TOAST": {
const { toastId } = action
// ! Side effects ! - This could be extracted into a dismissToast() action,
// but I'll keep it here for simplicity
if (toastId) {
addToRemoveQueue(toastId)
} else {
state.toasts.forEach((toast) => {
addToRemoveQueue(toast.id)
})
}
return {
...state,
toasts: state.toasts.map((t) =>
t.id === toastId || toastId === undefined
? {
...t,
open: false,
}
: t
),
}
}
case "REMOVE_TOAST":
if (action.toastId === undefined) {
return {
...state,
toasts: [],
}
}
return {
...state,
toasts: state.toasts.filter((t) => t.id !== action.toastId),
}
}
}
const listeners: Array<(state: State) => void> = []
let memoryState: State = { toasts: [] }
function dispatch(action: Action) {
memoryState = reducer(memoryState, action)
listeners.forEach((listener) => {
listener(memoryState)
})
}
type Toast = Omit<ToasterToast, "id">
function toast({ ...props }: Toast) {
const id = genId()
const update = (props: ToasterToast) =>
dispatch({
type: "UPDATE_TOAST",
toast: { ...props, id },
})
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id })
dispatch({
type: "ADD_TOAST",
toast: {
...props,
id,
open: true,
onOpenChange: (open) => {
if (!open) dismiss()
},
},
})
return {
id: id,
dismiss,
update,
}
}
function useToast() {
const [state, setState] = React.useState<State>(memoryState)
React.useEffect(() => {
listeners.push(setState)
return () => {
const index = listeners.indexOf(setState)
if (index > -1) {
listeners.splice(index, 1)
}
}
}, [state])
return {
...state,
toast,
dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
}
}
export { useToast, toast }
-5
View File
@@ -1,5 +0,0 @@
export interface Item {
title: string;
image: string;
url: string;
}
-20
View File
@@ -1,20 +0,0 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export const fetcher = (url: string) => fetch(url).then((res) => res.json());
export function encodeXor(str: string) {
if (!str) return str;
return encodeURIComponent(
str
.toString()
.split("")
.map((char, ind) =>
ind % 2 ? String.fromCharCode(char.charCodeAt(NaN) ^ 2) : char
)
.join("")
);
}