blowater/app/UI/key-view.tsx

67 lines
2.4 KiB
TypeScript
Raw Normal View History

2023-06-30 14:05:57 +00:00
/** @jsx h */
import { Fragment, h } from "https://esm.sh/preact@10.17.1";
2024-01-01 17:28:10 +00:00
import { PrivateKey, PublicKey } from "../../libs/nostr.ts/key.ts";
import { InputClass } from "./components/tw.ts";
import { PrimaryTextColor, TitleIconColor, WarnColor } from "./style/colors.ts";
2023-11-11 11:19:21 +00:00
import { KeyIcon } from "./icons/key-icon.tsx";
2023-11-15 02:45:34 +00:00
import { CopyButton } from "./components/copy-button.tsx";
2023-06-30 14:05:57 +00:00
export default function KeyView(props: {
publicKey: PublicKey;
privateKey: PrivateKey | undefined;
}) {
const privateKey = props.privateKey;
return (
<Fragment>
2023-12-18 10:23:15 +00:00
<p class={`text-[${PrimaryTextColor}] text-[1.3125rem] flex font-bold`}>
2023-06-30 14:05:57 +00:00
<KeyIcon
2023-12-18 10:23:15 +00:00
class={`w-[2rem] h-[2rem] mr-[1rem]`}
2023-06-30 14:05:57 +00:00
style={{
stroke: TitleIconColor,
fill: "none",
}}
/>
Key Pair
</p>
2023-12-18 10:23:15 +00:00
<p class={`mt-[1.75rem] text-[${PrimaryTextColor}]`}>Public Key</p>
<div class={`relative`}>
2023-06-30 14:05:57 +00:00
<input
value={props.publicKey.bech32()}
disabled
type="text"
2023-12-18 10:23:15 +00:00
class={`${InputClass} overflow-x-auto pr-[4rem]`}
2023-06-30 14:05:57 +00:00
/>
2023-11-15 02:45:34 +00:00
<CopyButton
2023-12-18 10:23:15 +00:00
class={`absolute right-4 top-4`}
2023-11-15 02:45:34 +00:00
text={props.publicKey.bech32()}
/>
2023-06-30 14:05:57 +00:00
</div>
2023-12-18 10:23:15 +00:00
<p class={`mt-[1.5rem] text-[${PrimaryTextColor}]`}>Private Key</p>
<div class={`relative`}>
2023-06-30 14:05:57 +00:00
<input
value="●●●●●●"
disabled
2023-11-15 02:45:34 +00:00
type="password"
2023-12-18 10:23:15 +00:00
class={`${InputClass} overflow-x-auto pr-[4rem]`}
2023-06-30 14:05:57 +00:00
/>
{privateKey
? (
2023-11-15 02:45:34 +00:00
<CopyButton
2023-12-18 10:23:15 +00:00
class={`absolute right-4 top-4`}
2023-11-15 02:45:34 +00:00
text={privateKey.bech32}
/>
2023-06-30 14:05:57 +00:00
)
: undefined}
</div>
{!privateKey
? (
2023-12-18 10:23:15 +00:00
<p class={`text-[${WarnColor}] text-[0.875rem] mt-[0.5rem]`}>
2023-06-30 14:05:57 +00:00
Blowater cannot view your private key because you logged in with an extension.
</p>
)
: undefined}
</Fragment>
);
}