Initial commit.

This commit is contained in:
CSG-Dominic
2025-03-11 13:06:14 -05:00
commit ba27084fa1
23 changed files with 2822 additions and 0 deletions

13
src/pages/_app.tsx Normal file
View File

@@ -0,0 +1,13 @@
import React from 'react';
import { AppProps } from 'next/app';
import './globals.scss';
const RootLayout:React.FC<AppProps> = ({ Component, pageProps }) => {
return (
<>
<Component {...pageProps} />
</>
);
}
export default RootLayout;

16
src/pages/_document.tsx Normal file
View File

@@ -0,0 +1,16 @@
import { Html, Head, Main, NextScript, DocumentProps } from 'next/document';
const RootDocument:React.FC<DocumentProps> = props => {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
};
export default RootDocument;

View File

@@ -0,0 +1,21 @@
import { typeDefs, resolvers } from "@/graphql/schema";
import { ApolloServer } from "apollo-server-micro";
import { NextApiRequest, NextApiResponse } from "next";
const apolloServer = new ApolloServer({ typeDefs, resolvers });
export const config = {
api: {
bodyParser: false,
},
};
const startServer = apolloServer.start();
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
await startServer;
await apolloServer.createHandler({ path: '/api/v1/graphql' })(req, res);
}

View File

@@ -0,0 +1,40 @@
import { GetServerSideProps, GetStaticPaths, GetStaticProps } from 'next';
import Link from 'next/link';
type PageParams = {
id:string;
}
type PageProps = {
id:string;
}
export const getServerSideProps:GetServerSideProps<> = async ({ params }) => {
const { id } = params as PageParams;
// if(id !== '0') {
// return {
// notFound: true
// };
// }
return {
props: {
id
},
};
};
export const Page:React.FC<PageProps> = ({ id }) => {
return (
<div>
<h1>Viewing Game ID: {id}</h1>
<Link href={`/games/${id}/play`}>
Play Game
</Link>
</div>
);
};
export default Page;

View File

@@ -0,0 +1,6 @@
.play {
&__emulator {
max-width: 320px;
margin: auto;
}
}

View File

@@ -0,0 +1,35 @@
import { GetServerSideProps } from 'next';
import { Emulator } from '@/components/Emulator';
import styles from './play.module.scss';
type PageParams = {
id:string;
}
type PageProps = {
id:string;
}
export const getServerSideProps:GetServerSideProps = async ({ params }) => {
const { id } = params as PageParams;
return {
props: {
id
},
};
};
export const Page:React.FC<PageProps> = ({ id }) => {
return (
<div className={styles.play}>
<h1>Playing Game ID: {id}</h1>
<div className={styles.play__emulator}>
<Emulator system='gbc' />
</div>
</div>
);
};
export default Page;

27
src/pages/games/index.tsx Normal file
View File

@@ -0,0 +1,27 @@
import { GetServerSideProps, GetStaticPaths, GetStaticProps } from 'next';
import Link from 'next/link';
type PageProps = {
}
export const getServerSideProps:GetServerSideProps = async ({ params }) => {
return {
props: {
},
};
};
export const Page:React.FC<PageProps> = ({ }) => {
return (
<div>
<h1>Games</h1>
<div>
<Link href="/games/0">
Test Game
</Link>
</div>
</div>
);
};
export default Page;

2
src/pages/globals.scss Normal file
View File

@@ -0,0 +1,2 @@
@use 'src/styles/elements/all';
@use 'src/styles/elements/html';

46
src/pages/index.tsx Normal file
View File

@@ -0,0 +1,46 @@
import Head from 'next/head';
import React from 'react';
import { GetServerSideProps } from 'next';
import { apiClientGet } from '@/lib/apiClient';
import { ApolloQueryResult, gql } from '@apollo/client';
import Link from 'next/link';
type PageData = {
hello:string;
}
type PageProps = ApolloQueryResult<PageData>
export const getServerSideProps:GetServerSideProps<PageProps> = async () => {
const client = await apiClientGet();
const res = await client.query<PageData>({
query: gql`
query {
hello
}
`
});
return {
props: res
};
};
const HomePage: React.FC<PageProps> = props => {
return (
<div className="homepage">
<Head>
<title>HomePlay, your personal video game library</title>
</Head>
<Link href="/game/1/play">
Play Game
</Link>
{ props.data?.hello }
</div>
);
}
export default HomePage;