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 "./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";
const questions = [
@ -78,58 +81,61 @@ const App = () => {
};
return (
<div className="flex items-center justify-center min-h-screen bg-gray-100 relative">
<div className="w-full max-w-lg bg-white p-6 rounded-lg shadow-md text-center relative">
<h1 className="text-2xl font-bold">Rating Umur Game</h1>
{/* 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 && (
<div>
<Header/>
<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%" }}>
<div className={`w-full max-w-lg p-6 text-center relative ${step > 0 || rating ? 'bg-white rounded-lg shadow-md' : ''}`}>
{step === 0 && !rating && (
<h1 className="text-6xl text-white text-2xl text-left font-bold ">Rating Umur Game</h1>
)}
{/* 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
onClick={() => {
setAnswers(answers.slice(0, -1));
setStep(step - 1);
setAnswers(answers.slice(0, -1));
setStep(step - 1);
}}
className="w-6 h-6 bg-yellow-500 rounded-full hover:bg-yellow-700"
/>
)}
)}
{/* Tombol merah: Kembali ke input nama game */}
<button
{/* Tombol merah: Kembali ke input nama game */}
<button
onClick={() => {
setStep(0);
setAnswers([]);
setGameName("");
}}
className="w-6 h-6 bg-red-500 rounded-full hover:bg-red-700"
/>
</div>
)}
/>
</div>
)}
{!rating && step === 0 && (
<>
<p className="mt-4">Masukkan nama game:</p>
<input
{!rating && step === 0 && (
<>
<p className="mt-4 text-left text-white">Masukkan nama game:</p>
<input
type="text"
value={gameName}
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"
/>
<button
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
onClick={checkGame}
className="bg-blue-500 text-white px-4 py-2 rounded mt-4"
>
>
Cek
</button>
</>
)}
</button>
</>
)}
{!rating && step > 0 && step <= questions.length && (
<>
<p className="mt-4">{questions[step - 1]}</p>
{options.map((option) => (
{!rating && step > 0 && step <= questions.length && (
<>
<p className="mt-4">{questions[step - 1]}</p>
{options.map((option) => (
<button
key={option}
onClick={() => handleOptionClick(option)}
@ -137,63 +143,63 @@ const App = () => {
>
{option}
</button>
))}
</>
)}
))}
</>
)}
{!rating && step > questions.length && (
<>
{/* Menampilkan tabel hasil jawaban */}
<div className="mt-4">
{!rating && step > questions.length && (
<>
{/* Menampilkan tabel hasil jawaban */}
<div className="mt-4">
<h2 className="text-lg font-semibold">Hasil Jawaban Anda:</h2>
<table className="table-auto w-full border mt-4">
<thead>
<tr className="bg-gray-200">
<th className="border px-4 py-2">Pertanyaan</th>
<th className="border px-4 py-2">Jawaban</th>
</tr>
<tr className="bg-gray-200">
<th className="border px-4 py-2">Pertanyaan</th>
<th className="border px-4 py-2">Jawaban</th>
</tr>
</thead>
<tbody>
{questions.map((question, index) => (
<tr key={index}>
<td className="border px-4 py-2">{question}</td>
<td className="border px-4 py-2">{answers[index]}</td>
</tr>
))}
{questions.map((question, index) => (
<tr key={index}>
<td className="border px-4 py-2">{question}</td>
<td className="border px-4 py-2">{answers[index]}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
{/* Tombol kembali ke input game */}
<button
{/* Tombol kembali ke input game */}
<button
onClick={() => {
setStep(0);
setAnswers([]);
setGameName("");
}}
className="bg-red-500 text-white px-4 py-2 rounded mt-4 w-full"
>
>
Kembali
</button>
</button>
{/* Tombol untuk konfirmasi hasil */}
<button
{/* Tombol untuk konfirmasi hasil */}
<button
onClick={submitAnswers}
className="bg-green-500 text-white px-4 py-2 rounded mt-4 w-full"
>
>
Cek Hasil
</button>
</>
)}
</button>
</>
)}
{rating && (
<>
<h2 className="text-xl font-semibold mt-4">
{rating && (
<>
<h2 className="text-xl font-semibold mt-4">
Game <span className="font-bold text-blue-500">{gameName}</span> memiliki rating
<span className="font-bold text-red-500"> {rating}</span>
</h2>
<p className="mt-2"><strong>Penjelasan:</strong> {ratingDescriptions[rating]}</p>
<button
</h2>
<p className="mt-2"><strong>Penjelasan:</strong> {ratingDescriptions[rating]}</p>
<button
onClick={() => {
setStep(0);
setAnswers([]);
@ -201,30 +207,34 @@ const App = () => {
setGameName("");
}}
className="bg-red-500 text-white px-4 py-2 rounded mt-4 w-full"
>
>
Coba Lagi
</button>
</>
)}
</button>
</>
)}
{/* Pop-up konfirmasi pilihan jawaban */}
<PopUp
isOpen={isPopUpOpen}
onClose={() => setIsPopUpOpen(false)}
onConfirm={confirmSelection}
selectedOption={selectedOption}
/>
{/* Pop-up konfirmasi pilihan jawaban */}
<PopUp
isOpen={isPopUpOpen}
onClose={() => setIsPopUpOpen(false)}
onConfirm={confirmSelection}
selectedOption={selectedOption}
/>
{/* Pop-up konfirmasi cek hasil */}
<PopUp
isOpen={isConfirmPopupOpen}
onClose={() => setIsConfirmPopupOpen(false)}
onConfirm={confirmSubmit}
selectedOption="Apakah Anda yakin ingin melihat hasil rating?"
/>
</div>
{/* Pop-up konfirmasi cek hasil */}
<PopUp
isOpen={isConfirmPopupOpen}
onClose={() => setIsConfirmPopupOpen(false)}
onConfirm={confirmSubmit}
selectedOption="Apakah Anda yakin ingin melihat hasil rating?"
/>
</div>
</div>
<Tentang />
<KategoriRating />
<Footer />
</div>
);
};
export default App;
export default App;

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;