mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-05-13 13:17:45 +00:00
fix: react error 482
This commit is contained in:
parent
ae266d5aa0
commit
46202b22b0
2 changed files with 48 additions and 47 deletions
|
|
@ -1,42 +1,42 @@
|
||||||
import { Icon } from "@iconify/react";
|
import { Icon } from "@iconify/react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
text: string;
|
text: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds fancy formatting to links
|
// Adds fancy formatting to links
|
||||||
export default function Description({ text, className }: Props) {
|
export default function Description({ text, className }: Props) {
|
||||||
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
||||||
const parts = text.split(urlRegex);
|
const parts = text.split(urlRegex);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<p className={`text-sm mt-2 bg-white/50 p-3 rounded-lg border border-orange-200 whitespace-break-spaces max-h-54 overflow-y-auto ${className}`}>
|
<p className={`text-sm mt-2 bg-white/50 p-3 rounded-lg border border-orange-200 whitespace-break-spaces max-h-54 overflow-y-auto ${className}`}>
|
||||||
{parts.map(async (part, index) => {
|
{parts.map((part, index) => {
|
||||||
try {
|
try {
|
||||||
// Check if it's a URL
|
// Check if it's a URL
|
||||||
if (!urlRegex.test(part)) throw new Error("Not a URL");
|
if (!urlRegex.test(part)) throw new Error("Not a URL");
|
||||||
const url = new URL(part);
|
const url = new URL(part);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
key={index}
|
key={index}
|
||||||
href={`/out?url=${encodeURIComponent(part)}`}
|
href={`/out?url=${encodeURIComponent(part)}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className="text-blue-700 underline break-all ml-1 inline-flex items-center group"
|
className="text-blue-700 underline break-all ml-1 inline-flex items-center group"
|
||||||
title={`Go to ${url.hostname}`}
|
title={`Go to ${url.hostname}`}
|
||||||
>
|
>
|
||||||
{url.hostname}
|
{url.hostname}
|
||||||
{url.pathname !== "/" ? url.pathname : ""}
|
{url.pathname !== "/" ? url.pathname : ""}
|
||||||
{url.search}
|
{url.search}
|
||||||
<Icon icon="mi:arrow-right-up" fontSize={16} className="transition group-hover:translate-x-0.5 group-hover:-translate-y-0.5" />
|
<Icon icon="mi:arrow-right-up" fontSize={16} className="transition group-hover:translate-x-0.5 group-hover:-translate-y-0.5" />
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
// Normal text/Invalid URL fallback
|
// Normal text/Invalid URL fallback
|
||||||
return <span key={index}>{part}</span>;
|
return <span key={index}>{part}</span>;
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { SwitchMiiInstructions } from "@tomodachi-share/shared";
|
import type { SwitchMiiInstructions } from "@tomodachi-share/shared";
|
||||||
|
|
||||||
// import ImageViewer from "../components/image-viewer";
|
import ImageViewer from "../components/image-viewer";
|
||||||
import LikeButton from "../components/like-button";
|
import LikeButton from "../components/like-button";
|
||||||
import Description from "../components/description";
|
import Description from "../components/description";
|
||||||
import ShareMiiButton from "../components/mii/share-mii-button";
|
import ShareMiiButton from "../components/mii/share-mii-button";
|
||||||
|
|
@ -64,7 +64,7 @@ export default function MiiPage() {
|
||||||
<div className="bg-amber-50 rounded-3xl border-2 border-amber-500 shadow-lg p-4 h-min flex flex-col items-center max-w-md w-full max-md:place-self-center max-md:row-start-2">
|
<div className="bg-amber-50 rounded-3xl border-2 border-amber-500 shadow-lg p-4 h-min flex flex-col items-center max-w-md w-full max-md:place-self-center max-md:row-start-2">
|
||||||
{/* Mii Image */}
|
{/* Mii Image */}
|
||||||
<div className="bg-linear-to-b from-amber-100 to-amber-200 overflow-hidden rounded-xl w-full mb-4 flex justify-center">
|
<div className="bg-linear-to-b from-amber-100 to-amber-200 overflow-hidden rounded-xl w-full mb-4 flex justify-center">
|
||||||
<img
|
<ImageViewer
|
||||||
src={`${API_URL}/mii/${mii.id}/image?type=mii`}
|
src={`${API_URL}/mii/${mii.id}/image?type=mii`}
|
||||||
alt="mii headshot"
|
alt="mii headshot"
|
||||||
width={250}
|
width={250}
|
||||||
|
|
@ -75,7 +75,7 @@ export default function MiiPage() {
|
||||||
{/* QR Code */}
|
{/* QR Code */}
|
||||||
{mii.platform === "THREE_DS" ? (
|
{mii.platform === "THREE_DS" ? (
|
||||||
<div className="bg-amber-200 overflow-hidden rounded-xl w-full mb-4 flex justify-center p-2">
|
<div className="bg-amber-200 overflow-hidden rounded-xl w-full mb-4 flex justify-center p-2">
|
||||||
<img
|
<ImageViewer
|
||||||
src={`${API_URL}/mii/${mii.id}/image?type=qr-code`}
|
src={`${API_URL}/mii/${mii.id}/image?type=qr-code`}
|
||||||
alt="mii qr code"
|
alt="mii qr code"
|
||||||
width={128}
|
width={128}
|
||||||
|
|
@ -84,7 +84,7 @@ export default function MiiPage() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<img
|
<ImageViewer
|
||||||
src={`${API_URL}/mii/${mii.id}/image?type=features`}
|
src={`${API_URL}/mii/${mii.id}/image?type=features`}
|
||||||
alt="mii features"
|
alt="mii features"
|
||||||
width={300}
|
width={300}
|
||||||
|
|
@ -348,12 +348,13 @@ export default function MiiPage() {
|
||||||
className="absolute size-full blur-sm contrast-150 brightness-[0.65] object-cover"
|
className="absolute size-full blur-sm contrast-150 brightness-[0.65] object-cover"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<img
|
<ImageViewer
|
||||||
src={src}
|
src={src}
|
||||||
alt="mii screenshot"
|
alt="mii screenshot"
|
||||||
width={256}
|
width={256}
|
||||||
height={170}
|
height={170}
|
||||||
className="aspect-3/2 w-full object-contain hover:scale-105 duration-300 transition-transform relative z-10"
|
className="aspect-3/2 w-full object-contain hover:scale-105 duration-300 transition-transform relative z-10"
|
||||||
|
images={images}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue