Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lottie animations #10

Merged
merged 2 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions components/home/HeroSection/HeroSection.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Header, LottieAnimation } from 'components'
import { HeroSectionProps } from './types.d'
import { calendarAnimation } from 'public'
import { useTranslate } from 'hooks'
import { Header } from 'components'
import { calendar } from 'public'
import Image from 'next/image'
import Link from 'next/link'

const HeroSection: React.FC<HeroSectionProps> = (props) => {
Expand All @@ -14,11 +13,11 @@ const HeroSection: React.FC<HeroSectionProps> = (props) => {

<main
onClick={() => blurContent && setBlurContent(false)}
className={`lg:relative h-full ${
className={`lg:relative h-[92%] sm:h-full ${
blurContent ? 'blur-[2.4px]' : 'blur-0'
} md:blur-0 flex flex-col justify-between`}
>
<div className='mx-auto lg:h-screen lg:flex lg:items-center lg:pb-[3%] w-full text-center lg:text-left'>
<div className='mx-auto xl:px-14 lg:h-screen lg:flex lg:items-center lg:pb-[3%] w-full text-center lg:text-left'>
<div className='px-4 sm:px-8 lg:w-1/2 xl:pr-16 lg:pt-[3%]'>
<h2 className='text-4xl lg:mt-14 mb-7 font-bold tracking-tight text-gray-900 sm:text-5xl md:text-6xl lg:text-5xl xl:text-6xl'>
<span>{useTranslate('overview:plan')}</span>{' '}
Expand All @@ -39,15 +38,9 @@ const HeroSection: React.FC<HeroSectionProps> = (props) => {
</div>
</div>

<div className='relative h-64 w-full sm:h-72 md:h-96 lg:absolute lg:inset-y-0 lg:right-0 lg:h-full lg:w-1/2'>
<div className='absolute inset-0 h-full w-full object-cover'>
<Image
className='object-cover w-full h-full'
alt='calendar image'
src={calendar}
layout='fill'
priority
/>
<div className='relative h-80 w-full lg:pt-16 sm:h-72 md:h-96 lg:absolute lg:inset-y-0 lg:right-0 lg:h-full lg:flex lg:justify-center lg:items-center lg:w-1/2'>
<div className='inset-0 -z-10 cursor-default h-full w-full lg:h-4/5 lg:w-4/5 object-cover'>
<LottieAnimation animationData={calendarAnimation} />
</div>
</div>
</main>
Expand Down
23 changes: 23 additions & 0 deletions components/shared/LottieAnimation/LottieAnimation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { LottieAnimationProps } from './types.d'
import Lottie from 'react-lottie'

const LottieAnimation: React.FC<LottieAnimationProps> = (props) => {
const { animationData, styles, disableLoop } = props

return (
<Lottie
style={{ height: '100%', width: '100%', cursor: 'default', ...styles }}
isClickToPauseDisabled
options={{
loop: disableLoop ? false : true,
autoplay: true,
animationData,
rendererSettings: {
preserveAspectRatio: 'xMidYMid slice',
},
}}
/>
)
}

export default LottieAnimation
1 change: 1 addition & 0 deletions components/shared/LottieAnimation/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as LottieAnimation } from './LottieAnimation'
5 changes: 5 additions & 0 deletions components/shared/LottieAnimation/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type LottieAnimationProps = {
animationData: object | string
disableLoop?: boolean
styles?: object
}
1 change: 1 addition & 0 deletions components/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './InputErrorMessage'
export * from './LanguageSelector'
export * from './LottieAnimation'
export * from './AuthQuestion'
export * from './SubmitButton'
export * from './SuccessModal'
Expand Down
2 changes: 1 addition & 1 deletion components/sign-up/SignUpForm/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const SignUpForm = () => {
{signUpSuccess && (
<SuccessModal
description={t('auth:confirmation-instructions')}
linkActionText={t('auth:go-to-gmail')}
title={t('auth:confirmation-sent')}
actionText={t('auth:go-to-gmail')}
setSuccess={setSignUpSuccess}
isSuccess={signUpSuccess}
linkAction={true}
Expand Down
10 changes: 5 additions & 5 deletions hooks/useAccountActivation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { carOnFire, party, girlWithLaptop, searching } from 'public'
import { partyPop, dataNotFount, serverError, identity } from 'public'
import { accountActivation } from 'services'
import { useEffect, useState } from 'react'
import { useMutation } from 'react-query'
Expand All @@ -16,13 +16,13 @@ const useAccountActivation = () => {
const token = query.token

let imageSrc = activationSuccess
? party
? partyPop
: alreadyActivated
? girlWithLaptop
? identity
: accountNotFound
? searching
? dataNotFount
: activationFail
? carOnFire
? serverError
: ''

const { mutate: activateAccount, isLoading } = useMutation(accountActivation)
Expand Down
96 changes: 96 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"next-i18next": "^12.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-lottie": "^1.2.3",
"react-query": "^3.39.2",
"react-redux": "^8.0.4",
"yup": "^0.32.11"
Expand All @@ -32,6 +33,7 @@
"@types/node": "18.7.22",
"@types/react": "18.0.21",
"@types/react-dom": "18.0.6",
"@types/react-lottie": "^1.2.6",
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"autoprefixer": "^10.4.12",
Expand Down
20 changes: 11 additions & 9 deletions pages/sign-up/account-activation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { LoadingIcon, ActivationText, ActivationButton } from 'components'
import { useAccountActivation } from 'hooks'
import { GetStaticProps } from 'next'
import Image from 'next/image'
import {
ActivationButton,
LottieAnimation,
ActivationText,
LoadingIcon,
} from 'components'

const AccountActivation = () => {
const {
Expand All @@ -16,15 +20,13 @@ const AccountActivation = () => {
} = useAccountActivation()

return (
<div className='bg-gray-200 h-screen w-full flex justify-center'>
<div className='h-screen bg-white w-full flex justify-center'>
{isMounted && !isLoading && imageSrc ? (
<div className='flex items-center justify-center flex-col gap-5'>
<div className='relative h-[180px] w-[280px] md:h-[300px] md:w-[450px] lg:h-[400px] lg:w-[550px] 3xl:h-[600px] 3xl:w-[700px]'>
<Image
alt='illustration'
priority={true}
src={imageSrc}
layout='fill'
<div className='relative h-[50vh] w-full'>
<LottieAnimation
disableLoop={accountNotFound ? true : false}
animationData={imageSrc}
/>
</div>

Expand Down
Binary file removed public/assets/images/car-on-fire.png
Binary file not shown.
Binary file removed public/assets/images/girl-with-laptop.png
Binary file not shown.
4 changes: 0 additions & 4 deletions public/assets/images/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export { default as girlWithLaptop } from './girl-with-laptop.png'
export { default as georgianFlag } from './georgian-flag.png'
export { default as britainFlag } from './britain-flag.png'
export { default as carOnFire } from './car-on-fire.png'
export { default as searching } from './searching.png'
export { default as calendar } from './calendar.jpg'
export { default as party } from './party.png'
Binary file removed public/assets/images/party.png
Binary file not shown.
Binary file removed public/assets/images/searching.png
Binary file not shown.
1 change: 1 addition & 0 deletions public/assets/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './lotties'
export * from './images'
1 change: 1 addition & 0 deletions public/assets/lotties/calendar.json

Large diffs are not rendered by default.

Loading