-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,001 additions
and
866 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { aspectRatioClasses } from '../../utils/propClasses' | ||
import { useLinkContext } from '../LinkProvider/useLinkContext' | ||
|
||
type aspectRatioKeys = keyof typeof aspectRatioClasses | ||
|
||
export interface ImageProps { | ||
imageUrl: string | ||
focalPointX?: number | ||
focalPointY?: number | ||
title?: string | ||
link?: string | ||
aspectRatio?: aspectRatioKeys | ||
} | ||
|
||
export const Image = ({ | ||
imageUrl, | ||
focalPointX = 50, | ||
focalPointY = 50, | ||
title, | ||
link, | ||
aspectRatio = 'landscape', | ||
}: ImageProps) => { | ||
const LinkComponent = useLinkContext() | ||
const inlineImageStyles = { | ||
backgroundImage: `url(${imageUrl})`, | ||
backgroundPosition: `${focalPointX}% ${focalPointY}%`, | ||
} | ||
|
||
return ( | ||
<div | ||
className={`relative ${aspectRatioClasses[aspectRatio]} bg-cover bg-center rounded-lg bg-black w-full h-full transition-[width] duration-[5000] ease-in-out`} | ||
style={inlineImageStyles} | ||
> | ||
{title && ( | ||
<div | ||
className={`bg-black/75 text-white absolute bottom-2 left-2 right-2 px-4 py-2.5 rounded-md ${link ? 'hover:bg-cu-red/85' : ''}`} | ||
> | ||
{link ? ( | ||
<LinkComponent href={link} className="cursor-pointer block hover-bg-cu-red"> | ||
<p className="text-sm md:text-base font-semibold line-clamp-2">{title}</p> | ||
</LinkComponent> | ||
) : ( | ||
<p className="text-sm md:text-base font-semibold line-clamp-2">{title}</p> | ||
)} | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,58 @@ | ||
import { useEffect } from 'react' | ||
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/solid' | ||
import { ImageSliderItem } from './ImageSliderItem' | ||
import SwiperSlider from './script' | ||
import { Slide } from './Slide' | ||
import { Image } from './Image' | ||
import SliderScript from './script.ts' | ||
|
||
export interface ImageSliderProp { | ||
children: React.ReactNode | ||
loop?: boolean | ||
speed?: number | ||
slidesPerViewMobile?: number | ||
slidesPerViewTablet?: number | ||
slidesPerViewDesktop: number | ||
customClass?: string | ||
slidesPerViewTablet?: number | ||
slidesPerViewMobile?: number | ||
} | ||
|
||
export const ImageSliderWrapper = ({ | ||
children, | ||
loop = false, | ||
speed = 500, | ||
slidesPerViewMobile = 1, | ||
slidesPerViewTablet = 2, | ||
slidesPerViewDesktop = 3, | ||
customClass, | ||
slidesPerViewDesktop, | ||
slidesPerViewTablet, | ||
slidesPerViewMobile, | ||
}: ImageSliderProp) => { | ||
useEffect(() => { | ||
SwiperSlider() | ||
}, []) | ||
SliderScript() | ||
}) | ||
|
||
const arrowButtons = `bg-cu-black-50 text-cu-black-800 hover:bg-cu-red hover:text-white hover:bg-cu-red relative flex items-center justify-center rounded-md h-8 w-8 z-50` | ||
const arrowIcons = `w-5 h-5 [&>path]:stroke-[2]` | ||
|
||
return ( | ||
<div | ||
className={`swiper swiper--slider ${customClass ? customClass : ''}`} | ||
data-swiper-class={`${customClass ? customClass : 'swiper'}`} | ||
data-swiper-loop={loop} | ||
data-swiper-speed={speed} | ||
data-swiper-perview-mobile={slidesPerViewMobile} | ||
data-swiper-perview-tablet={slidesPerViewTablet} | ||
data-swiper-perview-desktop={slidesPerViewDesktop} | ||
className="slider overflow-hidden" | ||
data-slides-desktop={slidesPerViewDesktop} | ||
data-slides-tablet={slidesPerViewTablet} | ||
data-slides-mobile={slidesPerViewMobile} | ||
> | ||
<div className="swiper-wrapper">{children}</div> | ||
<div className="swiper__footer"> | ||
<button type="button" className="swiper__button swiper__button--prev" aria-label="Previous slide"> | ||
<ChevronLeftIcon className="w-8 h-8 [&>path]:stroke-[2]" aria-hidden="true" /> | ||
{/* Slider Slides */} | ||
<div className="slider__wrap flex align-items-center">{children}</div> | ||
|
||
{/* Slider Arrow */} | ||
<div className="flex align-items-center gap-3 justify-center mt-4"> | ||
<button className={`slider__arrow slider__arrow--prev ${arrowButtons}`}> | ||
<span className="sr-only">Go to Previous Slide</span> | ||
<ChevronLeftIcon className={arrowIcons} aria-hidden="true" /> | ||
</button> | ||
<button type="button" className="swiper__button swiper__button--next" aria-label="Next slide"> | ||
<ChevronRightIcon className="w-8 h-8 [&>path]:stroke-[2]" aria-hidden="true" /> | ||
|
||
<button className={`slider__arrow slider__arrow--next ${arrowButtons}`}> | ||
<span className="sr-only">Go to Next Slide</span> | ||
<ChevronRightIcon className={arrowIcons} aria-hidden="true" /> | ||
</button> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export const ImageSlider = Object.assign(ImageSliderWrapper, { | ||
Item: ImageSliderItem, | ||
Slide: Slide, | ||
Image: Image, | ||
}) | ||
|
||
ImageSliderWrapper.displayName = 'ImageSlider' |
Oops, something went wrong.