Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Server Side Loading Page Problems #101

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions app/components/LoadingContainer/component.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#container {

display: flex;

margin: auto;

height: 80vh;
width: 100%;

animation: forwards showUp 450ms;

}

@keyframes showUp {

0% {
opacity: 0;
}

100% {
opacity: 1;
}

}

#content_container {

margin: auto;

display: flex;
flex-direction: column;

}

#content_container #img_container {

position: relative;

aspect-ratio: 1117/393;

width: 80vw;
max-width: 200px;

}

#content_container>p {

margin: auto;
margin-top: 16px;

font-size: var(--font-size--h5);
color: var(--white-50);
font-weight: 600;

}
28 changes: 28 additions & 0 deletions app/components/LoadingContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react'
import LoadingSvg from "@/public/assets/Eclipse-1s-200px.svg"
import Image from 'next/image'
import Logo from "@/public/logo.png"
import styles from "./component.module.css"

function LoadingPageContainer() {

return (
<div id={styles.container}>
<div id={styles.content_container}>

<div id={styles.img_container}>
<Image fill alt="Logo" src={Logo} />
</div>

<LoadingSvg width={64} height={82} alt="Loading" />

<p>
Loading...
</p>

</div>
</div>
)
}

export default LoadingPageContainer
4 changes: 2 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export default function RootLayout({

<body className={inter.className}>

<Analytics />
<Analytics /> {/* Vercel */}

<StoreProvider>

<Header />

<NextTopLoader
Expand Down
37 changes: 4 additions & 33 deletions app/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
import React, { DetailedHTMLProps, HTMLAttributes } from 'react'
import LoadingSvg from "@/public/assets/Eclipse-1s-200px.svg"
import Image from 'next/image'
import Logo from "@/public/logo.png"
import LoadingPageContainer from "@/app/components/LoadingContainer";

const imgContainerStyles = {
position: "relative",
aspectRatio: "1117 / 393",
width: "80vw",
maxWidth: "200px"
} as DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>

function LoadingPlaceholder() {

return (
<div style={{ height: "80vh", width: "100%", margin: "auto", display: "flex" }}>
<div style={{ margin: "auto", display: "flex", flexDirection: "column" }}>

<div style={imgContainerStyles}>
<Image fill alt="Logo" src={Logo} />
</div>

<LoadingSvg width={64} height={82} alt="Loading" />

<p style={{ margin: "auto", marginTop: "16px", fontSize: "var(--font-size--h5)", color: "var(--white-50)", fontWeight: 600 }}>
Loading...
</p>

</div>
</div>
)
}

export default LoadingPlaceholder
export default function Loading() {
return <LoadingPageContainer />
}
5 changes: 5 additions & 0 deletions app/media/[id]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingPageContainer from "@/app/components/LoadingContainer";

export default function Loading() {
return <LoadingPageContainer />
}
5 changes: 5 additions & 0 deletions app/news/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingPageContainer from "@/app/components/LoadingContainer";

export default function Loading() {
return <LoadingPageContainer />
}
5 changes: 5 additions & 0 deletions app/read/[id]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingPageContainer from "@/app/components/LoadingContainer";

export default function Loading() {
return <LoadingPageContainer />
}
5 changes: 5 additions & 0 deletions app/watch/[id]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingPageContainer from "@/app/components/LoadingContainer";

export default function Loading() {
return <LoadingPageContainer />
}
Loading