Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Feature/rkm66 55 invite modal logic (#52)
Browse files Browse the repository at this point in the history
* feat: add modal ui component

* refactor: prepare modal ui set for implementation

* chore: minor changes

* chore: purple color

* chore: typo

---------

Co-authored-by: shalluv <[email protected]>
  • Loading branch information
NakZaa and shalluv authored Jul 16, 2023
1 parent 04f69ce commit 601999a
Show file tree
Hide file tree
Showing 21 changed files with 191 additions and 31 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"prepare": "husky install"
},
"dependencies": {
"@headlessui/react": "1.7.15",
"@heroicons/react": "2.0.18",
"autoprefixer": "10.4.14",
"axios": "1.4.0",
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions src/components/Modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { Dialog, Transition } from '@headlessui/react';
import { Fragment, ReactNode } from 'react';

export interface ModalProps {
open: boolean;
onClose: () => any;
children?: ReactNode;
answer1?: string;
answer2?: string;
}

export const Modal = ({
open,
onClose,
children,
answer1,
answer2,
}: ModalProps) => {
return (
<>
<Transition.Root show={open} as={Fragment}>
<Dialog
as="div"
className="relative z-50 text-white"
onClose={onClose}
>
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-50 backdrop-blur-lg transition-opacity" />
</Transition.Child>

<div className="fixed inset-0 z-10 overflow-y-auto">
<div className="flex min-h-full items-center justify-center p-4 text-center">
<Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
enterTo="opacity-100 translate-y-0 sm:scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
>
<Dialog.Panel className="relative w-full max-w-2xl transform overflow-hidden rounded-3xl bg-gray-900 p-8 py-10 text-center shadow-xl transition-all">
<div>
<div className="text-center">
<div className="text-lg text-white">
{children}
</div>
</div>
</div>
<div className="mt-6 flex flex-row justify-center gap-6">
<button
type="button"
className={` ${
`${answer1}` == ''
? 'aria-hidden hidden'
: 'inline-flex max-w-fit flex-1 justify-center rounded-3xl bg-pink-600 px-8 py-2 text-lg font-semibold text-white shadow-sm transition-all hover:ring-2 hover:ring-pink-600/20 hover:ring-offset-4 hover:ring-offset-pink-600/50'
}
`}
onClick={onClose}
>
{answer1}
</button>
<button
type="button"
className="inline-flex max-w-fit flex-1 justify-center rounded-3xl bg-purple-300 px-8 py-2 text-lg font-semibold text-white shadow-sm transition-all hover:ring-2 hover:ring-purple-300/20 hover:ring-offset-4 hover:ring-offset-purple-300/50"
onClick={onClose}
>
{answer2}
</button>
</div>
</Dialog.Panel>
</Transition.Child>
</div>
</div>
</Dialog>
</Transition.Root>
</>
);
};
2 changes: 1 addition & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function Navbar() {
const { user, logout, login } = useAuth();

return (
<nav className="sticky top-0 z-50 flex h-11 w-full items-center justify-between bg-black/50 px-2 py-2 backdrop-blur-sm md:px-5 lg:h-20 lg:px-10 lg:py-4">
<nav className="sticky top-0 z-40 flex h-11 w-full items-center justify-between bg-black/50 px-2 py-2 backdrop-blur-sm md:px-5 lg:h-20 lg:px-10 lg:py-4">
<div className="relative h-full w-12">
<Link href="/">
<Image
Expand Down
8 changes: 4 additions & 4 deletions src/components/Profile/BaanSelection/components/BaanPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function BaanPanel() {

return (
<div className="flex flex-col rounded-xl bg-white p-4 ring-8 ring-white ring-opacity-25">
<p className="mb-4 text-center text-xl font-bold text-purple lg:text-3xl">
<p className="mb-4 text-center text-xl font-bold text-purple-400 lg:text-3xl">
บ้านรับเพื่อนที่เลือก
</p>
<div className="flex flex-col items-center justify-center gap-4 lg:flex-row">
Expand All @@ -24,13 +24,13 @@ export default function BaanPanel() {
key={data.name}
className="flex h-full w-full flex-col items-center justify-center gap-4 px-4"
>
<div className="relative aspect-3/4 w-full max-w-xxs overflow-clip rounded-lg border-2 border-purple lg:w-28">
<p className="text-md absolute flex h-7 items-center justify-center rounded-br-lg bg-purple px-2 font-bold leading-none lg:h-7 lg:text-lg">
<div className="relative aspect-3/4 w-full max-w-xxs overflow-clip rounded-lg border-2 border-purple-400 lg:w-28">
<p className="text-md absolute flex h-7 items-center justify-center rounded-br-lg bg-purple-400 px-2 font-bold leading-none lg:h-7 lg:text-lg">
{data.num}
</p>
<Image fill src={data.imgUrl} alt={data.name} />
</div>
<div className="flex select-none flex-col text-center text-xl leading-none text-purple lg:w-28">
<div className="flex select-none flex-col text-center text-xl leading-none text-purple-400 lg:w-28">
<p>{data.name}</p>
<p>({data.size})</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function GroupPanel() {

return (
<div className="flex flex-col gap-4 rounded-xl bg-white p-4 ring-8 ring-white/30">
<p className="h-12 text-center text-xl font-bold text-purple lg:text-3xl">
<p className="h-12 text-center text-xl font-bold text-purple-400 lg:text-3xl">
สมาชิกในกลุ่ม(2/3)
</p>
<div className="flex h-full flex-col justify-center gap-4 lg:flex-row">
Expand All @@ -32,10 +32,10 @@ export default function GroupPanel() {
className="relative flex h-full w-full flex-col items-center gap-4 px-4"
key={data.name}
>
<div className="relative aspect-3/4 w-full max-w-xxs overflow-clip rounded-lg border-2 border-purple lg:w-28">
<div className="relative aspect-3/4 w-full max-w-xxs overflow-clip rounded-lg border-2 border-purple-400 lg:w-28">
<Image src={data.imgUrl} fill alt={data.name} />
</div>
<div className="relative z-0 flex select-none flex-col text-center text-lg leading-none text-purple">
<div className="relative z-0 flex select-none flex-col text-center text-lg leading-none text-purple-400">
<p>{data.name}</p>
<p>{data.surname}</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function InviteLink() {
return (
<div className="flex w-full flex-col items-center justify-center gap-4 text-white xl:flex-row">
<label className="min-w-max text-xl lg:text-2xl">Invite Link</label>
<div className="relative flex w-full overflow-x-auto rounded-full bg-white px-5 py-2 text-sm text-purple ring-8 ring-white/30">
<div className="relative flex w-full overflow-x-auto rounded-full bg-white px-5 py-2 text-sm text-purple-400 ring-8 ring-white/30">
{inviteLink}
<Square2StackIcon
className="absolute right-2 top-1/2 w-7 -translate-y-1/2 cursor-pointer rounded-full bg-pink-400 p-1 text-white"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function ProfileInfoPanel() {
<Image src={profilePic} fill alt="profile pic" />
</div>
<div className="flex flex-col">
<p className="select-none text-center text-3xl font-bold text-purple">
<p className="select-none text-center text-3xl font-bold text-purple-400">
แจฮยอน <br /> คงแก่การเรียน
</p>
<button className="mx-auto mt-8 w-36 rounded-lg bg-pink-400 py-2 text-xl ring-4 ring-pink-400/30 transition-all duration-500 hover:ring-8">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Profile/WaitForBaan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Rocket from '@/public/images/rocket.svg';
const WaitForBaanselection: NextPage = () => {
return (
<div className="relative flex min-h-screen w-full items-center overflow-x-hidden bg-gray-800/30 px-8 backdrop-blur-sm backdrop-filter">
<div className="relative mx-auto flex w-full flex-col gap-8 rounded-3xl bg-gradient-to-bl from-purple to-pink-800/20 px-5 pb-8 pt-10 text-center ring-16 ring-purple/30 lg:w-auto lg:rounded-6xl lg:pb-16 lg:pl-16 lg:pr-52 lg:pt-24 lg:text-left lg:ring-32">
<div className="relative mx-auto flex w-full flex-col gap-8 rounded-3xl bg-gradient-to-bl from-purple-400 to-pink-800/20 px-5 pb-8 pt-10 text-center ring-16 ring-purple-400/30 lg:w-auto lg:rounded-6xl lg:pb-16 lg:pl-16 lg:pr-52 lg:pt-24 lg:text-left lg:ring-32">
<h1 className="text-2xl font-bold lg:text-4xl">
กรุณารอการเลือกบ้าน
</h1>
Expand Down
2 changes: 1 addition & 1 deletion src/components/baan-selection/ListBaan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ListBaan = (props: any) => {
className="text-md mx-auto flex h-min w-min flex-col items-center gap-2"
>
<div
className="relative aspect-square w-36 max-w-full items-center justify-center overflow-clip rounded-xl bg-white ring-4 ring-purple"
className="relative aspect-square w-36 max-w-full items-center justify-center overflow-clip rounded-xl bg-white ring-4 ring-purple-400"
draggable
onDragStart={(event) =>
event.dataTransfer.setData(
Expand Down
2 changes: 1 addition & 1 deletion src/components/baan-selection/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ChangeEvent } from 'react';

const SearchBar = (props: any) => {
return (
<form className="relative w-full text-purple">
<form className="relative w-full text-purple-400">
<label htmlFor="search">
<MagnifyingGlassIcon className="absolute left-2 top-1/2 h-5 w-5 -translate-y-1/2 lg:h-6 lg:w-6" />
</label>
Expand Down
6 changes: 3 additions & 3 deletions src/components/baan-selection/SelectedBaan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const SelectedBaan = (props: any) => {
return (
<div
key={props.num}
className="flex flex-col items-center gap-2 text-sm text-purple lg:flex-row"
className="flex flex-col items-center gap-2 text-sm text-purple-400 lg:flex-row"
onDrop={props.handleDrop}
onDragOver={(e) => e.preventDefault()}
>
<div className="relative flex aspect-square w-32 max-w-full items-center justify-center overflow-clip rounded-lg border-2 border-purple bg-white">
<p className="text-md absolute left-0 top-0 z-10 flex h-7 items-center justify-center rounded-br-lg bg-purple px-2 font-bold leading-none text-white lg:h-7 lg:text-lg">
<div className="relative flex aspect-square w-32 max-w-full items-center justify-center overflow-clip rounded-lg border-2 border-purple-400 bg-white">
<p className="text-md absolute left-0 top-0 z-10 flex h-7 items-center justify-center rounded-br-lg bg-purple-400 px-2 font-bold leading-none text-white lg:h-7 lg:text-lg">
{props.num}
</p>
{props.id === -1 ? (
Expand Down
49 changes: 49 additions & 0 deletions src/context/ModalContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { createContext, useContext, ReactNode, useState } from 'react';

type ModalId =
| 'modal-1'
| 'modal-2'
| 'modal-3'
| 'modal-4'
| 'modal-5'
| 'modal-6'
| 'modal-7'
| 'modal-8'
| 'modal-9'
| 'modal-10';

export interface AppContextProps {
modalToOpen: ModalId | null;
closeModal: () => void;
openModal: (id: ModalId) => void;
}

export const AppContext = createContext<AppContextProps>({
modalToOpen: null,
closeModal: () => {},
openModal: (id: ModalId) => {},
});

export interface AppContextProviderProps {
children: ReactNode;
}

export const AppContextProvider = ({ children }: AppContextProviderProps) => {
const [modalToOpen, setModalToOpen] = useState<ModalId | null>(null);

const closeModal = () => {
setModalToOpen(null);
};

const openModal = (id: ModalId) => {
setModalToOpen(id);
};

return (
<AppContext.Provider value={{ modalToOpen, closeModal, openModal }}>
{children}
</AppContext.Provider>
);
};

export const useAppContext = () => useContext(AppContext);
14 changes: 9 additions & 5 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Head from 'next/head';
import Footer from '@/components/Footer';
import Navbar from '@/components/Navbar';
import { ToastProvider } from '@/components/Toast';
import { AppContextProvider } from '@/context/ModalContext';

const ibmPlexSansThai = IBM_Plex_Sans_Thai({
subsets: ['latin'],
Expand Down Expand Up @@ -64,12 +65,15 @@ export default function App({ Component, pageProps }: AppProps) {
<main className={`${ibmPlexSansThai.variable} font-ibm text-white`}>
<ToastProvider>
<AuthProvider>
<MetaData />
<AppContextProvider>
<MetaData />

<Navbar />
<Component {...pageProps} />
<Background />
<Footer />
<Navbar />
<Component {...pageProps} />

<Background />
<Footer />
</AppContextProvider>
</AuthProvider>
</ToastProvider>

Expand Down
4 changes: 2 additions & 2 deletions src/pages/baan-selection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const BaanChoosing = () => {
return (
<div className="flex min-h-screen w-full items-center justify-center px-6 py-24">
<div className="flex min-h-max w-full flex-col justify-center xl:flex-row">
<div className="flex w-full flex-col items-start gap-2 border bg-white px-8 py-10 text-purple max-xl:rounded-t-3xl xl:w-fit xl:items-start xl:justify-center xl:rounded-l-3xl">
<div className="flex w-full flex-col items-start gap-2 border bg-white px-8 py-10 text-purple-400 max-xl:rounded-t-3xl xl:w-fit xl:items-start xl:justify-center xl:rounded-l-3xl">
<h1 className="select-none text-3xl font-bold xl:text-5xl">
เลือกบ้าน
</h1>
Expand Down Expand Up @@ -97,7 +97,7 @@ const BaanChoosing = () => {
<SearchBar input={input} setInput={setInput} />
</div>
<FilterButton filter={filter} filterBaan={filterBaan} />
<div className="grid w-full grid-flow-row auto-rows-auto grid-cols-1 gap-8 rounded-3xl bg-white p-4 text-purple ring-8 ring-white/40 sm:grid-cols-2 md:grid-cols-4 xl:h-96 xl:overflow-y-auto">
<div className="grid w-full grid-flow-row auto-rows-auto grid-cols-1 gap-8 rounded-3xl bg-white p-4 text-purple-400 ring-8 ring-white/40 sm:grid-cols-2 md:grid-cols-4 xl:h-96 xl:overflow-y-auto">
<ListBaan
baan={baan}
selectedBaan={selectedBaan}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/faq.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const FAQ = () => {
key={question.header}
className="flex flex-col gap-2 rounded-md bg-white px-8 py-8 shadow-md"
>
<h2 className="text-xl font-semibold text-purple">
<h2 className="text-xl font-semibold text-purple-400">
{question.header}
</h2>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/privacy-policy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function getStaticProps() {
const PrivacyPolicy = ({ source }: { source: any }) => {
return (
<div className="h-full w-full">
<article className="prose w-full list-disc whitespace-pre-line bg-purple/75 p-14 leading-loose backdrop-blur-lg">
<article className="prose w-full list-disc whitespace-pre-line bg-purple-400/75 p-14 leading-loose backdrop-blur-lg">
<div className="mx-auto w-full max-w-lg px-2">{source}</div>
</article>
</div>
Expand Down
Loading

0 comments on commit 601999a

Please sign in to comment.