mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 15:06:59 +00:00
Remove lazy loading & change rotation animation
This commit is contained in:
parent
00184e674f
commit
c76a406aa0
@ -1,22 +1,15 @@
|
|||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import cn from 'clsx'
|
import cn from 'clsx'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import dynamic from 'next/dynamic'
|
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import type { Page } from '@commerce/types/page'
|
import type { Page } from '@commerce/types/page'
|
||||||
import getSlug from '@lib/get-slug'
|
import getSlug from '@lib/get-slug'
|
||||||
import { Github, Vercel } from '@components/icons'
|
import { Github, Vercel } from '@components/icons'
|
||||||
import { Logo, Container } from '@components/ui'
|
import { Logo, Container } from '@components/ui'
|
||||||
import { I18nWidget } from '@components/common'
|
import { I18nWidget } from '@components/common'
|
||||||
|
import ThemeSwitcher from '@components/ui/ThemeSwitcher'
|
||||||
import s from './Footer.module.css'
|
import s from './Footer.module.css'
|
||||||
|
|
||||||
const ThemeSwitcher = dynamic(() => import('@components/ui/ThemeSwitcher'), {
|
|
||||||
ssr: false,
|
|
||||||
loading: () => (
|
|
||||||
<div className="w-24 h-10 rounded-md bg-accent-2 animate-pulse" />
|
|
||||||
),
|
|
||||||
})
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string
|
className?: string
|
||||||
children?: any
|
children?: any
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.icon.active {
|
.icon.active {
|
||||||
transform: rotate(180deg);
|
transform: rotate(90deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@screen lg {
|
@screen lg {
|
||||||
|
@ -3,7 +3,7 @@ import Link from 'next/link'
|
|||||||
import { FC, useState } from 'react'
|
import { FC, useState } from 'react'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import s from './I18nWidget.module.css'
|
import s from './I18nWidget.module.css'
|
||||||
import { Cross, ChevronUp } from '@components/icons'
|
import { Cross, ChevronRight } from '@components/icons'
|
||||||
import ClickOutside from '@lib/click-outside'
|
import ClickOutside from '@lib/click-outside'
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
interface LOCALE_DATA {
|
interface LOCALE_DATA {
|
||||||
@ -61,7 +61,7 @@ const I18nWidget: FC = () => {
|
|||||||
/>
|
/>
|
||||||
{options && (
|
{options && (
|
||||||
<span className="cursor-pointer">
|
<span className="cursor-pointer">
|
||||||
<ChevronUp className={cn(s.icon, { [s.active]: display })} />
|
<ChevronRight className={cn(s.icon, { [s.active]: display })} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
import { useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useTheme } from 'next-themes'
|
import { useTheme } from 'next-themes'
|
||||||
import { ChevronUp, Cross } from '@components/icons'
|
import { ChevronRight, Cross } from '@components/icons'
|
||||||
|
|
||||||
import cn from 'clsx'
|
import cn from 'clsx'
|
||||||
import ClickOutside from '@lib/click-outside'
|
import ClickOutside from '@lib/click-outside'
|
||||||
import ThemeIcon from './ThemeIcon'
|
import ThemeIcon from './ThemeIcon'
|
||||||
|
|
||||||
const ThemeSwitcher = () => {
|
const ThemeSwitcher = () => {
|
||||||
|
const [mounted, setMounted] = useState(false)
|
||||||
const [display, setDisplay] = useState(false)
|
const [display, setDisplay] = useState(false)
|
||||||
const { theme, themes, setTheme } = useTheme()
|
const { theme, themes, setTheme } = useTheme()
|
||||||
|
|
||||||
|
useEffect(() => setMounted(true), [])
|
||||||
|
|
||||||
|
if (!mounted) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ClickOutside active={display} onClick={() => setDisplay(false)}>
|
<ClickOutside active={display} onClick={() => setDisplay(false)}>
|
||||||
<nav className="relative">
|
<div className="relative">
|
||||||
<div
|
<div
|
||||||
className="flex items-center relative"
|
className="flex items-center relative"
|
||||||
onClick={() => setDisplay(!display)}
|
onClick={() => setDisplay(!display)}
|
||||||
@ -26,9 +31,9 @@ const ThemeSwitcher = () => {
|
|||||||
<ThemeIcon width={20} height={20} theme={theme} />
|
<ThemeIcon width={20} height={20} theme={theme} />
|
||||||
<span className="capitalize">{theme}</span>
|
<span className="capitalize">{theme}</span>
|
||||||
<span className="cursor-pointer">
|
<span className="cursor-pointer">
|
||||||
<ChevronUp
|
<ChevronRight
|
||||||
className={cn('transition duration-300', {
|
className={cn('transition duration-300', {
|
||||||
['rotate-180']: display,
|
['rotate-90']: display,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
@ -69,7 +74,7 @@ const ThemeSwitcher = () => {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</div>
|
||||||
</ClickOutside>
|
</ClickOutside>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user