Skip to content

Commit

Permalink
make it pop
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabor Juhasz committed Jul 9, 2022
1 parent 46b17b3 commit 47622ab
Show file tree
Hide file tree
Showing 7 changed files with 568 additions and 84 deletions.
87 changes: 87 additions & 0 deletions components/Box.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { Button, Group, Popover } from "@mantine/core";
import { FC, useState } from "react";
import { useLongPress } from "react-use";
import { Item } from "types";

interface BoxProps {
cutoff: number;
item: Item;
setShowOverlay: (open: boolean) => void;
}
export const Box: FC<BoxProps> = ({ item, cutoff, setShowOverlay }) => {
console.log(item);
const [popoverOpen, setPopoverOpen] = useState(false);
const longPressEvent = useLongPress(() => {
setPopoverOpen(true);
setShowOverlay(true);
});

return (
<li
{...longPressEvent}
style={{
listStyle: "none",
position: "absolute",
left: 0,
top: (item.relativeDateInMinutes - cutoff) * 2,
padding: 4,
}}
>
<Popover
opened={popoverOpen}
onClose={() => {
setPopoverOpen(false);
setShowOverlay(false);
}}
position="bottom"
target={
<div
style={{
position: "relative",
display: "flex",
flexDirection: "column",
justifyContent: "space-between",
background: "white",
border: "1px solid gray",
height: popoverOpen ? "auto" : item.duration * 2,
minHeight: popoverOpen ? item.duration * 2 : "",
transform: popoverOpen ? "scale(1.05)" : "",
transition: "transform 400ms",
overflow: "hidden",
zIndex: popoverOpen ? 2 : "",
width: 272,
}}
>
<div style={{ padding: 8, flex: 1, minHeight: 0 }}>
<p
style={{
marginBottom: 16,
}}
>
{item.title}
</p>
<p dangerouslySetInnerHTML={{ __html: item.description }} />
</div>
<div
style={{
padding: 8,
background: "white",
display: "flex",
justifyContent: "space-between",
}}
>
<p>{item.time?.name}</p>
<p>{item.duration} perc</p>
</div>
</div>
}
>
<Group direction="column">
<Button color="green">Kötelező</Button>
<Button color="yellow">Jó lenne</Button>
<Button color="red">Rejtsd el</Button>
</Group>
</Popover>
</li>
);
};
Loading

1 comment on commit 47622ab

@vercel
Copy link

@vercel vercel bot commented on 47622ab Jul 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

katlan – ./

katlan-juhg24.vercel.app
katlan-git-main-juhg24.vercel.app
katlan.vercel.app

Please sign in to comment.