Add random background color to product page

This commit is contained in:
Daniele Pancottini
2023-03-01 11:38:02 +01:00
parent 35ef0b0f8f
commit ab0f1a6e6d
5 changed files with 51 additions and 27 deletions

View File

@@ -29,7 +29,6 @@
.album {
width: 100%;
height: 100%;
@apply bg-violet-dark;
box-sizing: content-box;
overflow-y: hidden;
overflow-x: auto;

View File

@@ -10,15 +10,20 @@ import cn from 'clsx'
import { a } from '@react-spring/web'
import s from './ProductSlider.module.css'
import ProductSliderControl from '../ProductSliderControl'
import random from 'lodash.random'
interface ProductSliderProps {
children?: React.ReactNode[]
className?: string
className?: string,
lighterColor: string,
darkerColor: string
}
const ProductSlider: React.FC<ProductSliderProps> = ({
children,
className = '',
lighterColor,
darkerColor
}) => {
const [currentSlide, setCurrentSlide] = useState(0)
const [isMounted, setIsMounted] = useState(false)
@@ -81,9 +86,10 @@ const ProductSlider: React.FC<ProductSliderProps> = ({
<div className={cn(s.root, className)} ref={sliderContainerRef}>
<div
ref={ref}
style={{backgroundColor: lighterColor}}
className={cn(s.slider, { [s.show]: isMounted }, 'keen-slider')}
>
{slider && <ProductSliderControl onPrev={onPrev} onNext={onNext} />}
{slider && <ProductSliderControl lighterColor={lighterColor} darkerColor={darkerColor} onPrev={onPrev} onNext={onNext} />}
{Children.map(children, (child) => {
// Add the keen-slider__slide className to children
if (isValidElement(child)) {
@@ -101,7 +107,7 @@ const ProductSlider: React.FC<ProductSliderProps> = ({
})}
</div>
<a.div className={s.album} ref={thumbsContainerRef}>
<a.div style={{backgroundColor: darkerColor}} className={s.album} ref={thumbsContainerRef}>
{slider &&
Children.map(children, (child, idx) => {
if (isValidElement(child)) {