Skip to content

Commit 109b23e

Browse files
committed
Setup basic modal
1 parent 14e308a commit 109b23e

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

src/app/staking/page.tsx

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use client';
2-
import { useMemo } from 'react';
2+
import { useEffect, useMemo } from 'react';
33
import { SolidButton } from 'src/components/buttons/SolidButton';
44
import { Card } from 'src/components/layout/Card';
55
import { Section } from 'src/components/layout/Section';
6+
import { Modal, useModal } from 'src/components/menus/Modal';
67
import { Amount } from 'src/components/numbers/Amount';
78
import { ValidatorGroupTable } from 'src/features/validators/ValidatorGroupTable';
89
import { ValidatorGroup, ValidatorStatus } from 'src/features/validators/types';
@@ -11,11 +12,20 @@ import { bigIntMin } from 'src/utils/math';
1112

1213
export default function Index() {
1314
const { groups, totalVotes } = useValidatorGroups();
15+
const showModal = useModal('stake');
16+
useEffect(() => {
17+
setTimeout(() => {
18+
showModal();
19+
}, 5000);
20+
}, [showModal]);
1421
return (
15-
<div className="space-y-8">
16-
<HeroSection totalVotes={totalVotes} groups={groups} />
17-
<ListSection totalVotes={totalVotes} groups={groups} />
18-
</div>
22+
<>
23+
<div className="space-y-8">
24+
<HeroSection totalVotes={totalVotes} groups={groups} />
25+
<ListSection totalVotes={totalVotes} groups={groups} />
26+
</div>
27+
<Modal id="stake">Test</Modal>
28+
</>
1929
);
2030
}
2131

src/components/menus/Modal.tsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { PropsWithChildren } from 'react';
2+
3+
export function useModal(id: string) {
4+
return () => {
5+
const dialog = document.getElementById(id) as HTMLDialogElement;
6+
dialog?.showModal();
7+
};
8+
}
9+
10+
export function Modal({
11+
id,
12+
className,
13+
children,
14+
}: PropsWithChildren<{ id: string; className?: string }>) {
15+
return (
16+
<dialog id={id} className="modal modal-bottom sm:modal-middle">
17+
<div className={`modal-box ${className}`}>
18+
<form method="dialog">
19+
<button className="btn btn-circle btn-ghost btn-sm absolute right-2 top-2 outline-none">
20+
21+
</button>
22+
</form>
23+
{children}
24+
</div>
25+
<form method="dialog" className="modal-backdrop">
26+
<button>close</button>
27+
</form>
28+
</dialog>
29+
);
30+
}

0 commit comments

Comments
 (0)