-
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathscroll-icons.tsx
More file actions
97 lines (83 loc) · 3 KB
/
scroll-icons.tsx
File metadata and controls
97 lines (83 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use client';
import { aboutPageConfig } from '@/lib/config/pages';
import { useClient } from '@/lib/hooks/use-client';
import React, { useEffect, useMemo, useRef } from 'react';
import '@/styles/scroll-icons.scss';
function ScrollIcons() {
const scrollRef = useRef<HTMLDivElement | null>(null);
const { isMobile } = useClient();
useEffect(() => {
const scrollContainer = scrollRef.current;
if (!scrollContainer) return;
let currentScrollPosition = 0;
const startScrolling = () => {
const move = () => {
const totalWidth = scrollContainer.scrollWidth;
currentScrollPosition += 1; // move 1px per interval
if (currentScrollPosition >= totalWidth / 2) {
currentScrollPosition = 0; // reset to 0 when it reaches the end
}
scrollContainer.scrollTo(currentScrollPosition, 0);
};
return setInterval(move, isMobile ? 48 : 20); // faster scrolling on desktop
};
const intervalId = startScrolling();
// clear interval on unmount
return () => clearInterval(intervalId);
}, []);
const logos = useMemo(
() => [
...aboutPageConfig.developers.logos,
...aboutPageConfig.developers.logos, // copy the logos to make the scrolling smoother
],
[]
);
return (
<div className={'scroll-icons'}>
<div className={'scroll-icons-title'}>Trusted by teams and individuals from</div>
<div ref={scrollRef} className={'developers-logos'}>
<div className={'logo-wrapper'}>
{logos.map((item, index) => {
// Extract logo name from path (e.g., '/images/google.svg' -> 'google')
const logoName = item.logo.replace('/images/', '').replace('.svg', '');
return (
<div
key={index}
style={{
display: 'flex',
width: '220px',
height: '100px',
padding: '30px 20px',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
gap: '10px',
borderRadius: '79px',
background: 'rgba(245, 245, 250, 0.45)',
color: 'var(--color-text)',
}}
className={'logo opacity-100'}
>
<svg
className='opacity-60'
style={{
width: '100%',
height: '100%',
maxWidth: '160px',
maxHeight: '50px',
filter:
'brightness(0) saturate(100%) invert(7%) sepia(32%) saturate(2387%) hue-rotate(264deg) brightness(96%) contrast(104%)',
}}
aria-label={item.name}
>
<use href={`/images/company-logos-sprite.svg#logo-${logoName}`} />
</svg>
</div>
);
})}
</div>
</div>
</div>
);
}
export default ScrollIcons;