Skip to content

Commit

Permalink
feat: add sponsor button
Browse files Browse the repository at this point in the history
  • Loading branch information
S-N-O-R-L-A-X committed Sep 15, 2024
1 parent 8711574 commit 81982ee
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { MoneyButton } from "artistic-components";
import Octocat from "./Octocat";
import { FlexBox } from "@ui5/webcomponents-react";
import SponsorDialog from "../SponsorDialog/SponsorDialog";
import { useState } from "react";

export default function Header() {
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);
const clickHandler = () => {
setIsDialogOpen(true);
}
return (
<div>
<>
<p className="marquee">
Welcome to my site. I'm SNORLAX.
</p>
<Octocat />
</div>
<FlexBox>
<MoneyButton style={{ "margin": "1rem" }} onClick={clickHandler}> Sponsor me </MoneyButton>
<Octocat />
</FlexBox>
<SponsorDialog open={isDialogOpen} closeHandler={() => { setIsDialogOpen(false) }} />
</>
)
}
17 changes: 17 additions & 0 deletions src/components/SponsorDialog/SponsorDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Bar, Button, Dialog, DialogPropTypes } from "@ui5/webcomponents-react";
import { MouseEventHandler } from "react";
import { createPortal } from "react-dom";

interface SponsorDialogProps extends DialogPropTypes {
closeHandler: MouseEventHandler<HTMLButtonElement>;
}

export default function SponsorDialog(props: SponsorDialogProps) {
const { open, closeHandler, ...rest } = props;
return (
createPortal(
<Dialog open={open} {...rest} footer={<Bar design="Footer" endContent={<button onClick={closeHandler}>Close</button>} />}></Dialog>,
document.body
)
)
}
1 change: 0 additions & 1 deletion src/views/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "./index.css"
import Sidebar from "../../components/Sidebar/Sidebar";
import Header from "../../components/Header/Header";
import Home from "../Home/Home";
import { Outlet } from "react-router-dom";

export default function Layout() {
Expand Down

0 comments on commit 81982ee

Please sign in to comment.