Skip to content

Commit

Permalink
fix: auto browser language translation for seed phrases / private keys (
Browse files Browse the repository at this point in the history
  • Loading branch information
magiziz authored May 16, 2024
1 parent 82a8c62 commit 52e1dc8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/design-system/components/Box/Box.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as Polymorphic from '@radix-ui/react-polymorphic';
import clsx, { ClassValue } from 'clsx';
import React, { forwardRef } from 'react';
import React, { HTMLAttributes, forwardRef } from 'react';

import {
BoxStyles,
Expand Down Expand Up @@ -41,6 +41,7 @@ export type BoxProps = Omit<BoxStyles, 'background'> & {
isModal?: boolean;
isExplainerSheet?: boolean;
testId?: string;
translate?: HTMLAttributes<unknown>['translate'];
onKeyDown?: React.KeyboardEventHandler;
tabIndex?: number;
};
Expand All @@ -54,6 +55,7 @@ export const Box = forwardRef(function Box(
isModal,
isExplainerSheet,
testId,
translate,
...props
},
ref,
Expand Down Expand Up @@ -123,6 +125,7 @@ export const Box = forwardRef(function Box(
data-is-modally-presented={isModal || undefined}
data-is-explainer-sheet={isExplainerSheet || undefined}
data-testid={testId}
translate={translate}
// Since Box is a primitive component, it needs to spread props
// eslint-disable-next-line react/jsx-props-no-spreading
{...restProps}
Expand Down
5 changes: 4 additions & 1 deletion src/design-system/components/Text/Text.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx';
import React from 'react';
import React, { HTMLAttributes } from 'react';

import { TextStyles, textStyles } from '../../styles/core.css';
import { Box } from '../Box/Box';
Expand All @@ -21,6 +21,7 @@ export interface TextProps {
whiteSpace?: TextStyles['whiteSpace'];
textShadow?: TextStyles['textShadow'];
fontFamily?: TextStyles['fontFamily'];
translate?: HTMLAttributes<unknown>['translate'];
}

export function Text({
Expand All @@ -38,6 +39,7 @@ export function Text({
whiteSpace,
textShadow,
fontFamily = 'rounded',
translate,
}: TextProps) {
return (
<Box
Expand All @@ -62,6 +64,7 @@ export function Text({
testId={testId}
marginVertical={webkitBackgroundClip === 'text' ? '-6px' : undefined}
paddingVertical={webkitBackgroundClip === 'text' ? '6px' : undefined}
translate={translate}
>
{children}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default function SeedPhraseTable({ seed }: { seed: string }) {
color="label"
align="center"
testId={`seed_word_${index + 1}`}
translate="no"
>
{word}
</Text>
Expand Down Expand Up @@ -105,6 +106,7 @@ export default function SeedPhraseTable({ seed }: { seed: string }) {
color="label"
align="center"
testId={`seed_word_${index + 7}`}
translate="no"
>
{word}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ const SeedWordRow = ({
</Box>

<Box style={{ width: 57 + additionalWidth }}>
<Text size="14pt" weight="bold" color="label" align="left">
<Text
size="14pt"
weight="bold"
color="label"
align="left"
translate="no"
>
{word}
</Text>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export function PrivateKey() {
wordBreak: 'break-all',
}}
>
<Text size="14pt" weight="bold" testId={'private-key-hash'}>
<Text
size="14pt"
weight="bold"
testId={'private-key-hash'}
translate="no"
>
{privKey}
</Text>
</Box>
Expand Down

0 comments on commit 52e1dc8

Please sign in to comment.