From 38f3caa524858e9fe807d2fdfa51b0997f1fb393 Mon Sep 17 00:00:00 2001
From: strNophix
Date: Sun, 16 Oct 2022 16:26:24 +0200
Subject: [PATCH] Grouped components into folders
---
client/components/BrowseLayout.tsx | 38 --------
client/components/NavBar.tsx | 65 --------------
client/components/SideNavChannel.tsx | 28 ------
client/components/{ => common}/Button.tsx | 0
client/components/{ => common}/InlineLink.tsx | 0
client/components/{ => common}/Input.tsx | 0
.../{ => common/form}/FormField.tsx | 2 +-
.../{ => common/form}/SubmitButton.tsx | 0
client/components/layout/BrowseLayout.tsx | 13 +++
client/components/{ => login}/LoginForm.tsx | 28 +++---
client/components/{ => login}/LoginModal.tsx | 38 +++++---
.../components/{ => login}/LoginModalTab.tsx | 0
client/components/{ => login}/SignupForm.tsx | 11 ++-
client/components/{ => message}/ChatBadge.tsx | 0
.../components/{ => message}/ChatMessage.tsx | 10 +--
client/components/nav/NavBar.tsx | 71 +++++++++++++++
client/pages/[channel]/index.tsx | 86 +++++++------------
client/pages/category/[categoryName].tsx | 8 +-
client/pages/login.tsx | 10 +--
client/pages/signup.tsx | 11 ++-
20 files changed, 177 insertions(+), 242 deletions(-)
delete mode 100644 client/components/BrowseLayout.tsx
delete mode 100644 client/components/NavBar.tsx
delete mode 100644 client/components/SideNavChannel.tsx
rename client/components/{ => common}/Button.tsx (100%)
rename client/components/{ => common}/InlineLink.tsx (100%)
rename client/components/{ => common}/Input.tsx (100%)
rename client/components/{ => common/form}/FormField.tsx (95%)
rename client/components/{ => common/form}/SubmitButton.tsx (100%)
create mode 100644 client/components/layout/BrowseLayout.tsx
rename client/components/{ => login}/LoginForm.tsx (58%)
rename client/components/{ => login}/LoginModal.tsx (58%)
rename client/components/{ => login}/LoginModalTab.tsx (100%)
rename client/components/{ => login}/SignupForm.tsx (94%)
rename client/components/{ => message}/ChatBadge.tsx (100%)
rename client/components/{ => message}/ChatMessage.tsx (84%)
create mode 100644 client/components/nav/NavBar.tsx
diff --git a/client/components/BrowseLayout.tsx b/client/components/BrowseLayout.tsx
deleted file mode 100644
index d73e41e..0000000
--- a/client/components/BrowseLayout.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { ArrowLeftIcon } from '@heroicons/react/24/outline';
-
-import Button from './Button';
-import NavBar from './NavBar';
-import SideNavChannel from './SideNavChannel';
-import streamData from '../placeholder/GetStreams';
-import { NextPage } from 'next';
-import Link from 'next/link';
-
-const BrowseLayout: NextPage = ({children}) => {
- return (
-
-
-
-
-
-
Trending channels
-
-
-
- {streamData.data.map((stream) => (
- -
-
-
-
-
- ))}
-
-
- {children}
-
-
- );
-}
-
-export default BrowseLayout;
diff --git a/client/components/NavBar.tsx b/client/components/NavBar.tsx
deleted file mode 100644
index 544db0e..0000000
--- a/client/components/NavBar.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { UserIcon } from '@heroicons/react/24/outline';
-import { FC, useState } from 'react';
-
-import Button from './Button';
-import Input from './Input';
-import LoginModal from './LoginModal';
-
-const NavBar: FC = () => {
- const [showLogin, setShowLogin] = useState(false);
- const [showTab, setShowTab] = useState(0);
-
- const showLoginTab = () => {
- setShowTab(0);
- setShowLogin(true);
- };
-
- const showSignupTab = () => {
- setShowTab(1);
- setShowLogin(true);
- };
-
- return (
-
- );
-};
-
-export default NavBar;
diff --git a/client/components/SideNavChannel.tsx b/client/components/SideNavChannel.tsx
deleted file mode 100644
index 314c7f2..0000000
--- a/client/components/SideNavChannel.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { FC } from 'react';
-
-import { Stream } from '../types';
-import { numFormatter } from '../utils/format';
-
-interface SideNavChannelProps {
- stream: Stream;
-}
-
-const SideNavChannel: FC = ({ stream }) => {
- return (
-
-

-
-
-
{stream.user_name}
-
-
-
{numFormatter.format(stream.viewer_count)}
-
-
-
{stream.game_name}
-
-
- );
-};
-
-export default SideNavChannel;
diff --git a/client/components/Button.tsx b/client/components/common/Button.tsx
similarity index 100%
rename from client/components/Button.tsx
rename to client/components/common/Button.tsx
diff --git a/client/components/InlineLink.tsx b/client/components/common/InlineLink.tsx
similarity index 100%
rename from client/components/InlineLink.tsx
rename to client/components/common/InlineLink.tsx
diff --git a/client/components/Input.tsx b/client/components/common/Input.tsx
similarity index 100%
rename from client/components/Input.tsx
rename to client/components/common/Input.tsx
diff --git a/client/components/FormField.tsx b/client/components/common/form/FormField.tsx
similarity index 95%
rename from client/components/FormField.tsx
rename to client/components/common/form/FormField.tsx
index 5c3c413..0fc6ba2 100644
--- a/client/components/FormField.tsx
+++ b/client/components/common/form/FormField.tsx
@@ -1,7 +1,7 @@
/* eslint-disable react/display-name */
import { forwardRef, ReactNode } from "react"
-import Input from "./Input"
+import Input from "../Input"
interface FormFieldProps extends React.ComponentPropsWithoutRef<"input"> {
label?: string
diff --git a/client/components/SubmitButton.tsx b/client/components/common/form/SubmitButton.tsx
similarity index 100%
rename from client/components/SubmitButton.tsx
rename to client/components/common/form/SubmitButton.tsx
diff --git a/client/components/layout/BrowseLayout.tsx b/client/components/layout/BrowseLayout.tsx
new file mode 100644
index 0000000..78037f2
--- /dev/null
+++ b/client/components/layout/BrowseLayout.tsx
@@ -0,0 +1,13 @@
+import NavBar from "../nav/NavBar"
+import { NextPage } from "next"
+
+const BrowseLayout: NextPage = ({ children }) => {
+ return (
+
+
+ {children}
+
+ )
+}
+
+export default BrowseLayout
diff --git a/client/components/LoginForm.tsx b/client/components/login/LoginForm.tsx
similarity index 58%
rename from client/components/LoginForm.tsx
rename to client/components/login/LoginForm.tsx
index 23f6d7a..1236cbf 100644
--- a/client/components/LoginForm.tsx
+++ b/client/components/login/LoginForm.tsx
@@ -1,30 +1,30 @@
-import { FC } from 'react';
-import { useForm, SubmitHandler } from 'react-hook-form';
+import { FC } from "react"
+import { useForm, SubmitHandler } from "react-hook-form"
-import FormField from './FormField';
-import InlineLink from './InlineLink';
-import SubmitButton from './SubmitButton';
+import FormField from "../common/form/FormField"
+import InlineLink from "../common/InlineLink"
+import SubmitButton from "../common/form/SubmitButton"
interface LoginFormValues {
- username: string;
- password: string;
+ username: string
+ password: string
}
const LoginForm: FC = () => {
- const { register, handleSubmit } = useForm();
- const onSubmit: SubmitHandler = (data) => console.log(data);
+ const { register, handleSubmit } = useForm()
+ const onSubmit: SubmitHandler = (data) => console.log(data)
return (
- );
-};
+ )
+}
-export default LoginForm;
+export default LoginForm
diff --git a/client/components/LoginModal.tsx b/client/components/login/LoginModal.tsx
similarity index 58%
rename from client/components/LoginModal.tsx
rename to client/components/login/LoginModal.tsx
index e2a6b8c..ca099db 100644
--- a/client/components/LoginModal.tsx
+++ b/client/components/login/LoginModal.tsx
@@ -1,14 +1,14 @@
-import { Dialog, Tab } from '@headlessui/react';
-import { FC, useEffect, useRef } from 'react';
+import { Dialog, Tab } from "@headlessui/react"
+import { FC } from "react"
-import LoginForm from './LoginForm';
-import LoginModalTab from './LoginModalTab';
-import SignupForm from './SignupForm';
+import LoginForm from "./LoginForm"
+import LoginModalTab from "./LoginModalTab"
+import SignupForm from "./SignupForm"
export interface LoginModelProps {
- isOpen: boolean;
- onClose: () => any;
- defaultPage?: number;
+ isOpen: boolean
+ onClose: () => any
+ defaultPage?: number
}
const LoginModal: FC = ({ defaultPage, isOpen, onClose }) => {
@@ -18,16 +18,25 @@ const LoginModal: FC = ({ defaultPage, isOpen, onClose }) => {
-
Log in to twitch-clone
+
{" "}
+ Log in to twitch-clone
- {({ selected }) => Log In}
+ {({ selected }) => (
+ Log In
+ )}
- {({ selected }) => Sign Up}
+ {({ selected }) => (
+ Sign Up
+ )}
@@ -41,7 +50,8 @@ const LoginModal: FC = ({ defaultPage, isOpen, onClose }) => {
- )
-};
+
+ )
+}
-export default LoginModal;
+export default LoginModal
diff --git a/client/components/LoginModalTab.tsx b/client/components/login/LoginModalTab.tsx
similarity index 100%
rename from client/components/LoginModalTab.tsx
rename to client/components/login/LoginModalTab.tsx
diff --git a/client/components/SignupForm.tsx b/client/components/login/SignupForm.tsx
similarity index 94%
rename from client/components/SignupForm.tsx
rename to client/components/login/SignupForm.tsx
index 43fa3b5..a0a8ab3 100644
--- a/client/components/SignupForm.tsx
+++ b/client/components/login/SignupForm.tsx
@@ -1,16 +1,15 @@
import { zodResolver } from "@hookform/resolvers/zod"
import { SelfServiceRegistrationFlow } from "@ory/client"
import { useRouter } from "next/router"
-import { useMemo } from "react"
import { FC, useEffect, useState } from "react"
import { SubmitHandler, useForm } from "react-hook-form"
import { z } from "zod"
-import ory from "../services/ory"
+import ory from "../../services/ory"
-import FormField from "./FormField"
-import InlineLink from "./InlineLink"
-import Input from "./Input"
-import SubmitButton from "./SubmitButton"
+import FormField from "../common/form/FormField"
+import InlineLink from "../common/InlineLink"
+import Input from "../common/Input"
+import SubmitButton from "../common/form/SubmitButton"
const PASSWORD_REGEX =
/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,64}$/
diff --git a/client/components/ChatBadge.tsx b/client/components/message/ChatBadge.tsx
similarity index 100%
rename from client/components/ChatBadge.tsx
rename to client/components/message/ChatBadge.tsx
diff --git a/client/components/ChatMessage.tsx b/client/components/message/ChatMessage.tsx
similarity index 84%
rename from client/components/ChatMessage.tsx
rename to client/components/message/ChatMessage.tsx
index c0121cc..b04d54f 100644
--- a/client/components/ChatMessage.tsx
+++ b/client/components/message/ChatMessage.tsx
@@ -1,6 +1,6 @@
-import { FC } from 'react';
+import { FC } from "react"
-import ChatBadge from './ChatBadge';
+import ChatBadge from "./ChatBadge"
const ChatMessage: FC = () => {
return (
@@ -19,7 +19,7 @@ const ChatMessage: FC = () => {
/>
- );
-};
+ )
+}
-export default ChatMessage;
+export default ChatMessage
diff --git a/client/components/nav/NavBar.tsx b/client/components/nav/NavBar.tsx
new file mode 100644
index 0000000..7de64e0
--- /dev/null
+++ b/client/components/nav/NavBar.tsx
@@ -0,0 +1,71 @@
+import { UserIcon } from "@heroicons/react/24/outline"
+import { FC, useState } from "react"
+
+import Button from "../common/Button"
+import Input from "../common/Input"
+import LoginModal from "../login/LoginModal"
+
+const NavBar: FC = () => {
+ const [showLogin, setShowLogin] = useState(false)
+ const [showTab, setShowTab] = useState(0)
+
+ const showLoginTab = () => {
+ setShowTab(0)
+ setShowLogin(true)
+ }
+
+ const showSignupTab = () => {
+ setShowTab(1)
+ setShowLogin(true)
+ }
+
+ return (
+
+ )
+}
+
+export default NavBar
diff --git a/client/pages/[channel]/index.tsx b/client/pages/[channel]/index.tsx
index b58dcab..1044492 100644
--- a/client/pages/[channel]/index.tsx
+++ b/client/pages/[channel]/index.tsx
@@ -1,68 +1,42 @@
-import { ArrowRightIcon, HeartIcon, UserIcon } from '@heroicons/react/24/outline';
-
-import Button from '../../components/Button';
-import ChatMessage from '../../components/ChatMessage';
-import Input from '../../components/Input';
-import { numFormatter } from '../../utils/format';
-import streams from '../../placeholder/GetStreams';
-import { NextPage } from 'next';
-import BrowseLayout from '../../components/BrowseLayout';
+import Button from "../../components/common/Button"
+import ChatMessage from "../../components/message/ChatMessage"
+import Input from "../../components/common/Input"
+import streams from "../../placeholder/GetStreams"
+import { NextPage } from "next"
+import BrowseLayout from "../../components/layout/BrowseLayout"
const ChannelPage: NextPage = () => {
- const stream = streams.data[1];
+ const stream = streams.data[1]
return (
-
-
-
-
-
-
-
-
{stream.user_name}
-
-
-
-
-
-
-
{stream.title}
-
{stream.game_name}
-
-
-
-
- {numFormatter.format(stream.viewer_count)}
-
- {stream.started_at}
-
+
+
+
+
+
+
+ {stream.user_name}
+
1:14:32
+
+
+
+
+
+ {new Array(60).fill(0).map((_, i) => (
+
+ ))}
+
+
+
-
-
-
- {new Array(60).fill(0).map((_, i) => (
-
- ))}
-
-
-
-
-
-
- );
+ )
}
-export default ChannelPage;
+export default ChannelPage
diff --git a/client/pages/category/[categoryName].tsx b/client/pages/category/[categoryName].tsx
index fe523d9..ac9facc 100644
--- a/client/pages/category/[categoryName].tsx
+++ b/client/pages/category/[categoryName].tsx
@@ -1,7 +1,7 @@
-import { categories } from '../../placeholder/SearchCategories';
+import { categories } from "../../placeholder/SearchCategories"
function ChannelPage() {
- const category = categories.data[0];
+ const category = categories.data[0]
return (
@@ -20,7 +20,7 @@ function ChannelPage() {
- );
+ )
}
-export default ChannelPage;
+export default ChannelPage
diff --git a/client/pages/login.tsx b/client/pages/login.tsx
index 77b86f1..f08417e 100644
--- a/client/pages/login.tsx
+++ b/client/pages/login.tsx
@@ -1,13 +1,13 @@
-import { NextPage } from 'next';
+import { NextPage } from "next"
-import LoginModal from '../components/LoginModal';
+import LoginModal from "../components/login/LoginModal"
const LoginPage: NextPage = () => {
return (
{}} />
- );
-};
+ )
+}
-export default LoginPage;
+export default LoginPage
diff --git a/client/pages/signup.tsx b/client/pages/signup.tsx
index ab51a85..91bfcec 100644
--- a/client/pages/signup.tsx
+++ b/client/pages/signup.tsx
@@ -1,13 +1,12 @@
-
-import { NextPage } from 'next';
-import LoginModal from '../components/LoginModal';
+import { NextPage } from "next"
+import LoginModal from "../components/login/LoginModal"
const SignupPage: NextPage = () => {
return (
{}} />
- );
-};
+ )
+}
-export default SignupPage;
+export default SignupPage