styles: random avatar

This commit is contained in:
oiov
2025-05-27 16:18:43 +08:00
parent 157c07c747
commit ec3372a3c0
14 changed files with 99 additions and 2634 deletions
+2
View File
@@ -6,6 +6,8 @@ interface CurrentLocation {
longitude: number;
}
export const dynamic = "force-dynamic";
export async function GET(req: NextRequest) {
try {
const geo = geolocation(req);
+1 -19
View File
@@ -18,6 +18,7 @@ import Peer from "peerjs";
import { toast } from "sonner";
import { siteConfig } from "@/config/site";
import { generateGradientClasses } from "@/lib/enums";
import { cn } from "@/lib/utils";
import { useMediaQuery } from "@/hooks/use-media-query";
@@ -47,25 +48,6 @@ const formatTime = (date: Date) => {
return date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
};
const generateGradientClasses = (seed: string) => {
const gradients = [
"bg-gradient-to-br from-red-400 to-pink-500",
"bg-gradient-to-br from-blue-400 to-indigo-500",
"bg-gradient-to-br from-green-400 to-teal-500",
"bg-gradient-to-br from-yellow-400 to-orange-500",
"bg-gradient-to-br from-purple-400 to-pink-500",
"bg-gradient-to-br from-cyan-400 to-blue-500",
"bg-gradient-to-br from-pink-400 to-red-500",
"bg-gradient-to-br from-teal-400 to-green-500",
"bg-gradient-to-br from-orange-400 to-yellow-500",
"bg-gradient-to-br from-indigo-400 to-blue-500",
];
const hash = seed
.split("")
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
return gradients[hash % gradients.length];
};
export default function ChatRoom() {
const { isMobile, isSm } = useMediaQuery();
const [peerId, setPeerId] = useState("");
+4 -4
View File
@@ -217,7 +217,7 @@ export function DomainForm({
<Label className="mt-2.5 text-nowrap" htmlFor="domain_name">
Domain Name:
</Label>
<div className="w-full sm:w-[60%]">
<div className="w-full sm:w-3/5">
<Input
id="target"
className="flex-1 bg-neutral-50 shadow-inner"
@@ -318,7 +318,7 @@ export function DomainForm({
<Label className="mt-2.5 text-nowrap" htmlFor="zone_id">
Zone ID:
</Label>
<div className="w-full sm:w-[60%]">
<div className="w-full sm:w-3/5">
<Input
id="target"
className="flex-1 bg-neutral-50 shadow-inner"
@@ -352,7 +352,7 @@ export function DomainForm({
<Label className="mt-2.5 text-nowrap" htmlFor="api-key">
API Token:
</Label>
<div className="w-full sm:w-[60%]">
<div className="w-full sm:w-3/5">
<Input
id="target"
className="flex-1 bg-neutral-50 shadow-inner"
@@ -386,7 +386,7 @@ export function DomainForm({
<Label className="mt-2.5 text-nowrap" htmlFor="email">
Account Email:
</Label>
<div className="w-full sm:w-[60%]">
<div className="w-full sm:w-3/5">
<Input
id="target"
className="flex-1 bg-neutral-50 shadow-inner"
+10 -2
View File
@@ -39,7 +39,11 @@ export function UserAccountNav() {
<Drawer.Root open={open} onClose={closeDrawer}>
<Drawer.Trigger onClick={() => setOpen(true)}>
<UserAvatar
user={{ name: user.name || null, image: user.image || null }}
user={{
name: user.name || null,
image: user.image || null,
email: user.email || null,
}}
className="size-9 border"
/>
</Drawer.Trigger>
@@ -134,7 +138,11 @@ export function UserAccountNav() {
<DropdownMenu open={open} onOpenChange={setOpen}>
<DropdownMenuTrigger>
<UserAvatar
user={{ name: user.name || null, image: user.image || null }}
user={{
name: user.name || null,
image: user.image || null,
email: user.email || null,
}}
className="size-8 border border-gray-200 shadow-inner"
/>
</DropdownMenuTrigger>
@@ -60,6 +60,7 @@ function DeleteAccountModal({
user={{
name: session?.user?.name || null,
image: session?.user?.image || null,
email: session?.user?.email || null,
}}
/>
<h3 className="text-lg font-semibold">Delete Account</h3>
+3 -3
View File
@@ -237,7 +237,7 @@ export default function QRCodeEditor({
Url
</h3>
<Input
className="ml-auto w-[60%]"
className="ml-auto w-3/5"
type="text"
placeholder="https://example.com"
defaultValue={params.url}
@@ -338,7 +338,7 @@ export default function QRCodeEditor({
></div>
<input
id="color"
className="block w-full rounded-r-md border-2 border-l-0 pl-3 text-neutral-900 placeholder-gray-400 focus:outline-none focus:ring-black dark:text-neutral-300 sm:text-sm"
className="block w-full rounded-r-md border-2 border-l-0 pl-3 text-neutral-900 placeholder:text-gray-400 focus:outline-none focus:ring-black dark:text-neutral-300 sm:text-sm"
spellCheck="false"
defaultValue={params.fgColor}
name="color"
@@ -392,7 +392,7 @@ export default function QRCodeEditor({
></div>
<input
id="color"
className="block w-full rounded-r-md border-2 border-l-0 pl-3 text-neutral-900 placeholder-gray-400 focus:outline-none focus:ring-black dark:text-neutral-300 sm:text-sm"
className="block w-full rounded-r-md border-2 border-l-0 pl-3 text-neutral-900 placeholder:text-gray-400 focus:outline-none focus:ring-black dark:text-neutral-300 sm:text-sm"
spellCheck="false"
defaultValue={params.bgColor}
name="color"
+20 -11
View File
@@ -1,24 +1,33 @@
import { User } from "@prisma/client"
import { AvatarProps } from "@radix-ui/react-avatar"
import { User } from "@prisma/client";
import { AvatarProps } from "@radix-ui/react-avatar";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
import { Icons } from "@/components/shared/icons"
import { generateGradientClasses } from "@/lib/enums";
import { Avatar, AvatarImage } from "@/components/ui/avatar";
interface UserAvatarProps extends AvatarProps {
user: Pick<User, "image" | "name">
user: Pick<User, "image" | "name" | "email">;
}
export function UserAvatar({ user, ...props }: UserAvatarProps) {
return (
<Avatar {...props}>
{user.image ? (
<AvatarImage alt="Picture" src={user.image} referrerPolicy="no-referrer" />
<AvatarImage
alt="Picture"
src={user.image}
referrerPolicy="no-referrer"
/>
) : (
<AvatarFallback>
<span className="sr-only">{user.name}</span>
<Icons.user className="size-4" />
</AvatarFallback>
<RandomAvatar text={user.name || user.email || ""} />
)}
</Avatar>
)
);
}
export function RandomAvatar({ text }: { text?: string }) {
return (
<div
className={`flex size-full shrink-0 items-center justify-center rounded-full text-white ${generateGradientClasses(text || "wr.do")}`}
></div>
);
}
+19
View File
@@ -322,3 +322,22 @@ export const DAILY_DIMENSION_ENUMS = [
{ value: "12h", label: "Last 12 Hours", key: 720 },
{ value: "24h", label: "Last 24 Hours", key: 1440 },
] as const;
export const generateGradientClasses = (seed: string) => {
const gradients = [
"bg-gradient-to-br from-red-400 to-pink-500",
"bg-gradient-to-br from-blue-400 to-indigo-500",
"bg-gradient-to-br from-green-400 to-teal-500",
"bg-gradient-to-br from-yellow-400 to-orange-500",
"bg-gradient-to-br from-purple-400 to-pink-500",
"bg-gradient-to-br from-cyan-400 to-blue-500",
"bg-gradient-to-br from-pink-400 to-red-500",
"bg-gradient-to-br from-teal-400 to-green-500",
"bg-gradient-to-br from-orange-400 to-yellow-500",
"bg-gradient-to-br from-indigo-400 to-blue-500",
];
const hash = seed
.split("")
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
return gradients[hash % gradients.length];
};
+37 -36
View File
@@ -1,39 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url><loc>https://wr.do/robots.txt</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/pricing</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/privacy</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/terms</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/authentification</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/cloudflare</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/cloudflare-email-worker</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/components</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/config-files</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/database</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/email</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/installation</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/markdown-files</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/quick-start</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/dns-records</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/emails</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/examples/cloudflare</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/examples/other</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/examples/vercel</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/examples/zeabur</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/icon</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/markdown</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/meta-info</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/qrcode</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/screenshot</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/text</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/plan</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/quick-start</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/short-urls</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/wroom</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/chat</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/password-prompt</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/manifest.json</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/opengraph-image.jpg</loc><lastmod>2025-05-26T09:40:46.922Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/robots.txt</loc><lastmod>2025-05-27T08:17:27.586Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/pricing</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/privacy</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/terms</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/authentification</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/cloudflare</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/cloudflare-email-worker</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/components</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/config-files</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/database</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/deploy</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/email</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/installation</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/markdown-files</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/developer/quick-start</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/dns-records</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/emails</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/examples/cloudflare</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/examples/other</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/examples/vercel</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/examples/zeabur</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/icon</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/markdown</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/meta-info</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/qrcode</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/screenshot</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/open-api/text</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/plan</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/quick-start</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/short-urls</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/docs/wroom</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/chat</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/password-prompt</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/manifest.json</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://wr.do/opengraph-image.jpg</loc><lastmod>2025-05-27T08:17:27.587Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
</urlset>
+1 -101
View File
File diff suppressed because one or more lines are too long
-1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long