Added styled-components + various
Includes changes due to NextJS version bump and attempts at storing theme via cookie
This commit is contained in:
parent
8a763ee72e
commit
21e613891e
13 changed files with 325 additions and 102 deletions
|
@ -3,7 +3,10 @@ import type { ReactElement, ReactNode } from 'react'
|
|||
import Layout from '../components/layout'
|
||||
import type { NextPage } from 'next'
|
||||
import { AppProps } from 'next/app';
|
||||
|
||||
import { DefaultTheme, ThemeProvider } from 'styled-components';
|
||||
import { createContext, useContext, useEffect, useState } from 'react'
|
||||
import { getCookie, getCookies, setCookie } from 'cookies-next'
|
||||
import { darkTheme } from '../components/themes';
|
||||
|
||||
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
|
||||
getLayout?: (page: ReactElement) => ReactNode
|
||||
|
@ -13,10 +16,41 @@ export type AppPropsWithLayout = AppProps & {
|
|||
Component: NextPageWithLayout
|
||||
}
|
||||
|
||||
|
||||
const ThemeUpdateContext = createContext(
|
||||
(theme: DefaultTheme) => console.error("attempted to set theme outside of a ThemeUpdateContext.Provider")
|
||||
)
|
||||
|
||||
export const useUpdateTheme = () => useContext(ThemeUpdateContext);
|
||||
|
||||
|
||||
export default function Website({ Component, pageProps }: AppPropsWithLayout) {
|
||||
const [selectedTheme, setselectedTheme] = useState(darkTheme);
|
||||
//console.log("Selected Theme: ", selectedTheme); // DEBUG
|
||||
|
||||
useEffect(() => {
|
||||
setCookie('theme', selectedTheme.themeId);
|
||||
}, [selectedTheme])
|
||||
|
||||
|
||||
// Use the layout defined at the page level, if available
|
||||
const getLayout = Component.getLayout ?? ((page) => (
|
||||
<Layout>{page}</Layout>))
|
||||
|
||||
return getLayout(<Component {...pageProps} />)
|
||||
return (
|
||||
<ThemeProvider theme={selectedTheme}>
|
||||
<ThemeUpdateContext.Provider value={setselectedTheme}>
|
||||
{getLayout(<Component {...pageProps} />)}
|
||||
</ThemeUpdateContext.Provider>
|
||||
</ThemeProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
|
||||
return {
|
||||
props: {
|
||||
token: {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
import { Html, Head, Main, NextScript } from 'next/document'
|
||||
import { getCookie, getCookies, setCookie } from 'cookies-next';
|
||||
import { Html, Head, Main, NextScript, DocumentContext } from 'next/document'
|
||||
import { useUpdateTheme } from './_app';
|
||||
import { darkTheme } from '../components/themes';
|
||||
import { GetServerSidePropsContext } from 'next';
|
||||
|
||||
export default function Document() {
|
||||
export default function Document(ctx: DocumentContext) {
|
||||
const updateTheme = useUpdateTheme();
|
||||
|
||||
return (
|
||||
<Html lang='en'>
|
||||
<Head />
|
||||
|
|
|
@ -26,23 +26,21 @@ function Servers(props: EntryList) {
|
|||
{Object.values(serverList).map((item: CustomLink) => {
|
||||
if (item.href != null) {
|
||||
return (
|
||||
<Link key={item.name} href={item.href}>
|
||||
<a className={styles.contentcard}>
|
||||
<div className={styles.contenttitle}><h2>{item.name }</h2></div>
|
||||
<div><p>{item.desc}</p></div>
|
||||
<div><p>{item.ip }</p></div>
|
||||
<div className={item.status == "Online" ? styles.contentonline : styles.contentoffline}><p>{item.status}</p></div>
|
||||
</a>
|
||||
<Link className={styles.contentcard} key={item.name} href={item.href}>
|
||||
<div className={styles.contenttitle}><h2>{item.name}</h2></div>
|
||||
<div><p>{item.desc}</p></div>
|
||||
<div><p>{item.ip}</p></div>
|
||||
<div className={item.status == "Online" ? styles.contentonline : styles.contentoffline}><p>{item.status}</p></div>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<a key={item.name} className={styles.contentcardstatic}>
|
||||
<div className={styles.contenttitle}><h2>{item.name }</h2></div>
|
||||
<div><p>{item.desc}</p></div>
|
||||
<div><p>{item.ip}</p></div>
|
||||
<div className={item.status == "Online" ? styles.contentonline : styles.contentoffline}><p>{item.status}</p></div>
|
||||
<div className={styles.contenttitle}><h2>{item.name}</h2></div>
|
||||
<div><p>{item.desc}</p></div>
|
||||
<div><p>{item.ip}</p></div>
|
||||
<div className={item.status == "Online" ? styles.contentonline : styles.contentoffline}><p>{item.status}</p></div>
|
||||
</a>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -6,11 +6,10 @@ export default function Home() {
|
|||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Neshura Servers</title>
|
||||
<title>Neshweb - Home</title>
|
||||
<meta charSet='utf-8' />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
|
||||
<h1 className={styles.title}>
|
||||
Welcome to my Servers Webpage
|
||||
</h1>
|
||||
|
@ -19,28 +18,22 @@ export default function Home() {
|
|||
Feel free to look around
|
||||
</p>
|
||||
<div className={styles.grid}>
|
||||
<Link key="about" href="/about">
|
||||
<a className={styles.card}>
|
||||
<h2>About →</h2>
|
||||
<p>Useless Info, don't bother</p>
|
||||
</a>
|
||||
<Link className={styles.card} key="about" href="/about">
|
||||
<h2>About →</h2>
|
||||
<p>Useless Info, don't bother</p>
|
||||
</Link>
|
||||
|
||||
<Link key="servers" href="/games">
|
||||
<a className={styles.card}>
|
||||
<h2>Games →</h2>
|
||||
<p>List of all available Servers</p>
|
||||
</a>
|
||||
<Link className={styles.card} key="servers" href="/games">
|
||||
<h2>Games →</h2>
|
||||
<p>List of all available Servers</p>
|
||||
</Link>
|
||||
|
||||
<Link key="services" href="/services">
|
||||
<a className={styles.card}>
|
||||
<h2>Services →</h2>
|
||||
<p>List of available Services</p>
|
||||
</a>
|
||||
<Link className={styles.card} key="services" href="/services">
|
||||
<h2>Services →</h2>
|
||||
<p>List of available Services</p>
|
||||
</Link>
|
||||
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
|
@ -20,24 +20,22 @@ function Services() {
|
|||
content =
|
||||
<div className={styles.grid}>
|
||||
{initialData?.map((item: Service) => (
|
||||
<Link key={item.name} href={item.href}>
|
||||
<a className={styles.contentcard}>
|
||||
<div className={styles.contentTitle}>
|
||||
{
|
||||
item.icon ? (
|
||||
<div className={styles.contentIcon}>
|
||||
<Image alt="icon" src={item.icon} layout="fill" objectFit="contain"></Image>
|
||||
</div>
|
||||
) : (<></>)
|
||||
}
|
||||
<h2>{item.name}</h2>
|
||||
</div>
|
||||
<div className={item.status === ServiceStatus.online ? styles.statusOnline : item.status === ServiceStatus.offline ? styles.statusOffline : styles.statusLoading}>
|
||||
{item.status}
|
||||
</div>
|
||||
<div><p>{item.desc}</p></div>
|
||||
<div className={styles.cardwarn}><p>{item.warn}</p></div>
|
||||
</a>
|
||||
<Link className={styles.contentcard} key={item.name} href={item.href}>
|
||||
<div className={styles.contentTitle}>
|
||||
{
|
||||
item.icon ? (
|
||||
<div className={styles.contentIcon}>
|
||||
<Image alt="icon" src={item.icon} layout="fill" objectFit="contain"></Image>
|
||||
</div>
|
||||
) : (<></>)
|
||||
}
|
||||
<h2>{item.name}</h2>
|
||||
</div>
|
||||
<div className={item.status === ServiceStatus.online ? styles.statusOnline : item.status === ServiceStatus.offline ? styles.statusOffline : styles.statusLoading}>
|
||||
{item.status}
|
||||
</div>
|
||||
<div><p>{item.desc}</p></div>
|
||||
<div className={styles.cardwarn}><p>{item.warn}</p></div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
@ -46,24 +44,22 @@ function Services() {
|
|||
content =
|
||||
<div className={styles.grid}>
|
||||
{fullData.map((item: Service) => (
|
||||
<Link key={item.name} href={item.href}>
|
||||
<a className={styles.contentcard}>
|
||||
<div className={styles.contentTitle}>
|
||||
{
|
||||
item.icon ? (
|
||||
<div className={styles.contentIcon}>
|
||||
<Image alt="icon" src={item.icon} layout="fill" objectFit="contain"></Image>
|
||||
</div>
|
||||
) : (<></>)
|
||||
}
|
||||
<h2>{item.name}</h2>
|
||||
</div>
|
||||
<div className={item.status === ServiceStatus.online ? styles.statusOnline : item.status === ServiceStatus.offline ? styles.statusOffline : styles.statusLoading}>
|
||||
{item.status}
|
||||
</div>
|
||||
<div><p>{item.desc}</p></div>
|
||||
<div className={styles.cardwarn}><p>{item.warn}</p></div>
|
||||
</a>
|
||||
<Link className={styles.contentcard} key={item.name} href={item.href}>
|
||||
<div className={styles.contentTitle}>
|
||||
{
|
||||
item.icon ? (
|
||||
<div className={styles.contentIcon}>
|
||||
<Image alt="icon" src={item.icon} fill></Image>
|
||||
</div>
|
||||
) : (<></>)
|
||||
}
|
||||
<h2>{item.name}</h2>
|
||||
</div>
|
||||
<div className={item.status === ServiceStatus.online ? styles.statusOnline : item.status === ServiceStatus.offline ? styles.statusOffline : styles.statusLoading}>
|
||||
{item.status}
|
||||
</div>
|
||||
<div><p>{item.desc}</p></div>
|
||||
<div className={styles.cardwarn}><p>{item.warn}</p></div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue