1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2024-09-18 21:55:52 +02:00

chore: remove usage of styled-jsx

This commit is contained in:
Divlo 2022-10-03 20:52:15 +02:00
parent 03e7e22d74
commit c419fb3bb4
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
19 changed files with 570 additions and 527 deletions

View File

@ -1,2 +1 @@
ARG VARIANT="16" FROM mcr.microsoft.com/devcontainers/javascript-node:18
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

View File

@ -1,5 +1,5 @@
{ {
"name": "divlo", "name": "Divlo",
"dockerComposeFile": "./docker-compose.yml", "dockerComposeFile": "./docker-compose.yml",
"service": "workspace", "service": "workspace",
"workspaceFolder": "/workspace", "workspaceFolder": "/workspace",
@ -10,8 +10,6 @@
"editorconfig.editorconfig", "editorconfig.editorconfig",
"esbenp.prettier-vscode", "esbenp.prettier-vscode",
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"divlo.vscode-styled-jsx-syntax",
"divlo.vscode-styled-jsx-languageserver",
"bradlc.vscode-tailwindcss", "bradlc.vscode-tailwindcss",
"mikestead.dotenv", "mikestead.dotenv",
"davidanson.vscode-markdownlint", "davidanson.vscode-markdownlint",

View File

@ -16,12 +16,12 @@ jobs:
language: ['javascript'] language: ['javascript']
steps: steps:
- uses: 'actions/checkout@v3.0.0' - uses: 'actions/checkout@v3.1.0'
- name: 'Initialize CodeQL' - name: 'Initialize CodeQL'
uses: 'github/codeql-action/init@v1' uses: 'github/codeql-action/init@v2'
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
- name: 'Perform CodeQL Analysis' - name: 'Perform CodeQL Analysis'
uses: 'github/codeql-action/analyze@v1' uses: 'github/codeql-action/analyze@v2'

View File

@ -10,12 +10,12 @@ jobs:
build: build:
runs-on: 'ubuntu-latest' runs-on: 'ubuntu-latest'
steps: steps:
- uses: 'actions/checkout@v3.0.0' - uses: 'actions/checkout@v3.1.0'
- name: 'Use Node.js' - name: 'Use Node.js'
uses: 'actions/setup-node@v3.0.0' uses: 'actions/setup-node@v3.5.1'
with: with:
node-version: '16.x' node-version: '18.x'
cache: 'npm' cache: 'npm'
- name: 'Install' - name: 'Install'

View File

@ -10,12 +10,12 @@ jobs:
lint: lint:
runs-on: 'ubuntu-latest' runs-on: 'ubuntu-latest'
steps: steps:
- uses: 'actions/checkout@v3.0.0' - uses: 'actions/checkout@v3.1.0'
- name: 'Use Node.js' - name: 'Use Node.js'
uses: 'actions/setup-node@v3.0.0' uses: 'actions/setup-node@v3.5.1'
with: with:
node-version: '16.x' node-version: '18.x'
cache: 'npm' cache: 'npm'
- name: 'Install' - name: 'Install'

View File

@ -8,7 +8,7 @@ jobs:
release: release:
runs-on: 'ubuntu-latest' runs-on: 'ubuntu-latest'
steps: steps:
- uses: 'actions/checkout@v3.0.0' - uses: 'actions/checkout@v3.1.0'
with: with:
fetch-depth: 0 fetch-depth: 0
persist-credentials: false persist-credentials: false
@ -21,9 +21,9 @@ jobs:
git_commit_gpgsign: true git_commit_gpgsign: true
- name: 'Use Node.js' - name: 'Use Node.js'
uses: 'actions/setup-node@v3.0.0' uses: 'actions/setup-node@v3.5.1'
with: with:
node-version: '16.x' node-version: '18.x'
cache: 'npm' cache: 'npm'
- name: 'Install' - name: 'Install'

View File

@ -10,12 +10,12 @@ jobs:
test-unit: test-unit:
runs-on: 'ubuntu-latest' runs-on: 'ubuntu-latest'
steps: steps:
- uses: 'actions/checkout@v3.0.0' - uses: 'actions/checkout@v3.1.0'
- name: 'Use Node.js' - name: 'Use Node.js'
uses: 'actions/setup-node@v3.0.0' uses: 'actions/setup-node@v3.5.1'
with: with:
node-version: '16.x' node-version: '18.x'
cache: 'npm' cache: 'npm'
- name: 'Install' - name: 'Install'
@ -27,12 +27,12 @@ jobs:
test-lighthouse: test-lighthouse:
runs-on: 'ubuntu-latest' runs-on: 'ubuntu-latest'
steps: steps:
- uses: 'actions/checkout@v3.0.0' - uses: 'actions/checkout@v3.1.0'
- name: 'Use Node.js' - name: 'Use Node.js'
uses: 'actions/setup-node@v3.0.0' uses: 'actions/setup-node@v3.5.1'
with: with:
node-version: '16.x' node-version: '18.x'
cache: 'npm' cache: 'npm'
- name: 'Install' - name: 'Install'
@ -52,12 +52,12 @@ jobs:
test-e2e: test-e2e:
runs-on: 'ubuntu-latest' runs-on: 'ubuntu-latest'
steps: steps:
- uses: 'actions/checkout@v3.0.0' - uses: 'actions/checkout@v3.1.0'
- name: 'Use Node.js' - name: 'Use Node.js'
uses: 'actions/setup-node@v3.0.0' uses: 'actions/setup-node@v3.5.1'
with: with:
node-version: '16.x' node-version: '18.x'
cache: 'npm' cache: 'npm'
- name: 'Install' - name: 'Install'

View File

@ -3,8 +3,6 @@
"editorconfig.editorconfig", "editorconfig.editorconfig",
"esbenp.prettier-vscode", "esbenp.prettier-vscode",
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"divlo.vscode-styled-jsx-syntax",
"divlo.vscode-styled-jsx-languageserver",
"bradlc.vscode-tailwindcss", "bradlc.vscode-tailwindcss",
"mikestead.dotenv", "mikestead.dotenv",
"davidanson.vscode-markdownlint", "davidanson.vscode-markdownlint",

View File

@ -1,18 +1,18 @@
FROM node:16.17.1 AS dependencies FROM node:18.11.0 AS dependencies
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY ./package*.json ./ COPY ./package*.json ./
RUN npm install RUN npm install
FROM node:16.17.1 AS builder FROM node:18.11.0 AS builder
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY ./ ./ COPY ./ ./
COPY --from=dependencies /usr/src/app/node_modules ./node_modules COPY --from=dependencies /usr/src/app/node_modules ./node_modules
RUN npm run build RUN npm run build
FROM node:16.17.1 AS runner FROM node:18.11.0 AS runner
WORKDIR /usr/src/app WORKDIR /usr/src/app
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED 1 ENV NEXT_TELEMETRY_DISABLED=1
COPY --from=builder /usr/src/app/.next/standalone ./ COPY --from=builder /usr/src/app/.next/standalone ./
COPY --from=builder /usr/src/app/.next/static ./.next/static COPY --from=builder /usr/src/app/.next/static ./.next/static
COPY --from=builder /usr/src/app/public ./public COPY --from=builder /usr/src/app/public ./public

View File

@ -1,53 +1,44 @@
import useTranslation from 'next-translate/useTranslation' import useTranslation from 'next-translate/useTranslation'
import Link from 'next/link' 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 statusCode: number
message: string message: string
} }
export const ErrorPage: React.FC<ErrorPageProps> = (props) => { export const ErrorPage: React.FC<ErrorPageProps> = (props) => {
const { message, statusCode } = props const { message, statusCode, version } = props
const { t } = useTranslation() const { t } = useTranslation()
return ( return (
<> <>
<h1 className='my-6 text-4xl font-semibold'> <div className='flex h-screen flex-col pt-0'>
{t('errors:error')}{' '} <Header showLanguage />
<span <main className='flex min-w-full flex-1 flex-col items-center justify-center'>
className='text-yellow dark:text-yellow-dark' <h1 className='my-6 text-4xl font-semibold'>
data-cy='status-code' {t('errors:error')}{' '}
> <span
{statusCode} className='text-yellow dark:text-yellow-dark'
</span> data-cy='status-code'
</h1> >
<p className='text-center text-lg'> {statusCode}
{message}{' '} </span>
<Link href='/'> </h1>
<a className='text-yellow hover:underline dark:text-yellow-dark'> <p className='text-center text-lg'>
{t('errors:return-to-home-page')} {message}{' '}
</a> <Link href='/'>
</Link> <a className='text-yellow hover:underline dark:text-yellow-dark'>
</p> {t('errors:return-to-home-page')}
</a>
<style jsx global> </Link>
{` </p>
main { </main>
display: flex; <Footer version={version} />
flex-direction: column; </div>
justify-content: center;
align-items: center;
min-width: 100vw;
flex: 1;
}
#__next {
display: flex;
flex-direction: column;
padding-top: 0;
height: 100vh;
}
`}
</style>
</> </>
) )
} }

View File

@ -1,4 +1,5 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import classNames from 'clsx'
import { useTheme } from 'next-themes' import { useTheme } from 'next-themes'
export const SwitchTheme: React.FC = () => { export const SwitchTheme: React.FC = () => {
@ -18,109 +19,60 @@ export const SwitchTheme: React.FC = () => {
} }
return ( return (
<> <div
<div className='flex items-center'
className='flex items-center' data-cy='switch-theme-click'
data-cy='switch-theme-click' onClick={handleClick}
onClick={handleClick} >
> <div className='relative inline-block cursor-pointer touch-pan-x select-none border-0 bg-transparent p-0'>
<div className='toggle-theme-button relative inline-block cursor-pointer bg-transparent'> <div className='h-[24px] w-[50px] rounded-[30px] bg-[#4d4d4d] p-0 text-white transition-all duration-200 ease-in-out'>
<div className='toggle-track'> <div
<div data-cy='switch-theme-dark'
data-cy='switch-theme-dark' className={classNames(
className='toggle-track-check absolute' 'absolute top-0 bottom-0 left-[8px] mt-auto mb-auto h-[10px] w-[14px] leading-[0] transition-opacity duration-[250ms] ease-in-out',
> {
<span className='toggle_Dark relative flex items-center justify-center'> 'opacity-100': theme === 'dark',
🌜 'opacity-0': theme === 'light'
</span> }
</div> )}
<div >
data-cy='switch-theme-light' <span className='relative flex h-[10px] w-[10px] items-center justify-center'>
className='toggle-track-x absolute' 🌜
> </span>
<span className='toggle_Light relative flex items-center justify-center'> </div>
🌞 <div
</span> data-cy='switch-theme-light'
</div> className={classNames(
'absolute right-[10px] top-0 bottom-0 mt-auto mb-auto h-[10px] w-[10px] leading-[0]',
{
'opacity-100': theme === 'light',
'opacity-0': theme === 'dark'
}
)}
>
<span className='relative flex h-[10px] w-[10px] items-center justify-center'>
🌞
</span>
</div> </div>
<div className='toggle-thumb absolute' />
<input
data-cy='switch-theme-input'
type='checkbox'
aria-label='Dark mode toggle'
className='toggle-screenreader-only absolute overflow-hidden'
defaultChecked
/>
</div> </div>
<div
className={classNames(
'absolute top-[1px] box-border h-[22px] w-[22px] rounded-[50%] bg-[#fafafa] text-white transition-all duration-[250ms] ease-in-out',
{
'left-[27px]': theme === 'dark',
'left-0': theme === 'light'
}
)}
style={{ border: '1px solid #4d4d4d' }}
/>
<input
data-cy='switch-theme-input'
type='checkbox'
aria-label='Dark mode toggle'
className='absolute m-[-1px] h-[1px] w-[1px] overflow-hidden border-0 p-0'
defaultChecked
/>
</div> </div>
</div>
<style jsx>
{`
.toggle-theme-button {
touch-action: pan-x;
border: 0;
padding: 0;
user-select: none;
}
.toggle-track {
width: 50px;
height: 24px;
padding: 0;
border-radius: 30px;
background-color: #4d4d4d;
transition: all 0.2s ease;
color: #fff;
}
.toggle-track-check {
width: 14px;
height: 10px;
top: 0;
bottom: 0;
margin-top: auto;
margin-bottom: auto;
line-height: 0;
left: 8px;
opacity: ${theme === 'dark' ? 1 : 0};
transition: opacity 0.25s ease;
}
.toggle-track-x {
width: 10px;
height: 10px;
top: 0;
bottom: 0;
margin-top: auto;
margin-bottom: auto;
line-height: 0;
right: 10px;
opacity: ${theme === 'dark' ? 0 : 1};
}
.toggle_Dark,
.toggle_Light {
height: 10px;
width: 10px;
}
.toggle-thumb {
left: ${theme === 'dark' ? '27px' : '0px'};
width: 22px;
height: 22px;
border: 1px solid #4d4d4d;
border-radius: 50%;
background-color: #fafafa;
box-sizing: border-box;
transition: all 0.25s ease;
top: 1px;
color: #fff;
}
.toggle-screenreader-only {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
padding: 0;
width: 1px;
}
`}
</style>
</>
) )
} }

View File

@ -3,14 +3,11 @@ import { defineConfig } from 'cypress'
export default defineConfig({ export default defineConfig({
fixturesFolder: false, fixturesFolder: false,
video: false, video: false,
downloadsFolder: undefined,
screenshotOnRunFailure: false, screenshotOnRunFailure: false,
e2e: { e2e: {
baseUrl: 'http://localhost:3000', baseUrl: 'http://localhost:3000',
supportFile: false supportFile: false
}, },
component: { component: {
devServer: { devServer: {
framework: 'next', framework: 'next',

View File

@ -2,5 +2,5 @@
"return-to-home-page": "Revenir à la page d'accueil ?", "return-to-home-page": "Revenir à la page d'accueil ?",
"error": "Erreur", "error": "Erreur",
"server-error": "Erreur Interne du Serveur !", "server-error": "Erreur Interne du Serveur !",
"not-found": "Cette page n'existe pas!" "not-found": "Cette page n'existe pas !"
} }

View File

@ -5,9 +5,9 @@ const nextPWA = require('next-pwa')({
const nextTranslate = require('next-translate') const nextTranslate = require('next-translate')
/** @type {import("next").NextConfig} */ /** @type {import("next").NextConfig} */
module.exports = nextTranslate( const nextConfig = {
nextPWA({ reactStrictMode: true,
reactStrictMode: true, output: 'standalone'
output: 'standalone' }
})
) module.exports = nextTranslate(nextPWA(nextConfig))

755
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@
"postinstall": "husky install" "postinstall": "husky install"
}, },
"dependencies": { "dependencies": {
"@fontsource/montserrat": "4.5.12", "@fontsource/montserrat": "4.5.13",
"@fortawesome/fontawesome-svg-core": "6.2.0", "@fortawesome/fontawesome-svg-core": "6.2.0",
"@fortawesome/free-brands-svg-icons": "6.2.0", "@fortawesome/free-brands-svg-icons": "6.2.0",
"@fortawesome/free-solid-svg-icons": "6.2.0", "@fortawesome/free-solid-svg-icons": "6.2.0",
@ -66,33 +66,33 @@
"@saithodev/semantic-release-backmerge": "2.1.2", "@saithodev/semantic-release-backmerge": "2.1.2",
"@semantic-release/git": "10.0.1", "@semantic-release/git": "10.0.1",
"@tailwindcss/typography": "0.5.7", "@tailwindcss/typography": "0.5.7",
"@types/node": "18.7.23", "@types/node": "18.8.0",
"@types/react": "18.0.21", "@types/react": "18.0.21",
"@types/unist": "2.0.6", "@types/unist": "2.0.6",
"@typescript-eslint/eslint-plugin": "5.38.1", "@typescript-eslint/eslint-plugin": "5.39.0",
"autoprefixer": "10.4.12", "autoprefixer": "10.4.12",
"cypress": "10.9.0", "cypress": "10.9.0",
"editorconfig-checker": "4.0.2", "editorconfig-checker": "4.0.2",
"eslint": "8.24.0", "eslint": "8.24.0",
"eslint-config-conventions": "4.0.1", "eslint-config-conventions": "5.0.0",
"eslint-config-next": "12.3.1", "eslint-config-next": "12.3.1",
"eslint-config-prettier": "8.5.0", "eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0", "eslint-plugin-import": "2.26.0",
"eslint-plugin-prettier": "4.2.1", "eslint-plugin-prettier": "4.2.1",
"eslint-plugin-promise": "6.0.1", "eslint-plugin-promise": "6.0.1",
"eslint-plugin-unicorn": "43.0.2", "eslint-plugin-unicorn": "44.0.0",
"html-w3c-validator": "1.2.0", "html-w3c-validator": "1.2.0",
"husky": "8.0.1", "husky": "8.0.1",
"jsonresume-theme-custom": "file:./jsonresume-theme-custom", "jsonresume-theme-custom": "file:./jsonresume-theme-custom",
"lint-staged": "13.0.3", "lint-staged": "13.0.3",
"markdownlint-cli2": "0.5.1", "markdownlint-cli2": "0.5.1",
"postcss": "8.4.16", "postcss": "8.4.17",
"prettier": "2.7.1", "prettier": "2.7.1",
"prettier-plugin-tailwindcss": "0.1.13", "prettier-plugin-tailwindcss": "0.1.13",
"semantic-release": "19.0.5", "semantic-release": "19.0.5",
"start-server-and-test": "1.14.0", "start-server-and-test": "1.14.0",
"tailwindcss": "3.1.8", "tailwindcss": "3.1.8",
"typescript": "4.8.4", "typescript": "4.8.4",
"vercel": "28.4.5" "vercel": "28.4.6"
} }
} }

View File

@ -3,9 +3,7 @@ import useTranslation from 'next-translate/useTranslation'
import { ErrorPage } from 'components/ErrorPage' import { ErrorPage } from 'components/ErrorPage'
import { Head } from 'components/Head' import { Head } from 'components/Head'
import { Header } from 'components/Header'
import type { FooterProps } from 'components/Footer' import type { FooterProps } from 'components/Footer'
import { Footer } from 'components/Footer'
interface Error404Props extends FooterProps {} interface Error404Props extends FooterProps {}
@ -16,12 +14,11 @@ const Error404: NextPage<Error404Props> = (props) => {
return ( return (
<> <>
<Head title='404 | Divlo' /> <Head title='404 | Divlo' />
<ErrorPage
<Header showLanguage /> statusCode={404}
<main className='flex flex-col md:mx-auto md:max-w-4xl lg:max-w-7xl'> message={t('errors:not-found')}
<ErrorPage statusCode={404} message={t('errors:not-found')} /> version={version}
</main> />
<Footer version={version} />
</> </>
) )
} }

View File

@ -3,9 +3,7 @@ import useTranslation from 'next-translate/useTranslation'
import { ErrorPage } from 'components/ErrorPage' import { ErrorPage } from 'components/ErrorPage'
import { Head } from 'components/Head' import { Head } from 'components/Head'
import { Header } from 'components/Header'
import type { FooterProps } from 'components/Footer' import type { FooterProps } from 'components/Footer'
import { Footer } from 'components/Footer'
interface Error500Props extends FooterProps {} interface Error500Props extends FooterProps {}
@ -16,12 +14,11 @@ const Error500: NextPage<Error500Props> = (props) => {
return ( return (
<> <>
<Head title='500 | Divlo' /> <Head title='500 | Divlo' />
<ErrorPage
<Header showLanguage /> statusCode={500}
<main className='flex flex-col md:mx-auto md:max-w-4xl lg:max-w-7xl'> message={t('errors:server-error')}
<ErrorPage statusCode={500} message={t('errors:server-error')} /> version={version}
</main> />
<Footer version={version} />
</> </>
) )
} }

View File

@ -1,4 +1,5 @@
module.exports = { /** @type {import('tailwindcss').Config} */
const tailwindConfig = {
content: [ content: [
'./pages/**/*.{js,ts,jsx,tsx}', './pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}' './components/**/*.{js,ts,jsx,tsx}'
@ -47,3 +48,5 @@ module.exports = {
}, },
plugins: [require('@tailwindcss/typography')] plugins: [require('@tailwindcss/typography')]
} }
module.exports = tailwindConfig