-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add language select carousel, button animations
- Loading branch information
1 parent
3c34081
commit 5fb4c78
Showing
35 changed files
with
864 additions
and
205 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
37 changes: 37 additions & 0 deletions
37
src/modules/shared/components/icons/pinkButtonIcon/PinkButtonIcon.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
export * from "./PinkButtonIcon"; |
64 changes: 64 additions & 0 deletions
64
src/modules/shared/components/icons/playBubbleIcon/PlayBubbleIcon.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
export * from "./PlayBubbleIcon"; |
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
3 changes: 3 additions & 0 deletions
3
src/modules/story/components/baseCarousel/BaseCarousel.module.scss
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,3 @@ | ||
.carousel-container { | ||
width: 100%; | ||
} |
86 changes: 86 additions & 0 deletions
86
src/modules/story/components/baseCarousel/BaseCarousel.tsx
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,86 @@ | ||
import React, { FC } from "react"; | ||
import Carousel from "react-multi-carousel"; | ||
import cx from "classnames/bind"; | ||
import styles from "./BaseCarousel.module.scss"; | ||
|
||
const cxBind = cx.bind(styles); | ||
|
||
interface IBaseCarouselProps { | ||
children: React.ReactNode; | ||
className?: string; | ||
onSlideChange: (currentItemIndex: number) => void; | ||
dataLength: number; | ||
} | ||
|
||
export const BaseCarousel: FC<IBaseCarouselProps> = ({ | ||
children, | ||
className, | ||
onSlideChange, | ||
dataLength, | ||
}) => { | ||
const responsive = { | ||
superLargeDesktop: { | ||
breakpoint: { max: 4000, min: 3000 }, | ||
items: 1, | ||
}, | ||
desktop: { | ||
breakpoint: { max: 3000, min: 1024 }, | ||
items: 1, | ||
}, | ||
tablet: { | ||
breakpoint: { max: 1024, min: 464 }, | ||
items: 1, | ||
}, | ||
mobile: { | ||
breakpoint: { max: 464, min: 0 }, | ||
items: 1, | ||
}, | ||
}; | ||
|
||
const beforeSlideChange = (prev: number, curr: number) => { | ||
const itemIndex = ( | ||
document.querySelector(".react-multi-carousel-item--active") | ||
?.firstChild as HTMLElement | ||
).dataset.index; | ||
|
||
console.log(document.querySelector(".react-multi-carousel-item--active")); | ||
|
||
if (prev > curr) { | ||
Number(itemIndex) === dataLength - 1 | ||
? onSlideChange(0) | ||
: onSlideChange(Number(itemIndex) + 1); | ||
} else { | ||
Number(itemIndex) === 0 | ||
? onSlideChange(dataLength - 1) | ||
: onSlideChange(Number(itemIndex) - 1); | ||
} | ||
}; | ||
|
||
return ( | ||
<Carousel | ||
autoPlaySpeed={3000} | ||
infinite | ||
centerMode | ||
containerClass={cxBind("carousel-container", className)} | ||
focusOnSelect={true} | ||
itemClass={cxBind("carousel-item")} | ||
keyBoardControl | ||
minimumTouchDrag={80} | ||
pauseOnHover | ||
responsive={responsive} | ||
rewindWithAnimation={true} | ||
shouldResetAutoplay | ||
showDots={false} | ||
slidesToSlide={1} | ||
draggable | ||
swipeable | ||
transitionDuration={1000} | ||
// afterChange={() => onSlideChange && onSlideChange()} | ||
beforeChange={(previousSlide, { currentSlide }) => | ||
beforeSlideChange(previousSlide, currentSlide) | ||
} | ||
> | ||
{children} | ||
</Carousel> | ||
); | ||
}; |
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 @@ | ||
export * from "./BaseCarousel"; |
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,3 +1,6 @@ | ||
export * from "./lottieAnimation"; | ||
export * from "./animationController"; | ||
export * from "./sceneSelect"; | ||
export * from "./modal"; | ||
export * from "./baseCarousel"; | ||
export * from "./languageSelect"; |
53 changes: 53 additions & 0 deletions
53
src/modules/story/components/languageSelect/LanguageSelect.module.scss
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,53 @@ | ||
@import "../../../../styles/globals"; | ||
|
||
.language-select-container { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
.modal { | ||
justify-content: flex-end; | ||
} | ||
|
||
.language-container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
|
||
img { | ||
height: 30rem; | ||
} | ||
} | ||
|
||
.icon-container { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
width: 4rem; | ||
height: 4rem; | ||
} | ||
|
||
.carousel-container { | ||
position: absolute; | ||
bottom: -4rem; | ||
} | ||
|
||
.image-container { | ||
position: absolute; | ||
bottom: -4rem; | ||
right: -0.5rem; | ||
height: 8rem; | ||
transform: rotate(-10deg); | ||
|
||
img { | ||
height: 100%; | ||
} | ||
} | ||
|
||
.icon-container { | ||
position: absolute; | ||
left: -2rem; | ||
top: 4rem; | ||
cursor: pointer; | ||
} |
105 changes: 105 additions & 0 deletions
105
src/modules/story/components/languageSelect/LanguageSelect.tsx
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,105 @@ | ||
import { FC, useEffect, useState } from "react"; | ||
import { | ||
IconButton, | ||
PinkButtonIcon, | ||
PlayBubbleIcon, | ||
} from "../../../shared/components"; | ||
import { BaseCarousel } from "../baseCarousel"; | ||
import { Modal } from "../modal"; | ||
import cx from "classnames/bind"; | ||
import styles from "./LanguageSelect.module.scss"; | ||
import { ELanguage, ILanguage } from "../../types"; | ||
|
||
const cxBind = cx.bind(styles); | ||
|
||
interface ILanguageSelectProps { | ||
languages: ILanguage[]; | ||
onSelectLanguage: (languageId: ELanguage) => void; | ||
currentLanguageId: ELanguage; | ||
className?: string; | ||
} | ||
|
||
export const LanguageSelect: FC<ILanguageSelectProps> = ({ | ||
currentLanguageId, | ||
languages, | ||
onSelectLanguage, | ||
className, | ||
}) => { | ||
const [popupIsOpen, setPopupIsOpen] = useState<boolean>(false); | ||
const currenLanguage = languages.find( | ||
(language) => language.id === currentLanguageId | ||
); | ||
const [currentLanguageIndex, setCurrentLanguageIndex] = useState<number>(0); | ||
|
||
const onSelect = (lngId: ELanguage) => { | ||
onSelectLanguage(lngId); | ||
setPopupIsOpen(false); | ||
}; | ||
|
||
useEffect(() => { | ||
console.log(currentLanguageIndex); | ||
}, [currentLanguageIndex]); | ||
|
||
return ( | ||
<> | ||
<div | ||
className={cxBind("language-select-container", className)} | ||
onClick={() => setPopupIsOpen(!popupIsOpen)} | ||
> | ||
<IconButton icon={<PinkButtonIcon />} /> | ||
|
||
<div className={cxBind("image-container")}> | ||
<img src={currenLanguage?.asset} alt={currenLanguage?.name} /> | ||
</div> | ||
</div> | ||
|
||
<Modal | ||
isOpen={popupIsOpen} | ||
onClose={() => setPopupIsOpen(false)} | ||
className={cxBind("modal")} | ||
> | ||
<BaseCarousel | ||
className={cxBind("carousel-container")} | ||
onSlideChange={setCurrentLanguageIndex} | ||
dataLength={languages.length} | ||
> | ||
{languages.map((language, index) => ( | ||
<div | ||
className={cxBind("language-container")} | ||
key={`language-option-${index}`} | ||
data-index={index} | ||
> | ||
<h2>{language.name}</h2> | ||
<img src={language.asset} alt={language.name} /> | ||
|
||
{index === currentLanguageIndex && ( | ||
<div | ||
className={`react-multi-carousel-item-button ${cxBind( | ||
"icon-container" | ||
)}`} | ||
onClick={() => onSelect(language.id)} | ||
> | ||
<PlayBubbleIcon /> | ||
</div> | ||
)} | ||
</div> | ||
))} | ||
{/* {scenes.map((scene, index) => ( | ||
<div className={cxBind("scene")} key={index}> | ||
<div | ||
className={cxBind("icon-container")} | ||
onClick={() => onSelect(index)} | ||
></div> | ||
<div className={cxBind("scene-thumbnail-container")}> | ||
<img src={scene.thumbnail} alt={scene.name} /> | ||
</div> | ||
<div className={cxBind("scene-index")}>{index + 1}</div> | ||
</div> | ||
))} */} | ||
</BaseCarousel> | ||
</Modal> | ||
</> | ||
); | ||
}; |
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 @@ | ||
export * from "./LanguageSelect"; |
12 changes: 12 additions & 0 deletions
12
src/modules/story/components/lottieAnimation/LottieAnimation.module.scss
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,12 @@ | ||
.animation { | ||
z-index: z-index; | ||
position: "absolute"; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
|
||
svg { | ||
max-width: 100%; | ||
} | ||
} |
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
Oops, something went wrong.