diff --git a/packages/wallets/src/components/Base/IconButton/IconButton.scss b/packages/wallets/src/components/Base/IconButton/IconButton.scss new file mode 100644 index 000000000000..33bae284a4de --- /dev/null +++ b/packages/wallets/src/components/Base/IconButton/IconButton.scss @@ -0,0 +1,92 @@ +$color-map: ( + 'primary': ( + backgroundcolor: #ff444f, + hover: #eb3e48, + ), + 'white': ( + backgroundcolor: #fff, + hover: #d6dadb, + ), + 'black': ( + backgroundcolor: #0e0e0e, + hover: #323738, + ), + 'transparent': ( + backgroundcolor: transparent, + hover: #d6dadb, + ), +); + +$size-map: ( + sm: ( + padding: 0.4rem, + height: 2.4rem, + ), + md: ( + padding: 0.8rem, + height: 3.2rem, + ), + lg: ( + padding: 1.2rem, + height: 4rem, + ), +); + +$border-radius-map: ( + sm: 0.4rem, + md: 6.4rem, + lg: 50%, +); + +.wallets-icon-button { + display: grid; + place-content: center; + border: none; + + &:hover { + cursor: pointer; + } + + &:disabled { + display: none; + } + + &__border-radius { + &--round { + border-radius: 50%; + } + + &--default { + border-radius: 0.4rem; + } + } + + @each $color, $values in $color-map { + &__color--#{$color} { + background-color: map-get($values, backgroundcolor); + &:hover { + background-color: map-get($values, hover); + } + } + } + + @each $size, $values in $size-map { + &__size--#{$size} { + padding: map-get($values, padding); + height: map-get($values, height); + } + } + + @each $size, $values in $border-radius-map { + &__border-radius--#{$size} { + border-radius: ($values); + } + } + + &__icon { + display: grid; + place-content: center; + width: 1.6rem; + height: 1.6rem; + } +} diff --git a/packages/wallets/src/components/Base/IconButton/IconButton.tsx b/packages/wallets/src/components/Base/IconButton/IconButton.tsx new file mode 100644 index 000000000000..47fbd5b735e0 --- /dev/null +++ b/packages/wallets/src/components/Base/IconButton/IconButton.tsx @@ -0,0 +1,36 @@ +import React, { ButtonHTMLAttributes, ComponentProps, forwardRef, Ref } from 'react'; +import classNames from 'classnames'; +import { TGenericSizes } from '../types'; +import './IconButton.scss'; + +interface IconButtonProps extends ButtonHTMLAttributes { + color?: 'black' | 'primary' | 'transparent' | 'white'; + icon: React.ReactNode; + isRound?: boolean; + onClick?: ComponentProps<'button'>['onClick']; + size?: Extract; +} + +const IconButton = forwardRef( + ( + { className, color = 'primary', disabled, icon, isRound, onClick, size = 'sm', ...rest }, + ref: Ref + ) => { + const iconButtonClassNames = classNames( + 'wallets-icon-button', + `wallets-icon-button__size--${size}`, + `wallets-icon-button__color--${color}`, + `wallets-icon-button__border-radius--${isRound ? 'round' : 'default'}`, + className + ); + + return ( + + ); + } +); + +IconButton.displayName = 'IconButton'; +export default IconButton; diff --git a/packages/wallets/src/components/Base/IconButton/index.ts b/packages/wallets/src/components/Base/IconButton/index.ts new file mode 100644 index 000000000000..9a2d049fab32 --- /dev/null +++ b/packages/wallets/src/components/Base/IconButton/index.ts @@ -0,0 +1 @@ +export { default as IconButton } from './IconButton'; diff --git a/packages/wallets/src/components/Base/index.ts b/packages/wallets/src/components/Base/index.ts index 4118cfe9336f..0639a9824c20 100644 --- a/packages/wallets/src/components/Base/index.ts +++ b/packages/wallets/src/components/Base/index.ts @@ -1,4 +1,5 @@ export * from './Divider'; +export * from './IconButton'; export * from './InlineMessage'; export * from './ModalStepWrapper'; export * from './ModalWrapper';