diff --git a/ui/components/app/beta-header/index.js b/ui/components/app/beta-header/index.js index 12c922be6..f030d53f6 100644 --- a/ui/components/app/beta-header/index.js +++ b/ui/components/app/beta-header/index.js @@ -14,7 +14,7 @@ import { import { BETA_BUGS_URL } from '../../../helpers/constants/beta'; import { hideBetaHeader } from '../../../store/actions'; -import { ButtonIcon } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; import { ICON_NAMES, ICON_SIZES, diff --git a/ui/components/app/connected-accounts-list/connected-accounts-list-options/connected-accounts-list-options.component.js b/ui/components/app/connected-accounts-list/connected-accounts-list-options/connected-accounts-list-options.component.js index 522de0097..90d1146c9 100644 --- a/ui/components/app/connected-accounts-list/connected-accounts-list-options/connected-accounts-list-options.component.js +++ b/ui/components/app/connected-accounts-list/connected-accounts-list-options/connected-accounts-list-options.component.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React, { useRef } from 'react'; import { Menu } from '../../../ui/menu'; import { ICON_NAMES } from '../../../component-library/icon/deprecated'; -import { ButtonIcon } from '../../../component-library'; +import { ButtonIcon } from '../../../component-library/button-icon/deprecated'; import { useI18nContext } from '../../../../hooks/useI18nContext'; const ConnectedAccountsListOptions = ({ diff --git a/ui/components/app/dropdowns/network-dropdown.js b/ui/components/app/dropdowns/network-dropdown.js index 33f95e3b4..131b700f6 100644 --- a/ui/components/app/dropdowns/network-dropdown.js +++ b/ui/components/app/dropdowns/network-dropdown.js @@ -32,7 +32,7 @@ import { ADD_POPULAR_CUSTOM_NETWORK, ADVANCED_ROUTE, } from '../../../helpers/constants/routes'; -import { ButtonIcon } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; import { Icon, ICON_NAMES, diff --git a/ui/components/app/flask/snap-authorship/snap-authorship.js b/ui/components/app/flask/snap-authorship/snap-authorship.js index 760d42096..4c44d20eb 100644 --- a/ui/components/app/flask/snap-authorship/snap-authorship.js +++ b/ui/components/app/flask/snap-authorship/snap-authorship.js @@ -20,7 +20,8 @@ import { getSnapName, removeSnapIdPrefix, } from '../../../../helpers/utils/util'; -import { Text, ButtonIcon } from '../../../component-library'; +import { ButtonIcon } from '../../../component-library/button-icon/deprecated'; +import { Text } from '../../../component-library'; import { ICON_NAMES, ICON_SIZES, diff --git a/ui/components/app/menu-bar/menu-bar.js b/ui/components/app/menu-bar/menu-bar.js index 32ce255b3..fac87c26f 100644 --- a/ui/components/app/menu-bar/menu-bar.js +++ b/ui/components/app/menu-bar/menu-bar.js @@ -14,7 +14,7 @@ import { CONNECTED_ACCOUNTS_ROUTE } from '../../../helpers/constants/routes'; import { useI18nContext } from '../../../hooks/useI18nContext'; import { getOriginOfCurrentTab } from '../../../selectors'; import { MetaMetricsContext } from '../../../contexts/metametrics'; -import { ButtonIcon } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; import { ICON_NAMES } from '../../component-library/icon/deprecated'; import { GlobalMenu } from '../../multichain/global-menu'; import AccountOptionsMenu from './account-options-menu'; diff --git a/ui/components/app/modals/contract-details-modal/contract-details-modal.js b/ui/components/app/modals/contract-details-modal/contract-details-modal.js index 6c6a5e7ec..563feb982 100644 --- a/ui/components/app/modals/contract-details-modal/contract-details-modal.js +++ b/ui/components/app/modals/contract-details-modal/contract-details-modal.js @@ -25,7 +25,7 @@ import { useCopyToClipboard } from '../../../../hooks/useCopyToClipboard'; import { getAddressBookEntry } from '../../../../selectors'; import { TokenStandard } from '../../../../../shared/constants/transaction'; import NftCollectionImage from '../../../ui/nft-collection-image/nft-collection-image'; -import { ButtonIcon } from '../../../component-library'; +import { ButtonIcon } from '../../../component-library/button-icon/deprecated'; import { ICON_NAMES } from '../../../component-library/icon/deprecated'; export default function ContractDetailsModal({ diff --git a/ui/components/app/modals/customize-nonce/customize-nonce.component.js b/ui/components/app/modals/customize-nonce/customize-nonce.component.js index 0c4f8b4cb..e1e0a944b 100644 --- a/ui/components/app/modals/customize-nonce/customize-nonce.component.js +++ b/ui/components/app/modals/customize-nonce/customize-nonce.component.js @@ -15,7 +15,7 @@ import Box from '../../../ui/box'; import withModalProps from '../../../../helpers/higher-order-components/with-modal-props'; import { useI18nContext } from '../../../../hooks/useI18nContext'; import ZENDESK_URLS from '../../../../helpers/constants/zendesk-url'; -import { ButtonIcon } from '../../../component-library'; +import { ButtonIcon } from '../../../component-library/button-icon/deprecated'; import { ICON_NAMES, ICON_SIZES, diff --git a/ui/components/app/modals/edit-approval-permission/edit-approval-permission.component.js b/ui/components/app/modals/edit-approval-permission/edit-approval-permission.component.js index 43602ba42..3c3b85cf0 100644 --- a/ui/components/app/modals/edit-approval-permission/edit-approval-permission.component.js +++ b/ui/components/app/modals/edit-approval-permission/edit-approval-permission.component.js @@ -10,7 +10,7 @@ import { calcTokenAmount, toPrecisionWithoutTrailingZeros, } from '../../../../../shared/lib/transactions-controller-utils'; -import { ButtonIcon } from '../../../component-library'; +import { ButtonIcon } from '../../../component-library/button-icon/deprecated'; import { ICON_SIZES, ICON_NAMES, diff --git a/ui/components/app/modals/hold-to-reveal-modal/hold-to-reveal-modal.js b/ui/components/app/modals/hold-to-reveal-modal/hold-to-reveal-modal.js index 3368017e3..de5a6a962 100644 --- a/ui/components/app/modals/hold-to-reveal-modal/hold-to-reveal-modal.js +++ b/ui/components/app/modals/hold-to-reveal-modal/hold-to-reveal-modal.js @@ -2,12 +2,8 @@ import PropTypes from 'prop-types'; import React from 'react'; import withModalProps from '../../../../helpers/higher-order-components/with-modal-props'; import Box from '../../../ui/box'; -import { - Text, - Button, - BUTTON_TYPES, - ButtonIcon, -} from '../../../component-library'; +import { Text, Button, BUTTON_TYPES } from '../../../component-library'; +import { ButtonIcon } from '../../../component-library/button-icon/deprecated'; import { ICON_NAMES } from '../../../component-library/icon/deprecated'; import { AlignItems, diff --git a/ui/components/app/modals/new-account-modal/new-account-modal.component.js b/ui/components/app/modals/new-account-modal/new-account-modal.component.js index 5e05df4ea..9ff7f9cdd 100644 --- a/ui/components/app/modals/new-account-modal/new-account-modal.component.js +++ b/ui/components/app/modals/new-account-modal/new-account-modal.component.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Button from '../../../ui/button/button.component'; -import { ButtonIcon } from '../../../component-library'; +import { ButtonIcon } from '../../../component-library/button-icon/deprecated'; import { ICON_NAMES } from '../../../component-library/icon/deprecated'; export default class NewAccountModal extends Component { diff --git a/ui/components/app/nft-details/nft-details.js b/ui/components/app/nft-details/nft-details.js index 3885126dd..1888f32f1 100644 --- a/ui/components/app/nft-details/nft-details.js +++ b/ui/components/app/nft-details/nft-details.js @@ -53,7 +53,7 @@ import { TokenStandard, } from '../../../../shared/constants/transaction'; import NftDefaultImage from '../nft-default-image'; -import { ButtonIcon } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; import { ICON_NAMES } from '../../component-library/icon/deprecated'; import Tooltip from '../../ui/tooltip'; import { decWEIToDecETH } from '../../../../shared/modules/conversion.utils'; diff --git a/ui/components/app/nft-options/nft-options.js b/ui/components/app/nft-options/nft-options.js index 2241da905..e67525f7c 100644 --- a/ui/components/app/nft-options/nft-options.js +++ b/ui/components/app/nft-options/nft-options.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import { I18nContext } from '../../../contexts/i18n'; import { Menu, MenuItem } from '../../ui/menu'; -import { ButtonIcon } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; import { ICON_NAMES } from '../../component-library/icon/deprecated'; import { Color } from '../../../helpers/constants/design-system'; diff --git a/ui/components/app/wallet-overview/eth-overview.js b/ui/components/app/wallet-overview/eth-overview.js index 8027e1e89..0352039c4 100644 --- a/ui/components/app/wallet-overview/eth-overview.js +++ b/ui/components/app/wallet-overview/eth-overview.js @@ -37,7 +37,10 @@ import { import Spinner from '../../ui/spinner'; import { startNewDraftTransaction } from '../../../ducks/send'; import { AssetType } from '../../../../shared/constants/transaction'; -import { ButtonIcon, BUTTON_ICON_SIZES } from '../../component-library'; +import { + ButtonIcon, + BUTTON_ICON_SIZES, +} from '../../component-library/button-icon/deprecated'; import { Icon, ICON_NAMES } from '../../component-library/icon/deprecated'; import { IconColor } from '../../../helpers/constants/design-system'; import useRamps from '../../../hooks/experiences/useRamps'; diff --git a/ui/components/component-library/banner-base/banner-base.js b/ui/components/component-library/banner-base/banner-base.js index 5f9dcc28e..fa4d39464 100644 --- a/ui/components/component-library/banner-base/banner-base.js +++ b/ui/components/component-library/banner-base/banner-base.js @@ -1,8 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import { ButtonIcon, ButtonLink, Text } from '..'; -import { IconName } from '../icon'; +import { ButtonIcon } from '../button-icon/deprecated'; +import { ButtonLink, Text } from '..'; +import { ICON_NAMES } from '../icon/deprecated'; import Box from '../../ui/box'; @@ -72,7 +73,7 @@ export const BannerBase = ({ ```jsx -import { Size } from '../../../helpers/constants/design-system'; +import { ButtonIconSize } from '../../../helpers/constants/design-system'; import { ButtonIcon } from '../ui/component-library'; - - + + ``` ### Aria Label diff --git a/ui/components/component-library/button-icon/__snapshots__/button-icon.test.js.snap b/ui/components/component-library/button-icon/__snapshots__/button-icon.test.tsx.snap similarity index 100% rename from ui/components/component-library/button-icon/__snapshots__/button-icon.test.js.snap rename to ui/components/component-library/button-icon/__snapshots__/button-icon.test.tsx.snap diff --git a/ui/components/component-library/button-icon/button-icon.stories.js b/ui/components/component-library/button-icon/button-icon.stories.tsx similarity index 50% rename from ui/components/component-library/button-icon/button-icon.stories.js rename to ui/components/component-library/button-icon/button-icon.stories.tsx index a86ad8312..d9afbca05 100644 --- a/ui/components/component-library/button-icon/button-icon.stories.js +++ b/ui/components/component-library/button-icon/button-icon.stories.tsx @@ -1,35 +1,11 @@ import React from 'react'; -import { - AlignItems, - Color, - DISPLAY, - FLEX_DIRECTION, - Size, -} from '../../../helpers/constants/design-system'; -import Box from '../../ui/box/box'; +import { ComponentStory, ComponentMeta } from '@storybook/react'; +import { Color } from '../../../helpers/constants/design-system'; import { IconName } from '..'; -import { BUTTON_ICON_SIZES } from './button-icon.constants'; +import { ButtonIconSize } from './button-icon.types'; import { ButtonIcon } from './button-icon'; import README from './README.mdx'; -const marginSizeControlOptions = [ - undefined, - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 'auto', -]; - export default { title: 'Components/ComponentLibrary/ButtonIcon', @@ -40,58 +16,18 @@ export default { }, }, argTypes: { - ariaLabel: { - control: 'text', - }, as: { control: 'select', options: ['button', 'a'], }, - className: { - control: 'text', - }, - color: { - control: 'select', - options: Object.values(Color), - }, - disabled: { - control: 'boolean', - }, - href: { - control: 'text', - }, - iconName: { - control: 'select', - options: Object.values(IconName), - }, - size: { - control: 'select', - options: Object.values(BUTTON_ICON_SIZES), - }, - marginTop: { - options: marginSizeControlOptions, - control: 'select', - table: { category: 'box props' }, - }, - marginRight: { - options: marginSizeControlOptions, - control: 'select', - table: { category: 'box props' }, - }, - marginBottom: { - options: marginSizeControlOptions, - control: 'select', - table: { category: 'box props' }, - }, - marginLeft: { - options: marginSizeControlOptions, - control: 'select', - table: { category: 'box props' }, - }, }, -}; +} as ComponentMeta; -export const DefaultStory = (args) => ; +const Template: ComponentStory = (args) => ( + +); + +export const DefaultStory = Template.bind({}); DefaultStory.args = { iconName: IconName.Close, @@ -100,7 +36,9 @@ DefaultStory.args = { DefaultStory.storyName = 'Default'; -export const IconNameStory = (args) => ; +export const IconNameStory: ComponentStory = (args) => ( + +); IconNameStory.args = { iconName: IconName.Close, @@ -109,32 +47,27 @@ IconNameStory.args = { IconNameStory.storyName = 'IconName'; -export const SizeStory = (args) => ( - +export const SizeStory: ComponentStory = (args) => ( + <> - + ); SizeStory.storyName = 'Size'; -export const AriaLabel = (args) => ( +export const AriaLabel: ComponentStory = (args) => ( <> ( ); -export const As = (args) => ( - +export const As: ComponentStory = (args) => ( + <> ( iconName={IconName.Export} ariaLabel="demo" /> - + ); -export const Href = (args) => ( +export const Href: ComponentStory = (args) => ( ); @@ -178,7 +111,7 @@ Href.args = { color: Color.primaryDefault, }; -export const ColorStory = (args) => ( +export const ColorStory: ComponentStory = (args) => ( ); ColorStory.storyName = 'Color'; @@ -187,7 +120,7 @@ ColorStory.args = { color: Color.primaryDefault, }; -export const Disabled = (args) => ( +export const Disabled: ComponentStory = (args) => ( ); diff --git a/ui/components/component-library/button-icon/button-icon.test.tsx b/ui/components/component-library/button-icon/button-icon.test.tsx new file mode 100644 index 000000000..1b4ae6a93 --- /dev/null +++ b/ui/components/component-library/button-icon/button-icon.test.tsx @@ -0,0 +1,147 @@ +/* eslint-disable jest/require-top-level-describe */ +import { render } from '@testing-library/react'; +import React from 'react'; +import { IconColor } from '../../../helpers/constants/design-system'; +import { IconName } from '..'; +import { ButtonIconSize } from './button-icon.types'; +import { ButtonIcon } from './button-icon'; + +describe('ButtonIcon', () => { + it('should render button element correctly', () => { + const { getByTestId, container } = render( + , + ); + expect(container.querySelector('button')).toBeDefined(); + expect(getByTestId('button-icon')).toHaveClass('mm-button-icon'); + expect(container).toMatchSnapshot(); + }); + + it('should render anchor element correctly', () => { + const { getByTestId, container } = render( + , + ); + expect(getByTestId('button-icon')).toHaveClass('mm-button-icon'); + const anchor = container.getElementsByTagName('a').length; + expect(anchor).toBe(1); + }); + + it('should render anchor element correctly using href', () => { + const { getByTestId, getByRole } = render( + , + ); + expect(getByTestId('button-icon')).toHaveClass('mm-button-icon'); + expect(getByRole('link')).toBeDefined(); + }); + + it('should render with different size classes', () => { + const { getByTestId } = render( + <> + + + , + ); + expect(getByTestId(ButtonIconSize.Sm)).toHaveClass( + `mm-button-icon--size-${ButtonIconSize.Sm}`, + ); + expect(getByTestId(ButtonIconSize.Lg)).toHaveClass( + `mm-button-icon--size-${ButtonIconSize.Lg}`, + ); + }); + + it('should render with different colors', () => { + const { getByTestId } = render( + <> + + + , + ); + expect(getByTestId(IconColor.iconDefault)).toHaveClass( + `box--color-${IconColor.iconDefault}`, + ); + expect(getByTestId(IconColor.errorDefault)).toHaveClass( + `box--color-${IconColor.errorDefault}`, + ); + }); + + it('should render with added classname', () => { + const { getByTestId } = render( + , + ); + expect(getByTestId('classname')).toHaveClass('mm-button-icon--test'); + }); + + it('should render with different button states', () => { + const { getByTestId } = render( + <> + + , + ); + + expect(getByTestId('disabled')).toHaveClass(`mm-button-icon--disabled`); + expect(getByTestId('disabled')).toBeDisabled(); + }); + it('should render with icon', () => { + const { getByTestId } = render( + , + ); + + expect(getByTestId('button-icon')).toBeDefined(); + }); + + it('should render with aria-label', () => { + const { getByLabelText } = render( + , + ); + + expect(getByLabelText('add')).toBeDefined(); + }); +}); diff --git a/ui/components/component-library/button-icon/button-icon.tsx b/ui/components/component-library/button-icon/button-icon.tsx new file mode 100644 index 000000000..3831cb838 --- /dev/null +++ b/ui/components/component-library/button-icon/button-icon.tsx @@ -0,0 +1,72 @@ +import React from 'react'; +import classnames from 'classnames'; + +import { + AlignItems, + BackgroundColor, + BorderRadius, + DISPLAY, + IconColor, + JustifyContent, +} from '../../../helpers/constants/design-system'; + +import Box from '../../ui/box'; +import { Icon, IconSize } from '../icon'; + +import { ButtonIconSize, ButtonIconProps } from './button-icon.types'; + +const buttonIconSizeToIconSize: Record = { + [ButtonIconSize.Sm]: IconSize.Sm, + [ButtonIconSize.Lg]: IconSize.Lg, +}; + +export const ButtonIcon = React.forwardRef( + ( + { + ariaLabel, + as = 'button', + className = '', + color = IconColor.iconDefault, + href, + size = ButtonIconSize.Lg, + iconName, + disabled, + iconProps, + ...props + }: ButtonIconProps, + ref: React.Ref, + ) => { + const Tag = href ? 'a' : as; + const isDisabled = disabled && Tag === 'button'; + return ( + + + + ); + }, +); diff --git a/ui/components/component-library/button-icon/button-icon.types.ts b/ui/components/component-library/button-icon/button-icon.types.ts new file mode 100644 index 000000000..d50d4cd85 --- /dev/null +++ b/ui/components/component-library/button-icon/button-icon.types.ts @@ -0,0 +1,50 @@ +import type { BoxProps } from '../../ui/box/box.d'; +import { IconName } from '../icon'; +import type { IconProps } from '../icon'; +import { IconColor } from '../../../helpers/constants/design-system'; + +export enum ButtonIconSize { + Sm = 'sm', + Lg = 'lg', +} + +export interface ButtonIconProps extends BoxProps { + /** + * String that adds an accessible name for ButtonIcon + */ + ariaLabel: string; + /** + * The polymorphic `as` prop allows you to change the root HTML element of the Button component between `button` and `a` tag + */ + as?: 'button' | 'a'; + /** + * An additional className to apply to the ButtonIcon. + */ + className?: string; + /** + * The color of the ButtonIcon component should use the IconColor object from + * ./ui/helpers/constants/design-system.js + */ + color?: IconColor; + /** + * Boolean to disable button + */ + disabled?: boolean; + /** + * When an `href` prop is passed, ButtonIcon will automatically change the root element to be an `a` (anchor) tag + */ + href?: string; + /** + * The name of the icon to display. Should be one of IconName + */ + iconName: IconName; + /** + * iconProps accepts all the props from Icon + */ + iconProps?: IconProps; + /** + * The size of the ButtonIcon. + * Possible values could be 'ButtonIconSize.Sm' 24px, 'ButtonIconSize.Lg' 32px, + */ + size?: ButtonIconSize; +} diff --git a/ui/components/component-library/button-icon/deprecated/__snapshots__/button-icon.test.js.snap b/ui/components/component-library/button-icon/deprecated/__snapshots__/button-icon.test.js.snap new file mode 100644 index 000000000..8a527a095 --- /dev/null +++ b/ui/components/component-library/button-icon/deprecated/__snapshots__/button-icon.test.js.snap @@ -0,0 +1,16 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ButtonIcon should render button element correctly 1`] = ` +
+ +
+`; diff --git a/ui/components/component-library/button-icon/button-icon.constants.js b/ui/components/component-library/button-icon/deprecated/button-icon.constants.js similarity index 50% rename from ui/components/component-library/button-icon/button-icon.constants.js rename to ui/components/component-library/button-icon/deprecated/button-icon.constants.js index 138a42034..de770633f 100644 --- a/ui/components/component-library/button-icon/button-icon.constants.js +++ b/ui/components/component-library/button-icon/deprecated/button-icon.constants.js @@ -1,4 +1,4 @@ -import { Size } from '../../../helpers/constants/design-system'; +import { Size } from '../../../../helpers/constants/design-system'; export const BUTTON_ICON_SIZES = { SM: Size.SM, diff --git a/ui/components/component-library/button-icon/button-icon.js b/ui/components/component-library/button-icon/deprecated/button-icon.js similarity index 91% rename from ui/components/component-library/button-icon/button-icon.js rename to ui/components/component-library/button-icon/deprecated/button-icon.js index 2428aedf6..bf3ecc9e8 100644 --- a/ui/components/component-library/button-icon/button-icon.js +++ b/ui/components/component-library/button-icon/deprecated/button-icon.js @@ -10,10 +10,10 @@ import { IconColor, JustifyContent, Size, -} from '../../../helpers/constants/design-system'; +} from '../../../../helpers/constants/design-system'; -import Box from '../../ui/box'; -import { Icon, IconName } from '../icon'; +import Box from '../../../ui/box'; +import { Icon, ICON_NAMES } from '../../icon/deprecated'; import { BUTTON_ICON_SIZES } from './button-icon.constants'; @@ -86,7 +86,7 @@ ButtonIcon.propTypes = { /** * The name of the icon to display. Should be one of IconName */ - iconName: PropTypes.oneOf(Object.values(IconName)).isRequired, + iconName: PropTypes.oneOf(Object.values(ICON_NAMES)).isRequired, /** * iconProps accepts all the props from Icon */ diff --git a/ui/components/component-library/button-icon/button-icon.test.js b/ui/components/component-library/button-icon/deprecated/button-icon.test.js similarity index 85% rename from ui/components/component-library/button-icon/button-icon.test.js rename to ui/components/component-library/button-icon/deprecated/button-icon.test.js index 236c258a8..d5ee5b88b 100644 --- a/ui/components/component-library/button-icon/button-icon.test.js +++ b/ui/components/component-library/button-icon/deprecated/button-icon.test.js @@ -1,8 +1,8 @@ /* eslint-disable jest/require-top-level-describe */ import { render } from '@testing-library/react'; import React from 'react'; -import { IconColor } from '../../../helpers/constants/design-system'; -import { IconName } from '..'; +import { IconColor } from '../../../../helpers/constants/design-system'; +import { ICON_NAMES } from '../../icon/deprecated'; import { BUTTON_ICON_SIZES } from './button-icon.constants'; import { ButtonIcon } from './button-icon'; @@ -11,7 +11,7 @@ describe('ButtonIcon', () => { const { getByTestId, container } = render( , ); @@ -25,7 +25,7 @@ describe('ButtonIcon', () => { , ); @@ -39,7 +39,7 @@ describe('ButtonIcon', () => { , ); @@ -51,13 +51,13 @@ describe('ButtonIcon', () => { const { getByTestId } = render( <> { const { getByTestId } = render( <> { , ); @@ -115,7 +115,7 @@ describe('ButtonIcon', () => { , @@ -128,7 +128,7 @@ describe('ButtonIcon', () => { const { getByTestId } = render( , @@ -139,7 +139,7 @@ describe('ButtonIcon', () => { it('should render with aria-label', () => { const { getByLabelText } = render( - , + , ); expect(getByLabelText('add')).toBeDefined(); diff --git a/ui/components/component-library/button-icon/index.js b/ui/components/component-library/button-icon/deprecated/index.js similarity index 100% rename from ui/components/component-library/button-icon/index.js rename to ui/components/component-library/button-icon/deprecated/index.js diff --git a/ui/components/component-library/button-icon/index.ts b/ui/components/component-library/button-icon/index.ts new file mode 100644 index 000000000..466166377 --- /dev/null +++ b/ui/components/component-library/button-icon/index.ts @@ -0,0 +1,3 @@ +export { ButtonIcon } from './button-icon'; +export { ButtonIconSize } from './button-icon.types'; +export type { ButtonIconProps } from './button-icon.types'; diff --git a/ui/components/component-library/header-base/README.mdx b/ui/components/component-library/header-base/README.mdx index 9b7ea11c1..547e374b5 100644 --- a/ui/components/component-library/header-base/README.mdx +++ b/ui/components/component-library/header-base/README.mdx @@ -56,6 +56,7 @@ import { HeaderBase, Text, ButtonIcon, + ButtonIconSize, IconName, } from '../../component-library'; import { @@ -66,7 +67,7 @@ import { @@ -91,7 +92,7 @@ Use the `endAccessoryWrapperProps` prop to customize the wrapper element around ```jsx import { ButtonIcon, - BUTTON_ICON_SIZES, + ButtonIconSize, HeaderBase, IconName, Text, @@ -104,7 +105,7 @@ import { diff --git a/ui/components/component-library/header-base/header-base.stories.tsx b/ui/components/component-library/header-base/header-base.stories.tsx index 8ca56d49b..c02ade945 100644 --- a/ui/components/component-library/header-base/header-base.stories.tsx +++ b/ui/components/component-library/header-base/header-base.stories.tsx @@ -4,11 +4,12 @@ import Box from '../../ui/box'; import { IconName, Button, - ButtonIcon, - BUTTON_ICON_SIZES, BUTTON_SIZES, + ButtonIcon, + ButtonIconSize, Text, } from '..'; + import { AlignItems, BackgroundColor, @@ -42,14 +43,14 @@ DefaultStory.args = { ), startAccessory: ( ), endAccessory: ( @@ -74,7 +75,7 @@ export const StartAccessory = (args) => { marginBottom={4} startAccessory={ @@ -94,7 +95,7 @@ export const EndAccessory = (args) => { marginBottom={4} endAccessory={ @@ -129,7 +130,7 @@ export const UseCaseDemos = (args) => ( endAccessory={ @@ -152,7 +153,7 @@ export const UseCaseDemos = (args) => ( startAccessory={ @@ -175,7 +176,7 @@ export const UseCaseDemos = (args) => ( startAccessory={ @@ -183,7 +184,7 @@ export const UseCaseDemos = (args) => ( endAccessory={ @@ -215,7 +216,7 @@ export const UseCaseDemos = (args) => ( endAccessory={ @@ -242,7 +243,7 @@ export const UseCaseDemos = (args) => ( startAccessory={ @@ -281,7 +282,7 @@ export const UseCaseDemos = (args) => ( endAccessory={ diff --git a/ui/components/component-library/icon/icon.stories.tsx b/ui/components/component-library/icon/icon.stories.tsx index b3523d2df..0fdc61942 100644 --- a/ui/components/component-library/icon/icon.stories.tsx +++ b/ui/components/component-library/icon/icon.stories.tsx @@ -26,7 +26,7 @@ import { TextField, TextFieldSearch, TEXT_FIELD_SIZES, - BUTTON_ICON_SIZES, + ButtonIconSize, BUTTON_LINK_SIZES, } from '..'; @@ -131,7 +131,7 @@ export const DefaultStory: ComponentStory = (args) => { endAccessory={ diff --git a/ui/components/component-library/text-field/README.mdx b/ui/components/component-library/text-field/README.mdx index 81631aec5..62a4c0c5d 100644 --- a/ui/components/component-library/text-field/README.mdx +++ b/ui/components/component-library/text-field/README.mdx @@ -90,8 +90,8 @@ Use the `startAccessory` and `endAccessory` props to add components such as icon ```jsx import { Color, IconColor, SIZES, DISPLAY } from '../../../helpers/constants/design-system'; -import { Icon, IconName } from '../../component-library/deprecated' -import { ButtonIcon, TextField } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; +import { TextField, Icon, IconName } from '../../component-library'; { /** * The content of the Box component. diff --git a/ui/components/ui/callout/callout.js b/ui/components/ui/callout/callout.js index 95585a728..8538d69cd 100644 --- a/ui/components/ui/callout/callout.js +++ b/ui/components/ui/callout/callout.js @@ -5,7 +5,7 @@ import InfoIconInverted from '../icon/info-icon-inverted.component'; import { SEVERITIES, Color } from '../../../helpers/constants/design-system'; import { MILLISECOND } from '../../../../shared/constants/time'; import Typography from '../typography'; -import { ButtonIcon } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; import { ICON_NAMES, ICON_SIZES, diff --git a/ui/components/ui/contract-token-values/contract-token-values.js b/ui/components/ui/contract-token-values/contract-token-values.js index 8667a379c..b34b34b6a 100644 --- a/ui/components/ui/contract-token-values/contract-token-values.js +++ b/ui/components/ui/contract-token-values/contract-token-values.js @@ -16,7 +16,7 @@ import { Color, } from '../../../helpers/constants/design-system'; import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard'; -import { ButtonIcon } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; import { ICON_NAMES } from '../../component-library/icon/deprecated'; export default function ContractTokenValues({ diff --git a/ui/components/ui/editable-label/editable-label.js b/ui/components/ui/editable-label/editable-label.js index bab04c839..98385776d 100644 --- a/ui/components/ui/editable-label/editable-label.js +++ b/ui/components/ui/editable-label/editable-label.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { Color } from '../../../helpers/constants/design-system'; import { getAccountNameErrorMessage } from '../../../helpers/utils/accounts'; -import { ButtonIcon } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; import { ICON_NAMES } from '../../component-library/icon/deprecated'; export default class EditableLabel extends Component { diff --git a/ui/components/ui/nickname-popover/nickname-popover.component.js b/ui/components/ui/nickname-popover/nickname-popover.component.js index 2c48d086c..60785b18a 100644 --- a/ui/components/ui/nickname-popover/nickname-popover.component.js +++ b/ui/components/ui/nickname-popover/nickname-popover.component.js @@ -15,7 +15,7 @@ import { ICON_NAMES, ICON_SIZES, } from '../../component-library/icon/deprecated'; -import { ButtonIcon } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; const NicknamePopover = ({ address, diff --git a/ui/components/ui/popover/popover.component.js b/ui/components/ui/popover/popover.component.js index 6d0a1ba8f..6e62e0bfd 100644 --- a/ui/components/ui/popover/popover.component.js +++ b/ui/components/ui/popover/popover.component.js @@ -23,7 +23,8 @@ import { ICON_NAMES, ICON_SIZES, } from '../../component-library/icon/deprecated'; -import { ButtonIcon, Text } from '../../component-library'; +import { ButtonIcon } from '../../component-library/button-icon/deprecated'; +import { Text } from '../../component-library'; const defaultHeaderProps = { padding: [6, 4, 4], diff --git a/ui/pages/add-nft/add-nft.js b/ui/pages/add-nft/add-nft.js index a4569da92..1463896b0 100644 --- a/ui/pages/add-nft/add-nft.js +++ b/ui/pages/add-nft/add-nft.js @@ -40,7 +40,7 @@ import { ICON_NAMES, ICON_SIZES, } from '../../components/component-library/icon/deprecated'; -import { ButtonIcon } from '../../components/component-library'; +import { ButtonIcon } from '../../components/component-library/button-icon/deprecated'; export default function AddNft() { const t = useI18nContext(); diff --git a/ui/pages/asset/components/asset-options.js b/ui/pages/asset/components/asset-options.js index 5498e279c..b5a46a683 100644 --- a/ui/pages/asset/components/asset-options.js +++ b/ui/pages/asset/components/asset-options.js @@ -8,7 +8,7 @@ import { Menu, MenuItem } from '../../../components/ui/menu'; import { getBlockExplorerLinkText } from '../../../selectors'; import { NETWORKS_ROUTE } from '../../../helpers/constants/routes'; import { ICON_NAMES } from '../../../components/component-library/icon/deprecated'; -import { ButtonIcon } from '../../../components/component-library'; +import { ButtonIcon } from '../../../components/component-library/button-icon/deprecated'; import { Color } from '../../../helpers/constants/design-system'; const AssetOptions = ({ diff --git a/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js b/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js index 1a91543f8..4d1f8dfbf 100644 --- a/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js +++ b/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.js @@ -30,7 +30,8 @@ import { ICON_NAMES, Icon, } from '../../../components/component-library/icon/deprecated'; -import { ButtonIcon, Text } from '../../../components/component-library'; +import { ButtonIcon } from '../../../components/component-library/button-icon/deprecated'; +import { Text } from '../../../components/component-library'; export default class ConfirmApproveContent extends Component { static contextTypes = { diff --git a/ui/pages/home/home.component.js b/ui/pages/home/home.component.js index 86d2f63b7..c525bd161 100644 --- a/ui/pages/home/home.component.js +++ b/ui/pages/home/home.component.js @@ -35,7 +35,8 @@ import { ICON_NAMES, ICON_SIZES, } from '../../components/component-library/icon/deprecated'; -import { ButtonIcon, Text } from '../../components/component-library'; +import { ButtonIcon } from '../../components/component-library/button-icon/deprecated'; +import { Text } from '../../components/component-library'; import { ASSET_ROUTE, diff --git a/ui/pages/institutional/compliance-feature-page/compliance-feature-page.js b/ui/pages/institutional/compliance-feature-page/compliance-feature-page.js index ac2491593..acc8e63f4 100644 --- a/ui/pages/institutional/compliance-feature-page/compliance-feature-page.js +++ b/ui/pages/institutional/compliance-feature-page/compliance-feature-page.js @@ -13,7 +13,8 @@ import { Color, FLEX_DIRECTION, } from '../../../helpers/constants/design-system'; -import { ButtonIcon, Text } from '../../../components/component-library'; +import { ButtonIcon } from '../../../components/component-library/button-icon/deprecated'; +import { Text } from '../../../components/component-library'; import { ICON_NAMES, ICON_SIZES, diff --git a/ui/pages/notifications/notifications.js b/ui/pages/notifications/notifications.js index c52332c89..5e37225e1 100644 --- a/ui/pages/notifications/notifications.js +++ b/ui/pages/notifications/notifications.js @@ -20,7 +20,7 @@ import { ICON_SIZES, ICON_NAMES, } from '../../components/component-library/icon/deprecated'; -import { ButtonIcon } from '../../components/component-library'; +import { ButtonIcon } from '../../components/component-library/button-icon/deprecated'; import { Color } from '../../helpers/constants/design-system'; export function NotificationItem({ notification, snaps, onItemClick }) { diff --git a/ui/pages/send/send-content/add-recipient/domain-input.component.js b/ui/pages/send/send-content/add-recipient/domain-input.component.js index a074937a6..26f0898ae 100644 --- a/ui/pages/send/send-content/add-recipient/domain-input.component.js +++ b/ui/pages/send/send-content/add-recipient/domain-input.component.js @@ -13,7 +13,7 @@ import { ICON_NAMES, ICON_SIZES, } from '../../../../components/component-library/icon/deprecated'; -import { ButtonIcon } from '../../../../components/component-library'; +import { ButtonIcon } from '../../../../components/component-library/button-icon/deprecated'; import { IconColor } from '../../../../helpers/constants/design-system'; export default class DomainInput extends Component { diff --git a/ui/pages/settings/contact-list-tab/view-contact/view-contact.component.js b/ui/pages/settings/contact-list-tab/view-contact/view-contact.component.js index b4c6ed2f1..8a28efe00 100644 --- a/ui/pages/settings/contact-list-tab/view-contact/view-contact.component.js +++ b/ui/pages/settings/contact-list-tab/view-contact/view-contact.component.js @@ -9,7 +9,7 @@ import { ICON_SIZES, } from '../../../../components/component-library/icon/deprecated'; -import { ButtonIcon } from '../../../../components/component-library'; +import { ButtonIcon } from '../../../../components/component-library/button-icon/deprecated'; import Tooltip from '../../../../components/ui/tooltip'; import { useI18nContext } from '../../../../hooks/useI18nContext'; diff --git a/ui/pages/settings/settings.component.js b/ui/pages/settings/settings.component.js index d87ab0c4e..b9e007e86 100644 --- a/ui/pages/settings/settings.component.js +++ b/ui/pages/settings/settings.component.js @@ -27,7 +27,7 @@ import { import { getSettingsRoutes } from '../../helpers/utils/settings-search'; import AddNetwork from '../../components/app/add-network/add-network'; -import { ButtonIcon } from '../../components/component-library'; +import { ButtonIcon } from '../../components/component-library/button-icon/deprecated'; import { Icon, ICON_NAMES, diff --git a/ui/pages/token-details/token-details-page.js b/ui/pages/token-details/token-details-page.js index 8959547fe..91a088b3d 100644 --- a/ui/pages/token-details/token-details-page.js +++ b/ui/pages/token-details/token-details-page.js @@ -29,7 +29,7 @@ import { ICON_SIZES, ICON_NAMES, } from '../../components/component-library/icon/deprecated'; -import { ButtonIcon } from '../../components/component-library'; +import { ButtonIcon } from '../../components/component-library/button-icon/deprecated'; export default function TokenDetailsPage() { const dispatch = useDispatch();