Skip to content

Commit

Permalink
let's try a plus
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed Feb 7, 2024
1 parent c79661f commit 5c7e85b
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 121 deletions.
Binary file added src/assets/plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/components/BalanceBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ export function BalanceBox(props: { loading?: boolean; small?: boolean }) {
const usableOnchain = () =>
(state.balance?.confirmed || 0n) + (state.balance?.unconfirmed || 0n);

const lightningPlusFedi = () =>
(state.balance?.federation || 0n) + (state.balance?.lightning || 0n);

return (
<Switch>
<Match when={props.small}>
<Show when={!props.loading} fallback={<LoadingShimmer small />}>
<h1 class="whitespace-nowrap text-right text-2xl font-light">
<AmountSats
amountSats={state.balance?.lightning || 0}
amountSats={lightningPlusFedi()}
icon="lightning"
denominationSize="lg"
/>
Expand Down Expand Up @@ -122,7 +125,7 @@ export function BalanceBox(props: { loading?: boolean; small?: boolean }) {
<AmountSats
amountSats={
state.balance?.federation ||
0
0n
}
icon="community"
denominationSize="lg"
Expand Down
199 changes: 199 additions & 0 deletions src/components/Fab.tsx
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>
</>
);
}
9 changes: 6 additions & 3 deletions src/components/HomeSubnav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ export function HomeSubnav() {
<>
<div class="flex gap-2">
<button
class="rounded bg-m-grey-700 px-2 py-1 text-sm"
class="rounded px-2 py-1 text-sm"
classList={{
"bg-m-red": activeView() === "me",
"bg-m-grey-800 text-m-grey-400": activeView() !== "me"
}}
onClick={() => setActiveView("me")}
>
Just Me
</button>
<button
class="rounded bg-m-grey-700 px-2 py-1 text-sm"
class="rounded px-2 py-1 text-sm"
classList={{
"bg-m-red": activeView() === "everybody",
"bg-m-grey-800 text-m-grey-400":
activeView() !== "everybody"
}}
Expand All @@ -42,8 +44,9 @@ export function HomeSubnav() {
</button>

<button
class="rounded bg-m-grey-700 px-2 py-1 text-sm"
class="rounded px-2 py-1 text-sm"
classList={{
"bg-m-red": activeView() === "requests",
"bg-m-grey-800 text-m-grey-400":
activeView() !== "requests"
}}
Expand Down
2 changes: 1 addition & 1 deletion src/components/SharpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function SharpButton(props: {
<button
onClick={() => props.onClick()}
disabled={props.disabled}
class="flex items-center gap-2 rounded px-2 py-1 text-sm font-light text-m-grey-400 md:text-base"
class="text-m-grey-300 flex items-center gap-2 rounded px-2 py-1 text-sm font-light md:text-base"
classList={{
"border-b border-t border-b-white/10 border-t-white/50 bg-m-grey-750 active:mt-[1px] active:-mb-[1px]":
!props.disabled
Expand Down
Loading

0 comments on commit 5c7e85b

Please sign in to comment.