diff --git a/nepalingo-web/src/components/Header.tsx b/nepalingo-web/src/components/Header.tsx index 34e0ae4..ddaad08 100644 --- a/nepalingo-web/src/components/Header.tsx +++ b/nepalingo-web/src/components/Header.tsx @@ -1,12 +1,20 @@ import React from 'react'; import styles from './header.module.css'; - +import Card from './card/Card' const Header: React.FC = () => { return (

Hello, World!

+
); }; diff --git a/nepalingo-web/src/components/card/Card.tsx b/nepalingo-web/src/components/card/Card.tsx new file mode 100644 index 0000000..05303fd --- /dev/null +++ b/nepalingo-web/src/components/card/Card.tsx @@ -0,0 +1,60 @@ +import React, { useState } from 'react'; + +const Card: React.FC<{ + Word: string; + TranslatedWord: string; + Pronunciation: string; + DevenagiriSpelling: string; + ImageUrl?: string; + PronounciationUrl?: string; +}> = ({ Word, TranslatedWord, Pronunciation, DevenagiriSpelling, ImageUrl, PronounciationUrl }) => { + const [isFlipped, setIsFlipped] = useState(false); + const [audio, setAudio] = useState(null); + + const handleFlip = () => { + setIsFlipped(!isFlipped); + }; + + const handlePronunciation = (event: React.MouseEvent) => { + event.stopPropagation(); + if (PronounciationUrl) { + if (audio) { + if (!audio.paused) { + audio.pause(); + audio.currentTime = 0; + } else { + audio.play(); + } + } else { + const newAudio = new Audio(PronounciationUrl); + setAudio(newAudio); + newAudio.play(); + } + } + }; + + return ( +
+
+
+ {!isFlipped &&
{Word}
} +
+
+
+ {ImageUrl && {Word}} +

{TranslatedWord}

+

{DevenagiriSpelling}

+

{Pronunciation}

+ {PronounciationUrl && ( + + )} +
+
+
+
+ ); +}; + +export default Card; diff --git a/nepalingo-web/src/index.css b/nepalingo-web/src/index.css index bd6213e..d544329 100644 --- a/nepalingo-web/src/index.css +++ b/nepalingo-web/src/index.css @@ -1,3 +1,19 @@ @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities; + +.backface-hidden { + backface-visibility: hidden; +} +.flipped .rotateY-180 { + transform: rotateY(0deg); +} +.flipped .rotateY-0 { + transform: rotateY(-180deg); +} +.rotateY-180 { + transform: rotateY(180deg); +} +.rotateY-0 { + transform: rotateY(0deg); +} \ No newline at end of file