From 67a169910286674fa771a58ba5e4ac99776b5005 Mon Sep 17 00:00:00 2001 From: Divlo Date: Tue, 13 Dec 2022 22:31:32 +0100 Subject: [PATCH] chore: remove usage of `styled-jsx` --- .devcontainer/devcontainer.json | 2 - .vscode/extensions.json | 2 - .../Application/UserProfile/UserProfile.tsx | 156 +++++++++--------- components/ErrorPage.tsx | 69 ++++---- components/Header/SwitchTheme.tsx | 78 +++++++++ components/Header/SwitchTheme/SwitchTheme.tsx | 126 -------------- components/Header/SwitchTheme/index.ts | 1 - components/ScrollableBody.tsx | 20 --- components/design/Input/Input.tsx | 94 +++++------ components/design/Loader/Loader.module.css | 39 +++++ components/design/Loader/Loader.tsx | 66 +------- .../SocialMediaButton.module.css | 11 ++ .../SocialMediaButton/SocialMediaButton.tsx | 70 ++++---- cypress.config.ts | 3 - pages/404.tsx | 13 +- pages/500.tsx | 10 +- pages/authentication/forgot-password.tsx | 5 +- pages/authentication/reset-password.tsx | 5 +- pages/authentication/signin.tsx | 5 +- pages/authentication/signup.tsx | 5 +- pages/index.tsx | 5 +- styles/global.css | 9 + tailwind.config.js | 5 +- 23 files changed, 345 insertions(+), 454 deletions(-) create mode 100644 components/Header/SwitchTheme.tsx delete mode 100644 components/Header/SwitchTheme/SwitchTheme.tsx delete mode 100644 components/Header/SwitchTheme/index.ts delete mode 100644 components/ScrollableBody.tsx create mode 100644 components/design/Loader/Loader.module.css create mode 100644 components/design/SocialMediaButton/SocialMediaButton.module.css diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 24cd732..77a7bfd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,8 +10,6 @@ "editorconfig.editorconfig", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint", - "divlo.vscode-styled-jsx-syntax", - "divlo.vscode-styled-jsx-languageserver", "bradlc.vscode-tailwindcss", "mikestead.dotenv", "davidanson.vscode-markdownlint", diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 111dbb1..8aae002 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,8 +3,6 @@ "editorconfig.editorconfig", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint", - "divlo.vscode-styled-jsx-syntax", - "divlo.vscode-styled-jsx-languageserver", "bradlc.vscode-tailwindcss", "mikestead.dotenv", "davidanson.vscode-markdownlint", diff --git a/components/Application/UserProfile/UserProfile.tsx b/components/Application/UserProfile/UserProfile.tsx index f7d470a..6b4a847 100644 --- a/components/Application/UserProfile/UserProfile.tsx +++ b/components/Application/UserProfile/UserProfile.tsx @@ -16,96 +16,88 @@ export const UserProfile: React.FC = (props) => { const { t } = useTranslation() return ( - <> -
-
-
-
-
-
- Profil Picture +
+
+
+
+
+
+ Profil Picture +
+
+
+

+ {user.name} +

+

+ {date.format(new Date(user.createdAt), 'DD/MM/YYYY')} +

-
-
-

- {user.name} +

+ {user.email != null && ( +

+ Email:{' '} + + {user.email} +

-

- {date.format(new Date(user.createdAt), 'DD/MM/YYYY')} + )} + {user.website != null && ( +

+ {t('application:website')}:{' '} + + {user.website} +

-
-
- {user.email != null && ( -

- Email:{' '} - - {user.email} - -

- )} - {user.website != null && ( -

- {t('application:website')}:{' '} - - {user.website} - -

- )} - {user.status != null && ( -

- {t('application:status')}:{' '} - - {user.status} - -

- )} -
+ )} + {user.status != null && ( +

+ {t('application:status')}:{' '} + + {user.status} + +

+ )}
- {user.biography != null && ( -
-

{user.biography}

-
- )}
+ {user.biography != null && ( +
+

{user.biography}

+
+ )}
- - - +
) } diff --git a/components/ErrorPage.tsx b/components/ErrorPage.tsx index e1c7ba6..107d24a 100644 --- a/components/ErrorPage.tsx +++ b/components/ErrorPage.tsx @@ -1,54 +1,45 @@ import useTranslation from 'next-translate/useTranslation' import Link from 'next/link' -export interface ErrorPageProps { +import type { FooterProps } from './Footer' +import { Footer } from './Footer' +import { Header } from './Header' + +export interface ErrorPageProps extends FooterProps { statusCode: number message: string } export const ErrorPage: React.FC = (props) => { - const { message, statusCode } = props + const { message, statusCode, version } = props const { t } = useTranslation() return ( <> -

- {t('errors:error')}{' '} - - {statusCode} - -

-

- {message}{' '} - - {t('errors:return-to-home-page')} - -

- - +
+
+
+

+ {t('errors:error')}{' '} + + {statusCode} + +

+

+ {message}{' '} + + {t('errors:return-to-home-page')} + +

+
+
+
) } diff --git a/components/Header/SwitchTheme.tsx b/components/Header/SwitchTheme.tsx new file mode 100644 index 0000000..812c34a --- /dev/null +++ b/components/Header/SwitchTheme.tsx @@ -0,0 +1,78 @@ +import { useEffect, useState } from 'react' +import classNames from 'clsx' +import { useTheme } from 'next-themes' + +export const SwitchTheme: React.FC = () => { + const [mounted, setMounted] = useState(false) + const { theme, setTheme } = useTheme() + + useEffect(() => { + setMounted(true) + }, []) + + if (!mounted) { + return null + } + + const handleClick = (): void => { + setTheme(theme === 'dark' ? 'light' : 'dark') + } + + return ( +
+
+
+
+ + 🌜 + +
+
+ + 🌞 + +
+
+
+ +
+
+ ) +} diff --git a/components/Header/SwitchTheme/SwitchTheme.tsx b/components/Header/SwitchTheme/SwitchTheme.tsx deleted file mode 100644 index 6a3ab61..0000000 --- a/components/Header/SwitchTheme/SwitchTheme.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import { useEffect, useState } from 'react' -import { useTheme } from 'next-themes' - -export const SwitchTheme: React.FC = () => { - const [mounted, setMounted] = useState(false) - const { theme, setTheme } = useTheme() - - useEffect(() => { - setMounted(true) - }, []) - - if (!mounted) { - return null - } - - const handleClick = (): void => { - setTheme(theme === 'dark' ? 'light' : 'dark') - } - - return ( - <> -
-
-
-
- - 🌜 - -
-
- - 🌞 - -
-
-
- -
-
- - - - ) -} diff --git a/components/Header/SwitchTheme/index.ts b/components/Header/SwitchTheme/index.ts deleted file mode 100644 index abe4c2b..0000000 --- a/components/Header/SwitchTheme/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './SwitchTheme' diff --git a/components/ScrollableBody.tsx b/components/ScrollableBody.tsx deleted file mode 100644 index a10e87d..0000000 --- a/components/ScrollableBody.tsx +++ /dev/null @@ -1,20 +0,0 @@ -export const ScrollableBody: React.FC> = ( - props -) => { - const { children } = props - - return ( - <> - {children} - - - ) -} diff --git a/components/design/Input/Input.tsx b/components/design/Input/Input.tsx index eeb7e97..a816752 100644 --- a/components/design/Input/Input.tsx +++ b/components/design/Input/Input.tsx @@ -35,60 +35,46 @@ export const Input: React.FC = (props) => { } return ( - <> -
-
- - {type === 'password' && showForgotPassword ? ( - - {t('authentication:forgot-password')} - - ) : null} -
-
- - {type === 'password' && ( -
- )} - -
+
+
+ + {type === 'password' && showForgotPassword ? ( + + {t('authentication:forgot-password')} + + ) : null}
- - - +
+ + {type === 'password' && ( +
+ )} + +
+
) } diff --git a/components/design/Loader/Loader.module.css b/components/design/Loader/Loader.module.css new file mode 100644 index 0000000..728d5ad --- /dev/null +++ b/components/design/Loader/Loader.module.css @@ -0,0 +1,39 @@ +@keyframes progressSpinnerRotate { + 100% { + transform: rotate(360deg); + } +} +@keyframes progressSpinnerDash { + 0% { + stroke-dasharray: 1, 200; + stroke-dashoffset: 0; + } + 50% { + stroke-dasharray: 89, 200; + stroke-dashoffset: -35px; + } + 100% { + stroke-dasharray: 89, 200; + stroke-dashoffset: -124px; + } +} + +.progressSpinnerSvg { + animation: progressSpinnerRotate 2s linear infinite; + height: 100%; + transform-origin: center center; + width: 100%; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + margin: auto; +} +.progressSpinnerCircle { + stroke-dasharray: 89, 200; + stroke-dashoffset: 0; + stroke: #27b05e; + animation: progressSpinnerDash 1.5s ease-in-out infinite; + stroke-linecap: round; +} diff --git a/components/design/Loader/Loader.tsx b/components/design/Loader/Loader.tsx index 9f2f771..ee636cd 100644 --- a/components/design/Loader/Loader.tsx +++ b/components/design/Loader/Loader.tsx @@ -1,3 +1,5 @@ +import styles from './Loader.module.css' + export interface LoaderProps { width?: number height?: number @@ -9,10 +11,14 @@ export const Loader: React.FC = (props) => { return (
-
- +
+ = (props) => { />
- -
) } diff --git a/components/design/SocialMediaButton/SocialMediaButton.module.css b/components/design/SocialMediaButton/SocialMediaButton.module.css new file mode 100644 index 0000000..cbc0b2d --- /dev/null +++ b/components/design/SocialMediaButton/SocialMediaButton.module.css @@ -0,0 +1,11 @@ +.buttonGoogle { + color: #000; + border: 1px solid #000; +} +.buttonMedia { + color: #fff; + border: none; +} +.button:focus { + box-shadow: 0 0 0 2px #27b05e; +} diff --git a/components/design/SocialMediaButton/SocialMediaButton.tsx b/components/design/SocialMediaButton/SocialMediaButton.tsx index 8c52ec8..7e571e0 100644 --- a/components/design/SocialMediaButton/SocialMediaButton.tsx +++ b/components/design/SocialMediaButton/SocialMediaButton.tsx @@ -3,6 +3,7 @@ import Image from 'next/image' import classNames from 'clsx' import type { ProviderOAuth } from '../../../models/OAuth' +import styles from './SocialMediaButton.module.css' export type SocialMedia = ProviderOAuth @@ -52,27 +53,21 @@ export const SocialMediaButton: React.FC = (props) => { }, [socialMedia]) return ( - <> - - - - + ) } @@ -88,23 +83,20 @@ export const SocialMediaLink: React.FC = (props) => { }, [socialMedia]) return ( - <> - - - - - - + + + ) } diff --git a/cypress.config.ts b/cypress.config.ts index 9f55039..cd8ebcb 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -19,9 +19,7 @@ let server: Mockttp | null = null export default defineConfig({ fixturesFolder: false, video: false, - downloadsFolder: undefined, screenshotOnRunFailure: false, - e2e: { baseUrl: 'http://127.0.0.1:3000', supportFile: false, @@ -62,7 +60,6 @@ export default defineConfig({ return config } }, - component: { devServer: { framework: 'next', diff --git a/pages/404.tsx b/pages/404.tsx index ada8f36..cd1cf40 100644 --- a/pages/404.tsx +++ b/pages/404.tsx @@ -3,9 +3,7 @@ import useTranslation from 'next-translate/useTranslation' import { ErrorPage } from '../components/ErrorPage' import { Head } from '../components/Head' -import { Header } from '../components/Header' import type { FooterProps } from '../components/Footer' -import { Footer } from '../components/Footer' const Error404: NextPage = (props) => { const { t } = useTranslation() @@ -14,12 +12,11 @@ const Error404: NextPage = (props) => { return ( <> - -
-
- -
-
+ ) } diff --git a/pages/500.tsx b/pages/500.tsx index 4420dac..d806bfb 100644 --- a/pages/500.tsx +++ b/pages/500.tsx @@ -5,7 +5,6 @@ import { ErrorPage } from '../components/ErrorPage' import { Head } from '../components/Head' import { Header } from '../components/Header' import type { FooterProps } from '../components/Footer' -import { Footer } from '../components/Footer' const Error500: NextPage = (props) => { const { t } = useTranslation() @@ -16,10 +15,11 @@ const Error500: NextPage = (props) => {
-
- -
-
+ ) } diff --git a/pages/authentication/forgot-password.tsx b/pages/authentication/forgot-password.tsx index d132870..c269340 100644 --- a/pages/authentication/forgot-password.tsx +++ b/pages/authentication/forgot-password.tsx @@ -15,7 +15,6 @@ import { Input } from '../../components/design/Input' import { Button } from '../../components/design/Button' import { FormState } from '../../components/design/FormState' import { authenticationFromServerSide } from '../../tools/authentication' -import { ScrollableBody } from '../../components/ScrollableBody' import { userSchema } from '../../models/User' import { api } from '../../tools/api' import { useFormTranslation } from '../../hooks/useFormTranslation' @@ -60,7 +59,7 @@ const ForgotPassword: NextPage = (props) => { } return ( - + <>
@@ -86,7 +85,7 @@ const ForgotPassword: NextPage = (props) => { />
- + ) } diff --git a/pages/authentication/reset-password.tsx b/pages/authentication/reset-password.tsx index 46beebd..2afa510 100644 --- a/pages/authentication/reset-password.tsx +++ b/pages/authentication/reset-password.tsx @@ -15,7 +15,6 @@ import { Input } from '../../components/design/Input' import { Button } from '../../components/design/Button' import { authenticationFromServerSide } from '../../tools/authentication' import { AuthenticationForm } from '../../components/Authentication' -import { ScrollableBody } from '../../components/ScrollableBody' import { api } from '../../tools/api' import { userSchema } from '../../models/User' import { useFormTranslation } from '../../hooks/useFormTranslation' @@ -55,7 +54,7 @@ const ResetPassword: NextPage = (props) => { } return ( - + <>
@@ -81,7 +80,7 @@ const ResetPassword: NextPage = (props) => { />
- + ) } diff --git a/pages/authentication/signin.tsx b/pages/authentication/signin.tsx index 77cd2ba..9fc1d50 100644 --- a/pages/authentication/signin.tsx +++ b/pages/authentication/signin.tsx @@ -7,19 +7,18 @@ import { Header } from '../../components/Header' import type { FooterProps } from '../../components/Footer' import { Footer } from '../../components/Footer' import { authenticationFromServerSide } from '../../tools/authentication' -import { ScrollableBody } from '../../components/ScrollableBody' const Signin: NextPage = (props) => { const { version } = props const { t } = useTranslation() return ( - + <>
- + ) } diff --git a/pages/authentication/signup.tsx b/pages/authentication/signup.tsx index 1338474..c8ed5c6 100644 --- a/pages/authentication/signup.tsx +++ b/pages/authentication/signup.tsx @@ -7,19 +7,18 @@ import { Header } from '../../components/Header' import type { FooterProps } from '../../components/Footer' import { Footer } from '../../components/Footer' import { authenticationFromServerSide } from '../../tools/authentication' -import { ScrollableBody } from '../../components/ScrollableBody' const Signup: NextPage = (props) => { const { version } = props const { t } = useTranslation() return ( - + <>
- + ) } diff --git a/pages/index.tsx b/pages/index.tsx index f58eeda..4ebe9a1 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -11,14 +11,13 @@ import type { FooterProps } from '../components/Footer' import { Footer } from '../components/Footer' import { SocialMediaLink } from '../components/design/SocialMediaButton' import { ButtonLink } from '../components/design/Button' -import { ScrollableBody } from '../components/ScrollableBody' const Home: NextPage = (props) => { const { t } = useTranslation() const { version } = props return ( - + <>
@@ -71,7 +70,7 @@ const Home: NextPage = (props) => {