Skip to content

Commit 649663d

Browse files
committed
feat: create VerseSlideshow and VerseSlide components and insert into Dashboard
1 parent db3e0e3 commit 649663d

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

src/components/VerseSlide.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from "react";
2+
import { cn } from "@/lib/utils";
3+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
4+
import { motion, AnimatePresence } from "framer-motion";
5+
6+
interface VerseSlideProps {
7+
className?: string;
8+
verseReference?: string;
9+
verseText?: string;
10+
}
11+
12+
const VerseSlide: React.FC<VerseSlideProps> = ({
13+
className,
14+
verseReference,
15+
verseText,
16+
}) => {
17+
return (
18+
<div className={cn("default-class", className)}>
19+
<Card>
20+
<CardHeader>
21+
<CardTitle>{verseReference}</CardTitle>
22+
</CardHeader>
23+
{/* <AnimatePresence mode="wait">
24+
<motion.div
25+
key="verse"
26+
initial={{ opacity: 0 }}
27+
animate={{ opacity: 1 }}
28+
exit={{ opacity: 0 }}
29+
transition={{ duration: 0.5 }}
30+
> */}
31+
<CardContent>
32+
<blockquote className="text-lg italic mb-4">{verseText}</blockquote>
33+
</CardContent>
34+
{/* </motion.div>
35+
</AnimatePresence> */}
36+
</Card>
37+
</div>
38+
);
39+
};
40+
41+
export default VerseSlide;

src/components/VerseSlideshow.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from "react";
2+
import { cn } from "@/lib/utils";
3+
import VerseSlide from "./VerseSlide";
4+
import { useEffect, useState } from "react";
5+
import { motion, AnimatePresence } from "framer-motion";
6+
7+
interface VerseSlideshowProps {
8+
className?: string;
9+
}
10+
11+
const verseReferences = {
12+
"John 3:16":
13+
"For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.",
14+
"Philippians 4:13": "I can do all this through him who gives me strength.",
15+
"Psalm 23:1": "The Lord is my shepherd, I lack nothing.",
16+
};
17+
18+
const VerseSlideshow: React.FC<VerseSlideshowProps> = ({ className }) => {
19+
const [currentIndex, setCurrentIndex] = useState(0);
20+
const verseKeys = Object.keys(verseReferences);
21+
22+
useEffect(() => {
23+
const interval = setInterval(() => {
24+
setCurrentIndex((prevIndex) => (prevIndex + 1) % verseKeys.length);
25+
}, 4000);
26+
27+
return () => clearInterval(interval);
28+
}, [verseKeys.length]);
29+
30+
return (
31+
<div className={cn("default-class", className)}>
32+
<AnimatePresence>
33+
{Object.entries(verseReferences).map(
34+
([reference, text], index) =>
35+
index === currentIndex && (
36+
<motion.div
37+
key={reference}
38+
initial={{ opacity: 0 }}
39+
animate={{ opacity: 1 }}
40+
exit={{ opacity: 0 }}
41+
>
42+
<VerseSlide verseReference={reference} verseText={text} />
43+
</motion.div>
44+
)
45+
)}
46+
</AnimatePresence>
47+
</div>
48+
);
49+
};
50+
51+
export default VerseSlideshow;

src/pages/Dashboard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import MeditationCard from '@/components/MeditationCard';
2020
import CommunityMap from '@/components/CommunityMap';
2121
import { motion } from 'framer-motion';
2222
import { toast } from 'sonner';
23+
import VerseSlideshow from '@/components/VerseSlideshow';
2324

2425
const formatDate = (date: Date) => {
2526
return new Intl.DateTimeFormat('en-US', {
@@ -308,6 +309,7 @@ const Dashboard: React.FC = () => {
308309
<h3 className="text-xl font-medium mb-3">Daily Inspiration</h3>
309310
<blockquote className="text-lg italic mb-4"> "-- QUOTE HERE --"
310311
</blockquote>
312+
<VerseSlideshow />
311313
<p className="text-muted-foreground">Scripture Quote</p>
312314
</div>
313315
</motion.div>

0 commit comments

Comments
 (0)