Skip to content

Commit 81982ee

Browse files
committed
feat: add sponsor button
1 parent 8711574 commit 81982ee

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

src/components/Header/Header.tsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
import { MoneyButton } from "artistic-components";
12
import Octocat from "./Octocat";
3+
import { FlexBox } from "@ui5/webcomponents-react";
4+
import SponsorDialog from "../SponsorDialog/SponsorDialog";
5+
import { useState } from "react";
26

37
export default function Header() {
8+
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);
9+
const clickHandler = () => {
10+
setIsDialogOpen(true);
11+
}
412
return (
5-
<div>
13+
<>
614
<p className="marquee">
715
Welcome to my site. I'm SNORLAX.
816
</p>
9-
<Octocat />
10-
</div>
17+
<FlexBox>
18+
<MoneyButton style={{ "margin": "1rem" }} onClick={clickHandler}> Sponsor me </MoneyButton>
19+
<Octocat />
20+
</FlexBox>
21+
<SponsorDialog open={isDialogOpen} closeHandler={() => { setIsDialogOpen(false) }} />
22+
</>
1123
)
1224
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Bar, Button, Dialog, DialogPropTypes } from "@ui5/webcomponents-react";
2+
import { MouseEventHandler } from "react";
3+
import { createPortal } from "react-dom";
4+
5+
interface SponsorDialogProps extends DialogPropTypes {
6+
closeHandler: MouseEventHandler<HTMLButtonElement>;
7+
}
8+
9+
export default function SponsorDialog(props: SponsorDialogProps) {
10+
const { open, closeHandler, ...rest } = props;
11+
return (
12+
createPortal(
13+
<Dialog open={open} {...rest} footer={<Bar design="Footer" endContent={<button onClick={closeHandler}>Close</button>} />}></Dialog>,
14+
document.body
15+
)
16+
)
17+
}

src/views/Layout/Layout.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import "./index.css"
22
import Sidebar from "../../components/Sidebar/Sidebar";
33
import Header from "../../components/Header/Header";
4-
import Home from "../Home/Home";
54
import { Outlet } from "react-router-dom";
65

76
export default function Layout() {

0 commit comments

Comments
 (0)