ファイル
btrc-hub/frontend/src/components/ErrorScreen.tsx
T
2026-10-18 12:57:09 +09:00

62 行
2.0 KiB
TypeScript

import nikumaru from '@/assets/fonts/nikumaru.otf'
import errorImg from '@/assets/images/not-found.gif'
import MainArea from '@/components/layout/MainArea'
import PageHead from '@/components/common/PageHead'
import { useUITranslation } from '@/lib/useUITranslation'
import type { FC } from 'react'
type Props = { status: number }
const ErrorScreen: FC<Props> = ({ status }) => {
const { message: translate, label } = useUITranslation ('errors')
const [message]: [string, string, string] = (() => {
switch (status)
{
case 403:
case 404:
case 500:
case 503:
return [translate (`${ status }.message`).text,
translate (`${ status }.right`).text, translate (`${ status }.left`).text]
default:
throw new Error
}
}) ()
const title = message.replaceAll ('(', ' (').replaceAll (')', ')')
const style = document.createElement ('style')
style.innerHTML = `
@font-face
{
font-family: 'Nikumaru';
src: url(${ nikumaru }) format('opentype');
}`
document.head.appendChild (style)
return (
<MainArea>
<PageHead title={{ text: title,
language: translate (`${status}.message`).language }}>
<meta name="robots" content="noindex"/>
</PageHead>
<div className="text-6xl font-bold text-transparent
bg-[linear-gradient(90deg,#ff0000,#ff8800,#ffff00,#00ff00,#00ffff,#0000ff,#ff00ff,#ff0000)]
bg-clip-text bg-[length:200%_100%] animate-rainbow-scroll drop-shadow-[0_0_6px_black]
space-y-2 sm:space-y-4 md:space-y-6 text-center flex flex-col justify-center items-center"
style={{ fontFamily: 'Nikumaru' }}>
<p>{status}</p>
<div className="flex flex-row space-x-1 sm:space-x-2 md:space-x-4">
<p style={{ writingMode: 'vertical-rl' }}>{label (`${ status }.left`)}</p>
<img className="max-w-[70vw]" src={errorImg} alt={translate ('imageAlt').text}/>
<p style={{ writingMode: 'vertical-rl' }}>{label (`${ status }.right`)}</p>
</div>
<p className="mr-[-.5em]">{label (`${ status }.message`)}</p>
</div>
</MainArea>)
}
export default ErrorScreen