Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
66 changes: 65 additions & 1 deletion src/components/Carousel.css
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
/* write down the css for Carousel in this file */
/* write down the css for Carousel in this file */
.App {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: grey;
}

body {
margin: 0;
padding: 0;
}
.mainContainer{
display: flex;
justify-content: center;
align-items: center;
position: relative;
background-color: rgba(0, 0, 0, 0.651);
padding: 10px;
}

.imageBox{
width: 600px;
height: 600px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.imageContainer{
position: absolute;
height:600px ;
width: 600px;
overflow: hidden;
}
.titleBox, .subTitleBox{
display: flex;
align-items: center;
justify-content: center;
background-color: white;
opacity: 0.7;
border-radius: 10px;
}
.titleBox{
width: 50%;
margin-left: 25%;
margin-top: 15%;
font-weight: 900;
font-size: 20px;
}
.subTitleBox{
width: 80%;
margin-left: 12%;
margin-top: 50%;
font-weight: 800;
}


.arrow{
cursor: pointer;
filter: invert();
}
34 changes: 32 additions & 2 deletions src/components/Carousel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,41 @@ import "./Carousel.css";
import { images } from "../data/CarouselData";

// you can research - how to use material ui
import ArrowBackIosIcon from '@mui/icons-material/ArrowBackIos'
import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos";
import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";

// complete the function below:
function Carousel() {
const [currindex, setcurrIndex] = useState(0);
function handlePrev() {
setcurrIndex(currindex > 0 ? currindex - 1 : images.length - 1);
}
function handleNext() {
setcurrIndex(currindex < images.length - 1 ? currindex + 1 : 0);
}
return (
<>
<div className="mainContainer">
<div className="arrow" onClick={handlePrev}>
<ArrowBackIosIcon />
</div>
<div className="imageBox">
<img src={images[currindex].img} />
</div>
<div className="imageContainer">
<div className="titleBox">
<p>{images[currindex].title}</p>
</div>
<div className="subTitleBox">
<p>{images[currindex].subtitle}</p>
</div>
</div>
<div className="arrow" onClick={handleNext}>
<ArrowForwardIosIcon />
</div>
</div>
</>
);
}

export default Carousel;
export default Carousel;