-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrolly-controls.tsx
More file actions
79 lines (77 loc) · 2.12 KB
/
scrolly-controls.tsx
File metadata and controls
79 lines (77 loc) · 2.12 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
import styles from "./scrolly-controls.module.css";
interface ScrollyControlsProps {
canGoLeft: boolean;
canGoRight: boolean;
onScrollLeft: () => void;
onScrollRight: () => void;
ButtonLeft?: React.ComponentType<{ onClick: () => void }>;
ButtonRight?: React.ComponentType<{ onClick: () => void }>;
}
export default function ScrollyControls({
canGoLeft,
canGoRight,
onScrollLeft,
onScrollRight,
ButtonLeft,
ButtonRight,
}: ScrollyControlsProps) {
return (
<div className={styles.wrapper}>
<div
className={`${styles.btnWrapper} ${styles.btnWrapperLeft} ${
canGoLeft ? styles.btnWrapperVisible : null
}`}
>
{ButtonLeft ? (
<ButtonLeft
onClick={() => {
console.log("Custom button left clicked, calling onScrollLeft");
onScrollLeft();
}}
/>
) : (
<button onClick={onScrollLeft} className={styles.button}>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="m15 18-6-6 6-6" />
</svg>
</button>
)}
</div>
<div
className={`${styles.btnWrapper} ${styles.btnWrapperRight} ${
canGoRight ? styles.btnWrapperVisible : null
}`}
>
{ButtonRight ? (
<ButtonRight onClick={onScrollRight} />
) : (
<button className={styles.button} onClick={onScrollRight}>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="m9 18 6-6-6-6" />
</svg>
</button>
)}
</div>
</div>
);
}