-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite): quick-action refactotring, simplification of the UI and …
…adding a update icon chore(components): add frameProps for ComponentWithSubIcon
- Loading branch information
1 parent
52de43f
commit 17a4762
Showing
28 changed files
with
592 additions
and
287 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/components/src/components/ComponentWithSubIcon/ComponentWithSubIcon.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { Icon, iconVariants } from '../Icon/Icon'; | ||
import { | ||
allowedComponentWithSubIconFrameProps, | ||
ComponentWithSubIcon as ComponentWithSubIconComponent, | ||
ComponentWithSubIconProps, | ||
} from './ComponentWithSubIcon'; | ||
import { getFramePropsStory } from '../../utils/frameProps'; | ||
|
||
const meta: Meta = { | ||
title: 'ComponentWithSubIcon', | ||
component: ComponentWithSubIconComponent, | ||
} as Meta; | ||
export default meta; | ||
|
||
export const ComponentWithSubIcon: StoryObj<ComponentWithSubIconProps> = { | ||
args: { | ||
subIconProps: { | ||
name: 'check', | ||
}, | ||
variant: 'destructive', | ||
children: <Icon name="tor" />, | ||
...getFramePropsStory(allowedComponentWithSubIconFrameProps).args, | ||
}, | ||
argTypes: { | ||
variant: { | ||
options: iconVariants, | ||
control: { | ||
type: 'select', | ||
}, | ||
}, | ||
...getFramePropsStory(allowedComponentWithSubIconFrameProps).argTypes, | ||
}, | ||
}; |
86 changes: 86 additions & 0 deletions
86
packages/components/src/components/ComponentWithSubIcon/ComponentWithSubIcon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import styled, { useTheme } from 'styled-components'; | ||
import { | ||
ExclusiveColorOrVariant, | ||
getColorForIconVariant, | ||
getIconSize, | ||
Icon, | ||
IconProps, | ||
} from '../Icon/Icon'; | ||
import { borders, spacingsPx } from '@trezor/theme'; | ||
import { TransientProps } from '../../utils/transientProps'; | ||
import { ReactNode } from 'react'; | ||
import { FramePropsKeys, FrameProps, withFrameProps } from '../../utils/frameProps'; | ||
|
||
export const allowedComponentWithSubIconFrameProps: FramePropsKeys[] = ['margin']; | ||
type AllowedFrameProps = Pick<FrameProps, (typeof allowedComponentWithSubIconFrameProps)[number]>; | ||
|
||
const Container = styled.div<TransientProps<AllowedFrameProps>>` | ||
position: relative; | ||
${withFrameProps} | ||
`; | ||
|
||
type SubIconWrapperProps = TransientProps<ExclusiveColorOrVariant> & { | ||
$subIconColor: string; | ||
$subIconSize: number; | ||
}; | ||
|
||
const SubIconWrapper = styled.div<SubIconWrapperProps>` | ||
position: absolute; | ||
right: -${({ $subIconSize }) => $subIconSize / 2 + 3}px; | ||
top: -${({ $subIconSize }) => $subIconSize / 2 + 3}px; | ||
background-color: ${({ theme, $variant, $color }) => | ||
getColorForIconVariant({ theme, variant: $variant, color: $color })}; | ||
border-radius: ${borders.radii.full}; | ||
border: 1px solid ${({ theme }) => theme['borderElevationNegative']}; | ||
padding: ${spacingsPx.xxxs}; | ||
`; | ||
|
||
export type ComponentWithSubIconProps = AllowedFrameProps & | ||
ExclusiveColorOrVariant & { | ||
subIconProps?: IconProps; | ||
children: ReactNode; | ||
}; | ||
|
||
export const ComponentWithSubIcon = ({ | ||
variant, | ||
color, | ||
children, | ||
subIconProps, | ||
margin, | ||
}: ComponentWithSubIconProps) => { | ||
const theme = useTheme(); | ||
|
||
if (subIconProps === undefined) { | ||
return <Container $margin={margin}>{children}</Container>; | ||
} | ||
|
||
const backgroundIconColor = getColorForIconVariant({ | ||
theme, | ||
color, | ||
variant, | ||
}); | ||
|
||
const iconColor = getColorForIconVariant({ | ||
theme, | ||
color: subIconProps.color, | ||
variant: subIconProps.variant, | ||
}); | ||
|
||
const subIconSize = getIconSize(subIconProps.size ?? 12); | ||
|
||
return ( | ||
<Container $margin={margin}> | ||
{children} | ||
<SubIconWrapper | ||
$color={backgroundIconColor} | ||
$subIconColor={iconColor} | ||
$subIconSize={subIconSize} | ||
> | ||
<Icon {...subIconProps} size={subIconSize} /> | ||
</SubIconWrapper> | ||
</Container> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
packages/suite/src/components/suite/layouts/SuiteLayout/Sidebar/ActionButton.tsx
This file was deleted.
Oops, something went wrong.
91 changes: 0 additions & 91 deletions
91
packages/suite/src/components/suite/layouts/SuiteLayout/Sidebar/HelperIcons.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.