mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-18 06:44:27 +01:00
format everything with prettier
This commit is contained in:
@@ -1,69 +1,83 @@
|
||||
import { Card, VStack } from "~/components/layout";
|
||||
import { useCopy } from "~/utils/useCopy";
|
||||
import copyIcon from "~/assets/icons/copy.svg"
|
||||
import shareIcon from "~/assets/icons/share.svg"
|
||||
import eyeIcon from "~/assets/icons/eye.svg"
|
||||
import copyIcon from "~/assets/icons/copy.svg";
|
||||
import shareIcon from "~/assets/icons/share.svg";
|
||||
import eyeIcon from "~/assets/icons/eye.svg";
|
||||
import { Show, createSignal } from "solid-js";
|
||||
import { JsonModal } from "./JsonModal";
|
||||
|
||||
const STYLE = "px-4 py-2 rounded-xl border-2 border-white flex gap-2 items-center font-semibold hover:text-m-blue transition-colors"
|
||||
const STYLE =
|
||||
"px-4 py-2 rounded-xl border-2 border-white flex gap-2 items-center font-semibold hover:text-m-blue transition-colors";
|
||||
|
||||
export function ShareButton(props: { receiveString: string }) {
|
||||
async function share(receiveString: string) {
|
||||
// If the browser doesn't support share we can just copy the address
|
||||
if (!navigator.share) {
|
||||
console.error("Share not supported")
|
||||
console.error("Share not supported");
|
||||
}
|
||||
const shareData: ShareData = {
|
||||
title: "Mutiny Wallet",
|
||||
text: receiveString,
|
||||
}
|
||||
text: receiveString
|
||||
};
|
||||
try {
|
||||
await navigator.share(shareData)
|
||||
await navigator.share(shareData);
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<button class={STYLE} onClick={(_) => share(props.receiveString)}><span>Share</span><img src={shareIcon} alt="share" /></button>
|
||||
)
|
||||
<button class={STYLE} onClick={(_) => share(props.receiveString)}>
|
||||
<span>Share</span>
|
||||
<img src={shareIcon} alt="share" />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function TruncateMiddle(props: { text: string }) {
|
||||
return (
|
||||
<div class="flex text-neutral-400 font-mono">
|
||||
<span class="truncate">{props.text}</span>
|
||||
<span class="pr-2">{props.text.length > 8 ? props.text.slice(-8) : ""}</span>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div class="flex text-neutral-400 font-mono">
|
||||
<span class="truncate">{props.text}</span>
|
||||
<span class="pr-2">
|
||||
{props.text.length > 8 ? props.text.slice(-8) : ""}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function StringShower(props: { text: string }) {
|
||||
const [open, setOpen] = createSignal(false);
|
||||
return (
|
||||
<>
|
||||
<JsonModal open={open()} plaintext={props.text} title="Details" setOpen={setOpen} />
|
||||
<div class="w-full grid grid-cols-[minmax(0,_1fr)_auto]">
|
||||
<TruncateMiddle text={props.text} />
|
||||
<button class="w-[2rem]" onClick={() => setOpen(true)}>
|
||||
<img src={eyeIcon} alt="eye" />
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
const [open, setOpen] = createSignal(false);
|
||||
return (
|
||||
<>
|
||||
<JsonModal
|
||||
open={open()}
|
||||
plaintext={props.text}
|
||||
title="Details"
|
||||
setOpen={setOpen}
|
||||
/>
|
||||
<div class="w-full grid grid-cols-[minmax(0,_1fr)_auto]">
|
||||
<TruncateMiddle text={props.text} />
|
||||
<button class="w-[2rem]" onClick={() => setOpen(true)}>
|
||||
<img src={eyeIcon} alt="eye" />
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function CopyButton(props: { text?: string, title?: string }) {
|
||||
export function CopyButton(props: { text?: string; title?: string }) {
|
||||
const [copy, copied] = useCopy({ copiedTimeout: 1000 });
|
||||
|
||||
function handleCopy() {
|
||||
copy(props.text ?? "")
|
||||
copy(props.text ?? "");
|
||||
}
|
||||
|
||||
return (
|
||||
<button class={STYLE} onClick={handleCopy}>{copied() ? "Copied" : props.title ?? "Copy"}<img src={copyIcon} alt="copy" /></button>
|
||||
)
|
||||
<button class={STYLE} onClick={handleCopy}>
|
||||
{copied() ? "Copied" : props.title ?? "Copy"}
|
||||
<img src={copyIcon} alt="copy" />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export function ShareCard(props: { text?: string }) {
|
||||
@@ -78,7 +92,6 @@ export function ShareCard(props: { text?: string }) {
|
||||
</Show>
|
||||
</div>
|
||||
</VStack>
|
||||
</Card >
|
||||
)
|
||||
|
||||
}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user