fifty-shades-of-bully/src/pages/conversationPage.jsx

55 lines
1.6 KiB
React
Raw Normal View History

2025-05-06 15:36:55 +07:00
// src/ConversationPage.js
import { useEffect, useState } from 'react';
import '../css/global.css';
import '../css/textBox.css';
2025-05-06 17:08:03 +07:00
import '../css/nameBox.css';
import '../css/conversation.css'
2025-05-06 15:36:55 +07:00
function ConversationPage({data , onClicked}) {
const backgroundSRC = `${import.meta.env.VITE_ASSETS_URL}/${data.background}`
2025-06-17 23:20:56 +07:00
const [name] = useState(() => {
return sessionStorage.getItem("name") || '';
});
const DialogText = data.text.replace("{name}", name);
const DialogName = data.name.replace("{name}", name);
const videoPath = `${import.meta.env.VITE_ASSETS_URL}/${data.sprite}`; // data.sprite return webm file name
2025-06-21 16:58:33 +07:00
// https://dl.techtransthai.org/fsob-assets/F_Porsche_normal.webm
2025-06-21 16:59:28 +07:00
//console.log(data.sprite);
2025-05-06 15:36:55 +07:00
return (
<div
onClick={()=>onClicked(data.goTo-1)}
2025-05-06 15:36:55 +07:00
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
2025-05-06 17:08:03 +07:00
height: '100svh',
width: '100svw',
2025-05-06 15:36:55 +07:00
flexDirection: 'column',
backgroundImage: `url(${backgroundSRC})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
}}
>
2025-05-06 17:08:03 +07:00
<div className='spriteBox'>
2025-06-21 16:58:33 +07:00
<video width="200%" height="200%" autoPlay loop muted>
<source src={videoPath} type="video/webm" />
Your browser does not support the video tag.
</video>
2025-05-06 15:36:55 +07:00
</div>
2025-05-06 17:08:03 +07:00
<div style={{width:'60vw'}}>
<div className='nameBox title'>
2025-06-17 23:20:56 +07:00
{DialogName}
2025-05-06 17:08:03 +07:00
</div>
</div>
<div className='textBox title' style={{overflow: 'scroll',}}>
2025-06-17 23:20:56 +07:00
{DialogText}
2025-05-06 15:36:55 +07:00
</div>
</div>
);
}
export default ConversationPage;