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

RadioCard component #16619

Merged
merged 1 commit into from
Jan 28, 2025
Merged

RadioCard component #16619

merged 1 commit into from
Jan 28, 2025

Conversation

enjojoy
Copy link
Contributor

@enjojoy enjojoy commented Jan 27, 2025

Description

New RadioCard component, used in fees

Screenshots:

image image

Copy link

github-actions bot commented Jan 27, 2025

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 23
  • More info

Learn more about 𝝠 Expo Github Action

@enjojoy
Copy link
Contributor Author

enjojoy commented Jan 27, 2025

@peter-sanderson here is the component

@enjojoy enjojoy marked this pull request as ready for review January 27, 2025 14:14
Copy link
Contributor

@peter-sanderson peter-sanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets investigate if we can reuse ComponentWithSubIcon

Otherwise fine by me 👍

But please, lets wait for review from @jvaclavik / @adamhavel as well

@enjojoy
Copy link
Contributor Author

enjojoy commented Jan 27, 2025

Lets investigate if we can reuse ComponentWithSubIcon

Otherwise fine by me 👍

But please, lets wait for review from @jvaclavik / @adamhavel as well

I wouldn't use it because it has a border and also it is not placed on the border of the component but outside of it.

It's up to @trezor/suite-engagement if they would like to remake it to use it in radio card as well

image image

packages/components/src/components/RadioCard/RadioCard.tsx Outdated Show resolved Hide resolved
packages/components/src/components/RadioCard/RadioCard.tsx Outdated Show resolved Hide resolved
z-index: 2;
border-radius: ${borders.radii.full};
background-color: ${({ theme }) => theme.borderSecondary};
height: 14px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not set dimensions like this. Just set the right icon size and only use padding here. Then you won't need the flex properties below.

`;

const IconWrapper = styled.div`
position: absolute;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can extract these position and z-index props into a separate Box component

`;

export const RadioCard = ({ isActive, children }: RadioCardProps) => (
<Box position={{ type: 'relative' }} width="100%" height="100%">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the dimensions are not needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I guess I'll add dimensions as an optional prop? They're needed here for sure
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't get it:( Why w
Do you need them in this context? Width is 100% by default, or just use Column with stretch align. And height is dynamic based on content anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense, didn't think of the stretch. Thank you

packages/components/src/components/RadioCard/RadioCard.tsx Outdated Show resolved Hide resolved
packages/components/src/components/RadioCard/RadioCard.tsx Outdated Show resolved Hide resolved
packages/components/src/components/RadioCard/RadioCard.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@jvaclavik jvaclavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, Albina! 💪 Just stuff to polish and ready to merge!

@@ -635,6 +635,7 @@ export const icons = {
checkFat: require('../assets/checkFat.svg'),
checkFatFilled: require('../assets/checkFatFilled.svg'),
checkFilled: require('../assets/checkFilled.svg'),
checkMedium: require('../assets/checkMedium.svg'),
Copy link
Contributor

@jvaclavik jvaclavik Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use checkCircleFilled or ComponentWithSubIcon
(https://dev.suite.sldev.cz/components/develop/?path=/story/componentwithsubicon--component-with-sub-icon)? 🙏

We don't want to add new icons, because if we get new full export from designers, we might replace all the custom added icons by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried them all before but they're just not as good as the one on figma... I will discuss it with the designer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will use the existing thin checkmark as agreed with designer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

padding: 2px;
`;

export const RadioCard = ({ isActive, children }: RadioCardProps) => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: It would be nice to add also frameProps, but we can do it later on our own.

Comment on lines +24 to +26
outline: ${borders.widths.large} solid ${({ theme }) => theme.borderSecondary};
outline-offset: -${borders.widths.large};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is OK to use outline? IMHO yes.

@adamhavel What's your opinion here?

outline-offset: -${borders.widths.large};
`}
border-radius: ${borders.radii.md};
z-index: 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary if you move BorderActive below Card:

        <Card paddingType="small" fillType="none">
            {children}
        </Card>
        <BorderActive isActive={isActive} />

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it's a nice catch

const IconWrapper = styled.div`
border-radius: ${borders.radii.full};
background-color: ${({ theme }) => theme.borderSecondary};
padding: 2px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use spacingsPx.xxxs? 🙏

@enjojoy enjojoy requested a review from a team as a code owner January 28, 2025 11:47
@enjojoy enjojoy merged commit df94a19 into develop Jan 28, 2025
32 checks passed
@enjojoy enjojoy deleted the feat/radiocard branch January 28, 2025 12:27
@enjojoy enjojoy restored the feat/radiocard branch January 28, 2025 15:34
@enjojoy
Copy link
Contributor Author

enjojoy commented Jan 28, 2025

I noticed a leftower type that is not needed anymore, will add a fix now

@enjojoy enjojoy deleted the feat/radiocard branch January 28, 2025 15:36
@bosomt
Copy link
Contributor

bosomt commented Jan 29, 2025

QA OK

Info:

  • Suite version: desktop 25.2.0 (366cb09)
  • Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) TrezorSuiteDev/25.2.0 Chrome/128.0.6613.186 Electron/32.2.6 Safari/537.36
  • OS: MacIntel
  • Screen: 1470x956
  • Device: Trezor T3T1 2.8.7 regular (revision 8a254aa8eae82f99630df63f40e4d290066a3efc)
  • Transport: BridgeTransport 2.0.33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Approved
Development

Successfully merging this pull request may close these issues.

5 participants