Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
fix: ui & copy improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
reneaaron committed Jun 12, 2024
1 parent 1466c37 commit b3c2af7
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 75 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { ImportMnemonic } from "src/screens/setup/ImportMnemonic";
import { SetupFinish } from "src/screens/setup/SetupFinish";
import { SetupNode } from "src/screens/setup/SetupNode";
import { SetupPassword } from "src/screens/setup/SetupPassword";
import Wallet from "src/screens/wallet";
import SignMessage from "src/screens/wallet/SignMessage";
import { usePosthog } from "./hooks/usePosthog";

Expand All @@ -53,6 +52,7 @@ import { LDKForm } from "src/screens/setup/node/LDKForm";
import { LNDForm } from "src/screens/setup/node/LNDForm";
import { PhoenixdForm } from "src/screens/setup/node/PhoenixdForm";
import { PresetNodeForm } from "src/screens/setup/node/PresetNodeForm";
import Wallet from "src/screens/wallet";

function App() {
usePosthog();
Expand Down
133 changes: 133 additions & 0 deletions frontend/src/screens/wallet/OnboardingChecklist.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { Circle, CircleCheck } from "lucide-react";
import { Link } from "react-router-dom";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "src/components/ui/card";
import { ALBY_MIN_BALANCE, ALBY_SERVICE_FEE } from "src/constants";
import { useAlbyBalance } from "src/hooks/useAlbyBalance";
import { useAlbyMe } from "src/hooks/useAlbyMe";
import { useApps } from "src/hooks/useApps";
import { useChannels } from "src/hooks/useChannels";
import { useInfo } from "src/hooks/useInfo";
import { useNodeConnectionInfo } from "src/hooks/useNodeConnectionInfo";
import { cn } from "src/lib/utils";

function OnboardingChecklist() {
const { data: albyBalance } = useAlbyBalance();
const { data: albyMe } = useAlbyMe();
const { data: apps } = useApps();
const { data: channels } = useChannels();
const { data: info, hasChannelManagement, hasMnemonic } = useInfo();
const { data: nodeConnectionInfo } = useNodeConnectionInfo();

const hasAlbyBalance =
hasChannelManagement &&
albyBalance &&
albyBalance.sats * (1 - ALBY_SERVICE_FEE) >
ALBY_MIN_BALANCE + 50000; /* accomodate for onchain fees */
const isLinked =
albyMe &&
nodeConnectionInfo &&
albyMe?.keysend_pubkey === nodeConnectionInfo?.pubkey;
const hasChannel = hasChannelManagement && channels && channels?.length > 0;
const hasBackedUp =
hasMnemonic &&
info &&
(!info.nextBackupReminder ||
new Date(info.nextBackupReminder).getTime() > new Date().getTime());
const hasCustomApp =
apps && apps.find((x) => x.name !== "getalby.com") !== undefined;

return (
<Card>
<CardHeader>
<CardTitle>Get started with your Alby Hub</CardTitle>
<CardDescription>
Follow these initial steps to set up and make the most of your Alby
Hub.
</CardDescription>
</CardHeader>
<CardContent className="flex flex-col gap-3">
<ChecklistItem
title="Open your first channel"
description="Establish a new Lightning channel to enable fast and low-fee Bitcoin transactions."
checked={hasChannel}
to="/channels/new"
/>
<ChecklistItem
title="Link your Alby Account"
description="Link your lightning address & other apps to this hub."
checked={isLinked}
to="/settings"
/>
<ChecklistItem
title="Migrate your balance to your Alby Hub"
description="Move your existing funds into self-custody."
checked={!hasAlbyBalance}
to="/onboarding/lightning/migrate-alby"
/>
<ChecklistItem
title="Connect yor first app"
description="Seamlessly connect apps and integrate your wallet with other apps from your hub."
checked={hasCustomApp}
to="/appstore"
/>
<ChecklistItem
title="Backup your keys"
description="Secure your keys by creating a backup to ensure you don't lose access."
checked={hasBackedUp}
to="/settings/key-backup"
/>
{/* <ChecklistItem
title="Make first payment"
description="description"
checked={false}
/> */}
{/* <ChecklistItem
title="Help a friend to get on lightning"
description="Invite friends and earn fee credits"
checked={false} to={""} /> */}
</CardContent>
</Card>
);
}

function ChecklistItem({
title,
checked = false,
description,
to,
}: {
title: string;
checked?: boolean;
description: string;
to: string;
}) {
const content = (
<div className="flex flex-col">
<div className="flex items-center gap-2">
{checked && <CircleCheck className="w-6 h-6" />}
{!checked && <Circle className="w-6 h-6" />}
<div
className={cn(
"text-sm font-medium leading-none",
checked && "line-through"
)}
>
{title}
</div>
</div>
{!checked && (
<div className="text-muted-foreground text-sm ml-8">{description}</div>
)}
</div>
);

return checked ? content : <Link to={to}>{content}</Link>;
}

export default OnboardingChecklist;
76 changes: 2 additions & 74 deletions frontend/src/screens/wallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {
CardHeader,
CardTitle,
} from "src/components/ui/card";
import { Checkbox } from "src/components/ui/checkbox";
import { useBalances } from "src/hooks/useBalances";
import { useInfo } from "src/hooks/useInfo";
import OnboardingChecklist from "src/screens/wallet/OnboardingChecklist";

function Wallet() {
const { data: info } = useInfo();
Expand Down Expand Up @@ -103,83 +103,11 @@ function Wallet() {
)}
</div>

<Card>
<CardHeader>
<CardTitle>Get started with your Alby Hub</CardTitle>
<CardDescription>Some first steps to get you started</CardDescription>
</CardHeader>
<CardContent className="flex flex-col gap-3">
<CheckboxItem
id="open-channel"
title="Open your first channel"
description="alkdsfjla ksdjflaksjdfljaksdf "
checked={true}
/>
<CheckboxItem
id="link-alby"
title="Link your Alby Account"
description="description"
checked={true}
/>
<CheckboxItem
id="create-app"
title="Create your first app connection"
description="description"
checked={false}
/>
<CheckboxItem
id="backup-keys"
title="Backup your keys"
description="description"
checked={false}
/>
<CheckboxItem
id="make-payment"
title="Make first payment"
description="description"
checked={false}
/>
<CheckboxItem
id="help-friend"
title="Help a friend to get on lightning"
description="description"
checked={false}
/>
</CardContent>
</Card>
<OnboardingChecklist />

<BreezRedeem />
</>
);
}

function CheckboxItem({
id,
title,
checked,
description,
}: {
id: string;
title: string;
checked: boolean;
description: string;
}) {
return (
<div className="flex flex-col gap-1">
<div className="flex items-center gap-2">
<Checkbox id={id} checked={checked} />
<label
htmlFor={id}
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
{title}
</label>
</div>
{!checked && (
<div className="text-muted-foreground text-sm ml-6">{description}</div>
)}
</div>
);
}

export default Wallet;

0 comments on commit b3c2af7

Please sign in to comment.