diff --git a/src/components/BalanceBox.tsx b/src/components/BalanceBox.tsx index 4b4680f..1f70eae 100644 --- a/src/components/BalanceBox.tsx +++ b/src/components/BalanceBox.tsx @@ -1,7 +1,9 @@ import { Motion, Presence } from "@motionone/solid"; import { MutinyBalance } from "@mutinywallet/node-manager"; +import { createResource, Show } from "solid-js"; import { useNodeManager } from "~/state/nodeManagerState"; +import { ButtonLink } from "./Button"; function prettyPrintAmount(n?: number | bigint): string { if (!n || n.valueOf() === 0) { @@ -15,7 +17,15 @@ function prettyPrintBalance(b: MutinyBalance): string { } export default function BalanceBox() { - const { balance, refetchBalance } = useNodeManager(); + const { nodeManager } = useNodeManager(); + + const fetchBalance = async () => { + console.log("Refetching balance"); + const balance = await nodeManager()?.get_balance(); + return balance + }; + + const [balance, { refetch: refetchBalance }] = createResource(nodeManager, fetchBalance); return ( @@ -31,12 +41,15 @@ export default function BalanceBox() {

- {balance() && prettyPrintBalance(balance())} SAT + + {/* TODO: no-non-null-asssertion but type narrowing just isn't working */} + {prettyPrintBalance(balance()!)} SAT +

- - + Send + Receive
diff --git a/src/components/Button.tsx b/src/components/Button.tsx index afd181d..009e563 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -1,5 +1,6 @@ import { cva, VariantProps } from "class-variance-authority"; import { children, JSX, ParentComponent, splitProps } from "solid-js"; +import { A } from "solid-start"; const button = cva(["p-4", "rounded-xl", "text-xl", "font-semibold"], { variants: { @@ -7,7 +8,8 @@ const button = cva(["p-4", "rounded-xl", "text-xl", "font-semibold"], { active: "bg-white text-black", inactive: "bg-black text-white border border-white", blue: "bg-[#3B6CCC] text-white", - red: "bg-[#F61D5B] text-white" + red: "bg-[#F61D5B] text-white", + green: "bg-[#1EA67F] text-white", }, layout: { flex: "flex-1", @@ -43,4 +45,27 @@ export const Button: ParentComponent = props => { {slot()} ) +} + +interface ButtonLinkProps extends JSX.ButtonHTMLAttributes, StyleProps { + href: string +} + +export const ButtonLink: ParentComponent = props => { + const slot = children(() => props.children) + const [local, attrs] = splitProps(props, ['children', 'intent', 'layout', 'class', 'href']) + + return ( + + {slot()} + + ) } \ No newline at end of file diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index 0649931..61b5d52 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -4,14 +4,16 @@ import settings from '~/assets/icons/settings.svg'; import { A } from "solid-start"; -type ActiveTab = 'home' | 'scan' | 'settings'; +type ActiveTab = 'home' | 'scan' | 'settings' | 'none'; export default function NavBar(props: { activeTab: ActiveTab }) { const activeStyle = 'h-full border-t-2 border-b-2 border-b-black flex flex-col justify-center' return (