Рабочая версия (точки отключены)

This commit is contained in:
ifraimka1 committed 2024-02-21 12:42:44 +03:00
1 parent 1a4f0160e8
commit 26b6fefff9
11 files changed
+123 -13

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
{
"configurations": [
{
"type": "chrome",
"name": "http://localhost:3000/",
"request": "launch",
"url": "http://localhost:3000/"
}
]
}
+6 -7
View File
@@ -4,19 +4,18 @@ import Arrows from './components/Arrows';
import SlidesList from './components/SlidesList';
import Dots from './components/Dots';
//import { getSliderImages } from '../../api';
import { g1, g2, g3 } from '../../images/gallery';
import { getSliderImages } from '../../api';
import './Slider.styles.scss';
export const SliderContext = createContext();
function Slider({ autoPlay = 1, autoPlayTime = 1 }) {
function Slider({ autoPlay = 0, autoPlayTime = 0 }) {
const [items, setItems] = useState([]);
const [slide, setSlide] = useState(0);
useEffect(() => {
const loadData = () => {
const images = [g1, g2, g3];
const loadData = async () => {
const images = await getSliderImages();
setItems(images);
};
loadData();
@@ -32,7 +31,7 @@ function Slider({ autoPlay = 1, autoPlayTime = 1 }) {
}
setSlide(slideNumber);
}
};
const goToSlide = (number) => {
setSlide(number % items.length);
@@ -63,7 +62,7 @@ function Slider({ autoPlay = 1, autoPlayTime = 1 }) {
>
<Arrows />
<SlidesList />
<Dots />
{/* <Dots /> */}
</SliderContext.Provider>
</div>
);
+30
View File
@@ -0,0 +1,30 @@
.slider {
overflow: hidden;
position: relative;
& .slide-list {
display: flex;
height: 100%;
transition: transform 0.5s ease-in-out;
width: 100%;
& .slide {
flex: 1 0 100%;
position: relative;
& .slide-image {
display: flex;
width: 80%;
margin: 0 auto;
border-radius: 8px;
object-fit: contain;
}
& .slide-title {
text-align: center;
margin-top: 10px;
}
}
}
}
+9 -2
View File
@@ -1,13 +1,20 @@
import React, { useContext } from "react";
import { SliderContext } from "../Slider";
import { arrow } from '../../../images';
import './Arrows.styles.scss';
function Arrows() {
const { changeSlide } = useContext(SliderContext);
return (
<div className="arrows">
<div className="arrow left" onClick={() => changeSlide(-1)} />
<div className="arrow right" onClick={() => changeSlide(1)} />
<div className="arrow left" onClick={() => changeSlide(-1)}>
<img src={ arrow } alt="" />
</div>
<div className="arrow right" onClick={() => changeSlide(1)}>
<img src={ arrow } alt="" />
</div>
</div>
);
}
@@ -0,0 +1,36 @@
.arrows {
position: absolute;
z-index: 1;
display: flex;
justify-content: space-between;
align-items: center;
height: 100%;
width: calc(100% - 10% + 60px);
left: calc(5% - 30px);
margin: 0 auto;
color: white;
.arrow {
display: flex;
justify-content: center;
align-items: center;
height: 60px;
width: 60px;
padding-right: 5px;
border-radius: 100%;
background: #D9D9D9;
font-size: 30px;
box-sizing: border-box;
&:hover {
cursor: pointer;
}
&.right {
transform: rotateY(180deg);
}
}
}
+5 -2
View File
@@ -1,7 +1,8 @@
import React, { useContext } from "react";
import { useContext } from "react";
import { SliderContext } from "../Slider";
export default function Dot({ number }) {
function Dot({ number }) {
const { goToSlide, slideNumber } = useContext(SliderContext);
return (
@@ -11,3 +12,5 @@ export default function Dot({ number }) {
/>
);
}
export default Dot;
+5 -2
View File
@@ -1,8 +1,9 @@
import React, { useContext } from "react";
import { useContext } from "react";
import { SliderContext } from "../Slider";
import Dot from "./Dots";
export default function Dots() {
function Dots() {
const { slidesCount } = useContext(SliderContext);
const renderDots = () => {
@@ -16,3 +17,5 @@ export default function Dots() {
return <div className="dots">{renderDots()}</div>;
}
export default Dots;
+3
View File
@@ -0,0 +1,3 @@
<svg width="10" height="20" viewBox="0 0 10 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.46666 7.17325L7.58665 1.05325C7.83647 0.804916 8.17441 0.665527 8.52666 0.665527C8.8789 0.665527 9.21684 0.804916 9.46666 1.05325C9.59163 1.1772 9.69082 1.32467 9.75851 1.48715C9.8262 1.64963 9.86105 1.8239 9.86105 1.99992C9.86105 2.17593 9.8262 2.35021 9.75851 2.51269C9.69082 2.67517 9.59163 2.82263 9.46666 2.94658L3.33332 9.05325C3.20835 9.1772 3.10916 9.32467 3.04147 9.48715C2.97378 9.64963 2.93892 9.8239 2.93892 9.99992C2.93892 10.1759 2.97378 10.3502 3.04147 10.5127C3.10916 10.6752 3.20835 10.8226 3.33332 10.9466L9.46666 17.0533C9.71773 17.3026 9.85948 17.6414 9.86073 17.9952C9.86198 18.349 9.72262 18.6888 9.47332 18.9399C9.22402 19.191 8.88519 19.3327 8.53137 19.334C8.17755 19.3352 7.83773 19.1959 7.58665 18.9466L1.46666 12.8266C0.717587 12.0766 0.296841 11.0599 0.296841 9.99992C0.296841 8.93992 0.717587 7.92325 1.46666 7.17325Z" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 977 B

+1
View File
@@ -2,3 +2,4 @@ export { default as car } from './car.jpeg';
export { default as newsMock } from './newsMock.png';
export { default as scb } from './scb.svg';
export { default as fileUpload } from './fileUpload.svg';
export { default as arrow } from './arrow.svg';
@@ -1,5 +1,7 @@
import Slider from '../../../../components/Slider';
import './Gallery.styles.scss';
function Gallery() {
return (
<div className="block gallery">
@@ -0,0 +1,16 @@
#page .content .gallery {
margin-left: 0;
margin-right: 0;
h1 {
width: 80%;
margin-left: auto;
margin-right: auto;
font-size: 28px;
font-weight: 400;
line-height: 35px;
letter-spacing: 0em;
text-align: center;
}
}