Skip to content

Commit

Permalink
update mobile form #124
Browse files Browse the repository at this point in the history
  • Loading branch information
ukorvl committed Nov 30, 2024
1 parent bc31d12 commit c233195
Show file tree
Hide file tree
Showing 20 changed files with 4,454 additions and 11,455 deletions.
2 changes: 1 addition & 1 deletion app/contact/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const metadata: Metadata = {
const titleVariants = getTextSlideIntoViewVarinats('right');
const {FORMSPREE_ID} = env;
const containerCn = clsx('flex', 'flex-col', 'min-h-screen', 'w-full');
const titleCn = clsx('text-8xl', 'mt-24', 'ml-4', 'text-center');
const titleCn = clsx('text-6xl', 'md:text-8xl', 'mt-24', 'ml-4', 'text-center');

/**
* @returns React component.
Expand Down
4 changes: 2 additions & 2 deletions app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const errContainerCn = clsx('pt-64', 'flex', 'flex-col', 'gap-8');
* @param {{error: Error; reset: () => void}} props Props.
* @returns React component.
*/
export default function Error({reset}: {error: Error; reset: () => void}) {
export default function Error({reset}: {_err: Error; reset: () => void}) {
return (
<div className={errContainerCn}>
<h2>Something went wrong!</h2>
<Button onClick={() => reset()}>Try again</Button>
<Button onClick={() => reset()}>Reload</Button>
</div>
);
}
63 changes: 32 additions & 31 deletions app/gallery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Gallery from '@/components/pages/Gallery/Gallery';
import AppearInViewport from '@/components/shared/AppearInViewport/AppearInViewport';
import SocialIcons from '@/components/shared/SocialIcons/SocialIcons';
import TransitionDuration from '@/lib/framerMotion/TransitionDuration';
import getTextSlideIntoViewVarinats from '@/lib/framerMotion/variants/getTextSlideIntoViewVarinats';
import metadataBase from '../metadata';
import getSocialicons from '../socialIcons';
import './styles.css';
Expand All @@ -18,56 +19,56 @@ export const metadata: Metadata = {
};

const containerCn = clsx(
'grow',
'flex',
'flex-col',
'items-start',
'justify-start',
'min-h-screen',
'w-full',
'h-full',
'grid',
'grid-rows-auto',
'sm: grid-cols-1',
'md:grid-cols-2',
'lg:grid-cols-3',
'2xl:grid-cols-4',
);
const galleryTextItem = clsx(
'p-8',
const titleCn = clsx('lg:text-8xl', 'text-6xl', 'mt-24', 'ml-4');
const bottomText = clsx('text-2xl');
const bottomTextContainerCn = clsx(
'flex',
'flex-col',
'mt-16',
'items-center',
'justify-center',
'gap-8',
'w-full',
'gap-4',
'p-4',
'text-center',
);
const titleCn = clsx('text-4xl');
const subTitleCn = clsx('text-2xl');
const subTitleCn = clsx('text-4xl', 'my-12', 'lg:my-4', 'lg:w-2/3', 'ml-4');
const titleVariants = getTextSlideIntoViewVarinats('left');

/**
* @returns React component.
*/
export default function GalleryPage() {
return (
<div className={containerCn}>
<div className={galleryTextItem}>
<AppearInViewport
className={titleCn}
transition={{delay: 0.5, duration: TransitionDuration.LONG}}
as="h1"
>
SALSAVIVA GALLERY
</AppearInViewport>
<AppearInViewport
transition={{delay: 2, duration: TransitionDuration.VERY_LONG}}
className={subTitleCn}
>
Enjoy!
</AppearInViewport>
</div>
<AppearInViewport
as="h1"
className={titleCn}
variants={titleVariants}
transition={{duration: TransitionDuration.VERY_LONG, type: 'spring', bounce: 0.5}}
>
GALLERY
</AppearInViewport>
<AppearInViewport
className={subTitleCn}
transition={{delay: 1, duration: TransitionDuration.LONG}}
>
Dive into our vibrant world of social dance
</AppearInViewport>
<Gallery />
<div className={galleryTextItem}>
<div className={bottomTextContainerCn}>
<AppearInViewport
className={subTitleCn}
className={bottomText}
as="h3"
>
Want more? Follow us on social media!
Want more? Follow us on social media
</AppearInViewport>
<SocialIcons icons={getSocialicons('2x')} />
</div>
Expand Down
29 changes: 20 additions & 9 deletions components/pages/Contact/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import {FormikContext, useFormik} from 'formik';
import {m} from 'framer-motion';
import clsx from 'clsx';
import Button from '@/components/shared/Button/Button';
import validationSchema, {ContactFormData} from './validationSchema';
import FormField from './FormField';
import variants from './formElementChildrenVariants';

/**
* Props.
Expand All @@ -23,8 +25,9 @@ const initialValues = {
* @returns React element.
*/
export default function Form({onSubmit}: FormProps) {
const formCn = clsx('flex', 'flex-col', 'justify-center');
const mottoCn = 'text-center text-gray-300 mt-16';
const btnCn = 'mt-8';
const btnCn = clsx('mt-8', 'lg:mx-0', 'mx-auto', 'w-64', 'lg:w-1/2');

const formikData = useFormik<ContactFormData>({
initialValues,
Expand All @@ -41,20 +44,28 @@ export default function Form({onSubmit}: FormProps) {
initial="hidden"
whileInView="visible"
viewport={{once: true}}
className={formCn}
>
<FormField name="name" />
<FormField name="message" />
<div className={mottoCn}>Select your preferred method of contact:</div>
<m.div
className={mottoCn}
variants={variants}
>
Select your preferred method of contact:
</m.div>
<FormField name="email" />
<FormField name="tel" />
<FormField name="telegram" />
<Button
type="submit"
disabled={isSubmitting || !isValid || !dirty}
className={btnCn}
>
Submit
</Button>
<m.div variants={variants}>
<Button
type="submit"
disabled={isSubmitting || !isValid || !dirty}
className={btnCn}
>
Submit
</Button>
</m.div>
</m.form>
</FormikContext.Provider>
);
Expand Down
20 changes: 3 additions & 17 deletions components/pages/Contact/Form/FormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import formConfig from './formConfig';
import type {ContactFormData} from './validationSchema';
import TextField from '../TextField/TextField';
import ErrorMessage from './ErrorMessage';
import variants from './formElementChildrenVariants';

/**
* Props.
Expand All @@ -13,23 +14,6 @@ type FormFieldProps = {
name: keyof ContactFormData;
};

const variants = {
visible: {
y: 0,
opacity: 1,
transition: {
y: {stiffness: 1000, velocity: -100},
},
},
hidden: {
y: 50,
opacity: 0,
transition: {
y: {stiffness: 1000},
},
},
};

/**
* @param {FormFieldProps} props Props.
* @returns React element.
Expand All @@ -40,6 +24,8 @@ export default function FormField({name}: FormFieldProps) {
const hasError = meta.touched && !!meta.error;
const fieldCn = clsx('relative', 'h-16');

console.log('error', meta);

return (
<m.div
variants={variants}
Expand Down
21 changes: 21 additions & 0 deletions components/pages/Contact/Form/formElementChildrenVariants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Frmaer motion variants for form children elements.
*/
const variants = {
visible: {
y: 0,
opacity: 1,
transition: {
y: {stiffness: 1000, velocity: -100},
},
},
hidden: {
y: 50,
opacity: 0,
transition: {
y: {stiffness: 1000},
},
},
};

export default variants;
6 changes: 1 addition & 5 deletions components/pages/Contact/FormWrapper/FormWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,5 @@ export default function FormWrapper({formspreeId}: FormWrapperProps) {

// here animation on swich screen should occur

return (
<DynamicFormBg>
<div className={wrapperCn}>{render()}</div>
</DynamicFormBg>
);
return <div className={wrapperCn}>{render()}</div>;
}
38 changes: 27 additions & 11 deletions components/pages/Gallery/Gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {Gallery as PSGallery, GalleryProps} from 'react-photoswipe-gallery';
import 'photoswipe/dist/photoswipe.css';
import clsx from 'clsx';
import config from './config';
import GalleryItem from './GalleryItem';

Expand All @@ -16,21 +17,36 @@ const photoSwipeOptions: GalleryProps['options'] = {
preload: [1, 4],
};

const containerCn = clsx(
'grow',
'w-full',
'h-full',
'grid',
'grid-rows-auto',
'sm: grid-cols-1',
'md:grid-cols-2',
'lg:grid-cols-3',
'2xl:grid-cols-4',
'select-none',
);

/**
* @returns React component.
*/
export default function Gallery() {
return (
<PSGallery
options={photoSwipeOptions}
id={galleryId}
>
{config.map(props => (
<GalleryItem
key={props.src}
{...props}
/>
))}
</PSGallery>
<div className={containerCn}>
<PSGallery
options={photoSwipeOptions}
id={galleryId}
>
{config.map(props => (
<GalleryItem
key={props.src}
{...props}
/>
))}
</PSGallery>
</div>
);
}
3 changes: 1 addition & 2 deletions components/pages/Gallery/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ const config = [
{fileName: 'gallery.11.jpg', width: 920, height: 600, alt: ''},
{fileName: 'gallery.12.jpg', width: 920, height: 600, alt: ''},
{fileName: 'gallery.13.jpg', width: 920, height: 600, alt: ''},
{fileName: 'gallery.14.jpg', width: 920, height: 600, alt: ''},
{fileName: 'gallery.15.jpg', width: 1280, height: 854, alt: ''},
{fileName: 'gallery.14.jpg', width: 1280, height: 854, alt: ''},
] as const;

export default config.map(({fileName, ...rest}) => ({
Expand Down
4 changes: 3 additions & 1 deletion components/shared/Menu/MenuList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {useHotkeys} from 'react-hotkeys-hook';
import clsx from 'clsx';
import useWindowDimensions from '@/lib/shared/useWindowDimensions';
import {useContextSafe} from '@/utils/useContextSafe';
import {numericMobileMaxScreenSize} from '@/lib/shared/useIsMobile';
import {MenuContext} from './MenuContext';
import {MenuPosition} from './MenuPosition';
import menuButtonSize from './menuButtonSize';
Expand Down Expand Up @@ -65,6 +66,7 @@ export default function MenuList({children}: MenuListProps) {
const {height, width} = useWindowDimensions();
const bodyHasOverflow = height ? height < document.body.clientHeight : undefined;
const scrollbarWidth = width ? width - document.body.clientWidth : undefined;
const isMobile = width ? numericMobileMaxScreenSize >= width : false;
useHotkeys('esc', close);

useEffect(() => {
Expand All @@ -85,7 +87,7 @@ export default function MenuList({children}: MenuListProps) {
style={{paddingRight: bodyHasOverflow ? `${scrollbarWidth}px` : '0px'}}
>
{children}
<MenuDynamicBg />
{!isMobile && <MenuDynamicBg />}
</m.nav>
);
}
Expand Down
6 changes: 5 additions & 1 deletion lib/shared/useIsMobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import tailwindConfig from '../../tailwind.config';
import useWindowDimensions from './useWindowDimensions';

const mobileMaxScreenSize = tailwindConfig.theme.extend.screens.sm;
const numericMobileMaxScreenSize = parseInt(mobileMaxScreenSize.replace('px', ''));

/**
* Numeric mobile max screen size.
*/
export const numericMobileMaxScreenSize = parseInt(mobileMaxScreenSize.replace('px', ''));

/**
* @returns Is mobile.
Expand Down
Loading

0 comments on commit c233195

Please sign in to comment.