Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the rotating version of the image to the security check onboarding screen #16571

Merged
merged 5 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type DeviceAnimationProps = {
isOldT2B1Packaging?: boolean;
deviceUnitColor?: number;
className?: string;
sizeVariant?: 'LARGE';
vojtatranta marked this conversation as resolved.
Show resolved Hide resolved

onVideoMouseOver?: MouseEventHandler<HTMLVideoElement>;
};

Expand All @@ -46,6 +48,7 @@ export const DeviceAnimation = forwardRef<HTMLVideoElement, DeviceAnimationProps
deviceModelInternal = DEFAULT_FLAGSHIP_MODEL,
isOldT2B1Packaging,
deviceUnitColor,
sizeVariant,
onVideoMouseOver,
...props
},
Expand Down Expand Up @@ -141,7 +144,7 @@ export const DeviceAnimation = forwardRef<HTMLVideoElement, DeviceAnimationProps
`videos/device/trezor_${deviceModelInFilename}_rotate_color_${
// if device unit color is not set, use first color available
deviceUnitColor ?? 1
}.webm`,
}${sizeVariant ? `_${sizeVariant.toLowerCase()}` : ''}.webm`,
)}
type="video/webm"
/>
Expand Down
Binary file modified packages/suite-data/files/images/png/trezor-t1b1-large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/suite-data/files/images/png/trezor-t1b1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/suite-data/files/images/png/trezor-t1b1@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import styled from 'styled-components';

import { selectSelectedDevice } from '@suite-common/wallet-core';
import { Image, variables } from '@trezor/components';
import { DeviceAnimation, Image, variables } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';

import { useSelector } from 'src/hooks/suite';

Expand Down Expand Up @@ -45,19 +46,44 @@ const Content = styled.div`
interface SecurityCheckLayoutProps {
isFailed?: boolean;
children: React.ReactNode;
imageMode?: 'ROTATE' | 'STATIC';
}

export const SecurityCheckLayout = ({ isFailed, children }: SecurityCheckLayoutProps) => {
export const SecurityCheckLayout = ({
isFailed,
children,
imageMode,
}: SecurityCheckLayoutProps) => {
const device = useSelector(selectSelectedDevice);

const deviceModelInternal = device?.features?.internal_model;
const imageVariant = isFailed ? 'GHOST' : 'LARGE';
const isDeviceImageRotating =
imageMode === 'ROTATE' &&
deviceModelInternal &&
[
DeviceModelInternal.T1B1,
DeviceModelInternal.T2T1,
DeviceModelInternal.T2B1,
DeviceModelInternal.T3B1,
DeviceModelInternal.T3T1,
].includes(deviceModelInternal);

return (
<Wrapper>
{deviceModelInternal && (
<ImageWrapper>
<StyledImage image={`TREZOR_${deviceModelInternal}_${imageVariant}`} />
{isDeviceImageRotating ? (
<DeviceAnimation
type="ROTATE"
deviceModelInternal={deviceModelInternal}
deviceUnitColor={device.features?.unit_color}
height="300px" // NOTE: fill out the fixed height, we know that the video is 2x
sizeVariant="LARGE"
/>
) : (
<StyledImage image={`TREZOR_${deviceModelInternal}_${imageVariant}`} />
)}
</ImageWrapper>
)}
<Content>{children}</Content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';

import styled, { useTheme } from 'styled-components';

Expand All @@ -7,6 +7,7 @@ import { AcquiredDevice } from '@suite-common/suite-types';
import { getConnectedDeviceStatus } from '@suite-common/suite-utils';
import { deviceActions, selectDevices, selectSelectedDevice } from '@suite-common/wallet-core';
import { Button, Column, Divider, H2, Icon, Text, Tooltip } from '@trezor/components';
import { models } from '@trezor/connect/src/data/models';
import { spacings, spacingsPx, typography } from '@trezor/theme';
import {
TREZOR_RESELLERS_URL,
Expand Down Expand Up @@ -209,6 +210,14 @@ const SecurityCheckContent = ({
}
}, [initialized, isRecoveryInProgress, updateAnalytics]);

const humanizedModelColor = useMemo(
() =>
device?.features?.internal_model && device?.features?.unit_color
? models[device?.features?.internal_model]?.colors?.[device?.features?.unit_color]
: null,
[device],
);

return isFailed ? (
<SecurityCheckFail
goBack={toggleView}
Expand All @@ -217,13 +226,17 @@ const SecurityCheckContent = ({
supportUrl={supportUrl}
/>
) : (
<SecurityCheckLayout>
<SecurityCheckLayout imageMode="ROTATE">
<Column alignItems="flex-start">
<DeviceNameSection>
<Text variant="tertiary">
<Translation id="TR_YOU_HAVE_CONNECTED" />
</Text>
<DeviceName>{device?.name}</DeviceName>
<DeviceName>
{device?.name}
{humanizedModelColor && <Text> {humanizedModelColor}</Text>}
</DeviceName>

<OnboardingButtonSkip onClick={toggleView}>
<Translation id="TR_CONNECTED_DIFFERENT_DEVICE" />
</OnboardingButtonSkip>
Expand Down
Loading