Skip to content
This repository was archived by the owner on Feb 15, 2025. It is now read-only.

Commit 498ac9d

Browse files
committed
added basic card swipe support
1 parent ad63459 commit 498ac9d

File tree

6 files changed

+79
-59
lines changed

6 files changed

+79
-59
lines changed

docusaurus.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ const config = {
6262
colorMode: {
6363
defaultMode: 'dark',
6464
disableSwitch: false,
65-
respectPrefersColorScheme: true,
65+
respectPrefersColorScheme: false,
6666
},
67-
// image: '/img/meta.png', // Gets used in Head
67+
// image: '/img/meta.png', // Gets used in Head as Meta Image (og:image)
6868
announcementBar: {
6969
id: 'github-star',
7070
content: customFields.announcementBarContent,

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@
3434
"react-icons": "^4.1.0",
3535
"react-live": "^2.2.3",
3636
"react-spring": "^8.0.27",
37+
"react-swipeable": "^6.0.1",
3738
"react-toastify": "^6.2.0",
3839
"styled-components": "^5.2.1"
3940
},
4041
"devDependencies": {
42+
"@types/jest": "^26.0.15",
4143
"@types/node": "^12.0.0",
4244
"@types/react": "^17.0.0",
4345
"@types/react-dom": "^16.9.8",
4446
"@types/react-helmet": "^6.1.0",
4547
"@types/react-router-dom": "^5.1.6",
4648
"@types/styled-components": "^5.1.0",
47-
"@types/jest": "^26.0.15",
4849
"@typescript-eslint/eslint-plugin": "^4.12.0",
4950
"@typescript-eslint/parser": "^4.12.0",
5051
"eslint": "^7.17.0",

src/_pages/LandingPage/components/OtherFeaturesView/components/Cards/index.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Card from './components/Card';
33
import styles from './styles.module.css';
44
import BulletItem from './components/BulletItem';
55
import { useWindowSize } from '../../../../../../hooks/useWindowSize';
6+
import { useSwipeable } from 'react-swipeable';
67

78
export interface CardInterface {
89
title: string;
@@ -26,6 +27,19 @@ const Cards: React.FC<Props> = (props) => {
2627
height: 600,
2728
});
2829

30+
const handlers = useSwipeable({
31+
onSwipedLeft: () => {
32+
console.log('Swiped Left');
33+
if (index < cards.length - 1) setIndex(index + 1);
34+
},
35+
onSwipedRight: () => {
36+
console.log('Swiped Right');
37+
if (index > 0) setIndex(index - 1);
38+
},
39+
preventDefaultTouchmoveEvent: true,
40+
trackMouse: true,
41+
});
42+
2943
const getCardProps = useCallback(
3044
(
3145
i: number
@@ -104,7 +118,7 @@ const Cards: React.FC<Props> = (props) => {
104118
);
105119

106120
return (
107-
<div className={styles.Container}>
121+
<div className={styles.Container} {...handlers}>
108122
<div
109123
className={styles.Slider}
110124
style={{

src/_pages/LandingPage/components/OtherFeaturesView/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const cards: CardInterface[] = [
2727
{
2828
title: 'Well Tested',
2929
description:
30-
'AgileTs has over 1000 jest tests to ensure everything works as expected.',
30+
'AgileTs has over 2000 jest tests to ensure everything works as expected.',
3131
to: 'docs/introduction',
3232
imagePath: 'img/pages/landing/engineer.svg',
3333
},

0 commit comments

Comments
 (0)