1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2025-05-29 22:37:44 +02:00

build(deps): bump next to 11.0.0

This commit is contained in:
divlo
2021-06-15 20:35:52 +02:00
parent 61ef6c5525
commit 892bf0e87a
8 changed files with 776 additions and 756 deletions

View File

@ -1,15 +1,19 @@
import { useEffect, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import useTranslation from 'next-translate/useTranslation'
import setLanguage from 'next-translate/setLanguage'
import { Arrow } from './Arrow'
import { LanguageFlag } from './LanguageFlag'
import { locales } from 'i18n.json'
import i18n from 'i18n.json'
export const Language: React.FC = () => {
const { lang: currentLanguage } = useTranslation()
const [hiddenMenu, setHiddenMenu] = useState(true)
const handleHiddenMenu = useCallback(() => {
setHiddenMenu(!hiddenMenu)
}, [hiddenMenu])
useEffect(() => {
if (!hiddenMenu) {
window.document.addEventListener('click', handleHiddenMenu)
@ -20,17 +24,13 @@ export const Language: React.FC = () => {
return () => {
window.document.removeEventListener('click', handleHiddenMenu)
}
}, [hiddenMenu])
}, [hiddenMenu, handleHiddenMenu])
const handleLanguage = async (language: string): Promise<void> => {
await setLanguage(language)
handleHiddenMenu()
}
const handleHiddenMenu = (): void => {
setHiddenMenu(!hiddenMenu)
}
return (
<div className='flex flex-col justify-center items-center cursor-pointer'>
<div className='flex items-center mr-5' onClick={handleHiddenMenu}>
@ -39,7 +39,7 @@ export const Language: React.FC = () => {
</div>
{!hiddenMenu && (
<ul className='flex flex-col justify-center items-center absolute p-0 top-14 z-10 w-24 mt-3 mr-4 rounded-lg list-none shadow-light dark:shadow-dark bg-white dark:bg-black'>
{locales.map((language, index) => {
{i18n.locales.map((language, index) => {
if (language === currentLanguage) {
return null
}

View File

@ -1,20 +1,11 @@
import { forwardRef } from 'react'
type SectionHeadingProps = React.ComponentPropsWithRef<'h2'>
export const SectionHeading = forwardRef<
HTMLHeadingElement,
SectionHeadingProps
>((props, ref) => {
export const SectionHeading: React.FC<SectionHeadingProps> = (props) => {
const { children, ...rest } = props
return (
<h2
ref={ref}
{...rest}
className='text-4xl font-semibold text-center mt-1 mb-7'
>
<h2 {...rest} className='text-4xl font-semibold text-center mt-1 mb-7'>
{children}
</h2>
)
})
}

View File

@ -1,5 +1,3 @@
import { forwardRef } from 'react'
import { ShadowContainer } from '../ShadowContainer'
import { SectionHeading } from './SectionHeading'
@ -10,7 +8,7 @@ type SectionProps = React.ComponentPropsWithRef<'section'> & {
withoutShadowContainer?: boolean
}
export const Section = forwardRef<HTMLElement, SectionProps>((props, ref) => {
export const Section: React.FC<SectionProps> = (props) => {
const {
children,
heading,
@ -24,7 +22,7 @@ export const Section = forwardRef<HTMLElement, SectionProps>((props, ref) => {
return (
<div className='px-3 w-full'>
<ShadowContainer style={{ marginTop: 50 }}>
<section ref={ref} {...rest}>
<section {...rest}>
{heading != null && <SectionHeading>{heading}</SectionHeading>}
<div className='px-3 w-full'>{children}</div>
</section>
@ -35,7 +33,7 @@ export const Section = forwardRef<HTMLElement, SectionProps>((props, ref) => {
if (withoutShadowContainer) {
return (
<section ref={ref} {...rest}>
<section {...rest}>
{heading != null && <SectionHeading>{heading}</SectionHeading>}
<div className='px-3 w-full'>{children}</div>
</section>
@ -43,7 +41,7 @@ export const Section = forwardRef<HTMLElement, SectionProps>((props, ref) => {
}
return (
<section ref={ref} {...rest}>
<section {...rest}>
{heading != null && (
<SectionHeading style={{ ...(description != null && { margin: 0 }) }}>
{heading}
@ -61,4 +59,4 @@ export const Section = forwardRef<HTMLElement, SectionProps>((props, ref) => {
</div>
</section>
)
})
}