slicing layout

This commit is contained in:
Zeakeers 2025-02-27 01:25:03 +07:00
parent 003ebd1de1
commit 617aa7d898
7 changed files with 181 additions and 87 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

@ -1,5 +1,8 @@
import React, { useState } from "react"; import React, { useState } from "react";
import "./index.css"; import Header from "./components/Header";
import Footer from "./components/Footer";
import Tentang from "./components/Tentang";
import KategoriRating from "./components/KategoriRating";
import PopUp from "./components/PopUp"; import PopUp from "./components/PopUp";
const questions = [ const questions = [
@ -78,58 +81,61 @@ const App = () => {
}; };
return ( return (
<div className="flex items-center justify-center min-h-screen bg-gray-100 relative"> <div>
<div className="w-full max-w-lg bg-white p-6 rounded-lg shadow-md text-center relative"> <Header/>
<h1 className="text-2xl font-bold">Rating Umur Game</h1> <div className="h-screen w-full bg-cover bg-center bg-no-repeat bg-black bg-opacity-50 flex items-center justify-center"
style={{ backgroundImage: "url('/images/bgwebrating.png')", backgroundSize: "105%" }}>
{/* Tombol kembali hanya muncul saat berada di pertanyaan */} <div className={`w-full max-w-lg p-6 text-center relative ${step > 0 || rating ? 'bg-white rounded-lg shadow-md' : ''}`}>
{step > 0 && step <= questions.length && ( {step === 0 && !rating && (
<div className="absolute top-4 right-4 flex space-x-2"> <h1 className="text-6xl text-white text-2xl text-left font-bold ">Rating Umur Game</h1>
{step > 1 && ( )}
{/* Tombol kembali hanya muncul saat berada di pertanyaan */}
{step > 0 && step <= questions.length && (
<div className="absolute top-4 right-4 flex space-x-2">
{step > 1 && (
<button <button
onClick={() => { onClick={() => {
setAnswers(answers.slice(0, -1)); setAnswers(answers.slice(0, -1));
setStep(step - 1); setStep(step - 1);
}} }}
className="w-6 h-6 bg-yellow-500 rounded-full hover:bg-yellow-700" className="w-6 h-6 bg-yellow-500 rounded-full hover:bg-yellow-700"
/> />
)} )}
{/* Tombol merah: Kembali ke input nama game */} {/* Tombol merah: Kembali ke input nama game */}
<button <button
onClick={() => { onClick={() => {
setStep(0); setStep(0);
setAnswers([]); setAnswers([]);
setGameName(""); setGameName("");
}} }}
className="w-6 h-6 bg-red-500 rounded-full hover:bg-red-700" className="w-6 h-6 bg-red-500 rounded-full hover:bg-red-700"
/> />
</div> </div>
)} )}
{!rating && step === 0 && (
{!rating && step === 0 && ( <>
<> <p className="mt-4 text-left text-white">Masukkan nama game:</p>
<p className="mt-4">Masukkan nama game:</p> <input
<input
type="text" type="text"
value={gameName} value={gameName}
onChange={(e) => setGameName(e.target.value)} onChange={(e) => setGameName(e.target.value)}
className="border border-gray-600 bg-gray-100 p-2 w-full mt-2 focus:bg-gray-200 focus:border-black rounded mt-6" className="border border-gray-600 bg-gray-100 p-2 w-full mt-2 focus:bg-gray-200 focus:border-black rounded mt-1"
/> />
<button <button
onClick={checkGame} onClick={checkGame}
className="bg-blue-500 text-white px-4 py-2 rounded mt-4" className="bg-blue-500 text-white px-4 py-2 rounded mt-4"
> >
Cek Cek
</button> </button>
</> </>
)} )}
{!rating && step > 0 && step <= questions.length && ( {!rating && step > 0 && step <= questions.length && (
<> <>
<p className="mt-4">{questions[step - 1]}</p> <p className="mt-4">{questions[step - 1]}</p>
{options.map((option) => ( {options.map((option) => (
<button <button
key={option} key={option}
onClick={() => handleOptionClick(option)} onClick={() => handleOptionClick(option)}
@ -137,63 +143,63 @@ const App = () => {
> >
{option} {option}
</button> </button>
))} ))}
</> </>
)} )}
{!rating && step > questions.length && ( {!rating && step > questions.length && (
<> <>
{/* Menampilkan tabel hasil jawaban */} {/* Menampilkan tabel hasil jawaban */}
<div className="mt-4"> <div className="mt-4">
<h2 className="text-lg font-semibold">Hasil Jawaban Anda:</h2> <h2 className="text-lg font-semibold">Hasil Jawaban Anda:</h2>
<table className="table-auto w-full border mt-4"> <table className="table-auto w-full border mt-4">
<thead> <thead>
<tr className="bg-gray-200"> <tr className="bg-gray-200">
<th className="border px-4 py-2">Pertanyaan</th> <th className="border px-4 py-2">Pertanyaan</th>
<th className="border px-4 py-2">Jawaban</th> <th className="border px-4 py-2">Jawaban</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{questions.map((question, index) => ( {questions.map((question, index) => (
<tr key={index}> <tr key={index}>
<td className="border px-4 py-2">{question}</td> <td className="border px-4 py-2">{question}</td>
<td className="border px-4 py-2">{answers[index]}</td> <td className="border px-4 py-2">{answers[index]}</td>
</tr> </tr>
))} ))}
</tbody> </tbody>
</table> </table>
</div> </div>
{/* Tombol kembali ke input game */} {/* Tombol kembali ke input game */}
<button <button
onClick={() => { onClick={() => {
setStep(0); setStep(0);
setAnswers([]); setAnswers([]);
setGameName(""); setGameName("");
}} }}
className="bg-red-500 text-white px-4 py-2 rounded mt-4 w-full" className="bg-red-500 text-white px-4 py-2 rounded mt-4 w-full"
> >
Kembali Kembali
</button> </button>
{/* Tombol untuk konfirmasi hasil */} {/* Tombol untuk konfirmasi hasil */}
<button <button
onClick={submitAnswers} onClick={submitAnswers}
className="bg-green-500 text-white px-4 py-2 rounded mt-4 w-full" className="bg-green-500 text-white px-4 py-2 rounded mt-4 w-full"
> >
Cek Hasil Cek Hasil
</button> </button>
</> </>
)} )}
{rating && ( {rating && (
<> <>
<h2 className="text-xl font-semibold mt-4"> <h2 className="text-xl font-semibold mt-4">
Game <span className="font-bold text-blue-500">{gameName}</span> memiliki rating Game <span className="font-bold text-blue-500">{gameName}</span> memiliki rating
<span className="font-bold text-red-500"> {rating}</span> <span className="font-bold text-red-500"> {rating}</span>
</h2> </h2>
<p className="mt-2"><strong>Penjelasan:</strong> {ratingDescriptions[rating]}</p> <p className="mt-2"><strong>Penjelasan:</strong> {ratingDescriptions[rating]}</p>
<button <button
onClick={() => { onClick={() => {
setStep(0); setStep(0);
setAnswers([]); setAnswers([]);
@ -201,28 +207,32 @@ const App = () => {
setGameName(""); setGameName("");
}} }}
className="bg-red-500 text-white px-4 py-2 rounded mt-4 w-full" className="bg-red-500 text-white px-4 py-2 rounded mt-4 w-full"
> >
Coba Lagi Coba Lagi
</button> </button>
</> </>
)} )}
{/* Pop-up konfirmasi pilihan jawaban */} {/* Pop-up konfirmasi pilihan jawaban */}
<PopUp <PopUp
isOpen={isPopUpOpen} isOpen={isPopUpOpen}
onClose={() => setIsPopUpOpen(false)} onClose={() => setIsPopUpOpen(false)}
onConfirm={confirmSelection} onConfirm={confirmSelection}
selectedOption={selectedOption} selectedOption={selectedOption}
/> />
{/* Pop-up konfirmasi cek hasil */} {/* Pop-up konfirmasi cek hasil */}
<PopUp <PopUp
isOpen={isConfirmPopupOpen} isOpen={isConfirmPopupOpen}
onClose={() => setIsConfirmPopupOpen(false)} onClose={() => setIsConfirmPopupOpen(false)}
onConfirm={confirmSubmit} onConfirm={confirmSubmit}
selectedOption="Apakah Anda yakin ingin melihat hasil rating?" selectedOption="Apakah Anda yakin ingin melihat hasil rating?"
/> />
</div> </div>
</div>
<Tentang />
<KategoriRating />
<Footer />
</div> </div>
); );
}; };

View File

@ -0,0 +1,30 @@
import react from "react";
const Footer = () => {
return (
<div className="bg-black p-4 text-center text-white">
<p>&copy; 2023 Rating Umur Game. All rights reserved.</p>
<p>
Developed by <a href="#" className="text-white hover:text-white">Dimas Adi</a>
</p>
<ul className="flex justify-center mb-4">
<li className="mr-4">
<a href="#" className="text-white hover:text-white">
<i className="fab fa-facebook-f"></i>
</a>
</li>
<li className="mr-4">
<a href="#" className="text-white hover:text-white">
<i className="fab fa-twitter"></i>
</a>
</li>
<li>
<a href="#" className="text-white hover:text-white">
<i className="fab fa-instagram"></i>
</a>
</li>
</ul>
</div>
);
};
export default Footer;

View File

@ -0,0 +1,30 @@
import react from "react";
const Header = () => {
return (
<div className="bg-yellow-500 text-white p-4 flex justify-between">
<h1 className="text-3xl font-bold"></h1>
<nav>
<ul className="flex justify-end">
<li className="mr-4">
<a href="#" className="text-white hover:text-gray-300">
Beranda
</a>
</li>
<li className="mr-4">
<a href="#" className="text-white hover:text-gray-300">
Tentang
</a>
</li>
<li>
<a href="#" className="text-white hover:text-gray-300">
Kontak
</a>
</li>
</ul>
</nav>
</div>
);
};
export default Header;

View File

@ -0,0 +1,12 @@
import react from "react";
const KategoriRating = () => {
return (
<div className="bg-yellow-500 w-full h-[400px] mt-10 mb-10 p-10">
<h1 className="text-1xl text-left ">Worem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu</h1>
</div>
);
};
export default KategoriRating

View File

@ -0,0 +1,12 @@
import react from "react";
const Tentang = () => {
return (
<div className="bg-[#BBBBBB] mb-8 p-5 text-black text-center w-full h-[230px]">
<h1 className="text-3xl font-bold mt-4">Tentang</h1>
<h1 className="text-1xl mb-4">Worem ipsum dolor sit amet, consectetur adipiscing elit. Nunc vulputate libero et velit interdum, ac aliquet odio mattis. Class aptent taciti sociosqu</h1>
</div>
);
};
export default Tentang;