-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c79661f
commit 5c7e85b
Showing
7 changed files
with
269 additions
and
121 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
import { useNavigate } from "@solidjs/router"; | ||
import { createSignal, JSX, onCleanup, onMount, Show } from "solid-js"; | ||
|
||
import receive from "~/assets/icons/receive.svg"; | ||
import scan from "~/assets/icons/scan.svg"; | ||
import send from "~/assets/icons/send.svg"; | ||
import plus from "~/assets/plus.png"; | ||
import { Circle, SharpButton } from "~/components"; | ||
|
||
export function FabMenu(props: { | ||
setOpen: (open: boolean) => void; | ||
children: JSX.Element; | ||
right?: boolean; | ||
left?: boolean; | ||
}) { | ||
let navRef: HTMLElement; | ||
|
||
const handleClickOutside = (e: MouseEvent) => { | ||
if (e.target instanceof Element && !navRef.contains(e.target)) { | ||
e.stopPropagation(); | ||
props.setOpen(false); | ||
} | ||
}; | ||
|
||
onMount(() => { | ||
document.body.addEventListener("click", handleClickOutside); | ||
}); | ||
|
||
onCleanup(() => { | ||
document.body.removeEventListener("click", handleClickOutside); | ||
}); | ||
|
||
return ( | ||
<nav | ||
ref={(el) => (navRef = el)} | ||
class="fixed bottom-[calc(2rem+5rem)] rounded-xl bg-neutral-700/30 px-2 backdrop-blur-lg" | ||
classList={{ | ||
"right-8": props.right, | ||
"left-8": props.left | ||
}} | ||
> | ||
{props.children} | ||
</nav> | ||
); | ||
} | ||
|
||
export function Fab(props: { onSearch: () => void; onScan: () => void }) { | ||
const [open, setOpen] = createSignal(false); | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<> | ||
<Show when={open()}> | ||
<FabMenu setOpen={setOpen} right> | ||
<ul class="flex flex-col divide-y divide-m-grey-400/25"> | ||
<li> | ||
<button | ||
class="flex gap-2 px-2 py-4" | ||
onClick={() => { | ||
setOpen(false); | ||
props.onSearch(); | ||
}} | ||
> | ||
<img | ||
src={send} | ||
width={"24px"} | ||
height={"24px"} | ||
alt="Send" | ||
/>{" "} | ||
Send | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
class="flex gap-2 px-2 py-4" | ||
onClick={() => navigate("/receive")} | ||
> | ||
<img | ||
src={receive} | ||
width={"24px"} | ||
height={"24px"} | ||
alt="Receive" | ||
/>{" "} | ||
Recieve | ||
</button> | ||
</li> | ||
|
||
<li> | ||
<button | ||
class="flex gap-2 px-2 py-4" | ||
onClick={() => { | ||
setOpen(false); | ||
props.onScan(); | ||
}} | ||
> | ||
<img | ||
src={scan} | ||
width={"24px"} | ||
height={"24px"} | ||
alt="Scan" | ||
/>{" "} | ||
Scan | ||
</button> | ||
</li> | ||
</ul> | ||
</FabMenu> | ||
</Show> | ||
<div class="fixed bottom-8 right-8"> | ||
<button onClick={() => setOpen(!open())}> | ||
<Circle size="large"> | ||
<img | ||
src={plus} | ||
width={"24px"} | ||
height={"24px"} | ||
alt="Action" | ||
/>{" "} | ||
</Circle> | ||
</button> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export function MiniFab(props: { | ||
onSend: () => void; | ||
onRequest: () => void; | ||
onScan: () => void; | ||
}) { | ||
const [open, setOpen] = createSignal(false); | ||
return ( | ||
<> | ||
<Show when={open()}> | ||
<FabMenu setOpen={setOpen} left> | ||
<ul class="flex flex-col divide-y divide-m-grey-400/25"> | ||
<li> | ||
<button | ||
class="flex gap-2 px-2 py-4" | ||
onClick={() => { | ||
setOpen(false); | ||
props.onSend(); | ||
}} | ||
> | ||
<img | ||
src={send} | ||
width={"24px"} | ||
height={"24px"} | ||
alt="Send" | ||
/>{" "} | ||
Send | ||
</button> | ||
</li> | ||
<li> | ||
<button | ||
class="flex gap-2 px-2 py-4" | ||
onClick={() => props.onRequest()} | ||
> | ||
<img | ||
src={receive} | ||
width={"24px"} | ||
height={"24px"} | ||
alt="Request" | ||
/>{" "} | ||
Request | ||
</button> | ||
</li> | ||
|
||
<li> | ||
<button | ||
class="flex gap-2 px-2 py-4" | ||
onClick={() => { | ||
setOpen(false); | ||
props.onScan(); | ||
}} | ||
> | ||
<img | ||
src={scan} | ||
width={"24px"} | ||
height={"24px"} | ||
alt="Scan" | ||
/>{" "} | ||
Scan | ||
</button> | ||
</li> | ||
</ul> | ||
</FabMenu> | ||
</Show> | ||
<SharpButton onClick={() => setOpen(true)}> | ||
<img | ||
src={plus} | ||
width="24px" | ||
height="24px" | ||
style={{ | ||
"image-rendering": "pixelated" | ||
}} | ||
/> | ||
</SharpButton> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.