From 9309800ccd78ab390f2c8a8be933fca6e7474a39 Mon Sep 17 00:00:00 2001 From: blue Date: Thu, 21 Dec 2023 22:06:50 +0900 Subject: [PATCH 1/7] refactor. Separate secure-textarea and improve attributes in SeedBox component --- .../src/components/atoms/index.ts | 1 + .../atoms/secure-textarea/index.tsx | 47 +++++++++++++ .../components/molecules/seed-box/index.tsx | 67 ++++--------------- .../certify/approach-private-phrase/index.tsx | 60 ++++++++++------- .../src/pages/certify/enter-seed/index.tsx | 7 +- .../pages/certify/import-account/index.tsx | 7 +- .../certify/import-private-key/index.tsx | 12 +--- .../certify/reveal-private-phrase/index.tsx | 2 +- .../pages/certify/view-seed-phrase/index.tsx | 2 +- .../pages/certify/your-seed-phrase/index.tsx | 1 - 10 files changed, 109 insertions(+), 97 deletions(-) create mode 100644 packages/adena-extension/src/components/atoms/secure-textarea/index.tsx diff --git a/packages/adena-extension/src/components/atoms/index.ts b/packages/adena-extension/src/components/atoms/index.ts index 056e0f44..e68b2b43 100644 --- a/packages/adena-extension/src/components/atoms/index.ts +++ b/packages/adena-extension/src/components/atoms/index.ts @@ -24,3 +24,4 @@ export * from './copy-button'; export * from './full-button-right-icon'; export * from './hamburger-menu-button'; export * from './skeleton-box'; +export * from './secure-textarea'; diff --git a/packages/adena-extension/src/components/atoms/secure-textarea/index.tsx b/packages/adena-extension/src/components/atoms/secure-textarea/index.tsx new file mode 100644 index 00000000..5f91a024 --- /dev/null +++ b/packages/adena-extension/src/components/atoms/secure-textarea/index.tsx @@ -0,0 +1,47 @@ +import React from 'react'; +import styled, { FlattenSimpleInterpolation } from 'styled-components'; + +interface SecureTextareaProps { + value: string; + onChange: (e: React.ChangeEvent) => void; + onKeyDown: (e: React.KeyboardEvent) => void; + error: boolean; +} + +const StyledWrapper = styled.div<{ error: boolean }>` + position: relative; + width: 100%; + height: 140px; + border: 1px solid + ${({ error, theme }): string => (error ? theme.color.red[2] : theme.color.neutral[6])}; + background-color: ${({ theme }): string => theme.color.neutral[8]}; + border-radius: 18px; + overflow-y: auto; + padding: 14px 16px 8px; + margin-top: 20px; +`; + +const StyledTextarea = styled.textarea` + ${({ theme }): FlattenSimpleInterpolation => theme.fonts.body2Reg}; + width: 100%; + word-wrap: break-word; + background-color: inherit; + border: none; + outline: none; + color: white; + resize: none; + -webkit-text-security: disc; +`; + +export const SecureTextarea = ({ + value, + onChange, + onKeyDown, + error = false, +}: SecureTextareaProps): JSX.Element => { + return ( + + + + ); +}; diff --git a/packages/adena-extension/src/components/molecules/seed-box/index.tsx b/packages/adena-extension/src/components/molecules/seed-box/index.tsx index ab543d54..3fb7454b 100644 --- a/packages/adena-extension/src/components/molecules/seed-box/index.tsx +++ b/packages/adena-extension/src/components/molecules/seed-box/index.tsx @@ -1,38 +1,23 @@ import React from 'react'; -import styled, { CSSProp, FlattenSimpleInterpolation, css } from 'styled-components'; +import styled, { CSSProp } from 'styled-components'; import { Text, BlurScreen } from '../../atoms'; interface SeedScrollBoxProps { - value?: string; - onChange?: (e: React.ChangeEvent) => void; - onKeyDown?: (e: React.KeyboardEvent) => void; - error?: boolean; - scroll: boolean; - seeds?: string[] | string; + seeds: string[]; hasBlurScreen?: boolean; hasBlurText?: boolean; blurScreenText?: string; className?: string; } -const Wrapper = styled.div<{ error: boolean; scroll: boolean }>` +const Wrapper = styled.div` position: relative; width: 100%; height: 140px; - border: 1px solid - ${({ error, theme }): string => (error ? theme.color.red[2] : theme.color.neutral[6])}; + border: 1px solid ${({ theme }): string => theme.color.neutral[6]}; background-color: ${({ theme }): string => theme.color.neutral[8]}; border-radius: 18px; - ${({ scroll }): CSSProp => - scroll - ? css` - overflow-y: auto; - padding: 14px 16px 8px; - margin-top: 20px; - ` - : css` - padding: 8px; - `} + padding: 8px; `; const Inner = styled.div` @@ -48,48 +33,22 @@ const Inner = styled.div` } `; -const Textarea = styled.textarea` - ${({ theme }): FlattenSimpleInterpolation => theme.fonts.body2Reg}; - width: 100%; - word-wrap: break-word; - background-color: inherit; - border: none; - outline: none; - color: white; - resize: none; -`; - export const SeedBox = ({ seeds, - value, - onChange, - onKeyDown, - error = false, - scroll, hasBlurScreen = false, hasBlurText = false, blurScreenText = '', className = '', }: SeedScrollBoxProps): JSX.Element => { return ( - - {scroll && ( -