diff --git a/src/pages/Home/Carousel.jsx b/src/pages/Home/Carousel.jsx new file mode 100644 index 0000000..8f85eda --- /dev/null +++ b/src/pages/Home/Carousel.jsx @@ -0,0 +1,161 @@ +import { styled } from 'styled-components'; +import Slider from 'react-slick'; +import 'slick-carousel/slick/slick.css'; +import 'slick-carousel/slick/slick-theme.css'; +// import { useState } from 'react'; + +function Carousel() { + const settings = { + infinite: true, // loop를 만들지(마지막 이미지-처음 이미지-중간 이미지들-마지막 이미지) + speed: 300, // 애미메이션의 속도, 단위는 milliseconds + slidesToShow: 1, // 한번에 몇개의 슬라이드를 보여줄 지 + slidesToScroll: 1, // 한번 스크롤시 몇장의 슬라이드를 넘길지 + dots: true, + arrows: true, + pauseOnHover: true, + draggable: true + // 캐러셀이미지가 몇번째인지 알려주는 점을 보여줄지 정한다. + // dotsClass: 'custom_paging', + // customPaging: function (slider, i) { + // const thumb = slider.$slides[i].data(); + // return '' + i + ''; + // } + // centerPadding: '0px' // 0px 하면 슬라이드 끝쪽 이미지가 안잘림 + // beforeChange: (_current, next) => { + // changeCarouselImage(items[next].imageUrl[1]); + // setImg(next); + // }, + // autoplay: true, + // autoplaySpeed: 3000, //자동으로 슬라이드되게 만들어준다. + }; + return ( +
+ +
+

1

+
+
+

2

+
+
+

3

+
+
+

4

+
+
+

5

+
+
+

6

+
+
+
+ ); +} + +const StyledSlider = styled(Slider)` + width: 1920px; + height: 400px; + + .slick-slide { + background-color: #eaf8ff; + width: 100%; + height: 430px; + z-index: 1; + border-bottom: 1px solid lightgray; + } + + .slick-prev { + background-color: black; + opacity: 0.35; + width: 38.5px; + height: 30px; + top: 90%; + left: 90%; + z-index: 1; + padding-top: 2px; + border-radius: 50% 0% 0% 50%; + } + + .slick-next { + background-color: black; + opacity: 0.35; + width: 38px; + height: 30px; + top: 90%; + right: 6%; + z-index: 1; + padding-top: 2px; + border-radius: 0% 50% 50% 0%; + } + + .slick-prev:before, + .slick-next:before { + font-family: 'Font Awesome Free'; + font-size: 36px; + color: #ffffff; + } + + .slides .slick-prev, + .slides .slick-next { + position: absolute; + } + + .slick-dots { + // 점 스타일 관련 코드 + } +`; + +export default Carousel; + +// const [oldSlide, setOldSlide] = useState(0); +// const [activeSlide, setActiveSlide] = useState(0); +// const [activeSlide2, setActiveSlide2] = useState(0); + +// const settings = { +// dots: true, +// infinite: true, +// speed: 1000, +// slidesToShow: 1, +// slidesToScroll: 1, +// beforeChange: (current, next) => { +// setOldSlide(current); +// setActiveSlide(next); +// }, +// afterChange: (current) => setActiveSlide2(current) +// }; +// return ( +//
+//

beforeChange and afterChange hooks

+//

+// BeforeChange {'=>'} oldSlide: {oldSlide} +//

+//

+// BeforeChange {'=>'} activeSlide: {activeSlide} +//

+//

+// AfterChange {'=>'} activeSlide: {activeSlide2} +//

+// +//
+//

1

+//
+//
+//

2

+//
+//
+//

3

+//
+//
+//

4

+//
+//
+//

5

+//
+//
+//

6

+//
+//
+//
+// ); diff --git a/src/pages/Home/Home.jsx b/src/pages/Home/Home.jsx index 81f5795..c6d81bb 100644 --- a/src/pages/Home/Home.jsx +++ b/src/pages/Home/Home.jsx @@ -1,6 +1,7 @@ import { styled } from 'styled-components'; import Header from 'components/Header/Header'; import Footer from 'components/Footer/Footer'; +import Carousel from './Carousel'; import MainImg from 'asset/HomePhoto.png'; function Home() { @@ -8,32 +9,23 @@ function Home() {
- - MainImg - MainImg - {/*
오늘의 브랜드
+ + MainImg + + {/*
오늘의 브랜드
최근 본 상품과 함께 볼만한 상품
타임딜
*/} -
); } -const Wrap = styled.div` - min-height: 600px; - /* display: flex; */ -`; - const Content = styled.div` display: flex; - justify-content: center; + flex-direction: column; align-items: center; - width: 100%; - height: auto; - min-height: 100%; - padding-bottom: 100px; + justify-content: center; `; export default Home;