Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

Commit

Permalink
Added a lot
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanialhenniges committed Oct 30, 2023
1 parent e17592e commit fa7962d
Show file tree
Hide file tree
Showing 16 changed files with 396 additions and 97 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI

on: [push, pull_request]

env:
TWITCH_CLIENT_ID: "my-twitch-client-id"
TWITCH_CLIENT_SECRET: "my-twitch-client-secret"
NEXT_PUBLIC_APP_NAME: "my-app-name"
NEXT_PUBLIC_APP_DESCRIPTION: "my-app-description"
NEXT_PUBLIC_TWITTER_HANDLE: "my-twitter-handle"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Dependencies
run: npm install

- name: Typecheck
run: npm run typecheck

- name: Lint
run: npm run lint

- name: Print Environment Variable
run: echo $MY_ENV_VAR
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const config = {
},

images: {
domains: ["static-cdn.jtvnw.net", "gravatar.com"],
domains: ["static-cdn.jtvnw.net", "www.gravatar.com"],
},
};

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"build": "next build",
"dev": "next dev",
"lint": "next lint",
"typecheck": "tsc --noEmit",
"start": "next start"
},
"dependencies": {
Expand All @@ -20,6 +21,7 @@
"@trpc/server": "^10.37.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"dayjs": "^1.11.10",
"lucide-react": "^0.288.0",
"next": "^13.5.4",
"next-auth": "^4.23.0",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export default function Footer() {
const copyrightYear = new Date().getFullYear();
return (
<>
<footer className=" text-gray-700 dark:text-white">
<div className="container mx-auto flex flex-col items-center px-5 py-5 sm:flex-row">
<p className="text-center text-gray-500 md:text-right">
© {copyrightYear}
<a
href="https://www.mrdemonwolf.com"
className="ml-1 text-gray-200 dark:text-gray-400"
rel="noopener noreferrer"
target="_blank"
>
MrDemonWolf, Inc.
</a>
</p>
<span className="mt-4 inline-flex justify-center text-sm sm:ml-auto sm:mt-0 sm:justify-start">
this site is not affiliated with Twitch™ or any of it&rsquo;s
partners.
</span>
</div>
</footer>
</>
);
}
16 changes: 14 additions & 2 deletions src/components/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
export default function Home() {
return <>Please Login</>;
type Props = {
message: string;
};

export default function Hero(props: Props) {
return (
<div className="m-10 mx-auto max-w-md overflow-hidden rounded-lg bg-white shadow-lg dark:bg-gray-700">
<div className="flex items-center bg-gray-100 px-6 py-3 dark:bg-gray-600">
<h1 className="text-primary-500 text-2xl font-semibold dark:text-white">
{props.message}
</h1>
</div>
</div>
);
}
136 changes: 105 additions & 31 deletions src/components/InfoPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,114 @@
import { useSession } from "next-auth/react";
import DefaultLayout from "~/components/layout/default";
import Hero from "~/components/Hero";
import { api } from "~/utils/api";
import Image from "next/image";

import dayjs from "dayjs";
import {
WrenchIcon,
CheckBadgeIcon,
HeartIcon,
CalendarDaysIcon,
IdentificationIcon,
EnvelopeIcon,
} from "@heroicons/react/24/solid";

type Props = {
landingPage: true;
id: string;
display_name: string;
type: string;
broadcaster_type: string;
description: string;
profile_image_url: string;
offline_image_url: string;
email: string;
created_at: string;
};

export default function Home(props: Props) {
const { data: sessionData } = useSession();
if (!sessionData) return null;
const { data: twitch, isLoading: postLoading } = api.twitch.getUser.useQuery({
accessToken: sessionData.accessToken,
});

export default function InfoPanel(props: Props) {
return (
<>
<DefaultLayout>{twitch?.data[0]}</DefaultLayout>
<div className="m-10 mx-auto max-w-md overflow-hidden rounded-lg bg-white shadow-lg dark:bg-gray-700">
<Image
src={props.profile_image_url}
className="h-56 w-full object-cover object-center"
alt="avatar"
width={1920}
height={1080}
/>
<div className="flex items-center bg-gray-100 px-6 py-3 dark:bg-gray-600">
<h1 className="text-primary-500 text-2xl font-semibold dark:text-white">
{props.display_name}
</h1>
{props.type === "staff" && (
<>
<WrenchIcon
width={24}
height={24}
title="Twitch Staff"
className="text-primary-500 dark:text-secondary-400 ml-2 text-3xl"
/>
</>
)}
{props.broadcaster_type === "partner" && (
<>
<CheckBadgeIcon
width={28}
height={28}
title="Twitch Partner or Verified"
className="text-primary-500 dark:text-secondary-400 ml-2 text-3xl"
/>
</>
)}
{props.broadcaster_type === "affiliate" && (
<>
<HeartIcon
width={28}
height={28}
title="Twitch Partner or Verified"
className="text-primary-500 dark:text-secondary-400 ml-2 text-3xl"
/>
</>
)}
</div>
<div className="px-6 py-4">
{props.description && (
<>
<p className="mb-4 py-2 text-xl text-gray-700 dark:text-white">
{props.description}
</p>
</>
)}
<div className="mt-4 flex items-center text-gray-700 dark:text-white">
<CalendarDaysIcon
width={24}
height={24}
className="text-primary-500 dark:text-secondary-400"
/>

<h2 className="px-2 text-sm">
{dayjs(props.created_at).format("MMMM D, YYYY")}
</h2>
</div>
<div className="mt-4 flex items-center text-gray-700 dark:text-white">
<IdentificationIcon
width={24}
height={24}
className="text-primary-500 dark:text-secondary-400"
/>
<h2 className="px-2 text-sm">{props.id}</h2>
</div>
{props.email && (
<>
<div className="mt-4 flex items-center text-gray-700 dark:text-white">
<EnvelopeIcon
width={24}
height={24}
className="text-primary-500 dark:text-secondary-400"
/>
<h2 className="px-2 text-sm">{props.email}</h2>
</div>
</>
)}
</div>
</div>
</>
);
}

// export default function Home() {
// // get token from session and pass it to the server
// const { data: sessionData } = useSession();
// if (!sessionData) return <Hero />;

// const { data: twitch, isLoading: postLoading } = api.twitch.getUser.useQuery({
// accessToken: sessionData.accessToken,
// });

// if (postLoading) return <>Loading...</>;

// return (
// <>
// <DefaultLayout>{twitch?.data[0]?.display_name}</DefaultLayout>
// </>
// );
// }
10 changes: 5 additions & 5 deletions src/components/Navigation/logged-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function LoggedIn() {
const { data: sessionData } = useSession();
if (!sessionData) return <LoggedOut />;
return (
<Disclosure as="header" className="bg-gray-800">
<Disclosure as="header" className="bg-gray-200 dark:bg-gray-800">
{({ open }) => (
<>
<div className="mx-auto max-w-7xl px-2 sm:px-4 lg:divide-y lg:divide-gray-700 lg:px-8">
Expand All @@ -28,7 +28,7 @@ export default function LoggedIn() {
width={32}
height={32}
/>
<span className="ml-4 align-middle dark:text-white">
<span className="ml-4 align-middle font-bold text-gray-900 dark:text-white">
Streamer Quick Info
</span>
</div>
Expand All @@ -48,15 +48,15 @@ export default function LoggedIn() {
<input
id="search"
name="search"
className="block w-full rounded-md border-0 bg-gray-700 py-1.5 pl-10 pr-3 text-gray-300 placeholder:text-gray-400 focus:bg-white focus:text-gray-900 focus:ring-0 focus:placeholder:text-gray-500 sm:text-sm sm:leading-6"
className="block w-full rounded-md border-0 bg-white py-1.5 pl-10 pr-3 text-gray-800 placeholder:text-gray-400 focus:bg-white focus:text-gray-900 focus:ring-0 focus:placeholder:text-gray-500 dark:bg-gray-700 dark:text-gray-300 sm:text-sm sm:leading-6"
placeholder="Search"
type="search"
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
e.stopPropagation();
const query = e.currentTarget.value;
window.location.href = `/search?q=${query}`;
window.location.href = `/${query}`;
}
}}
/>
Expand All @@ -79,7 +79,7 @@ export default function LoggedIn() {
<ThemeToggle />
<Menu as="div" className="relative ml-4 flex-shrink-0">
<div>
<Menu.Button className="relative flex items-center rounded-full bg-gray-800 text-sm text-white focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800">
<Menu.Button className="relative flex items-center rounded-full bg-gray-400 text-sm text-white focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800 dark:bg-gray-800">
<span className="absolute -inset-1.5" />
<span className="sr-only">Open user menu</span>
<Image
Expand Down
6 changes: 3 additions & 3 deletions src/components/Navigation/logged-out.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Disclosure } from "@headlessui/react";

export default function LoggedOut() {
return (
<Disclosure as="header" className="bg-gray-800">
<Disclosure as="header" className="bg-gray-200 dark:bg-gray-800">
<>
<div className="mx-auto max-w-7xl px-2 sm:px-4 lg:divide-y lg:divide-gray-700 lg:px-8">
<div className="relative flex h-16 justify-between">
Expand All @@ -18,7 +18,7 @@ export default function LoggedOut() {
width={32}
height={32}
/>
<span className="ml-4 align-middle dark:text-white">
<span className="ml-4 align-middle font-bold text-gray-900 dark:text-white">
Streamer Quick Info
</span>
</div>
Expand All @@ -27,7 +27,7 @@ export default function LoggedOut() {
<button
type="button"
onClick={() => void signIn("twitch")}
className="rounded-md bg-indigo-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500"
className="rounded-md bg-blue-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500"
>
Sign In
</button>
Expand Down
27 changes: 17 additions & 10 deletions src/components/layout/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@ import type { PropsWithChildren } from "react";

import { useSession } from "next-auth/react";

import LoggedOut from "~/components/Navigation/logged-out";
import LoggedIn from "~/components/Navigation/logged-in";
import Footer from "~/components/Footer";
import NavigationLoggedOut from "~/components/Navigation/logged-out";
import NavigationLoggedIn from "~/components/Navigation/logged-in";

export default function DefaultLayout(props: PropsWithChildren) {
const { data: sessionData } = useSession();
const { status } = useSession();
return (
<main className="flex min-h-screen flex-col bg-white dark:bg-gray-900">
<header id="header" className="bg-white dark:bg-gray-800">
{sessionData ? <LoggedIn /> : <LoggedOut />}
</header>
{props.children}
{/* <Footer /> */}
</main>
<>
<main className="flex h-screen flex-col justify-between bg-gray-100 dark:bg-gray-900">
<header id="header" className="bg-white dark:bg-gray-800">
{status === "authenticated" ? (
<NavigationLoggedIn />
) : (
<NavigationLoggedOut />
)}
</header>
{props.children}
<Footer />
</main>
</>
);
}
Loading

0 comments on commit fa7962d

Please sign in to comment.