From 6388af62fb1933816240c99bf118e999c6d5ffbb Mon Sep 17 00:00:00 2001 From: whitetechna Date: Mon, 16 Dec 2024 11:29:02 +0000 Subject: [PATCH] fix the ui of mnemonic page --- .../Core/components/Mnemonic/Mnemonic.tsx | 141 +++++++++--------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/packages/app/src/systems/Core/components/Mnemonic/Mnemonic.tsx b/packages/app/src/systems/Core/components/Mnemonic/Mnemonic.tsx index 686dcdfb6..798309819 100644 --- a/packages/app/src/systems/Core/components/Mnemonic/Mnemonic.tsx +++ b/packages/app/src/systems/Core/components/Mnemonic/Mnemonic.tsx @@ -1,15 +1,16 @@ -import { cssObj } from '@fuel-ui/css'; -import { Box, Button, Grid, Icon, toast } from '@fuel-ui/react'; -import { MNEMONIC_SIZES } from 'fuels'; -import type { ClipboardEvent } from 'react'; -import { useEffect, useState } from 'react'; +import { cssObj } from "@fuel-ui/css"; +import { Box, Button, Grid, Icon, toast } from "@fuel-ui/react"; +import { MNEMONIC_SIZES } from "fuels"; +import type { ClipboardEvent } from "react"; +import { useEffect, useState } from "react"; -import { MnemonicInput } from './MnemonicInput'; +import { MnemonicInput } from "./MnemonicInput"; +import React from "react"; const WORDS = import.meta.env.VITE_MNEMONIC_WORDS; function fillArray(item: string[], format: number) { - return Array.from({ length: format }).map((_, idx) => item[idx] || ''); + return Array.from({ length: format }).map((_, idx) => item[idx] || ""); } function splitSeedPhrase(str: string) { @@ -17,8 +18,8 @@ function splitSeedPhrase(str: string) { } function checkMoreThanOneWord(word: string) { - if (word.split(' ').length > 1) { - const first = word.split(' ')[0]; + if (word.split(" ").length > 1) { + const first = word.split(" ")[0]; const half = first.slice(0, first.length / 2); return `${half}${half}` === first ? half : first; } @@ -26,7 +27,7 @@ function checkMoreThanOneWord(word: string) { } export type MnemonicProps = { - type: 'read' | 'write'; + type: "read" | "write"; value?: string[]; onFilled?: (val: string[]) => void; onChange?: (val: string[]) => void; @@ -58,9 +59,9 @@ export function Mnemonic({ ); async function handleCopy() { - const val = type === 'read' ? initialValue : value; - await navigator.clipboard.writeText(val.join(' ')); - toast.success('Seed phrase copied to clipboard'); + const val = type === "read" ? initialValue : value; + await navigator.clipboard.writeText(val.join(" ")); + toast.success("Seed phrase copied to clipboard"); } function handlePaste(words: string[]) { @@ -73,7 +74,7 @@ export function Mnemonic({ } function handlePasteInput(ev: ClipboardEvent, idx: number) { - const text = ev.clipboardData.getData('text/plain'); + const text = ev.clipboardData.getData("text/plain"); const words = splitSeedPhrase(text); // Only allow paste on the first input or @@ -132,7 +133,7 @@ export function Mnemonic({ )} - {type === 'read' ? ( + {type === "read" ? ( {initialValue?.map((word, idx) => ( // biome-ignore lint/suspicious/noArrayIndexKey: @@ -162,7 +163,7 @@ export function Mnemonic({ )} - {type === 'read' ? ( + {type === "read" ? (