Spaces:
Runtime error
Runtime error
File size: 4,272 Bytes
c5b7daf 7babbe1 c5b7daf 7babbe1 c5b7daf 7babbe1 c5b7daf 7babbe1 c5b7daf 7babbe1 c5b7daf 7babbe1 c5b7daf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | /**
* Generate 404 Error Page HTML (Shadcn-inspired design)
*/
export function generate404ErrorPage(params: {
fileId?: string;
title?: string;
message?: string;
description?: string;
illustrationSrc?: string;
}): string {
const {
fileId,
title = 'Whoops!',
message = 'Something went wrong',
description = "The page you're looking for isn't found, we suggest you back to home.",
illustrationSrc = '/box/error-illustration',
} = params;
return `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${message} - 404</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--foreground: 0 0% 3.9%;
--muted-foreground: 0 0% 45.1%;
--background: 0 0% 100%;
--primary: 0 0% 9%;
--primary-foreground: 0 0% 98%;
--radius: 0.5rem;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
color: hsl(var(--foreground));
background-color: hsl(var(--background));
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
.container {
display: grid;
min-height: 100vh;
grid-template-columns: 1fr;
}
@media (min-width: 1024px) {
.container {
grid-template-columns: 1fr 1fr;
}
}
/* Left Section: Text Content */
.content-section {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 2rem 1rem;
text-align: center;
}
.title {
margin-bottom: 1.5rem;
font-size: 3rem;
font-weight: 600;
line-height: 1;
}
@media (min-width: 768px) {
.title {
font-size: 3.75rem;
}
}
.heading {
margin-bottom: 0.375rem;
font-size: 1.875rem;
font-weight: 600;
line-height: 1.2;
}
@media (min-width: 768px) {
.heading {
font-size: 2.25rem;
}
}
.description {
color: hsl(var(--muted-foreground));
margin-bottom: 1.5rem;
max-width: 28rem;
font-size: 1rem;
}
@media (min-width: 768px) {
.description {
max-width: 28rem;
font-size: 1rem;
}
}
.file-id {
color: hsl(var(--muted-foreground));
margin-top: 1rem;
font-size: 0.875rem;
font-family: 'Courier New', monospace;
}
/* Right Section: Illustration */
.illustration-section {
position: relative;
max-height: 100vh;
width: 100%;
padding: 0.5rem;
display: none;
}
@media (min-width: 1024px) {
.illustration-section {
display: block;
}
}
.illustration-bg {
height: 100%;
width: 100%;
border-radius: 1rem;
background-color: #000000;
}
.illustration-image {
position: absolute;
top: 50%;
left: 50%;
height: clamp(260px, 25vw, 406px);
transform: translate(-50%, -50%);
}
/* Mobile-only illustration */
.mobile-illustration {
display: block;
margin: 2rem auto;
width: 80%;
max-width: 320px;
}
@media (min-width: 1024px) {
.mobile-illustration {
display: none;
}
}
</style>
</head>
<body>
<div class="container">
<!-- Left Section: Text Content -->
<div class="content-section">
<h2 class="title">${title}</h2>
<h3 class="heading">${message}</h3>
<p class="description">${description}</p>
${fileId ? `<p class="file-id">File ID: ${fileId}</p>` : ''}
<!-- Mobile illustration (visible only on small screens) -->
<img
src="${illustrationSrc}"
alt="404 illustration"
class="mobile-illustration"
loading="lazy"
/>
</div>
<!-- Right Section: Illustration (visible only on large screens) -->
<div class="illustration-section">
<div class="illustration-bg"></div>
<img
src="${illustrationSrc}"
alt="404 illustration"
class="illustration-image"
loading="lazy"
/>
</div>
</div>
</body>
</html>
`;
}
|