This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fasih: optimised carousel and auto typing (#5274)
* chore: optimized carousel and auto typing * fix: fix images issues * fix: updated formate and removed one breakpoint * chore: removed breakpoint prop * chore: updated state name * chore: replaced auto with png --------- Co-authored-by: Fasih Ali <[email protected]> Co-authored-by: Fasih Ali <[email protected]>
- Loading branch information
1 parent
10ef6f0
commit edc4848
Showing
8 changed files
with
144 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { useState, useEffect, ReactElement } from 'react' | ||
import * as styles from './slide-show.module.scss' | ||
import dclsx from 'features/utils/dclsx' | ||
|
||
type SlideshowItemProps = { | ||
key: string | ||
image: ReactElement | ||
} | ||
type SlideshowItemArrayProps = { | ||
items: SlideshowItemProps[] | ||
} | ||
|
||
const Slideshow = ({ items }: SlideshowItemArrayProps) => { | ||
const [current_image_index, setCurrentImageIndex] = useState(0) | ||
|
||
useEffect(() => { | ||
const intervalId = setInterval(() => { | ||
setCurrentImageIndex((prevIndex) => (prevIndex + 1) % items.length) | ||
}, 2500) // Adjust the interval between slides here (in milliseconds) | ||
|
||
return () => { | ||
clearInterval(intervalId) | ||
} | ||
}, [items.length]) | ||
|
||
return ( | ||
<div className={dclsx(styles.slideshow)}> | ||
{items.map((item, index) => ( | ||
<div | ||
className={dclsx( | ||
styles.slide, | ||
` ${index === current_image_index ? styles.fadeIn : styles.fadeOut}`, | ||
)} | ||
key={item.key} | ||
> | ||
{item.image} | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export default Slideshow |
23 changes: 23 additions & 0 deletions
23
src/features/components/molecules/slide-show/slide-show.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,23 @@ | ||
.slideshow { | ||
position: relative; | ||
width: 100vh; | ||
height: 100vw; | ||
overflow: hidden; | ||
} | ||
|
||
.slide { | ||
position: absolute; | ||
bottom: 0; | ||
right: 0; | ||
width: 100%; | ||
opacity: 0; | ||
transition: opacity 1s ease-in-out; | ||
|
||
&.fadeIn { | ||
opacity: 1; | ||
} | ||
|
||
&.fadeOut { | ||
opacity: 0; | ||
} | ||
} |
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
44 changes: 21 additions & 23 deletions
44
src/features/pages/home/hero/content/hero-features.carousel.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
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
Oops, something went wrong.
edc4848
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
deriv-com – ./
deriv-com-git-master.binary.sx
deriv-com.binary.sx