diff --git a/packages/adena-extension/src/common/utils/client-utils.ts b/packages/adena-extension/src/common/utils/client-utils.ts index c8ddabbf..bb9c62d0 100644 --- a/packages/adena-extension/src/common/utils/client-utils.ts +++ b/packages/adena-extension/src/common/utils/client-utils.ts @@ -181,17 +181,17 @@ export function getStatusStyle(status: string): { color: string; statusIcon: any switch (status) { case 'SUCCESS': return { - color: theme.color.green[2], + color: theme.green._5, statusIcon: success, }; case 'FAIL': return { - color: theme.color.red[2], + color: theme.red._5, statusIcon: failed, }; default: return { - color: theme.color.red[2], + color: theme.red._5, statusIcon: failed, }; } diff --git a/packages/adena-extension/src/components/atoms/blur-screen/index.tsx b/packages/adena-extension/src/components/atoms/blur-screen/index.tsx index 4ac6faa4..9ed759fb 100644 --- a/packages/adena-extension/src/components/atoms/blur-screen/index.tsx +++ b/packages/adena-extension/src/components/atoms/blur-screen/index.tsx @@ -1,7 +1,9 @@ import React from 'react'; -import styled, { CSSProp } from 'styled-components'; +import styled from 'styled-components'; + import { Text, Icon } from '@components/atoms'; import blurBg from '@assets/blur-bg.svg'; +import mixins from '@styles/mixins'; interface BlurScreenProps { hasText?: boolean; @@ -20,8 +22,8 @@ export const BlurScreen = ({ hasText, text }: BlurScreenProps): JSX.Element => { }; const Wrapper = styled.div<{ hasText?: boolean }>` - ${({ theme }): CSSProp => theme.mixins.flexbox('column', 'center', 'center')}; - ${({ theme }): CSSProp => theme.mixins.positionCenter()}; + ${mixins.flex('column', 'center', 'center')}; + ${mixins.positionCenter()}; gap: ${({ hasText }): false | '21px' | undefined => hasText && '21px'}; background: url(${blurBg}) no-repeat 100% 100% / 100% 100%; width: calc(100% - 12px); diff --git a/packages/adena-extension/src/components/atoms/button/index.tsx b/packages/adena-extension/src/components/atoms/button/index.tsx index af990952..0b1caa22 100644 --- a/packages/adena-extension/src/components/atoms/button/index.tsx +++ b/packages/adena-extension/src/components/atoms/button/index.tsx @@ -1,78 +1,72 @@ import styled, { css } from 'styled-components'; import React, { CSSProperties } from 'react'; import mixins from '@styles/mixins'; +import { getTheme } from '@styles/theme'; type Without = { [P in Exclude]?: never }; type XOR = T | U extends Record ? (Without & U) | (Without & T) : T | U; -export enum ButtonHierarchy { - Normal = 'normal', - Primary = 'Primary', - Ghost = 'Ghost', - Dark = 'Dark', - Danger = 'Danger', - Custom = 'Custom', -} +type ButtonHierarchy = 'normal' | 'primary' | 'ghost' | 'dark' | 'danger' | 'custom'; export const modeVariants = { normal: css` - background: ${({ theme }): string => theme.color.neutral[6]}; + background: ${getTheme('neutral', '_7')}; &:hover { - background: ${({ theme }): string => theme.color.neutral[11]}; + background: ${getTheme('neutral', 'b')}; } /* &:disabled { - background: ${({ theme }): string => theme.color.primary[6]}; - color: ${({ theme }): string => theme.color.neutral[4]}; + background: ${getTheme('primary', '_9')}; + color: ${getTheme('neutral', '_5')}; } */ `, primary: css` - background: ${({ theme }): string => theme.color.primary[3]}; + background: ${getTheme('primary', '_6')}; &:hover { - background: ${({ theme }): string => theme.color.primary[4]}; + background: ${getTheme('primary', '_7')}; } &:disabled { - background: ${({ theme }): string => theme.color.primary[6]}; - color: ${({ theme }): string => theme.color.neutral[4]}; + background: ${getTheme('primary', '_9')}; + color: ${getTheme('neutral', '_5')}; } `, ghost: css` - background: ${({ theme }): string => theme.color.neutral[8]}; - border: 1px solid ${({ theme }): string => theme.color.neutral[2]}; + background: ${getTheme('neutral', '_9')}; + border: 1px solid ${getTheme('neutral', '_3')}; &:hover { - background: ${({ theme }): string => theme.color.neutral[5]}; - border: 1px solid ${({ theme }): string => theme.color.neutral[2]}; + background: ${getTheme('neutral', '_6')}; + border: 1px solid ${getTheme('neutral', '_3')}; } &:disabled { - background: ${({ theme }): string => theme.color.neutral[6]}; - border: 1px solid ${({ theme }): string => theme.color.neutral[3]}; - color: ${({ theme }): string => theme.color.neutral[4]}; + background: ${getTheme('neutral', '_7')}; + border: 1px solid ${getTheme('neutral', '_4')}; + color: ${getTheme('neutral', '_5')}; } `, dark: css` - background: ${({ theme }): string => theme.color.neutral[4]}; + background: ${getTheme('neutral', '_5')}; &:hover { - background: ${({ theme }): string => theme.color.neutral[5]}; + background: ${getTheme('neutral', '_6')}; } &:disabled { - background: ${({ theme }): string => theme.color.neutral[5]}; - color: ${({ theme }): string => theme.color.neutral[4]}; + background: ${getTheme('neutral', '_6')}; + color: ${getTheme('neutral', '_5')}; } `, danger: css` - background: ${({ theme }): string => theme.color.red[2]}; + background: ${getTheme('red', '_5')}; &:hover { - background: ${({ theme }): string => theme.color.red[8]}; + background: #bb150b; } /* &:disabled { - background: ${({ theme }): string => theme.color.neutral[5]}; - color: ${({ theme }): string => theme.color.neutral[4]}; + background: ${getTheme('neutral', '_6')}; + color: ${getTheme('neutral', '_5')}; } */ `, }; -type ButtonProps = XOR< +export type ButtonProps = XOR< { fullWidth?: boolean; height?: CSSProperties['height']; @@ -106,7 +100,7 @@ export const Button = (props: ButtonProps): JSX.Element => { }; const ButtonWrapper = styled.button` - ${mixins.flexbox('row', 'center', 'center')}; + ${mixins.flex('row', 'center', 'center')}; width: ${({ width, fullWidth }): string => { if (width) return typeof width === 'number' ? `${width}px` : width; if (fullWidth) return '100%'; @@ -118,19 +112,19 @@ const ButtonWrapper = styled.button` }}; margin: ${(props): any => props.margin}; ${({ hierarchy, bgColor }): any => { - if (hierarchy === ButtonHierarchy.Primary) return modeVariants.primary; - if (hierarchy === ButtonHierarchy.Normal) return modeVariants.normal; - if (hierarchy === ButtonHierarchy.Ghost) return modeVariants.ghost; - if (hierarchy === ButtonHierarchy.Dark) return modeVariants.dark; - if (hierarchy === ButtonHierarchy.Danger) return modeVariants.danger; - if (hierarchy === ButtonHierarchy.Custom) + if (hierarchy === 'primary') return modeVariants.primary; + if (hierarchy === 'normal') return modeVariants.normal; + if (hierarchy === 'ghost') return modeVariants.ghost; + if (hierarchy === 'dark') return modeVariants.dark; + if (hierarchy === 'danger') return modeVariants.danger; + if (hierarchy === 'custom') return css` background-color: ${bgColor}; `; }}; border-radius: ${({ radius }): string => (radius ? radius : '30px')}; transition: all 0.4s ease; - color: ${({ theme }): string => theme.color.neutral[0]}; + color: ${getTheme('neutral', '_1')}; background-color: ${({ bgColor }): string | undefined => bgColor}; `; diff --git a/packages/adena-extension/src/components/atoms/copy-button/index.tsx b/packages/adena-extension/src/components/atoms/copy-button/index.tsx index dd86ab13..d8713e2b 100644 --- a/packages/adena-extension/src/components/atoms/copy-button/index.tsx +++ b/packages/adena-extension/src/components/atoms/copy-button/index.tsx @@ -1,17 +1,18 @@ import React, { useCallback, useEffect, useState } from 'react'; -import styled, { CSSProp } from 'styled-components'; +import styled, { useTheme } from 'styled-components'; -import theme from '@styles/theme'; +import { getTheme } from '@styles/theme'; import { Text, Button } from '@components/atoms'; +import mixins from '@styles/mixins'; const CopyButton = styled(Button)<{ isClicked: boolean }>` - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'center')}; + ${mixins.flex('row', 'center', 'center')}; height: 25px; border-radius: 12.5px; padding: 0px 12px; transition: background-color 0.4s ease; &:hover { - background-color: ${({ theme }): string => theme.color.neutral[11]}; + background-color: ${getTheme('neutral', 'b')}; } `; @@ -24,6 +25,7 @@ export const Copy = ({ }): JSX.Element => { const [isClicked, setIsClicked] = useState(false); + const theme = useTheme(); const handleButtonClick = useCallback(() => { setIsClicked((prev: boolean) => !prev); navigator.clipboard.writeText(copyStr); @@ -42,7 +44,7 @@ export const Copy = ({ onClick={handleButtonClick} disabled={isClicked} tabIndex={tabIndex && tabIndex} - bgColor={theme.color.neutral[6]} + bgColor={theme.neutral._7} > {isClicked ? 'Copied!' : 'Copy'} diff --git a/packages/adena-extension/src/components/atoms/copy-icon-button/copy-icon-button.styles.ts b/packages/adena-extension/src/components/atoms/copy-icon-button/copy-icon-button.styles.ts index 89cfb4dd..f205334f 100644 --- a/packages/adena-extension/src/components/atoms/copy-icon-button/copy-icon-button.styles.ts +++ b/packages/adena-extension/src/components/atoms/copy-icon-button/copy-icon-button.styles.ts @@ -1,3 +1,4 @@ +import { getTheme } from '@styles/theme'; import styled from 'styled-components'; interface CopyButtonWrapperProps { @@ -14,14 +15,13 @@ export const CopyButtonWrapper = styled.div` svg { path { transition: 0.2s; - stroke: ${({ theme, checked }): string => - checked ? theme.color.neutral[0] : theme.color.neutral[9]}; + stroke: ${({ theme, checked }): string => (checked ? theme.neutral._1 : theme.neutral.a)}; } } :hover svg { path { - stroke: ${({ theme }): string => theme.color.neutral[0]}; + stroke: ${getTheme('neutral', '_1')}; } } `; diff --git a/packages/adena-extension/src/components/atoms/copy-tooltip/index.tsx b/packages/adena-extension/src/components/atoms/copy-tooltip/index.tsx index 8cc05d96..ca5c78fe 100644 --- a/packages/adena-extension/src/components/atoms/copy-tooltip/index.tsx +++ b/packages/adena-extension/src/components/atoms/copy-tooltip/index.tsx @@ -1,6 +1,8 @@ import React, { useCallback, useEffect, useState } from 'react'; -import styled, { CSSProp, FlattenSimpleInterpolation } from 'styled-components'; +import styled from 'styled-components'; import { Text } from '@components/atoms'; +import mixins from '@styles/mixins'; +import { fonts, getTheme } from '@styles/theme'; interface CopyTooltipProps { children: React.ReactNode; @@ -10,15 +12,15 @@ interface CopyTooltipProps { } const ToolTipInner = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'center')}; - ${({ theme }): FlattenSimpleInterpolation => theme.fonts.body2Reg}; + ${mixins.flex('row', 'center', 'center')}; + ${fonts.body2Reg}; position: absolute; width: max-content; height: 25px; visibility: hidden; z-index: 1; padding: 0px 17px; - background-color: ${({ theme }): string => theme.color.neutral[8]}; + background-color: ${getTheme('neutral', '_9')}; border-radius: 13px; transform: scale(0.6); cursor: default; @@ -33,7 +35,7 @@ const ToolTipInner = styled.div` `; const ToolTipWrap = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'center')}; + ${mixins.flex('row', 'center', 'center')}; position: relative; cursor: pointer; &:hover .tooltip, diff --git a/packages/adena-extension/src/components/atoms/custom-network-input/custom-network-input.styles.ts b/packages/adena-extension/src/components/atoms/custom-network-input/custom-network-input.styles.ts index a9867e86..bee71d9b 100644 --- a/packages/adena-extension/src/components/atoms/custom-network-input/custom-network-input.styles.ts +++ b/packages/adena-extension/src/components/atoms/custom-network-input/custom-network-input.styles.ts @@ -1,4 +1,6 @@ -import styled, { FlattenSimpleInterpolation } from 'styled-components'; +import styled from 'styled-components'; + +import { fonts, getTheme } from '@styles/theme'; export const CustomNetworkInputWrapper = styled.div` display: flex; @@ -17,9 +19,9 @@ export const CustomNetworkInputWrapper = styled.div` width: 100%; min-height: 48px; padding: 12px 16px; - ${({ theme }): FlattenSimpleInterpolation => theme.fonts.body2Reg}; - background-color: ${({ theme }): string => theme.color.neutral[8]}; - border: 1px solid ${({ theme }): string => theme.color.neutral[6]}; + ${fonts.body2Reg}; + background-color: ${getTheme('neutral', '_9')}; + border: 1px solid ${getTheme('neutral', '_7')}; border-radius: 30px; align-items: center; margin-top: 12px; @@ -37,7 +39,7 @@ export const CustomNetworkInputWrapper = styled.div` line-height: 25px; ::placeholder { - color: ${({ theme }): string => theme.color.neutral[9]}; + color: ${getTheme('neutral', 'a')}; } } } @@ -46,8 +48,8 @@ export const CustomNetworkInputWrapper = styled.div` .error-message { position: relative; padding: 0 16px; - ${({ theme }): FlattenSimpleInterpolation => theme.fonts.captionReg}; + ${fonts.captionReg}; height: 14px; - color: ${({ theme }): string => theme.color.red[2]}; + color: ${getTheme('red', '_5')}; } `; diff --git a/packages/adena-extension/src/components/atoms/default-input/index.tsx b/packages/adena-extension/src/components/atoms/default-input/index.tsx index 919efba1..020b8c9b 100644 --- a/packages/adena-extension/src/components/atoms/default-input/index.tsx +++ b/packages/adena-extension/src/components/atoms/default-input/index.tsx @@ -1,4 +1,6 @@ -import styled, { FlattenSimpleInterpolation, css } from 'styled-components'; +import styled, { css } from 'styled-components'; + +import { fonts, getTheme } from '@styles/theme'; interface InputProps { error?: boolean; @@ -6,21 +8,20 @@ interface InputProps { } export const inputStyle = css` - ${({ theme }): FlattenSimpleInterpolation => theme.fonts.body2Reg}; + ${fonts.body2Reg}; width: 100%; height: 48px; - background-color: ${({ theme }): string => theme.color.neutral[8]}; - color: ${({ theme }): string => theme.color.neutral[0]}; + background-color: ${getTheme('neutral', '_9')}; + color: ${getTheme('neutral', '_1')}; border-radius: 30px; padding: 14px 16px; ::placeholder { - color: ${({ theme }): string => theme.color.neutral[9]}; + color: ${getTheme('neutral', 'a')}; } `; export const DefaultInput = styled.input` ${inputStyle}; - border: 1px solid - ${({ error, theme }): string => (error ? theme.color.red[2] : theme.color.neutral[6])}; + border: 1px solid ${({ error, theme }): string => (error ? theme.red._5 : theme.neutral._7)}; margin: ${({ margin }): string | undefined => margin && margin}; `; diff --git a/packages/adena-extension/src/components/atoms/error-text/index.tsx b/packages/adena-extension/src/components/atoms/error-text/index.tsx index 1bfb6e01..57adcd2c 100644 --- a/packages/adena-extension/src/components/atoms/error-text/index.tsx +++ b/packages/adena-extension/src/components/atoms/error-text/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import theme from '@styles/theme'; -import styled from 'styled-components'; +import styled, { useTheme } from 'styled-components'; + import { Text } from '../text'; const ErrorMsg = styled(Text)` @@ -9,8 +9,9 @@ const ErrorMsg = styled(Text)` `; export const ErrorText = ({ text }: { text: string }): JSX.Element => { + const theme = useTheme(); return ( - + {text} ); diff --git a/packages/adena-extension/src/components/atoms/full-button-right-icon/index.tsx b/packages/adena-extension/src/components/atoms/full-button-right-icon/index.tsx index d0b5cb1a..d9c3bab9 100644 --- a/packages/adena-extension/src/components/atoms/full-button-right-icon/index.tsx +++ b/packages/adena-extension/src/components/atoms/full-button-right-icon/index.tsx @@ -1,8 +1,9 @@ import React from 'react'; -import styled, { CSSProp, css } from 'styled-components'; +import styled, { css } from 'styled-components'; import { Text, Icon } from '@components/atoms'; -import { FontsType } from '@styles/theme'; +import { FontsType, getTheme } from '@styles/theme'; +import mixins from '@styles/mixins'; export type ButtonMode = 'DEFAULT' | 'DANGER' | 'HOVER'; export type IconMode = 'ARROW' | 'WEBLINK'; @@ -46,24 +47,20 @@ export const FullButtonRightIcon = ({ const defaultIconStyle = css` .icon-arrow-v2 * { transition: 0.2s; - stroke: ${({ theme, mode }): string => - mode === 'DANGER' ? theme.color.red[7] : theme.color.neutral[9]}; + stroke: ${({ theme, mode }): string => (mode === 'DANGER' ? theme.red.b : theme.neutral.a)}; } .icon-weblink * { transition: 0.2s; - fill: ${({ theme, mode }): string => - mode === 'DANGER' ? theme.color.red[7] : theme.color.neutral[9]}; + fill: ${({ theme, mode }): string => (mode === 'DANGER' ? theme.red.b : theme.neutral.a)}; } `; const hoverIconStyle = css` .icon-arrow-v2 * { - stroke: ${({ theme, mode }): string => - mode === 'DANGER' ? theme.color.red[2] : theme.color.neutral[0]}; + stroke: ${({ theme, mode }): string => (mode === 'DANGER' ? theme.red._5 : theme.neutral._1)}; } .icon-weblink * { - fill: ${({ theme, mode }): string => - mode === 'DANGER' ? theme.color.red[2] : theme.color.neutral[0]}; + fill: ${({ theme, mode }): string => (mode === 'DANGER' ? theme.red._5 : theme.neutral._1)}; } `; @@ -72,17 +69,16 @@ const ButtonWrapper = styled.button` margin-top: ${({ gap }): string | undefined => (typeof gap === 'number' ? gap + 'px' : gap)}; } ${defaultIconStyle}; - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'space-between')}; + ${mixins.flex('row', 'center', 'space-between')}; width: 100%; height: 54px; padding: 0px 24px 0px 20px; border-radius: 18px; transition: all 0.3s ease; - background-color: ${({ theme }): string => theme.color.neutral[6]}; - color: ${({ theme, mode }): string => - mode === 'DANGER' ? theme.color.red[2] : theme.color.neutral[0]}; + background-color: ${getTheme('neutral', '_7')}; + color: ${({ theme, mode }): string => (mode === 'DANGER' ? theme.red._5 : theme.neutral._1)}; &:hover { - background-color: ${({ theme }): string => theme.color.neutral[11]}; + background-color: ${getTheme('neutral', 'b')}; ${hoverIconStyle}; } `; diff --git a/packages/adena-extension/src/components/atoms/highlight-number/highlight-number.styles.ts b/packages/adena-extension/src/components/atoms/highlight-number/highlight-number.styles.ts index 3dc390ec..ced4ce97 100644 --- a/packages/adena-extension/src/components/atoms/highlight-number/highlight-number.styles.ts +++ b/packages/adena-extension/src/components/atoms/highlight-number/highlight-number.styles.ts @@ -1,4 +1,4 @@ -import theme, { FontsType } from '@styles/theme'; +import { FontsType, fonts } from '@styles/theme'; import styled, { FlattenSimpleInterpolation } from 'styled-components'; interface HighlightNumberWrapperProps { @@ -16,7 +16,7 @@ export const HighlightNumberWrapper = styled.div` .value { display: contents; - ${({ fontStyleKey }): FlattenSimpleInterpolation => theme.fonts[fontStyleKey]}; + ${({ fontStyleKey }): FlattenSimpleInterpolation => fonts[fontStyleKey]}; color: ${({ fontColor }): string => fontColor}; text-align: bottom; 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/list-box/index.tsx b/packages/adena-extension/src/components/atoms/list-box/index.tsx index 0cd00f56..b649107f 100644 --- a/packages/adena-extension/src/components/atoms/list-box/index.tsx +++ b/packages/adena-extension/src/components/atoms/list-box/index.tsx @@ -1,5 +1,8 @@ import React, { ReactElement } from 'react'; -import styled, { css, CSSProp, CSSProperties } from 'styled-components'; +import styled, { css, CSSProperties } from 'styled-components'; + +import mixins from '@styles/mixins'; +import { getTheme } from '@styles/theme'; export enum ListHierarchy { Default = 'default', @@ -24,19 +27,19 @@ interface ListBoxProps extends ListBoxStyleProps { const modeVariants = { default: css` - background: ${({ theme }): string => theme.color.neutral[6]}; + background: ${getTheme('neutral', '_7')}; &:hover { - background: ${({ theme }): string => theme.color.neutral[11]}; + background: ${getTheme('neutral', 'b')}; } `, normal: css` - background: ${({ theme }): string => theme.color.neutral[8]}; + background: ${getTheme('neutral', '_9')}; &:hover { - background: ${({ theme }): string => theme.color.neutral[6]}; + background: ${getTheme('neutral', '_7')}; } `, static: css` - background: ${({ theme }): string => theme.color.neutral[6]}; + background: ${getTheme('neutral', '_7')}; `, }; @@ -68,7 +71,7 @@ export const ListBox = ({ }; const Wrapper = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'center')}; + ${mixins.flex('row', 'center', 'center')}; ${({ mode }): any => { if (mode === ListHierarchy.Default) return modeVariants.default; if (mode === ListHierarchy.Normal) return modeVariants.normal; diff --git a/packages/adena-extension/src/components/atoms/loadings/circle.tsx b/packages/adena-extension/src/components/atoms/loadings/circle.tsx index 4a7f705d..7ee71830 100644 --- a/packages/adena-extension/src/components/atoms/loadings/circle.tsx +++ b/packages/adena-extension/src/components/atoms/loadings/circle.tsx @@ -11,7 +11,7 @@ interface CircleProps { const CircleStyle = styled.div` width: ${({ width }): string | undefined => width && width}; height: ${({ height }): string | undefined => height && height}; - background-color: ${({ theme, bgColor }): string => (bgColor ? bgColor : theme.color.neutral[4])}; + background-color: ${({ theme, bgColor }): string => (bgColor ? bgColor : theme.neutral._5)}; margin: ${({ margin }): string | undefined => margin && margin}; border-radius: 50%; `; diff --git a/packages/adena-extension/src/components/atoms/loadings/round.tsx b/packages/adena-extension/src/components/atoms/loadings/round.tsx index 3f89479e..55008633 100644 --- a/packages/adena-extension/src/components/atoms/loadings/round.tsx +++ b/packages/adena-extension/src/components/atoms/loadings/round.tsx @@ -1,3 +1,4 @@ +import mixins from '@styles/mixins'; import React from 'react'; import styled, { CSSProp } from 'styled-components'; @@ -11,11 +12,10 @@ interface RoundProps { } const RoundStyle = styled.div` - ${({ children, theme }): false | CSSProp => - !!children && theme.mixins.flexbox('row', 'center', 'center')}; + ${({ children }): false | CSSProp => !!children && mixins.flex('row', 'center', 'center')}; width: ${({ width }): string => (width ? width : '100%')}; height: ${({ height }): string | undefined => height && height}; - background-color: ${({ theme, bgColor }): string => (bgColor ? bgColor : theme.color.neutral[4])}; + background-color: ${({ theme, bgColor }): string => (bgColor ? bgColor : theme.neutral._5)}; margin: ${({ margin }): string | undefined => margin && margin}; border-radius: ${({ radius }): string | undefined => radius && radius}; `; diff --git a/packages/adena-extension/src/components/atoms/loadings/spinner.tsx b/packages/adena-extension/src/components/atoms/loadings/spinner.tsx index 55bfa84a..372be460 100644 --- a/packages/adena-extension/src/components/atoms/loadings/spinner.tsx +++ b/packages/adena-extension/src/components/atoms/loadings/spinner.tsx @@ -1,5 +1,8 @@ import React from 'react'; -import styled, { CSSProp, keyframes } from 'styled-components'; +import styled, { keyframes } from 'styled-components'; + +import mixins from '@styles/mixins'; +import { getTheme } from '@styles/theme'; const spinAnimation = keyframes` 0% { @@ -11,7 +14,7 @@ const spinAnimation = keyframes` `; const SpinRing = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'center')}; + ${mixins.flex('row', 'center', 'center')}; position: relative; width: 70px; height: 70px; @@ -20,7 +23,7 @@ const SpinRing = styled.div` animation: ${spinAnimation} 0.9s linear infinite; :before { content: ''; - background-color: ${({ theme }): string => theme.color.neutral[7]}; + background-color: ${getTheme('neutral', '_8')}; width: 36px; height: 36px; border-radius: 50%; @@ -34,7 +37,7 @@ const SpinBall = styled.span` width: 18px; height: 18px; border-radius: 50%; - background-color: ${({ theme }): string => theme.color.primary[3]}; + background-color: ${getTheme('primary', '_6')}; `; export const Spinner = (): JSX.Element => ( diff --git a/packages/adena-extension/src/components/atoms/search-input/search-input.styles.ts b/packages/adena-extension/src/components/atoms/search-input/search-input.styles.ts index bb2fbc76..fe32dcca 100644 --- a/packages/adena-extension/src/components/atoms/search-input/search-input.styles.ts +++ b/packages/adena-extension/src/components/atoms/search-input/search-input.styles.ts @@ -1,4 +1,5 @@ -import styled, { FlattenSimpleInterpolation } from 'styled-components'; +import { fonts, getTheme } from '@styles/theme'; +import styled from 'styled-components'; export const SearchInputWrapper = styled.div` display: flex; @@ -10,7 +11,7 @@ export const SearchInputWrapper = styled.div` align-items: center; justify-content: flex-start; border-radius: 30px; - border: 1px solid ${({ theme }): string => theme.color.neutral[6]}; + border: 1px solid ${getTheme('neutral', '_7')}; .search-icon-wrapper { display: inline-flex; @@ -34,7 +35,7 @@ export const SearchInputWrapper = styled.div` .search-input { width: 100%; - ${({ theme }): FlattenSimpleInterpolation => theme.fonts.body2Reg}; + ${fonts.body2Reg}; } } 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..c175cd95 --- /dev/null +++ b/packages/adena-extension/src/components/atoms/secure-textarea/index.tsx @@ -0,0 +1,48 @@ +import React from 'react'; +import styled from 'styled-components'; + +import { fonts, getTheme } from '@styles/theme'; + +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.red._5 : theme.neutral._7)}; + background-color: ${getTheme('neutral', '_9')}; + border-radius: 18px; + overflow-y: auto; + padding: 14px 16px 8px; + margin-top: 20px; +`; + +const StyledTextarea = styled.textarea` + ${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/atoms/skeleton-box/index.tsx b/packages/adena-extension/src/components/atoms/skeleton-box/index.tsx index 4ffc5276..a5ff8dc0 100644 --- a/packages/adena-extension/src/components/atoms/skeleton-box/index.tsx +++ b/packages/adena-extension/src/components/atoms/skeleton-box/index.tsx @@ -1,3 +1,4 @@ +import { getTheme } from '@styles/theme'; import styled, { keyframes } from 'styled-components'; const pulseKeyframe = keyframes` @@ -15,7 +16,7 @@ const pulseKeyframe = keyframes` export const SkeletonBoxStyle = styled.div` & { position: relative; - background-color: ${({ theme }): string => theme.color.neutral[6]}; + background-color: ${getTheme('neutral', '_7')}; border-radius: 18px; padding: 0px 17px 0px 14px; overflow: hidden; diff --git a/packages/adena-extension/src/components/atoms/static-multi-tooltip/index.tsx b/packages/adena-extension/src/components/atoms/static-multi-tooltip/index.tsx index 72085a73..02a511f8 100644 --- a/packages/adena-extension/src/components/atoms/static-multi-tooltip/index.tsx +++ b/packages/adena-extension/src/components/atoms/static-multi-tooltip/index.tsx @@ -1,6 +1,9 @@ import React from 'react'; -import styled, { CSSProp } from 'styled-components'; +import styled from 'styled-components'; + import { Text } from '@components/atoms'; +import mixins from '@styles/mixins'; +import { getTheme } from '@styles/theme'; interface TooltipProps { bgColor?: string; @@ -15,12 +18,12 @@ interface StaticTooltipProps extends TooltipProps { } const Tooltip = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'center')}; + ${mixins.flex('row', 'center', 'center')}; width: 171px; height: auto; visibility: hidden; z-index: 1; - background-color: ${({ theme, bgColor }): string => (bgColor ? bgColor : theme.color.neutral[8])}; + background-color: ${({ theme, bgColor }): string => (bgColor ? bgColor : theme.neutral._9)}; border-radius: 13px; position: absolute; right: 0px; @@ -33,7 +36,7 @@ const Tooltip = styled.div` width: 100%; height: 26px; padding: 2px 25px; - border-bottom: 1px solid ${({ theme }): string => theme.color.neutral[9]}; + border-bottom: 1px solid ${getTheme('neutral', 'a')}; &:last-child { border-bottom: none; diff --git a/packages/adena-extension/src/components/atoms/status-dot/index.tsx b/packages/adena-extension/src/components/atoms/status-dot/index.tsx index a35f3c6c..cffc484e 100644 --- a/packages/adena-extension/src/components/atoms/status-dot/index.tsx +++ b/packages/adena-extension/src/components/atoms/status-dot/index.tsx @@ -1,6 +1,9 @@ import React from 'react'; -import styled, { CSSProp } from 'styled-components'; +import styled from 'styled-components'; + import { Text } from '@components/atoms'; +import mixins from '@styles/mixins'; +import { getTheme } from '@styles/theme'; interface StatusDotProps { status: boolean; @@ -12,8 +15,7 @@ const Dot = styled.div<{ status: boolean }>` width: 12px; height: 12px; border-radius: 50%; - background-color: ${({ status, theme }): string => - status ? theme.color.green[2] : theme.color.red[2]}; + background-color: ${({ status, theme }): string => (status ? theme.green._5 : theme.red._5)}; cursor: pointer; &:hover > .static-tooltip { visibility: visible; @@ -23,13 +25,13 @@ const Dot = styled.div<{ status: boolean }>` `; const Tooltip = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'center')}; + ${mixins.flex('row', 'center', 'center')}; width: max-content; height: 25px; visibility: hidden; z-index: 1; padding: 0px 17px; - background-color: ${({ theme }): string => theme.color.neutral[8]}; + background-color: ${getTheme('neutral', '_9')}; border-radius: 13px; position: absolute; right: 0px; diff --git a/packages/adena-extension/src/components/atoms/sub-header/sub-header.styles.ts b/packages/adena-extension/src/components/atoms/sub-header/sub-header.styles.ts index cd0d4641..440c0f71 100644 --- a/packages/adena-extension/src/components/atoms/sub-header/sub-header.styles.ts +++ b/packages/adena-extension/src/components/atoms/sub-header/sub-header.styles.ts @@ -1,4 +1,5 @@ -import styled, { FlattenSimpleInterpolation } from 'styled-components'; +import { fonts } from '@styles/theme'; +import styled from 'styled-components'; export const SubHeaderWrapper = styled.div` position: relative; @@ -32,6 +33,6 @@ export const SubHeaderWrapper = styled.div` } .title-wrapper { - ${({ theme }): FlattenSimpleInterpolation => theme.fonts.header4} + ${fonts.header4} } `; diff --git a/packages/adena-extension/src/components/atoms/tab-container/index.tsx b/packages/adena-extension/src/components/atoms/tab-container/index.tsx index 00816d1f..e37ead75 100644 --- a/packages/adena-extension/src/components/atoms/tab-container/index.tsx +++ b/packages/adena-extension/src/components/atoms/tab-container/index.tsx @@ -1,5 +1,8 @@ import React from 'react'; -import styled, { CSSProp } from 'styled-components'; +import styled from 'styled-components'; + +import mixins from '@styles/mixins'; +import { getTheme } from '@styles/theme'; interface Props { header: React.ReactNode; @@ -18,18 +21,18 @@ export const TabContainer = ({ header, children }: Props): JSX.Element => { }; const Container = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('column', 'center', 'center')}; + ${mixins.flex('column', 'center', 'center')}; width: 100vw; height: 100vh; margin-top: -48px; - background-color: ${({ theme }): string => theme.color.neutral[8]}; + background-color: ${getTheme('neutral', '_9')}; `; const Wrapper = styled.div` position: relative; - ${({ theme }): CSSProp => theme.mixins.flexbox('column', 'center', 'center')}; + ${mixins.flex('column', 'center', 'center')}; width: 360px; height: 540px; - background-color: ${({ theme }): string => theme.color.neutral[7]}; + background-color: ${getTheme('neutral', '_8')}; z-index: 2; `; diff --git a/packages/adena-extension/src/components/atoms/text/index.tsx b/packages/adena-extension/src/components/atoms/text/index.tsx index cdfe068e..61d83f07 100644 --- a/packages/adena-extension/src/components/atoms/text/index.tsx +++ b/packages/adena-extension/src/components/atoms/text/index.tsx @@ -1,6 +1,6 @@ import styled, { CSSProp, css } from 'styled-components'; import React, { CSSProperties, PropsWithChildren } from 'react'; -import { FontsType } from '@styles/theme'; +import { FontsType, fonts } from '@styles/theme'; interface TextProps extends React.ComponentPropsWithoutRef<'div'> { className?: string; @@ -39,7 +39,7 @@ export const Text = ({ const Wrapper = styled.div` ${(props): CSSProp => { return css` - ${props.theme.fonts[props.type]}; + ${fonts[props.type]}; text-align: ${props.textAlign}; display: ${props.display}; color: ${props.color}; diff --git a/packages/adena-extension/src/components/atoms/warning-box/index.tsx b/packages/adena-extension/src/components/atoms/warning-box/index.tsx index 2afac809..7879e35f 100644 --- a/packages/adena-extension/src/components/atoms/warning-box/index.tsx +++ b/packages/adena-extension/src/components/atoms/warning-box/index.tsx @@ -1,7 +1,8 @@ import React from 'react'; -import styled, { CSSProp, CSSProperties } from 'styled-components'; +import styled, { CSSProperties, useTheme } from 'styled-components'; + import { Text } from '@components/atoms'; -import theme from '@styles/theme'; +import mixins from '@styles/mixins'; type WarningKeyType = | 'revealPassword' @@ -56,10 +57,11 @@ const warningType: { [key in WarningKeyType]: TextProperty } = { }; export const WarningBox = ({ type, margin, padding }: WarningBoxProps): JSX.Element => { + const theme = useTheme(); return ( {warningType[type].title && ( - + {warningType[type].title} )} @@ -73,7 +75,7 @@ export const WarningBox = ({ type, margin, padding }: WarningBoxProps): JSX.Elem }; const Wrapper = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('column', 'flex-start', 'space-between')}; + ${mixins.flex('column', 'flex-start', 'space-between')}; width: 100%; padding: ${(props): CSSProperties['padding'] => props.padding ?? '14px 16px'}; gap: 11px; diff --git a/packages/adena-extension/src/components/molecules/approve-injection-loading/approve-injection-loading.styles.ts b/packages/adena-extension/src/components/molecules/approve-injection-loading/approve-injection-loading.styles.ts index 3cd278f0..e98ce15e 100644 --- a/packages/adena-extension/src/components/molecules/approve-injection-loading/approve-injection-loading.styles.ts +++ b/packages/adena-extension/src/components/molecules/approve-injection-loading/approve-injection-loading.styles.ts @@ -1,4 +1,6 @@ -import styled, { FlattenSimpleInterpolation } from 'styled-components'; +import styled from 'styled-components'; + +import { fonts, getTheme } from '@styles/theme'; export const ApproveInjectionLoadingWrapper = styled.div` display: flex; @@ -11,13 +13,13 @@ export const ApproveInjectionLoadingWrapper = styled.div` .description { margin-top: 23px; - color: ${({ theme }): string => theme.color.neutral[0]}; - ${({ theme }): FlattenSimpleInterpolation => theme.fonts.header4} + color: ${getTheme('neutral', '_1')}; + ${fonts.header4} } .sub-description { margin-top: 12px; - color: ${({ theme }): string => theme.color.neutral[9]}; - ${({ theme }): FlattenSimpleInterpolation => theme.fonts.body1Reg} + color: ${getTheme('neutral', 'a')}; + ${fonts.body1Reg} } `; diff --git a/packages/adena-extension/src/components/molecules/approve-ledger-loading/approve-ledger-loading.styles.ts b/packages/adena-extension/src/components/molecules/approve-ledger-loading/approve-ledger-loading.styles.ts index d58c4516..74f528de 100644 --- a/packages/adena-extension/src/components/molecules/approve-ledger-loading/approve-ledger-loading.styles.ts +++ b/packages/adena-extension/src/components/molecules/approve-ledger-loading/approve-ledger-loading.styles.ts @@ -1,7 +1,9 @@ -import styled, { CSSProp } from 'styled-components'; +import styled from 'styled-components'; + +import mixins from '@styles/mixins'; export const ApproveLedgerLoadingWrapper = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('column', 'center', 'flex-start')}; + ${mixins.flex('column', 'center', 'flex-start')}; height: calc(100vh - 48px); padding: 50px 20px 24px; align-self: center; diff --git a/packages/adena-extension/src/components/molecules/approve-ledger-loading/index.tsx b/packages/adena-extension/src/components/molecules/approve-ledger-loading/index.tsx index e21b0c3b..a997e2a9 100644 --- a/packages/adena-extension/src/components/molecules/approve-ledger-loading/index.tsx +++ b/packages/adena-extension/src/components/molecules/approve-ledger-loading/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { Text, Icon, Button, ButtonHierarchy } from '@components/atoms'; +import { Text, Icon, Button } from '@components/atoms'; import { TitleWithDesc } from '@components/molecules'; import { ApproveLedgerLoadingWrapper } from './approve-ledger-loading.styles'; @@ -18,7 +18,7 @@ export const ApproveLedgerLoading: React.FC = ({ onCl /> @@ -18,7 +20,7 @@ export const CloseShadowButton = ({ onClick }: Props): JSX.Element => { }; const ButtonWrap = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'center')}; + ${mixins.flex('row', 'center', 'center')}; position: fixed; bottom: 0px; left: 0px; @@ -26,6 +28,6 @@ const ButtonWrap = styled.div` height: 96px; padding: 0px 20px; box-shadow: 0px -4px 4px rgba(0, 0, 0, 0.4); - background-color: ${({ theme }): string => theme.color.neutral[7]}; + background-color: ${getTheme('neutral', '_8')}; z-index: 1; `; diff --git a/packages/adena-extension/src/components/molecules/double-button/index.tsx b/packages/adena-extension/src/components/molecules/double-button/index.tsx index ec8f045f..94176e23 100644 --- a/packages/adena-extension/src/components/molecules/double-button/index.tsx +++ b/packages/adena-extension/src/components/molecules/double-button/index.tsx @@ -1,14 +1,15 @@ import React from 'react'; -import styled, { CSSProp } from 'styled-components'; +import styled from 'styled-components'; import { FontsType } from '@styles/theme'; -import { Text, Button, ButtonHierarchy } from '@components/atoms'; +import { Text, Button, ButtonProps } from '@components/atoms'; +import mixins from '@styles/mixins'; -interface ButtonProps { +interface EachButtonProps { onClick: () => void; text: string; props?: React.ComponentPropsWithoutRef<'button'>; - hierarchy?: ButtonHierarchy; + hierarchy?: ButtonProps['hierarchy']; bgColor?: string; fontType?: FontsType; } @@ -18,12 +19,12 @@ interface WrapperStyleProps { } interface DoubleButtonProps extends WrapperStyleProps { - leftProps: ButtonProps; - rightProps: ButtonProps; + leftProps: EachButtonProps; + rightProps: EachButtonProps; } const Wrapper = styled.div` - ${({ theme }): CSSProp => theme.mixins.flexbox('row', 'center', 'space-between')}; + ${mixins.flex('row', 'center', 'space-between')}; width: 100%; gap: 10px; ${({ margin }): string | undefined => margin && `margin: ${margin}`}; @@ -34,7 +35,7 @@ export const DoubleButton = ({ margin, leftProps, rightProps }: DoubleButtonProp