Skip to content

Commit

Permalink
Merge branch 'master' into getAlby#2573
Browse files Browse the repository at this point in the history
  • Loading branch information
Rithvik-padma committed Dec 25, 2023
2 parents 719109f + ef11719 commit 6121ffd
Show file tree
Hide file tree
Showing 23 changed files with 964 additions and 178 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
"dependencies": {
"@bitcoin-design/bitcoin-icons-react": "^0.1.10",
"@bitcoinerlab/secp256k1": "^1.0.5",
"@getalby/sdk": "^3.1.0",
"@getalby/sdk": "^3.2.2",
"@headlessui/react": "^1.7.16",
"@lightninglabs/lnc-web": "^0.2.4-alpha",
"@noble/curves": "^1.1.0",
"@noble/secp256k1": "^2.0.0",
"@popicons/react": "^0.0.8",
"@scure/bip32": "^1.3.1",
"@scure/bip39": "^1.2.1",
"@tailwindcss/forms": "^0.5.4",
Expand Down Expand Up @@ -104,6 +105,7 @@
"@types/webextension-polyfill": "^0.10.5",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@webbtc/webln-types": "^3.0.0",
"autoprefixer": "^10.4.16",
"buffer": "^6.0.3",
"clean-webpack-plugin": "^4.0.0",
Expand Down
16 changes: 9 additions & 7 deletions src/app/components/ConnectorPath/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ type Props = {
description: string;
content: React.ReactNode;
actions: React.ReactNode;
icon: React.ReactNode;
};

function ConnectorPath({ title, description, content, actions }: Props) {
function ConnectorPath({ title, icon, description, content, actions }: Props) {
return (
<div className="shadow-lg p-10 rounded-xl bg-white dark:bg-surface-02dp text-center">
<h1 className="text-2xl font-bold dark:text-white">{title}</h1>
<p className="text-gray-500 mt-4 dark:text-neutral-400 min-h-[48px]">
{description}
</p>
<div className="lg:h-56 py-4 flex flex-col justify-center items-center">
<div className="flex flex-col p-10 border border-neutral-200 dark:border-neutral-700 rounded-2xl bg-white dark:bg-surface-02dp">
<div className="flex flex-row items-center mb-4 space-x-3">
{icon}
<h1 className="text-xl font-bold dark:text-white">{title}</h1>
</div>
<p className="text-gray-800 dark:text-neutral-200 mb-6">{description}</p>
<div className="flex flex-col space-y-4 text-sm mb-8 dark:text-white">
{content}
</div>
<div className="flex gap-4 flex-col sm:flex-row">{actions}</div>
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/LinkButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ type Props = {

export default function LinkButton({ to, title, logo }: Props) {
return (
<Link to={to} className="block">
<div className="p-4 bg-white dark:bg-surface-02dp h-64 lg:h-80 text-center shadow overflow-hidden border-b border-gray-300 dark:border-neutral-700 rounded-lg hover:bg-gray-50 dark:hover:bg-neutral-800 transition duration-200">
<div className="my-4 lg:my-12">
<Link to={to}>
<div className="p-10 h-72 border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-surface-02dp text-center overflow-hidden rounded-lg hover:bg-gray-50 dark:hover:bg-neutral-800 transition duration-200 flex flex-col justify-center space-y-4">
<div>
<img src={logo} alt="logo" className="inline rounded-3xl w-32" />
</div>
<div>
Expand Down
25 changes: 25 additions & 0 deletions src/app/router/connectorRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import ConnectUmbrel from "@screens/connectors/ConnectUmbrel";
import { Route } from "react-router-dom";
import i18n from "~/i18n/i18nConfig";

import ConnectVoltage from "~/app/screens/connectors/ConnectVoltage";
import ConnectNWC from "~/app/screens/connectors/ConnectNWC";
import ConnectCommando from "../screens/connectors/ConnectCommando";
import btcpay from "/static/assets/icons/btcpay.svg";
import citadel from "/static/assets/icons/citadel.png";
Expand All @@ -27,9 +29,11 @@ import lnbits from "/static/assets/icons/lnbits.png";
import lnd from "/static/assets/icons/lnd.png";
import lndhubGo from "/static/assets/icons/lndhub_go.png";
import mynode from "/static/assets/icons/mynode.png";
import nwc from "/static/assets/icons/nwc.svg";
import raspiblitz from "/static/assets/icons/raspiblitz.png";
import start9 from "/static/assets/icons/start9.png";
import umbrel from "/static/assets/icons/umbrel.png";
import voltage from "/static/assets/icons/voltage.png";

export const normalizeKey = (key: string) =>
key as unknown as TemplateStringsArray;
Expand Down Expand Up @@ -95,6 +99,12 @@ const connectorMap: { [key: string]: ConnectorRoute } = {
title: i18n.t("translation:choose_connector.lnd.title"),
logo: lnd,
},
"voltage-lnd": {
path: "lnd",
element: <ConnectVoltage />,
title: i18n.t("translation:choose_connector.lnd.title"),
logo: lnd,
},
lnc: {
path: "lnc",
element: <ConnectLnc />,
Expand Down Expand Up @@ -149,6 +159,18 @@ const connectorMap: { [key: string]: ConnectorRoute } = {
title: i18n.t("translation:choose_connector.btcpay.title"),
logo: btcpay,
},
voltage: {
path: "voltage",
element: <ConnectVoltage />,
title: i18n.t("translation:choose_connector.voltage.title"),
logo: voltage,
},
nwc: {
path: "nwc",
element: <ConnectNWC />,
title: i18n.t("translation:choose_connector.nwc.title"),
logo: nwc,
},
};

function getDistribution(key: string): ConnectorRoute {
Expand Down Expand Up @@ -188,6 +210,7 @@ const distributionMap: { [key: string]: { logo: string; children: Route[] } } =
connectorMap["lnc"],
connectorMap["commando"],
connectorMap["lnbits"],
connectorMap["nwc"],
],
},
mynode: {
Expand Down Expand Up @@ -228,13 +251,15 @@ function getConnectorRoutes(): ConnectorRoute[] {
connectorMap["lnd-hub-go"],
connectorMap["eclair"],
connectorMap["btcpay"],
connectorMap["voltage"],
connectorMap[galoyPaths.blink],
connectorMap[galoyPaths.bitcoinJungle],
getDistribution("citadel"),
getDistribution("umbrel"),
getDistribution("mynode"),
getDistribution("start9"),
getDistribution("raspiblitz"),
connectorMap["nwc"],
];
}

Expand Down
8 changes: 5 additions & 3 deletions src/app/screens/ReceiveInvoice/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,11 @@ function ReceiveInvoice() {
{t("title")}
</Header>
{invoice ? (
<Container justifyBetween maxWidth="sm">
{renderInvoice()}
</Container>
<div className="h-full">
<Container justifyBetween maxWidth="sm">
{renderInvoice()}
</Container>
</div>
) : (
<div className="pt-4 h-full">
<form onSubmit={handleSubmit} className="h-full">
Expand Down
42 changes: 20 additions & 22 deletions src/app/screens/connectors/ChooseConnector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,26 @@ export default function ChooseConnector({
}: Props) {
return (
<>
<div className="relative mt-14 mb-4 lg:mb-14 lg:grid lg:gap-8 text-center">
<div className="relative">
<div className="mb-6 flex flex-col items-center w-full">
<h1 className="text-3xl font-bold dark:text-white max-md:w-64">
{title}
</h1>
{description && (
<p className="text-gray-500 mt-6 dark:text-neutral-400">
{description}
</p>
)}
</div>
<div className="flex flex-row flex-wrap justify-center -mb-4 -mx-2">
{connectorRoutes.map(({ path, title, logo }) => (
<div
key={path}
className="w-full sm:w-1/2 md:w-1/3 lg:w-1/4 mb-4 px-2"
>
<LinkButton to={path} title={title} logo={logo} />
</div>
))}
</div>
<div className="mt-14 mb-4 lg:mb-14 lg:grid lg:gap-8 text-center">
<div className="mb-6 flex flex-col items-center w-full">
<h1 className="text-3xl font-bold dark:text-white max-md:w-64">
{title}
</h1>
{description && (
<p className="text-gray-500 mt-6 dark:text-neutral-400">
{description}
</p>
)}
</div>
<div className="flex flex-row flex-wrap justify-center -mb-4 -mx-2">
{connectorRoutes.map(({ path, title, logo }) => (
<div
key={path}
className="w-full sm:w-1/2 md:w-1/3 lg:w-1/4 mb-4 px-2"
>
<LinkButton to={path} title={title} logo={logo} />
</div>
))}
</div>
</div>
</>
Expand Down
149 changes: 113 additions & 36 deletions src/app/screens/connectors/ChooseConnectorPath/index.tsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,143 @@
import {
PopiconsCircleCheckLine,
PopiconsCircleExclamationLine,
PopiconsCircleXLine,
} from "@popicons/react";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import Button from "~/app/components/Button";
import ConnectorPath from "~/app/components/ConnectorPath";
import { getConnectorRoutes } from "~/app/router/connectorRoutes";
import ConnectAlby from "~/app/screens/connectors/ConnectAlby";
import i18n from "~/i18n/i18nConfig";

import alby from "/static/assets/icons/alby.png";

export default function ChooseConnectorPath() {
let connectorRoutes = getConnectorRoutes();

i18n.on("languageChanged", () => {
connectorRoutes = getConnectorRoutes();
});
const { t } = useTranslation("translation", {
keyPrefix: "choose_path",
});

return (
<div className="relative mt-10 lg:grid lg:gap-8 text-center">
<div className="relative mt-10 lg:grid lg:gap-8">
<div className="relative">
<div className="grid lg:grid-cols-2 gap-10 mb-4">
<h1 className="text-2xl font-bold dark:text-white text-center mb-8">
{t("title")}
</h1>
<div className="grid lg:grid-cols-3 gap-5 mb-4">
<ConnectorPath
title={t("alby.title")}
description={t("alby.description")}
title={t("other.title")}
icon={
<div className="grid grid-cols-2 gap-1">
<img
src="assets/icons/lnd.png"
className="w-[18px] h-[18px] rounded-md"
/>
<img
src="assets/icons/umbrel.png"
className="w-[18px] h-[18px] rounded-md"
/>
<img
src="assets/icons/btcpay.svg"
className="w-[18px] h-[18px] rounded-md"
/>
<img
src="assets/icons/core_ln.png"
className="w-[18px] h-[18px] rounded-md"
/>
</div>
}
description={t("other.description")}
content={
<img src={alby} alt="logo" className="inline rounded-3xl w-32" />
<>
<FeatureItem type="success">{t("other.point1")}</FeatureItem>
<FeatureItem type="success">{t("other.point2")}</FeatureItem>
<FeatureItem type="success">{t("other.point3")}</FeatureItem>
<FeatureItem type="disabled">{t("other.point4")}</FeatureItem>
</>
}
actions={
<Link to="choose-connector" className="flex flex-1">
<Button tabIndex={-1} label={t("other.connect")} primary flex />
</Link>
}
actions={<ConnectAlby />}
/>
<ConnectorPath
title={t("other.title")}
description={t("other.description")}
title={t("voltage.title")}
icon={<img src="assets/icons/voltage.png" className="w-10 h-10" />}
description={t("voltage.description")}
content={
<>
<FeatureItem type="success">{t("voltage.point1")}</FeatureItem>
<FeatureItem type="success">{t("voltage.point2")}</FeatureItem>
<FeatureItem type="success">{t("voltage.point3")}</FeatureItem>
<FeatureItem type="success">{t("voltage.point4")}</FeatureItem>
</>
}
actions={
<Link
to="choose-connector"
className="flex flex-wrap gap-6 w-72 lg:w-80 mx-auto my-5 items-center"
tabIndex={-1}
to="/accounts/new/choose-connector/voltage"
rel="noreferrer noopener"
className="flex flex-1"
>
{connectorRoutes.slice(1, 8).map(({ path, title, logo }) => (
<img
key={path}
title={title}
src={logo}
alt="logo"
className="inline rounded-lg w-12"
/>
))}
<p className="text-gray-500 dark:text-neutral-400">
{t("other.and_more")}
</p>
<Button
tabIndex={-1}
label={t("voltage.connect")}
primary
flex
/>
</Link>
}
actions={
<Link to="choose-connector" className="flex flex-1">
<Button tabIndex={-1} label={t("other.connect")} primary flex />
</Link>
/>
<ConnectorPath
title={t("alby.title")}
icon={
<img
src="assets/icons/alby.png"
className="w-10 h-10 rounded-md"
/>
}
description={t("alby.description")}
content={
<>
<FeatureItem type="warning">{t("alby.point1")}</FeatureItem>
<FeatureItem type="warning">{t("alby.point2")}</FeatureItem>
<FeatureItem type="success">{t("alby.point3")}</FeatureItem>
<FeatureItem type="success">{t("alby.point4")}</FeatureItem>
</>
}
actions={<ConnectAlby />}
/>
</div>
</div>
</div>
);
}

const FeatureItem = ({
type,
children,
}: {
type: "success" | "disabled" | "warning";
children: React.ReactNode;
}) => (
<div className="flex flex-row items-center space-2">
<div className="mr-2">
{type == "success" && (
<PopiconsCircleCheckLine
key="success"
className="text-green-600 dark:text-green-400 w-6 h-6"
/>
)}
{type == "disabled" && (
<PopiconsCircleXLine
key="disabled"
className="text-gray-400 dark:text-neutral-500 w-6 h-6"
/>
)}
{type == "warning" && (
<PopiconsCircleExclamationLine
key="warning"
className="text-orange-500 w-6 h-6"
/>
)}
</div>
<div className="grow">{children}</div>
</div>
);
2 changes: 1 addition & 1 deletion src/app/screens/connectors/ConnectAlby/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export default function ConnectAlby() {
label={t("connect")}
loading={loading}
disabled={loading}
primary
flex
outline
onClick={connectAlby}
/>
);
Expand Down
Loading

0 comments on commit 6121ffd

Please sign in to comment.