Skip to content

Commit

Permalink
Fix modal overlay (#38)
Browse files Browse the repository at this point in the history
* Add Navbar and Home Page

* Add Temporary About Us Page

* Replace double quotes

* Remove unused button

* Fix Modal Overlay and About Us Page

* Fix Some Bug

* Remove Unused Modal

* Fix bug

* Fix layout and reorganize code

---------

Co-authored-by: Rafael Kristoforus Yanto <[email protected]>
Co-authored-by: izruff <[email protected]>
  • Loading branch information
3 people authored Oct 12, 2024
1 parent 7063889 commit 4770e97
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 60 deletions.
84 changes: 65 additions & 19 deletions app/about-us/page.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,85 @@
"use client";

import Image from 'next/image';
import VideoFrame from '../components/about-us/video-frame';
import Carousel from '../components/about-us/carousel';
import FunFact from '../components/about-us/funfact';
import ModalOverlay from '../components/modal-overlay';
import { useState } from 'react';
export default function AboutUs() {
//To Test the modal Overlay Uncomment below
const [isModalOpen, setIsModalOpen] = useState(true);
const onClose = () => setIsModalOpen(false);



return (
<div className="pt-12">
{
/*
To test the modal overlay, uncomment below
*/

isModalOpen &&
<ModalOverlay onClose={onClose}>
<div className="text-3xl mb-8 text-lime-900">
headddddddddasdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffadfasdhe
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
</ModalOverlay>

}
{/* What is Nuansa section */}
<section className="text-center py-12 px-10">
<section className="text-center py-12 px-4 md:px-10">
<h1 className="text-4xl font-bold mb-4">What is &quot;Nuansa&quot;</h1>
<p className="text-lg mb-8">
An annual arts and cultural event by a group of Indonesian students in NUS.
It aims to promote the rich and diverse cultures of Indonesia.
</p>
</section>

<section className="text-center py-12 px-20 bg-orange-50 flex flex-row items-end">
{/* Fun Fact Section */}
<section className="text-center py-12 px-4 md:px-20 bg-orange-50 flex flex-col md:flex-row items-center justify-center">
<h2 className="text-3xl mb-8 text-lime-900">Fun Fact</h2>
<div className="flex-grow px-20">
<div className="flex-grow px-4 md:px-20">
<FunFact>
<h2 className="text-3xl mb-8 text-lime-900">Fun Fact</h2>
<h2 className="text-3xl mb-8 text-lime-900">Fun Fict</h2>
</FunFact>
</div>
</section>

<section className="grid grid-cols-1 md:grid-cols-2 gap-8 py-12">
<div className="text-left px-10">
{/* Vision and Mission Section */}
<section className="grid grid-cols-1 md:grid-cols-2 bg-orange-50 gap-8 py-12 px-4 md:px-10 text-lime-900">
<div className="text-left">
<h2 className="text-2xl font-semibold mb-4">Our Vision</h2>
<p className="text-lg">
To enrich society by creating and sharing diverse cultural expressions that inspire, challenge, and connect people across different backgrounds.
</p>
</div>
<div className="text-right px-10">
<div className="text-left md:text-right">
<h2 className="text-2xl font-semibold mb-4">Our Mission</h2>
<p className="text-lg">
To produce and promote cultural works that reflect, preserve, and innovate cultural heritage, fostering greater understanding.
</p>
</div>
</section>

<section className="flex flex-col items-center justify-center py-12 text-center bg-lime-950 text-white pb-10">
{/* Memorable Clips Section */}
<section className="flex flex-col items-center justify-center py-12 text-center bg-lime-950 text-white pb-10">
<h2 className="text-3xl font-bold mb-5">Memorable Clips</h2>
<div className="flex flex-row items center justify-center gap-x-20">
<div className="flex flex-col md:flex-row items-center justify-center gap-y-8 md:gap-x-20">
<Carousel>
<img
src="https://media.licdn.com/dms/image/v2/D5622AQEyPzD7WAMiyA/feedshare-shrink_800/feedshare-shrink_800/0/1726034259793?e=2147483647&v=beta&t=yYGRAZoKbJV0xHLg8XkpiB2QF7J_g1hs02U5lFw_ziU"
Expand All @@ -61,22 +99,30 @@ export default function AboutUs() {
</Carousel>
</div>
</section>

<section className="text-center py-12 bg-orange-50">
<div className="flex items-center justify-center pb-10 gap-x-20">
<div className="flex items-center space-x-8">
<div className="grid md:grid-cols-3 items-center">
<div className="bg-red-900 text-white p-10 rounded-md w-48 h-44 flex justify-center items-center mx-2 my-2">Networking</div>
<div className="bg-yellow-500 text-white p-10 rounded-md-2 w-48 h-44 flex justify-center items-center mx-2 my-2">Networking</div>
<div className="bg-purple-900 text-white p-10 rounded-md w-48 h-44 flex justify-center items-center mx-2 my-2">Networking</div>
{/* Flex container for Why Join Us section */}
<div className="flex flex-col-reverse md:flex-row items-center justify-center pb-10 gap-8 md:gap-20">
{/* Grid of Features (Networking, Collaboration, Creativity) */}
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div className="bg-red-900 text-white p-10 rounded-md w-48 h-44 flex justify-center items-center mx-2 my-2">
Networking
</div>

<div>
<h1 className="text-4xl mb-4 text-center text-lime-950">Why Join Us</h1>
<div className="bg-yellow-500 text-white p-10 rounded-md w-48 h-44 flex justify-center items-center mx-2 my-2">
Networking
</div>
<div className="bg-purple-900 text-white p-10 rounded-md w-48 h-44 flex justify-center items-center mx-2 my-2">
Networking
</div>
</div>

{/* Why Join Us heading */}
<div className="mb-8 md:mb-0">
<h1 className="text-4xl mb-4 text-center text-lime-950">Why Join Us</h1>
</div>
</div>
<div className="flex items-center justify-center pb-10 gap-x-20">

{/* Video section */}
<div className="flex flex-col md:flex-row items-center justify-center pb-10 gap-8 md:gap-20">
<h1 className="text-4xl mb-4 text-lime-950">View Our Latest Show {">>"}</h1>
<VideoFrame
videoTitle="RickRoll"
Expand Down
30 changes: 23 additions & 7 deletions app/components/about-us/carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
'use client';
import { Swiper, SwiperSlide } from 'swiper/react';
import { Navigation, Pagination, Scrollbar, A11y } from 'swiper/modules';
import { useSwiper } from 'swiper/react';


import { ReactNode, useState } from 'react';
import { ReactNode, useEffect, useState } from 'react';
import 'swiper/css';
import 'swiper/css/navigation';
import 'swiper/css/pagination';
Expand All @@ -16,7 +13,20 @@ interface CarouselProps {
}

export default function Carousel({ children }: CarouselProps) {
const swiper = useSwiper();
const [windowWidth, setWindowWidth] = useState(0);

useEffect(() => {
const handleResize = () => {
setWindowWidth(window.innerWidth);
};

window.addEventListener('resize', handleResize);

// Cleanup listener on component unmount
return () => {
window.removeEventListener('resize', handleResize);
};
}, []);

return (
<Swiper
Expand All @@ -30,9 +40,15 @@ export default function Carousel({ children }: CarouselProps) {
onSlideChange={() => console.log('slide change')}
>
{children.map((child, index) => (
index % 2 == 0
windowWidth < 1000
? <SwiperSlide key={index}>
<div className="flex flex-row justify-center items-center gap-x-20 px-100 mb-10">
{child}
</div>
</SwiperSlide>
: index % 2 == 0
? <SwiperSlide key={index}>
<div className="flex flex-row justify-center items-center gap-x-20 px-100">
<div className="flex flex-row justify-center items-center gap-x-20 px-100 mb-10">
{children[index]}
{index + 1 != children.length ? children[index + 1] : <></>}
</div>
Expand Down
76 changes: 42 additions & 34 deletions app/components/modal-overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
"use client";
import { Suspense } from "react";
import { useSearchParams } from "next/navigation";
import Link from "next/link";
import { useEffect, MouseEvent, ReactNode } from 'react';

function ModalOverlayContent() {
const searchParams = useSearchParams();
const modal = searchParams.get("modal");
interface ModalOverlayProps {
onClose: () => void;
children: ReactNode;
}

function ModalOverlay({ onClose, children }: ModalOverlayProps) {
// Handle outside click to close modal
const handleOutsideClick = (e: MouseEvent<HTMLDivElement>) => {
if ((e.target as HTMLElement).id === 'modal-overlay') {
onClose();
}
};

// Close modal on 'Escape' key press
useEffect(() => {
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
onClose();
}
};
window.addEventListener('keydown', handleEscape);
return () => window.removeEventListener('keydown', handleEscape);
}, [onClose]);

return (
<>
{(modal === "true" || modal === null) &&
<dialog className="fixed top-0 left-0 w-full h-full bg-transparent flex justify-center items-center z-50">
<div className="relative w-full h-full flex justify-center items-center bg-black bg-opacity-20">
<div className="bg-white p-5 rounded-lg shadow-lg max-w-lg w-full text-center animate-slide-up">
<div className="text-lg text-[#bd9527] leading-6 font-myriad">
<p>Coming Soon: NUANSA 2025</p>
<br />
<Link href="?modal=false">
<button type="button" className="bg-[#fecd94] text-white border-none py-2 px-4 rounded cursor-pointer text-base hover:bg-[#0056b3]">
Continue
</button>
</Link>
</div>
</div>
</div>
</dialog>
}
</>
);
return (
<div
id="modal-overlay"
className="fixed max-h-screen py-10 inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50"
onClick={handleOutsideClick}
>
<div className="bg-white rounded-lg shadow-lg p-6 pt-10 relative max-w-md max-h-full sm:max-w-lg md:max-w-xl lg:max-w-2xl xl:max-w-3xl overflow-auto">
<button
onClick={onClose}
className="absolute top-4 right-4 text-gray-500 hover:text-gray-800"
>
&times;
</button>
{children}
</div>
</div>
);
}

export default function ModalOverlay() {
return (
<Suspense fallback={null}>
<ModalOverlayContent />
</Suspense>
);
}
export default ModalOverlay;

0 comments on commit 4770e97

Please sign in to comment.