radius
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
'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>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
'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>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
@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;
|
||||
}
|
||||
|
||||
.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%;
|
||||
}
|
||||
|
||||
.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%;
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
'use client'
|
||||
import Sidebar from '@/components/sidebar'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { encodeXor, formatSearch } 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
|
||||
}
|
||||
|
||||
export default function Route({ params }: { params: { route: string[] } }) {
|
||||
const ref = useRef<HTMLIFrameElement>(null)
|
||||
const [open, setOpen] = useState(false)
|
||||
const route = params.route.join('/')
|
||||
|
||||
const [tabIcon, setTabIcon] = useState('')
|
||||
const [tabName, setTabName] = useState('')
|
||||
const [shortcutted, setShortcutted] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker
|
||||
.register('/uv/sw.js', {
|
||||
scope: '/uv/service'
|
||||
})
|
||||
.then(() => {
|
||||
if (ref.current) {
|
||||
ref.current.src = '/uv/service/' + encodeXor(formatSearch(atob(decodeURIComponent(route))))
|
||||
}
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
function triggerShortcut() {
|
||||
store.set('shortcuts', [], false)
|
||||
if (!ref.current || !ref.current.contentWindow) return
|
||||
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() {
|
||||
if (!ref.current || !ref.current.contentWindow) return
|
||||
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)
|
||||
}
|
||||
}
|
||||
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 variant="ghost" size="icon">
|
||||
<Lucide.ArrowLeft />
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>Back</TooltipContent>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button 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>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { Inter } from 'next/font/google'
|
||||
import './globals.css'
|
||||
import Navbar from '@/components/navbar'
|
||||
|
||||
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" />
|
||||
</head>
|
||||
|
||||
<body className={inter.className}>
|
||||
<Navbar />
|
||||
|
||||
<div className="pt-14">{children}</div>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
'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[]>([])
|
||||
useEffect(() => {
|
||||
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>
|
||||
{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>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
'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 { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
||||
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { Textarea } from '@/components/ui/textarea'
|
||||
import { Save } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
|
||||
const formSchema = z.object({
|
||||
backgroundImage: z.string(),
|
||||
description: z.string()
|
||||
})
|
||||
|
||||
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)
|
||||
|
||||
setTimeout(() => {
|
||||
setSubmitting(false)
|
||||
toast.success('Settings saved')
|
||||
}, 1000)
|
||||
console.log(values)
|
||||
}
|
||||
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>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Button type="submit" disabled={submitting}>
|
||||
<Save className="mr-2 h-5 w-5" /> Save Changes
|
||||
</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
'use client'
|
||||
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Images, Link, Palette } 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/apperance/">
|
||||
<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>
|
||||
<Button variant={pathname?.includes('/settings/search') ? 'secondary' : 'ghost'} className="w-full items-center justify-start gap-2">
|
||||
<Images className="h-5 w-5" /> Images
|
||||
</Button>
|
||||
<Button variant={pathname?.includes('/settings/account') ? 'secondary' : 'ghost'} className="w-full items-center justify-start gap-2">
|
||||
<Link className="h-5 w-5" /> Social Links
|
||||
</Button>
|
||||
</div>
|
||||
<div className="w-3/4 px-12 py-8">{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import fs from 'fs'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { NextRequest } from 'next/server'
|
||||
|
||||
export async function GET(_req: NextRequest, { params }: { params: { uv: string } }) {
|
||||
const requestedFile = params.uv
|
||||
if (requestedFile === 'uv.config.js' || requestedFile === 'sw.js') {
|
||||
const file = fs.readFileSync(process.cwd() + `/src/lib/uv/${requestedFile}`)
|
||||
const fileBlob = new Blob([file])
|
||||
return new Response(fileBlob, {
|
||||
headers: {
|
||||
'Content-Type': 'application/javascript'
|
||||
}
|
||||
})
|
||||
} else {
|
||||
try {
|
||||
const res = await fetch(`https://unpkg.com/@titaniumnetwork-dev/ultraviolet@2.0.0/dist/${requestedFile}`)
|
||||
const file = await res.text()
|
||||
const fileBlob = new Blob([file])
|
||||
return new Response(fileBlob, {
|
||||
headers: {
|
||||
'Content-Type': 'application/javascript'
|
||||
}
|
||||
})
|
||||
} catch {
|
||||
notFound()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user