From 12223b79d5913c769df2d9dd7f943b03a4adb500 Mon Sep 17 00:00:00 2001 From: ner Date: Sat, 23 Mar 2024 11:20:30 +0200 Subject: [PATCH] feat: swiper --- app/(site)/container.tsx | 83 +++++++++++++------ app/(site)/favorites/page.tsx | 2 +- app/(site)/popular/page.tsx | 2 +- app/(site)/top/page.tsx | 2 +- app/(site)/useRandomMovie.ts | 35 ++++---- app/layout.tsx | 2 - components/Header/index.tsx | 2 +- components/Movie/Card.tsx | 54 ++++++++---- components/Movie/List.tsx | 5 +- .../Movie/Preview/components/Actions.tsx | 8 ++ components/Movie/Preview/index.tsx | 48 ++--------- components/Movie/components/Credits/index.tsx | 2 +- components/Movie/components/Poster/index.tsx | 41 ++++----- components/Movie/components/Rating/index.tsx | 17 ++-- components/Movie/components/Trailer/index.tsx | 29 +++---- package-lock.json | 39 ++++++++- package.json | 4 +- providers/index.tsx | 2 + styles/index.css | 4 + tailwind.config.js | 5 +- 20 files changed, 222 insertions(+), 164 deletions(-) diff --git a/app/(site)/container.tsx b/app/(site)/container.tsx index ad6ed6d..2209f2e 100644 --- a/app/(site)/container.tsx +++ b/app/(site)/container.tsx @@ -1,11 +1,14 @@ 'use client'; -import { useEffect, useState } from 'react'; +import { useEffect } from 'react'; import { createPortal } from 'react-dom'; import { useAtom } from 'jotai'; import { atomWithStorage } from 'jotai/utils'; import { ArrowLeft, ArrowRight, SlidersHorizontal } from 'lucide-react'; +import { EffectCreative } from 'swiper/modules'; +import { Swiper, SwiperSlide } from 'swiper/react'; +import Card from '@/components/Movie/Card'; import Movie from '@/components/Movie/Preview'; import { Button } from '@/components/ui/button'; import useMounted from '@/hooks/useMounted'; @@ -17,10 +20,23 @@ import useRandomMovie from './useRandomMovie'; const isShowFilterAtom = atomWithStorage('is-show-filters', false); +const creativeEffectProps = { + creativeEffect: { + prev: { + shadow: true, + translate: ['-120%', 0, -500] + }, + next: { + shadow: true, + translate: ['120%', 0, -500] + } + }, + modules: [EffectCreative] +}; + export default function Container() { const [isShowFilter, setIsShowFilter] = useAtom(isShowFilterAtom); - const { movie, next, previous, hasPrevious } = useRandomMovie(); - const [direction, setDirection] = useState(0); + const { ref, hasPrevious, movies, movie, next, previous, index, onIndexChange } = useRandomMovie(); const isMounted = useMounted(); useEffect(() => { @@ -29,37 +45,50 @@ export default function Container() { queryClient.prefetchQuery({ queryKey: ['genres'], queryFn: () => genres() }); }, []); - const handleChangeMovie = (direction: 1 | -1) => () => { - direction === 1 ? next() : previous(); - setDirection(direction); - }; - return ( <> {isShowFilter && } - -
+ {isMounted && + createPortal( , + document.getElementById('actions')! + )} + ( + (ref.current = instance)} + effect='creative' + lazyPreloadPrevNext={5} + resistance={false} + longSwipesRatio={0.25} + speed={600} + initialSlide={index} + onActiveIndexChange={onIndexChange} + className='w-[300px] shrink-0' + {...creativeEffectProps} + > + {movies?.map((movie) => ( + + + + ))} + + )} + > +
+ - {isMounted && - createPortal( - , - document.getElementById('actions')! - )} -
diff --git a/app/(site)/favorites/page.tsx b/app/(site)/favorites/page.tsx index 6c62924..579e79e 100644 --- a/app/(site)/favorites/page.tsx +++ b/app/(site)/favorites/page.tsx @@ -1,5 +1,5 @@ import Container from './container'; -export default async function Favorites() { +export default function Favorites() { return ; } diff --git a/app/(site)/popular/page.tsx b/app/(site)/popular/page.tsx index 09af17f..2c18948 100644 --- a/app/(site)/popular/page.tsx +++ b/app/(site)/popular/page.tsx @@ -13,7 +13,7 @@ queryClient.prefetchInfiniteQuery({ initialPageParam: '1' }); -export default async function Popular() { +export default function Popular() { return ( diff --git a/app/(site)/top/page.tsx b/app/(site)/top/page.tsx index 1625a24..ef28977 100644 --- a/app/(site)/top/page.tsx +++ b/app/(site)/top/page.tsx @@ -13,7 +13,7 @@ queryClient.prefetchInfiniteQuery({ initialPageParam: '1' }); -export default async function Top() { +export default function Top() { return ( diff --git a/app/(site)/useRandomMovie.ts b/app/(site)/useRandomMovie.ts index dd7eae7..2fe2eae 100644 --- a/app/(site)/useRandomMovie.ts +++ b/app/(site)/useRandomMovie.ts @@ -1,7 +1,8 @@ 'use client'; -import { useEffect, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { useQuery, useQueryClient } from '@tanstack/react-query'; +import { Swiper } from 'swiper/types'; import useFilters from '@/app/(site)/useFilters'; import { randomMovies } from '@/lib/api'; @@ -15,7 +16,8 @@ const useRandomMovie = () => { const queryClient = useQueryClient(); const { filters } = useFilters(); const indexByFilter = previousIndexes[JSON.stringify(filters)]; - const [index, setIndex] = useState(indexByFilter || 0); + const [index, setIndex] = useState(indexByFilter); + const ref = useRef(); const { data: movies, refetch } = useQuery({ queryKey: ['random-movie', filters], @@ -43,28 +45,25 @@ const useRandomMovie = () => { setIndex(indexByFilter || 0); }, [indexByFilter]); - const previous = () => { - if (!index) return; + const previous = () => ref.current?.slidePrev(); - setIndex((index) => index - 1); - }; - - const next = () => { - if ((index && index % UPDATE_RATE === 0) || movies!.length < UPDATE_RATE) { - refetch(); - } - - const nextIndex = index + 1; - - previousIndexes[JSON.stringify(filters)] = nextIndex; - setIndex(nextIndex); - }; + const next = () => ref.current?.slideNext(); return { + movies, movie: movies?.[index], hasPrevious: index > 0, + onIndexChange: ({ activeIndex }: Swiper) => { + if ((activeIndex && activeIndex % UPDATE_RATE === 0) || movies!.length < UPDATE_RATE) { + refetch(); + } + previousIndexes[JSON.stringify(filters)] = activeIndex; + setIndex(activeIndex); + }, next, - previous + previous, + index, + ref }; }; diff --git a/app/layout.tsx b/app/layout.tsx index 2ec8277..668a2f2 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,5 +1,4 @@ import React, { ReactNode } from 'react'; -import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import type { Metadata, Viewport } from 'next'; import { cookies } from 'next/headers'; @@ -33,7 +32,6 @@ export default function RootLayout({ children }: { children: ReactNode }) {
{children}
- diff --git a/components/Header/index.tsx b/components/Header/index.tsx index 01ed70f..6bbeb68 100644 --- a/components/Header/index.tsx +++ b/components/Header/index.tsx @@ -8,7 +8,7 @@ import ToggleSearch from './components/Search'; import ToggleTheme from './components/ThemeToggle'; const Header: FC = () => ( -
+
diff --git a/components/Movie/Card.tsx b/components/Movie/Card.tsx index 5a22693..75db186 100644 --- a/components/Movie/Card.tsx +++ b/components/Movie/Card.tsx @@ -1,31 +1,48 @@ -import { FC, ReactNode } from 'react'; +import { FC } from 'react'; import { motion } from 'framer-motion'; +import useFavorites, { useFavoritesMutation } from '@/app/(site)/favorites/useFavorites'; import Poster from '@/components/Movie/components/Poster'; import Rating from '@/components/Movie/components/Rating'; import Title from '@/components/Movie/components/Title'; +import { cn } from '@/lib/utils'; interface Props { movie?: Movie; - className?: string; - children?: ReactNode; onClick?: () => void; + fit?: boolean; } -const Card: FC = ({ movie, className, children, onClick }) => { +const Card: FC = ({ movie, onClick, fit }) => { + const { add, remove } = useFavoritesMutation(); + const { map } = useFavorites(); + if (!movie) return null; + const isFavorite = map.has(movie.id); + + const handleToggleFavorite = () => (isFavorite ? remove(movie.id) : add(movie)); + return ( -
- - - {children} -
-
+
+ +
+
- + <Title key={movie.title} title={movie.title} /> {movie.release_date && ( <span className='flex justify-end text-lg font-semibold'> {new Date(movie.release_date).getFullYear()} @@ -34,11 +51,16 @@ const Card: FC<Props> = ({ movie, className, children, onClick }) => { </div> </div> </div> - </motion.div> - <div className='absolute left-0 bottom-0 w-full bg-gradient-to-t from-black to-transparent h-20 text-white p-3 pb-2 flex flex-col justify-end opacity-80'> - <Rating movie={movie} iconsFillColor='fill-white' /> + <div className='absolute left-0 bottom-0 w-full bg-gradient-to-t from-black to-transparent h-20 text-white p-3 pb-2 flex flex-col justify-end opacity-75'> + <Rating + isFavorite={isFavorite} + toggleFavorite={handleToggleFavorite} + rating={movie.vote_average} + iconsFillColor='fill-white' + /> + </div> </div> - </div> + </motion.div> ); }; diff --git a/components/Movie/List.tsx b/components/Movie/List.tsx index 2858524..52d381e 100644 --- a/components/Movie/List.tsx +++ b/components/Movie/List.tsx @@ -71,10 +71,10 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr <motion.li key={movie.id} variants={item} - className='flex basis-[300px] cursor-pointer' + className='flex cursor-pointer' ref={isAnchor ? (element) => setLoader(element!) : undefined} > - <Card movie={movie} className='grow flex flex-col' onClick={() => setMovie(movie)} /> + <Card fit movie={movie} onClick={() => setMovie(movie)} /> </motion.li> ); })} @@ -85,6 +85,7 @@ const List: FC<Props> = ({ pages, hasNextPage, fetchNextPage, withBottomGap = tr <Modal isOpen={Boolean(movie)} onClose={() => setMovie(null)} className='block p-0'> {movie && ( <Preview + fit key={movie.id} movie={movie} className='border-none' diff --git a/components/Movie/Preview/components/Actions.tsx b/components/Movie/Preview/components/Actions.tsx index 3c7e99a..c83dca9 100644 --- a/components/Movie/Preview/components/Actions.tsx +++ b/components/Movie/Preview/components/Actions.tsx @@ -5,6 +5,7 @@ import { useRouter } from 'next/navigation'; import { Button } from '@/components/ui/button'; import { showTorrentsModal } from '../../components/Torrents'; +import ToggleTrailer from '../../components/Trailer'; interface Props { movie: Movie; @@ -16,6 +17,13 @@ export default function Actions({ onClose, movie }: Props) { return ( <> + <ToggleTrailer movieId={movie?.id}> + {({ onPlay, disabled }) => ( + <Button className='h-8 flex-grow w-[50%]' onClick={onPlay} disabled={disabled}> + Trailer + </Button> + )} + </ToggleTrailer> <Button className='h-8 flex-grow w-[50%]' onClick={() => showTorrentsModal({ title: movie.title, year: new Date(movie.release_date).getFullYear() })} diff --git a/components/Movie/Preview/index.tsx b/components/Movie/Preview/index.tsx index fa9c76c..0f857cd 100644 --- a/components/Movie/Preview/index.tsx +++ b/components/Movie/Preview/index.tsx @@ -1,10 +1,8 @@ 'use client'; import { FC, ReactNode } from 'react'; -import { AnimatePresence, motion } from 'framer-motion'; import Credits from '@/components/Movie/components/Credits'; -import ToggleTrailer from '@/components/Movie/components/Trailer'; import { Separator } from '@/components/ui/separator'; import { cn } from '@/lib/utils'; @@ -13,62 +11,30 @@ import Card from '../Card'; import Actions from './components/Actions'; interface Props { + fit?: boolean; movie?: Movie; className?: string; - direction?: number; onClose?: () => void; children?: ReactNode; + renderCard?: () => ReactNode; } -const variants = { - enter: (direction: number) => ({ - scale: direction === 0 ? 1 : 0.8, - opacity: direction === 0 ? 1 : 0, - x: direction === 0 ? 0 : direction * 300 - }), - center: { x: 0, opacity: 1, y: 0, scale: 1 }, - exit: (direction: number) => ({ scale: 0.8, opacity: 1, x: direction * -300 }) -}; - -const Preview: FC<Props> = ({ movie, className, direction, onClose, children }) => { +const Preview: FC<Props> = ({ movie, className, onClose, children, renderCard, fit }) => { if (!movie) return null; return ( <div className={cn('rounded-xl text-card-foreground', { 'p-2': Boolean(onClose) }, className)}> <div className='flex flex-col lg:flex-row max-w-[100%] gap-2'> - <div className='max-w-[300px] min-w-[300px] h-[450px] mx-auto w-[100%] relative overflow-hidden rounded-lg'> - <AnimatePresence custom={direction}> - <motion.div - className='absolute' - initial='enter' - animate='center' - exit='exit' - key={movie?.id} - variants={variants} - custom={direction} - transition={{ type: 'tween' }} - > - <Card movie={movie} className='max-w-[300px] min-w-[300px] mx-auto w-full'> - <ToggleTrailer movieId={movie?.id} /> - </Card> - </motion.div> - </AnimatePresence> - </div> + {renderCard?.() || <Card fit={fit} movie={movie} />} <div className='flex flex-col grow'> - {children && <div className='flex w-full mb-2 gap-2'>{children}</div>} + {children && <div className='flex hover-none:hidden w-full mb-2 gap-2'>{children}</div>} <div className='flex w-full gap-2'> <Actions movie={movie} onClose={onClose} /> </div> <Separator className='my-2' /> - <motion.p - key={movie.id} - className='leading-7' - initial={{ opacity: 0 }} - animate={{ opacity: 1 }} - exit={{ opacity: 0 }} - > + <p key={movie.id} className='leading-7'> {movie.overview} - </motion.p> + </p> </div> </div> <Credits movieId={movie.id} onPersonClick={onClose} /> diff --git a/components/Movie/components/Credits/index.tsx b/components/Movie/components/Credits/index.tsx index f805250..86fb96d 100644 --- a/components/Movie/components/Credits/index.tsx +++ b/components/Movie/components/Credits/index.tsx @@ -36,7 +36,7 @@ const Credits: FC<Props> = ({ movieId, onPersonClick }) => { return ( Boolean(credits?.length) && ( - <div className='overflow-auto no-scrollbar max-w-[100%] py-2 pb-5 mb-[-0.75rem]'> + <div className='overflow-auto no-scrollbar max-w-[100%] py-2 mb-[-0.75rem]'> <motion.ul className='flex gap-3' variants={container} initial='hidden' animate='visible' whileInView='visible'> {credits?.map((actor) => ( <motion.li diff --git a/components/Movie/components/Poster/index.tsx b/components/Movie/components/Poster/index.tsx index dea1855..9c50cac 100644 --- a/components/Movie/components/Poster/index.tsx +++ b/components/Movie/components/Poster/index.tsx @@ -1,38 +1,29 @@ -import { FC, ReactNode } from 'react'; +import { FC } from 'react'; import { ImageOff } from 'lucide-react'; import Image from 'next/image'; +import { cn } from '@/lib/utils'; + interface Props { title: string; poster: string; - width: number; - height: number; size: number; className?: string; - children?: ReactNode; } -const Poster: FC<Props> = ({ title, poster, width, height, size = 250, className, children }) => { - return ( - <div - className={`w-full flex flex-col rounded-lg overflow-hidden shrink-0 lg:m-0 mx-auto relative ${className}`} - style={{ minHeight: poster ? '' : height }} - > - {poster ? ( - <Image - className='rounded-lg mx-auto w-auto' - unoptimized - height={height} - width={width} - src={`https://image.tmdb.org/t/p/w500/${poster}`} - alt={title} - /> - ) : ( - <div className={`h-[${height}px] w-full flex items-center justify-center rounded-lg border grow`}> - <ImageOff size={size} strokeWidth={1} /> - </div> - )} - {children} +const Poster: FC<Props> = ({ title, poster, size = 250, className }) => { + return poster ? ( + <Image + className={cn('rounded-lg mx-auto w-auto h-full object-fill', className)} + unoptimized + height={750} + width={500} + src={`https://image.tmdb.org/t/p/w500/${poster}`} + alt={title} + /> + ) : ( + <div className={'w-full flex items-center justify-center rounded-lg grow'}> + <ImageOff size={size} strokeWidth={1} color='hsl(215.4 16.3% 46.9%)' /> </div> ); }; diff --git a/components/Movie/components/Rating/index.tsx b/components/Movie/components/Rating/index.tsx index 8991c00..5c4dea2 100644 --- a/components/Movie/components/Rating/index.tsx +++ b/components/Movie/components/Rating/index.tsx @@ -2,26 +2,21 @@ import { FC } from 'react'; import { motion } from 'framer-motion'; import { Heart, Star } from 'lucide-react'; -import useFavorites, { useFavoritesMutation } from '@/app/(site)/favorites/useFavorites'; - interface Props { - movie: Movie; + isFavorite: boolean; + toggleFavorite: () => void; iconsFillColor?: string; + rating?: number; } -const Rating: FC<Props> = ({ movie, iconsFillColor = 'fill-accent-foreground' }) => { - const { map } = useFavorites(); - const { add, remove } = useFavoritesMutation(); - - const isFavorite = map.has(movie.id); - +const Rating: FC<Props> = ({ isFavorite, rating, toggleFavorite, iconsFillColor = 'fill-accent-foreground' }) => { return ( <span className='select-none flex w-full items-center ml-auto gap-1 mt-[-8px] justify-between'> <motion.span onTap={(event) => { event.stopPropagation(); - isFavorite ? remove(movie.id) : add(movie); + toggleFavorite(); }} className='z-[2] cursor-pointer' title={isFavorite ? 'Remove from favorites' : 'Add to favorite'} @@ -30,7 +25,7 @@ const Rating: FC<Props> = ({ movie, iconsFillColor = 'fill-accent-foreground' }) </motion.span> <span className='flex items-center'> <Star size={18} className={`mr-1 ${iconsFillColor}`} /> - <span className='font-semibold'>{movie.vote_average?.toFixed(1)}</span> + <span className='font-semibold'>{rating?.toFixed(1)}</span> </span> </span> ); diff --git a/components/Movie/components/Trailer/index.tsx b/components/Movie/components/Trailer/index.tsx index 5d42d7a..a79219f 100644 --- a/components/Movie/components/Trailer/index.tsx +++ b/components/Movie/components/Trailer/index.tsx @@ -1,6 +1,6 @@ 'use client'; -import { FC } from 'react'; +import { FC, ReactNode } from 'react'; import { create, InstanceProps } from 'react-modal-promise'; import { motion } from 'framer-motion'; import { Play } from 'lucide-react'; @@ -10,6 +10,7 @@ import { Modal } from '@/components/ui/dialog'; interface Props { movieId?: number; + children?: ({ onPlay, disabled }: { onPlay: () => void; disabled: boolean }) => ReactNode; } const Trailer: FC<{ trailerKey?: string } & InstanceProps<void>> = ({ trailerKey, onResolve, isOpen }) => { @@ -35,18 +36,18 @@ const Trailer: FC<{ trailerKey?: string } & InstanceProps<void>> = ({ trailerKey export const showTrailerModal = create(Trailer); -export default function ToggleTrailer({ movieId }: Props) { - const { data: trailer } = useTrailer({ movieId }); +export default function ToggleTrailer({ movieId, children }: Props) { + const { data: trailer, isFetched } = useTrailer({ movieId }); - return ( - trailer && ( - <motion.div - onTap={() => showTrailerModal({ trailerKey: trailer?.key })} - title='Play trailer' - className='absolute w-full h-full left-0 top-0 bg-black cursor-pointer overflow-hidden rounded-lg transition-opacity opacity-0 hover:opacity-70 flex items-center justify-center' - > - <Play size={100} className='fill-white' /> - </motion.div> - ) - ); + return children + ? children({ onPlay: () => showTrailerModal({ trailerKey: trailer?.key }), disabled: isFetched && !trailer }) + : trailer && ( + <motion.div + onTap={() => showTrailerModal({ trailerKey: trailer?.key })} + title='Play trailer' + className='absolute w-full h-full left-0 top-0 bg-black cursor-pointer overflow-hidden rounded-lg transition-opacity opacity-0 hover:opacity-70 flex items-center justify-center' + > + <Play size={100} className='fill-white' /> + </motion.div> + ); } diff --git a/package-lock.json b/package-lock.json index 1e45454..374f940 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,7 @@ "react-dom": "^18.2.0", "react-fast-marquee": "^1.6.0", "react-modal-promise": "^1.0.2", + "swiper": "^11.0.7", "tailwind-merge": "^1.14.0", "tailwindcss-animate": "^1.0.6", "typescript": "5.1.6", @@ -58,7 +59,8 @@ "eslint-plugin-simple-import-sort": "^10.0.0", "postcss": "^8.4.27", "prettier": "^3.0.0", - "tailwindcss": "^3.3.3" + "tailwindcss": "^3.3.3", + "tailwindcss-touch": "^1.0.1" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -6501,6 +6503,24 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/swiper": { + "version": "11.0.7", + "resolved": "https://registry.npmjs.org/swiper/-/swiper-11.0.7.tgz", + "integrity": "sha512-cDfglW1B6uSmB6eB6pNmzDTNLmZtu5bWWa1vak0RU7fOI9qHjMzl7gVBvYSl34b0RU2N11HxxETJqQ5LeqI1cA==", + "funding": [ + { + "type": "patreon", + "url": "https://www.patreon.com/swiperjs" + }, + { + "type": "open_collective", + "url": "http://opencollective.com/swiper" + } + ], + "engines": { + "node": ">= 4.7.0" + } + }, "node_modules/synckit": { "version": "0.8.5", "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.5.tgz", @@ -6569,6 +6589,12 @@ "tailwindcss": ">=3.0.0 || insiders" } }, + "node_modules/tailwindcss-touch": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tailwindcss-touch/-/tailwindcss-touch-1.0.1.tgz", + "integrity": "sha512-h8A/S9+Mk2rnnaOB/NGCE7CxDhtGKbsAWf8Y2tCO6Zf381Y8dKcygPl1OXkFDnWXkL+FfHxmrGpwculDWAumbA==", + "dev": true + }, "node_modules/tailwindcss/node_modules/postcss-js": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.1.tgz", @@ -11216,6 +11242,11 @@ "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" }, + "swiper": { + "version": "11.0.7", + "resolved": "https://registry.npmjs.org/swiper/-/swiper-11.0.7.tgz", + "integrity": "sha512-cDfglW1B6uSmB6eB6pNmzDTNLmZtu5bWWa1vak0RU7fOI9qHjMzl7gVBvYSl34b0RU2N11HxxETJqQ5LeqI1cA==" + }, "synckit": { "version": "0.8.5", "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.5.tgz", @@ -11275,6 +11306,12 @@ "integrity": "sha512-4WigSGMvbl3gCCact62ZvOngA+PRqhAn7si3TQ3/ZuPuQZcIEtVap+ENSXbzWhpojKB8CpvnIsrwBu8/RnHtuw==", "requires": {} }, + "tailwindcss-touch": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tailwindcss-touch/-/tailwindcss-touch-1.0.1.tgz", + "integrity": "sha512-h8A/S9+Mk2rnnaOB/NGCE7CxDhtGKbsAWf8Y2tCO6Zf381Y8dKcygPl1OXkFDnWXkL+FfHxmrGpwculDWAumbA==", + "dev": true + }, "tapable": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", diff --git a/package.json b/package.json index bf07b49..09a8318 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "react-dom": "^18.2.0", "react-fast-marquee": "^1.6.0", "react-modal-promise": "^1.0.2", + "swiper": "^11.0.7", "tailwind-merge": "^1.14.0", "tailwindcss-animate": "^1.0.6", "typescript": "5.1.6", @@ -59,6 +60,7 @@ "eslint-plugin-simple-import-sort": "^10.0.0", "postcss": "^8.4.27", "prettier": "^3.0.0", - "tailwindcss": "^3.3.3" + "tailwindcss": "^3.3.3", + "tailwindcss-touch": "^1.0.1" } } diff --git a/providers/index.tsx b/providers/index.tsx index 444ca0c..ca593b1 100644 --- a/providers/index.tsx +++ b/providers/index.tsx @@ -3,6 +3,7 @@ import { ReactNode, useState } from 'react'; import ModalContainer from 'react-modal-promise'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { queryClientOptions } from '@/lib/queryClient'; import ThemeProvider from '@/providers/Theme'; @@ -14,6 +15,7 @@ const Providers = ({ children, theme }: { children: ReactNode; theme?: Theme }) <QueryClientProvider client={queryClient}> <ThemeProvider theme={theme}>{children}</ThemeProvider> <ModalContainer /> + {/* <ReactQueryDevtools initialIsOpen={false} /> */} </QueryClientProvider> ); }; diff --git a/styles/index.css b/styles/index.css index f77d968..e307ae3 100644 --- a/styles/index.css +++ b/styles/index.css @@ -2,6 +2,10 @@ @tailwind components; @tailwind utilities; +@import url('~swiper/css'); +@import url('~swiper/css/effect-creative'); +@import url('~swiper/css/effect-coverflow'); + @layer utilities { .no-scrollbar::-webkit-scrollbar { display: none; diff --git a/tailwind.config.js b/tailwind.config.js index 3ae75ce..dc88486 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -11,6 +11,9 @@ module.exports = { } }, extend: { + screens: { + xs: '400px' + }, colors: { border: 'hsl(var(--border))', input: 'hsl(var(--input))', @@ -70,5 +73,5 @@ module.exports = { corePlugins: { aspectRatio: false }, - plugins: [require('tailwindcss-animate'), require('@tailwindcss/aspect-ratio')] + plugins: [require('tailwindcss-animate'), require('@tailwindcss/aspect-ratio'), require('tailwindcss-touch')()] };