Skip to content

Commit 207f8d2

Browse files
2 parents f0f66a8 + 2eb5177 commit 207f8d2

File tree

10 files changed

+375
-23
lines changed

10 files changed

+375
-23
lines changed

package-lock.json

Lines changed: 60 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@trpc/server": "^10.9.0",
2222
"@types/react-speech-recognition": "^3.9.1",
2323
"axios": "^1.3.4",
24+
"framer-motion": "^10.5.0",
2425
"google-translate-api-browser": "^3.0.1",
2526
"livekit-client": "^1.6.9",
2627
"livekit-server-sdk": "^1.1.0",
@@ -31,7 +32,9 @@
3132
"pusher-js": "^8.0.1",
3233
"react": "18.2.0",
3334
"react-dom": "18.2.0",
35+
"react-icons": "^4.8.0",
3436
"react-speech-recognition": "^3.10.0",
37+
"react-type-animation": "^2.1.2",
3538
"superjson": "1.9.1",
3639
"transliteration": "^2.3.5",
3740
"zod": "^3.20.6"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React, { FC, useRef } from 'react';
2+
import { motion, useInView } from 'framer-motion';
3+
4+
const CharacterAnimation: FC<{
5+
text: string;
6+
className?: string;
7+
textStyle?: string;
8+
}> = ({ text, className, textStyle }) => {
9+
const ref = useRef<HTMLDivElement>(null);
10+
const isInView = useInView(ref, { once: true });
11+
const letters = Array.from(text);
12+
13+
const container = {
14+
hidden: { opacity: 0 },
15+
visible: (i = 1) => ({
16+
opacity: 1,
17+
transition: { staggerChildren: 0.03, delayChildren: 0.04 * i },
18+
}),
19+
};
20+
21+
const child = {
22+
visible: {
23+
opacity: 1,
24+
y: 0,
25+
transition: {
26+
type: 'spring',
27+
damping: 12,
28+
stiffness: 100,
29+
},
30+
},
31+
hidden: {
32+
opacity: 0,
33+
y: 20,
34+
transition: {
35+
type: 'spring',
36+
damping: 12,
37+
stiffness: 100,
38+
},
39+
},
40+
};
41+
42+
return (
43+
<motion.div
44+
ref={ref}
45+
className={className}
46+
style={{ overflow: 'hidden', display: 'flex', fontSize: '2rem' }}
47+
variants={container}
48+
initial="hidden"
49+
animate={isInView ? 'visible' : 'hidden'}
50+
>
51+
{letters.map((letter, index) => (
52+
<motion.span className={textStyle} variants={child} key={index}>
53+
{letter === ' ' ? '\u00A0' : letter}
54+
</motion.span>
55+
))}
56+
</motion.div>
57+
);
58+
};
59+
60+
export default CharacterAnimation;

src/components/animation/text.tsx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import React, { FC, useRef } from "react";
2+
import { motion, useInView } from "framer-motion";
3+
4+
const TextAnimation: FC<{
5+
text: string;
6+
className?: string;
7+
textStyle?: string;
8+
}> = ({ text, className, textStyle }) => {
9+
const ref = useRef<HTMLDivElement>(null);
10+
const isInView = useInView(ref, { once: true });
11+
const words = text.split(" ");
12+
13+
const container = {
14+
hidden: { opacity: 0 },
15+
visible: (i = 1) => ({
16+
opacity: 1,
17+
transition: { staggerChildren: 0.12, delayChildren: 0.04 * i },
18+
}),
19+
};
20+
21+
const child = {
22+
visible: {
23+
opacity: 1,
24+
y: 0,
25+
transition: {
26+
type: "spring",
27+
damping: 12,
28+
stiffness: 100,
29+
},
30+
},
31+
hidden: {
32+
opacity: 0,
33+
y: 20,
34+
transition: {
35+
type: "spring",
36+
damping: 12,
37+
stiffness: 100,
38+
},
39+
},
40+
};
41+
42+
return (
43+
<motion.div
44+
ref={ref}
45+
className={className}
46+
style={{ overflow: "hidden", display: "flex", fontSize: "2rem" }}
47+
variants={container}
48+
initial="hidden"
49+
animate={isInView ? "visible" : "hidden"}
50+
>
51+
{words.map((word, index) => (
52+
<motion.span
53+
variants={child}
54+
style={{ marginRight: "5px" }}
55+
key={index}
56+
className={textStyle}
57+
>
58+
{word}
59+
</motion.span>
60+
))}
61+
</motion.div>
62+
);
63+
};
64+
65+
export default TextAnimation;

src/components/animation/typing.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { TypeAnimation } from "react-type-animation";
2+
3+
export default function Typing() {
4+
return (
5+
<TypeAnimation
6+
cursor={true}
7+
sequence={[
8+
"Jab We Meet",
9+
3000,
10+
"जब हम मिले",
11+
3000,
12+
"ジャブ・ウィー・メット",
13+
3000,
14+
]}
15+
wrapper="h2"
16+
className="text-3xl font-semibold sm:text-3xl lg:text-4xl xl:text-5xl 2xl:text-6xl"
17+
repeat={Infinity}
18+
/>
19+
);
20+
}

src/components/captions/index.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ interface Props {
1818
languageCode: string;
1919
}
2020

21-
2221
const Captions: React.FC<Props> = ({
2322
transcriptionQueue,
2423
setTranscriptionQueue,
@@ -32,22 +31,34 @@ const Captions: React.FC<Props> = ({
3231
if (transcriptionQueue.length > 0) {
3332
const res = await translate(transcriptionQueue[0]?.message as string, {
3433
// @ts-ignore
35-
to: languageCode,
34+
to: languageCode.split("-")[0],
3635
});
3736
setCaption({
3837
message: res.text,
3938
sender: transcriptionQueue[0]?.sender as string,
4039
});
41-
const isEmpty = transcriptionQueue.length === 0
42-
speakOut(res.text as string,isEmpty )
40+
const isEmpty = transcriptionQueue.length === 0;
41+
speakOut(res.text as string, isEmpty);
4342
setTranscriptionQueue((prev) => prev.slice(1));
4443
}
4544
}
4645
translateText();
46+
47+
// Hide the caption after 5 seconds
48+
const timer = setTimeout(() => {
49+
setCaption({
50+
message: "",
51+
sender: "",
52+
});
53+
}, 5000);
54+
55+
return () => {
56+
clearTimeout(timer);
57+
};
4758
}, [transcriptionQueue]);
4859

4960
return (
50-
<div className="closed-captions-wrapper">
61+
<div className="closed-captions-wrapper z-50">
5162
<div className="closed-captions-container">
5263
{caption?.message ? (
5364
<>

0 commit comments

Comments
 (0)