Skip to content

Commit

Permalink
Aum/WALL-562/create-wallet-icon-component (binary-com#8501)
Browse files Browse the repository at this point in the history
* feat: created wallet-icon component

* feat: integrated wallet-icon with gradient-background-wallet-icon

* fix: changed the color positioning for icon gradient

* chore: replaced currency prop with icon

* chore: removed wallet-small and wallet-icon made by @hamid-deriv

* chore: removed dark prop for wallet-icon

* refactor: made gradient-background-wallet-icon dynamic and refactored wallet-icon

* fix: made changes from comments

* chore: renamed gradient-background component to two-point

* chore: removed unused code
  • Loading branch information
aum-deriv authored and nijil-deriv committed May 22, 2023
1 parent b49522b commit 173d054
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.gradient-background-two-point {
width: 100%;
height: 100%;
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 50%;
overflow: hidden;

&__primary {
height: 100%;
aspect-ratio: 1;
}

&__secondary {
height: 120%;
aspect-ratio: 1;
}

&__children {
position: absolute;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { CSSProperties } from 'react';
import './gradient-background-two-point.scss';

type TGradientBackgroundTwoPoint = {
blurRadius?: number;
backgroundColor: CSSProperties['backgroundColor'];
primaryColor: CSSProperties['background'];
secondaryColor: CSSProperties['background'];
};

const GradientBackgroundTwoPoint: React.FC<React.PropsWithChildren<TGradientBackgroundTwoPoint>> = ({
children,
blurRadius = 48,
backgroundColor,
primaryColor,
secondaryColor,
}) => (
<div className='gradient-background-two-point' style={{ backgroundColor }}>
<div
className='gradient-background-two-point__primary'
style={{ filter: `blur(${blurRadius}px)`, background: primaryColor }}
/>
<div
className='gradient-background-two-point__secondary'
style={{ filter: `blur(${blurRadius}px)`, background: secondaryColor }}
/>
{children && <div className='gradient-background-two-point__children'>{children}</div>}
</div>
);

export default GradientBackgroundTwoPoint;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import GradientBackgroundTwoPoint from './gradient-background-two-point';

export { GradientBackgroundTwoPoint };
3 changes: 3 additions & 0 deletions packages/components/src/components/wallet-icon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import WalletIcon from './wallet-icon';

export { WalletIcon };
33 changes: 33 additions & 0 deletions packages/components/src/components/wallet-icon/wallet-icon.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.wallet-icon {
position: relative;
display: flex;
align-items: center;
justify-content: center;
border-radius: $BORDER_RADIUS;
overflow: hidden;

&__background {
position: absolute;
width: 100%;
height: 100%;
}

&__icon {
z-index: 1;
}

&--small {
width: 4rem;
height: 2.4rem;
}

&--medium {
width: 6.4rem;
height: 4rem;
}

&--large {
width: 12.8rem;
height: 8rem;
}
}
37 changes: 37 additions & 0 deletions packages/components/src/components/wallet-icon/wallet-icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { CSSProperties } from 'react';
import Icon from '../icon';
import { GradientBackgroundTwoPoint } from '../gradient-background-two-point';
import './wallet-icon.scss';

type TWalletIcon = {
icon: string;
iconSize: number | string;
primaryColor: CSSProperties['backgroundColor'];
secondaryColor: CSSProperties['backgroundColor'];
size?: 'small' | 'medium' | 'large';
};

const getBlurRadius = (size: string) => {
if (size === 'small') return 16;
if (size === 'medium') return 24;

return 48;
};

const WalletIcon = ({ icon, iconSize = 24, primaryColor, secondaryColor, size = 'medium' }: TWalletIcon) => {
return (
<div className={`wallet-icon wallet-icon--${size}`}>
<div className='wallet-icon__background'>
<GradientBackgroundTwoPoint
blurRadius={getBlurRadius(size)}
backgroundColor='var(--general-main-2)'
primaryColor={primaryColor}
secondaryColor={secondaryColor}
/>
</div>
<Icon icon={icon} size={iconSize} className='wallet-icon__icon' />
</div>
);
};

export default WalletIcon;
28 changes: 0 additions & 28 deletions packages/components/src/components/wallet/icon/icon.scss

This file was deleted.

56 changes: 0 additions & 56 deletions packages/components/src/components/wallet/icon/icon.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions packages/components/src/components/wallet/icon/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/components/src/components/wallet/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/components/src/components/wallet/small/index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/components/src/components/wallet/small/small.scss

This file was deleted.

23 changes: 0 additions & 23 deletions packages/components/src/components/wallet/small/small.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export { default as FormSubmitButton } from './components/form-submit-button';
export { default as FormSubmitErrorMessage } from './components/form-submit-error-message';
export { default as FormCancelButton } from './components/form-cancel-button';
export * from './components/gradient-background';
export * from './components/gradient-background-two-point';
export { default as HintBox } from './components/hint-box';
export { default as HorizontalSwipe } from './components/horizontal-swipe';
export { default as Icon } from './components/icon';
Expand Down Expand Up @@ -112,5 +113,5 @@ export { default as UnhandledErrorModal } from './components/unhandled-error-mod
export { default as VerticalTab } from './components/vertical-tab';
export * from './components/watermark';
export { default as Wizard } from './components/wizard';
export * from './components/wallet';
export * from './components/wallet-icon';
export * from './hooks';

0 comments on commit 173d054

Please sign in to comment.