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

Fees redesign #16577

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
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
@@ -0,0 +1,23 @@
import { Meta, StoryObj } from '@storybook/react';

import { RadioCard as RadioCardComponent, RadioCardProps } from './RadioCard';

const meta: Meta = {
title: 'RadioCard',
component: RadioCardComponent,
} as Meta;
export default meta;

export const RadioCard: StoryObj<RadioCardProps> = {
args: {
isActive: true,
children: 'Content',
},
argTypes: {
isActive: {
control: {
type: 'boolean',
},
},
},
};
80 changes: 80 additions & 0 deletions packages/components/src/components/RadioCard/RadioCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import styled, { css } from 'styled-components';

import { palette, borders } from '@trezor/theme';

import { Card } from '../Card/Card';
import { Icon } from '../Icon/Icon';

export type RadioCardProps = {
isActive: boolean;
children: React.ReactNode;
onClick: () => void;
};

const BorderActive = styled.div<{ isActive: boolean }>`
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
box-sizing: border-box;
${({ isActive }) =>
isActive &&
css`
outline: 2px solid ${({ theme }) => theme.borderSecondary};
outline-offset: -2px;
`}
border-radius: ${borders.radii.md};
width: 100%;
height: 100%;
z-index: 1;
`;

const IconWrapper = styled.div`
position: absolute;
top: 2px;
right: 2px;
z-index: 2;
`;

const RadioCardWrapper = styled.div<{ isActive: boolean }>`
position: relative;
width: 100%;
height: 100%;
border-radius: ${borders.radii.md};
${({ isActive }) =>
isActive &&
css`
&::after {
content: '';
position: absolute;
top: -1px;
right: -1px;
background-color: ${({ theme }) => theme.borderSecondary};
color: white;
width: 14px;
height: 14px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: bold;
}
`}
`;

export const RadioCard = ({ isActive, children, onClick }: RadioCardProps) => (
<RadioCardWrapper isActive={isActive} onClick={onClick}>
{isActive && (
<IconWrapper>
<Icon name="checkMedium" size="extraSmall" color={palette.lightWhiteAlpha1000} />
</IconWrapper>
)}
<BorderActive isActive={isActive} />
<Card width="100%" paddingType="small" flex="1" fillType="none">
{children}
</Card>
</RadioCardWrapper>
);
2 changes: 2 additions & 0 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ export { getSafeWindowSize } from './utils/getSafeWindowSize';

export { intermediaryTheme } from './config/colors';
export type { SuiteThemeColors } from './config/colors';

export { RadioCard } from './components/RadioCard/RadioCard';
3 changes: 3 additions & 0 deletions suite-common/icons/assets/checkMedium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions suite-common/icons/src/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
checkSquare: require('../assets/checkSquare.svg'),
checkSquareFilled: require('../assets/checkSquareFilled.svg'),
checkSquareOffset: require('../assets/checkSquareOffset.svg'),
Expand Down
Loading