Skip to content

Commit 8d1fc6f

Browse files
Lisofffaalsakhaev
authored andcommitted
feat: added new examples
1 parent 7ca0e04 commit 8d1fc6f

File tree

4 files changed

+190
-3
lines changed

4 files changed

+190
-3
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
.wrapper {
2+
padding: 0 1.25rem;
3+
width: 100%;
4+
display: flex;
5+
flex-direction: column;
6+
max-width: 75rem;
7+
margin: 8.5rem auto 0;
8+
}
9+
10+
.title {
11+
font-size: var(--fs-24-48);
12+
font-weight: 600;
13+
line-height: 1;
14+
display: flex;
15+
}
16+
17+
.examplesContainer {
18+
display: flex;
19+
flex-direction: column;
20+
gap: 5rem;
21+
margin-top: 2.5rem;
22+
}
23+
24+
.exampleBlock {
25+
display: flex;
26+
align-items: center;
27+
gap: 3.75rem;
28+
29+
&.reverse {
30+
flex-direction: row-reverse;
31+
}
32+
}
33+
34+
.imageContainer {
35+
flex: 1;
36+
min-width: 0;
37+
will-change: transform, opacity;
38+
transform: translateY(1.25rem);
39+
opacity: 0;
40+
}
41+
42+
.exampleImage {
43+
width: 100%;
44+
height: auto;
45+
border-radius: .625rem;
46+
transition: none;
47+
}
48+
49+
.content {
50+
flex: 1;
51+
min-width: 0;
52+
}
53+
54+
.exampleTitle {
55+
font-size: var(--fs-18-24);
56+
font-weight: 600;
57+
}
58+
59+
.exampleDescription {
60+
display: block;
61+
margin-top: 1.25rem;
62+
font-size: var(--fs-14-16);
63+
line-height: 1.49;
64+
}
65+
66+
// Мобильная версия
67+
@media (max-width: 768px) {
68+
.wrapper {
69+
margin-top: 4rem;
70+
}
71+
72+
.examplesContainer {
73+
gap: 1.25rem;
74+
}
75+
76+
.exampleBlock {
77+
flex-direction: column;
78+
gap: 1.25rem;
79+
80+
&.reverse {
81+
flex-direction: column;
82+
}
83+
}
84+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
'use client';
2+
3+
import React, { useRef, useEffect } from 'react';
4+
import styles from './ExamplesFirstSection.module.scss';
5+
import { ThemeImage } from '../ThemeImage';
6+
import { Examples } from '@/constants/constantsText';
7+
import cn from 'classnames';
8+
import gsap from 'gsap';
9+
10+
export const ExamplesFirstSection = () => {
11+
const exampleBlocksRef = useRef<(HTMLDivElement | null)[]>([]);
12+
13+
const addToExampleBlocksRef = (el: HTMLDivElement | null, index: number) => {
14+
if (el) {
15+
gsap.set(el.querySelector(`.${styles.imageContainer}`), {
16+
opacity: 0,
17+
y: 50
18+
});
19+
exampleBlocksRef.current[index] = el;
20+
}
21+
};
22+
23+
useEffect(() => {
24+
if (typeof window === 'undefined') return;
25+
26+
const observers: IntersectionObserver[] = [];
27+
28+
exampleBlocksRef.current.forEach((block, index) => {
29+
if (!block) return;
30+
31+
const observer = new IntersectionObserver(
32+
(entries) => {
33+
entries.forEach((entry) => {
34+
if (entry.isIntersecting) {
35+
const imageContainer = entry.target.querySelector(`.${styles.imageContainer}`);
36+
if (imageContainer) {
37+
gsap.to(imageContainer, {
38+
y: 0,
39+
opacity: 1,
40+
duration: 0.8,
41+
delay: 0.1 * index,
42+
ease: 'power2.in',
43+
});
44+
}
45+
observer.unobserve(entry.target);
46+
}
47+
});
48+
},
49+
{
50+
threshold: 0.4,
51+
rootMargin: '0px 0px -150px 0px'
52+
}
53+
);
54+
55+
observer.observe(block);
56+
observers.push(observer);
57+
});
58+
59+
return () => {
60+
observers.forEach(observer => observer.disconnect());
61+
};
62+
}, []);
63+
64+
return (
65+
<section className={styles.wrapper}>
66+
<h2 className={styles.title}>
67+
examples
68+
</h2>
69+
70+
<div className={styles.examplesContainer}>
71+
{Examples.map((example, index) => (
72+
<div
73+
key={index}
74+
className={cn(styles.exampleBlock, {
75+
[styles.reverse]: index % 2 !== 0,
76+
})}
77+
ref={(el) => addToExampleBlocksRef(el, index)}
78+
>
79+
<div className={styles.imageContainer}>
80+
<ThemeImage
81+
width={500}
82+
height={300}
83+
alt={example.title}
84+
src={`images/example-${index + 1}.png`}
85+
className={styles.exampleImage}
86+
/>
87+
</div>
88+
<div className={styles.content}>
89+
<h3 className={styles.exampleTitle}>{example.title}</h3>
90+
<p className={styles.exampleDescription}>{example.description}</p>
91+
</div>
92+
</div>
93+
))}
94+
</div>
95+
</section>
96+
);
97+
};
98+
99+
100+
101+
export default ExamplesFirstSection;

website/src/components/HomePage/ExamplesSection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ const ExamplesSection = () => {
6767
return (
6868
<section className={styles.wrapper} ref={sectionRef}>
6969
<h2 className={styles.title}>
70-
mutations
70+
more
7171
<span className={cn(styles.title, styles['title--color'])}>
72-
&nbsp;example
72+
&nbsp;examples
7373
</span>
7474
</h2>
7575
<div className={styles.container}>

website/src/pages/home/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import HowItWorksSection from '@/components/HomePage/HowItWorksSection';
55
import ExamplesSection from '@/components/HomePage/ExamplesSection';
66
import FeaturesSection from '@/components/HomePage/FeaturesSection';
77
import GetStartedSection from '@/components/HomePage/GetStartedSection';
8+
import ExamplesFirstSection from '@/components/HomePage/ExamplesFirstSection';
89

910
const Home = () => {
1011
return (
@@ -14,8 +15,9 @@ const Home = () => {
1415
>
1516
<div className={styles.wrapper}>
1617
<HeroSection />
17-
<HowItWorksSection />
18+
<ExamplesFirstSection/>
1819
<ExamplesSection />
20+
<HowItWorksSection />
1921
<FeaturesSection />
2022
<GetStartedSection />
2123
</div>

0 commit comments

Comments
 (0)