Skip to content

Commit 1f6bfbb

Browse files
authored
feat(suite): Add new color palette (1.0.0 -> 1.1.0) (#17470)
* feat(suite): Add new color palette * fix(suite): Fix test for colors
1 parent b79c1ea commit 1f6bfbb

File tree

11 files changed

+379
-321
lines changed

11 files changed

+379
-321
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"nx:format": "yarn nx format:check",
5454
"_______ Commands _______": "Useful commands and scripts.",
5555
"patch": "yarn patch-package",
56+
"convert-figma-palette": "yarn tsx ./scripts/convertFigmaPalette.ts",
5657
"update-project-references": "yarn tsx ./scripts/updateProjectReferences.ts",
5758
"verify-project-references": "yarn update-project-references --test",
5859
"check-workspace-resolutions": "yarn tsx ./scripts/check-workspace-resolutions.ts",

packages/components/src/components/DataAnalytics.tsx

+10-17
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { FormattedMessage } from 'react-intl';
33

44
import styled from 'styled-components';
55

6-
import { spacingsPx } from '@trezor/theme';
6+
import { spacingsPx, typography } from '@trezor/theme';
77

8-
import { variables } from '../config';
98
import { Card } from './Card/Card';
109
import { CollapsibleBox } from './CollapsibleBox/CollapsibleBox';
1110
import { Button } from './buttons/Button/Button';
@@ -32,30 +31,23 @@ const ButtonWrapper = styled.div`
3231
align-self: center;
3332
`;
3433

35-
const StyledButton = styled(Button)`
36-
min-width: 180px;
37-
`;
38-
3934
const Label = styled.span`
4035
margin-left: ${spacingsPx.lg};
41-
font-size: ${variables.FONT_SIZE.SMALL};
42-
font-weight: ${variables.FONT_WEIGHT.MEDIUM};
43-
color: ${({ theme }) => theme.legacy.TYPE_DARK_GREY};
36+
${typography.hint};
37+
color: ${({ theme }) => theme.textDefault};
4438
align-items: center;
4539
display: flex;
4640
`;
4741

4842
const Heading = styled.h2`
49-
font-size: ${variables.FONT_SIZE.SMALL};
50-
font-weight: ${variables.FONT_WEIGHT.DEMI_BOLD};
51-
color: ${({ theme }) => theme.legacy.TYPE_DARK_GREY};
43+
${typography.callout};
44+
color: ${({ theme }) => theme.textDefault};
5245
text-align: left;
5346
`;
5447

5548
const Description = styled.span`
56-
font-size: ${variables.FONT_SIZE.SMALL};
57-
font-weight: ${variables.FONT_WEIGHT.MEDIUM};
58-
color: ${({ theme }) => theme.legacy.TYPE_LIGHT_GREY};
49+
${typography.hint};
50+
color: ${({ theme }) => theme.textSubdued};
5951
`;
6052

6153
const Category = styled.div`
@@ -185,12 +177,13 @@ export const DataAnalytics = ({
185177
</ContentWrapper>
186178

187179
<ButtonWrapper>
188-
<StyledButton
180+
<Button
189181
data-testid="@analytics/continue-button"
190182
onClick={() => onConfirm(trackingEnabled)}
183+
minWidth={180}
191184
>
192185
<FormattedMessage id="TR_CONFIRM" defaultMessage="Confirm" />
193-
</StyledButton>
186+
</Button>
194187
</ButtonWrapper>
195188
</Wrapper>
196189
</Card>

packages/components/src/components/ElevationContext/ElevationContext.stories.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
useElevation,
1919
} from './ElevationContext';
2020
import { Card } from '../Card/Card';
21+
import { Button } from '../buttons/Button/Button';
2122
import { Textarea } from '../form/Textarea/Textarea';
2223
import { Modal } from '../modals/Modal/Modal';
2324

@@ -78,6 +79,7 @@ const Box = ({ children }: { children?: ReactNode }) => {
7879
return (
7980
<UiBox $elevation={elevation}>
8081
<div>Elevation: {elevation}</div>
82+
<Button variant="tertiary">tertiary button</Button>
8183
<ElevationUp>{children}</ElevationUp>
8284
</UiBox>
8385
);
@@ -90,7 +92,7 @@ export const ElevationContext: StoryObj = {
9092
<ElevationDown>
9193
<Box />
9294
</ElevationDown>
93-
95+
<Box />
9496
<ElevationUp>
9597
<Box>
9698
<Box>

packages/components/src/components/buttons/buttonStyleUtils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ const mapElevationToButtonBackground = ({
8181

8282
// Button lies always on elevation so for example Button that lies has elevation 0, lies on elevation -1.
8383
// This is why the values here a shifted by 1.
84-
0: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevationNegative`,
85-
1: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation0`,
86-
2: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation1`,
87-
3: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation2`,
84+
0: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation0`,
85+
1: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation1`,
86+
2: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation2`,
87+
3: `interactionBackgroundTertiaryDefault${capitalizedState}OnElevation3`,
8888
};
8989

9090
return theme[map[elevation]];

packages/components/src/components/typography/Text/Text.stories.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,38 @@ const meta: Meta = {
2424
} as Meta;
2525
export default meta;
2626

27-
export const Text: StoryObj = {
28-
render: props => (
27+
export const Text: StoryObj<typeof TextComponent> = {
28+
render: ({ variant, color, ...rest }) => (
2929
<Wrapper>
3030
<ColoredBlock>
31-
<TextComponent {...props}>
31+
<TextComponent {...rest}>
3232
This is just a plain text with inherited color from its parent
3333
</TextComponent>
3434
</ColoredBlock>
3535
<Block>
36-
<TextComponent variant="default" {...props}>
36+
<TextComponent variant="default" {...rest}>
3737
This is <strong>default</strong> variant
3838
</TextComponent>
39-
<TextComponent variant="primary" {...props}>
39+
<TextComponent variant="primary" {...rest}>
4040
This is <strong>primary</strong> variant
4141
</TextComponent>
42-
<TextComponent variant="info" {...props}>
42+
<TextComponent variant="info" {...rest}>
4343
This is <TextComponent typographyStyle="highlight">info</TextComponent> variant
4444
</TextComponent>
45-
<TextComponent variant="warning" {...props}>
45+
<TextComponent variant="warning" {...rest}>
4646
This is <strong>warning</strong> variant
4747
</TextComponent>
48-
<TextComponent variant="destructive" {...props}>
48+
<TextComponent variant="destructive" {...rest}>
4949
This is <strong>destructive</strong> variant
5050
</TextComponent>
5151
</Block>
5252
<Block>
53-
<TextComponent color="#9be887" {...props}>
53+
<TextComponent color="#9be887" {...rest}>
5454
This is <strong>custom</strong> color variant
5555
</TextComponent>
5656
</Block>
5757
<Block>
58-
<TextComponent variant="info" typographyStyle="titleMedium" {...props}>
58+
<TextComponent variant="info" typographyStyle="titleMedium" {...rest}>
5959
This is just a plain Medium Title
6060
</TextComponent>
6161
</Block>

packages/suite-desktop-core/e2e/tests/settings/autodetect.test.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import { colorVariants } from '@trezor/theme';
2+
import { hexToRgba } from '@trezor/utils';
3+
14
import { expect, test } from '../../support/fixtures';
25

3-
const veryDarkGreyColor = 'rgb(23, 23, 23)';
4-
const darkGreyColor = 'rgb(31, 31, 31)';
5-
const veryLightGreyColor = 'rgb(246, 246, 246)';
6-
const lightGreyColor = 'rgb(234, 235, 237)';
76
enum ColorScheme {
87
Light = 'light',
98
Dark = 'dark',
@@ -14,22 +13,22 @@ const testCases = [
1413
testName: 'Light English',
1514
userPreferences: { colorScheme: ColorScheme.Light },
1615
text: 'Anonymous data collection',
17-
textColor: darkGreyColor,
18-
bodyBackgroundColor: veryLightGreyColor,
16+
textColor: colorVariants.standard.textDefault,
17+
bodyBackgroundColor: colorVariants.standard.backgroundSurfaceElevation0,
1918
},
2019
{
2120
testName: 'Dark English',
2221
userPreferences: { colorScheme: ColorScheme.Dark },
2322
text: 'Anonymous data collection',
24-
textColor: lightGreyColor,
25-
bodyBackgroundColor: veryDarkGreyColor,
23+
textColor: colorVariants.dark.textDefault,
24+
bodyBackgroundColor: colorVariants.dark.backgroundSurfaceElevation0,
2625
},
2726
{
2827
testName: 'Dark Spanish',
2928
userPreferences: { locale: 'es-ES', colorScheme: ColorScheme.Dark },
3029
text: 'Recogida de datos anónimos',
31-
textColor: lightGreyColor,
32-
bodyBackgroundColor: veryDarkGreyColor,
30+
textColor: colorVariants.dark.textDefault,
31+
bodyBackgroundColor: colorVariants.dark.backgroundSurfaceElevation0,
3332
},
3433
];
3534

@@ -40,10 +39,10 @@ testCases.forEach(({ testName, userPreferences, text, textColor, bodyBackgroundC
4039
test(testName, async ({ onboardingPage, analyticsSection }) => {
4140
await onboardingPage.optionallyDismissFwHashCheckError();
4241
await expect(analyticsSection.heading).toHaveText(text);
43-
await expect(analyticsSection.heading).toHaveCSS('color', textColor);
42+
await expect(analyticsSection.heading).toHaveCSS('color', hexToRgba(textColor));
4443
await expect(onboardingPage.page.locator('body')).toHaveCSS(
4544
'background-color',
46-
bodyBackgroundColor,
45+
hexToRgba(bodyBackgroundColor),
4746
);
4847
});
4948
});

0 commit comments

Comments
 (0)