diff --git a/ui/components/component-library/banner-base/README.mdx b/ui/components/component-library/banner-base/README.mdx index 5fbb23f49..7681b2273 100644 --- a/ui/components/component-library/banner-base/README.mdx +++ b/ui/components/component-library/banner-base/README.mdx @@ -68,7 +68,7 @@ import { BannerBase, ICON_NAMES } from '../../component-library'; title="Action prop demo" actionButtonLabel="Action" actionButtonProps={{ - icon: ICON_NAMES.ARROW_2_RIGHT, // TODO: change to iconName + iconName: ICON_NAMES.ARROW_2_RIGHT, iconPositionRight: true, }} actionButtonOnClick={() => console.log('ButtonLink actionButtonOnClick demo')} diff --git a/ui/components/component-library/banner-base/banner-base.js b/ui/components/component-library/banner-base/banner-base.js index 14a9e76b3..be4c01f95 100644 --- a/ui/components/component-library/banner-base/banner-base.js +++ b/ui/components/component-library/banner-base/banner-base.js @@ -57,8 +57,7 @@ export const BannerBase = ({ )} {actionButtonLabel && ( diff --git a/ui/components/component-library/banner-base/banner-base.stories.js b/ui/components/component-library/banner-base/banner-base.stories.js index 5efe86798..0ff626855 100644 --- a/ui/components/component-library/banner-base/banner-base.stories.js +++ b/ui/components/component-library/banner-base/banner-base.stories.js @@ -126,7 +126,7 @@ ActionButton.args = { actionButtonLabel: 'Action', actionButtonOnClick: () => console.log('ButtonLink actionButtonOnClick demo'), actionButtonProps: { - icon: ICON_NAMES.ARROW_2_RIGHT, // TODO: change to iconName + iconName: ICON_NAMES.ARROW_2_RIGHT, // TODO: change to iconName iconPositionRight: true, }, children: diff --git a/ui/components/component-library/button-base/README.mdx b/ui/components/component-library/button-base/README.mdx index 2cc551e53..25ba299cf 100644 --- a/ui/components/component-library/button-base/README.mdx +++ b/ui/components/component-library/button-base/README.mdx @@ -26,7 +26,6 @@ Optional: `BUTTON_BASE_SIZES` from `./button-base` object can be used instead of Possible sizes include: -- `SIZES.AUTO` inherits the font-size of the parent element. - `SIZES.SM` 32px - `SIZES.MD` 40px - `SIZES.LG` 48px @@ -39,7 +38,6 @@ Possible sizes include: import { SIZES } from '../../../helpers/constants/design-system'; import { ButtonBase } from '../../component-library'; - diff --git a/ui/components/component-library/button-base/button-base.constants.js b/ui/components/component-library/button-base/button-base.constants.js index a5c102366..9b70479c6 100644 --- a/ui/components/component-library/button-base/button-base.constants.js +++ b/ui/components/component-library/button-base/button-base.constants.js @@ -4,5 +4,4 @@ export const BUTTON_BASE_SIZES = { SM: SIZES.SM, MD: SIZES.MD, LG: SIZES.LG, - AUTO: SIZES.AUTO, }; diff --git a/ui/components/component-library/button-base/button-base.js b/ui/components/component-library/button-base/button-base.js index 0c554a991..acaf35777 100644 --- a/ui/components/component-library/button-base/button-base.js +++ b/ui/components/component-library/button-base/button-base.js @@ -31,7 +31,8 @@ export const ButtonBase = ({ loading, disabled, iconProps, - buttonTextProps, + iconLoadingProps, + textProps, ...props }) => { const Tag = href ? 'a' : as; @@ -41,13 +42,13 @@ export const ButtonBase = ({ backgroundColor={COLORS.BACKGROUND_ALTERNATIVE} color={COLORS.TEXT_DEFAULT} href={href} - paddingLeft={size === BUTTON_BASE_SIZES.AUTO ? 0 : 4} - paddingRight={size === BUTTON_BASE_SIZES.AUTO ? 0 : 4} - borderRadius={BORDER_RADIUS.PILL} + paddingLeft={4} + paddingRight={4} className={classnames( 'mm-button-base', - `mm-button-base--size-${size}`, { + [`mm-button-base--size-${size}`]: + Object.values(BUTTON_BASE_SIZES).includes(size), 'mm-button-base--loading': loading, 'mm-button-base--disabled': disabled, 'mm-button-base--block': block, @@ -58,6 +59,7 @@ export const ButtonBase = ({ display={DISPLAY.INLINE_FLEX} justifyContent={JUSTIFY_CONTENT.CENTER} alignItems={ALIGN_ITEMS.CENTER} + borderRadius={BORDER_RADIUS.PILL} {...props} > - {iconName && ( - - )} + {iconName && } {children} {loading && ( )} @@ -135,16 +132,27 @@ ButtonBase.propTypes = { /** * iconProps accepts all the props from Icon */ - iconProps: PropTypes.object, + iconProps: PropTypes.shape(Icon.PropTypes), + /** + * iconLoadingProps accepts all the props from Icon + */ + iconLoadingProps: PropTypes.shape(Icon.PropTypes), /** * Boolean to show loading spinner in button */ loading: PropTypes.bool, /** * The size of the ButtonBase. - * Possible values could be 'SIZES.AUTO', 'SIZES.SM'(32px), 'SIZES.MD'(40px), 'SIZES.LG'(48px), + * Possible values could be 'SIZES.SM'(32px), 'SIZES.MD'(40px), 'SIZES.LG'(48px), */ - size: PropTypes.oneOf(Object.values(BUTTON_BASE_SIZES)), + size: PropTypes.oneOfType([ + PropTypes.shape(BUTTON_BASE_SIZES), + PropTypes.string, + ]), + /** + * textProps accepts all the props from Icon + */ + textProps: PropTypes.shape(Text.PropTypes), /** * ButtonBase accepts all the props from Box */ diff --git a/ui/components/component-library/button-base/button-base.scss b/ui/components/component-library/button-base/button-base.scss index e7798075e..42e6d24a9 100644 --- a/ui/components/component-library/button-base/button-base.scss +++ b/ui/components/component-library/button-base/button-base.scss @@ -32,18 +32,6 @@ height: 48px; } - &--size-auto { - height: auto; - background-color: transparent; - border-radius: 0; - vertical-align: top; - font-family: inherit; - font-weight: inherit; - font-size: inherit; - line-height: inherit; - letter-spacing: inherit; - } - &--loading { cursor: not-allowed; } diff --git a/ui/components/component-library/button-base/button-base.stories.js b/ui/components/component-library/button-base/button-base.stories.js index 38b7c3c6f..7f61e99fc 100644 --- a/ui/components/component-library/button-base/button-base.stories.js +++ b/ui/components/component-library/button-base/button-base.stories.js @@ -4,11 +4,9 @@ import { DISPLAY, FLEX_DIRECTION, SIZES, - TEXT, } from '../../../helpers/constants/design-system'; import Box from '../../ui/box/box'; import { ICON_NAMES } from '../icon'; -import { Text } from '../text'; import { BUTTON_BASE_SIZES } from './button-base.constants'; import { ButtonBase } from './button-base'; import README from './README.mdx'; @@ -57,7 +55,7 @@ export default { disabled: { control: 'boolean', }, - icon: { + iconName: { control: 'select', options: Object.values(ICON_NAMES), }, @@ -116,12 +114,6 @@ export const Size = (args) => ( Button LG - - - Button Auto - {' '} - inherits the font-size of the parent element. - ); diff --git a/ui/components/component-library/button-base/button-base.test.js b/ui/components/component-library/button-base/button-base.test.js index 99ca354f9..965e07ec7 100644 --- a/ui/components/component-library/button-base/button-base.test.js +++ b/ui/components/component-library/button-base/button-base.test.js @@ -47,10 +47,6 @@ describe('ButtonBase', () => { it('should render with different size classes', () => { const { getByTestId } = render( <> - { /> , ); - expect(getByTestId(BUTTON_BASE_SIZES.AUTO)).toHaveClass( - `mm-button-base--size-${BUTTON_BASE_SIZES.AUTO}`, - ); expect(getByTestId(BUTTON_BASE_SIZES.SM)).toHaveClass( `mm-button-base--size-${BUTTON_BASE_SIZES.SM}`, ); diff --git a/ui/components/component-library/button-link/README.mdx b/ui/components/component-library/button-link/README.mdx index 75086eff9..da44afaca 100644 --- a/ui/components/component-library/button-link/README.mdx +++ b/ui/components/component-library/button-link/README.mdx @@ -1,10 +1,11 @@ import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'; import { ButtonLink } from './button-link'; +import { ButtonBase } from '../button-base'; # ButtonLink -The `ButtonLink` is an extension of `ButtonBase` to support link styles. +The `ButtonLink` is an extension of `ButtonBase` to support link styles @@ -16,18 +17,23 @@ The `ButtonLink` accepts all props below as well as all [Box](/docs/components-u +The `ButtonLink` accepts all [ButtonBase](/docs/components-componentlibrary-buttonbase--default-story#props) component props + + + ### Size -Use the `size` prop and the `SIZES` object from `./ui/helpers/constants/design-system.js` to change the size of `ButtonLink`. Defaults to `SIZES.MD` +Use the `size` prop and the `SIZES` object from `./ui/helpers/constants/design-system.js` to change the size of `ButtonLink`. Defaults to `SIZES.AUTO`. -Optional: `BUTTON_SIZES` from `./button-base` object can be used instead of `SIZES`. +Optional: `BUTTON_LINK_SIZES` from `../../component-library` object can be used instead of `SIZES` Possible sizes include: -- `SIZES.AUTO` inherits the font-size of the parent element. +- `SIZES.AUTO` sets the height to auto but retains `ButtonLink` font-size - `SIZES.SM` 32px - `SIZES.MD` 40px - `SIZES.LG` 48px +- `SIZES.INHERIT` inherits the font-size of the parent element. Used for inline links in paragraphs. @@ -35,12 +41,33 @@ Possible sizes include: ```jsx import { SIZES } from '../../../helpers/constants/design-system'; -import { ButtonLink } from '../../component-library'; +import { ButtonLink, Text, TEXT } from '../../component-library'; - - - - + + Auto (default) + + + Small + + + Medium + + + Large + + + + Inherits the font-size of the parent element. Learn more + + + Inherits the font-size of the parent element. Learn more + + + Inherits the font-size of the parent element. Learn more + + + Inherits the font-size of the parent element. Learn more + ``` ### Danger @@ -69,5 +96,33 @@ When an `href` prop is passed it will change the element to an anchor(`a`) tag. ```jsx import { ButtonLink } from '../../component-library'; -Anchor Element; +Href example; +``` + +### Hit area + +The default hit area for `ButtonLink` is the width of the text and height based on the `size` prop which is set to `SIZES.AUTO` by default. There may be times when you want to increase the hit area of the `ButtonLink`. To do this you can use the `Box` props `paddingLeft` and `paddingRight`. Or alternatively you can use the `block` prop which sets the width to 100%. + + + + + +```jsx +import { ButtonLink } from '../../component-library'; + + + Auto (default) + + + Small + + + Medium + + + Large + + + Large block + ``` diff --git a/ui/components/component-library/button-link/__snapshots__/button-link.test.js.snap b/ui/components/component-library/button-link/__snapshots__/button-link.test.js.snap index 0ff4b9a74..f62717f6c 100644 --- a/ui/components/component-library/button-link/__snapshots__/button-link.test.js.snap +++ b/ui/components/component-library/button-link/__snapshots__/button-link.test.js.snap @@ -3,7 +3,7 @@ exports[`ButtonLink should render button element correctly 1`] = `
+ - {' '} - inherits the font-size of the parent element. Auto size only used for + inherits the font-size of the parent element. Inherit size only used for ButtonLink. diff --git a/ui/components/component-library/button/button.test.js b/ui/components/component-library/button/button.test.js index 9cf7460d6..7241fecd8 100644 --- a/ui/components/component-library/button/button.test.js +++ b/ui/components/component-library/button/button.test.js @@ -75,11 +75,11 @@ describe('Button', () => { const { getByTestId } = render( <> , ); - expect(getByTestId(BUTTON_SIZES.AUTO)).toHaveClass( - `mm-button-base--size-${BUTTON_SIZES.AUTO}`, + expect(getByTestId(BUTTON_SIZES.INHERIT)).toHaveClass( + `mm-button-link--size-${BUTTON_SIZES.INHERIT}`, ); expect(getByTestId(BUTTON_SIZES.SM)).toHaveClass( `mm-button-base--size-${BUTTON_SIZES.SM}`, diff --git a/ui/components/component-library/form-text-field/README.mdx b/ui/components/component-library/form-text-field/README.mdx index 6a01a0279..ea2b16a10 100644 --- a/ui/components/component-library/form-text-field/README.mdx +++ b/ui/components/component-library/form-text-field/README.mdx @@ -296,12 +296,12 @@ import { color={COLORS.ICON_ALTERNATIVE} /> - Use default + Use default Max} + rightAccessory={Max} marginBottom={4} type={TEXT_FIELD_TYPES.NUMBER} /> @@ -314,6 +314,7 @@ import { display={DISPLAY.FLEX} alignItems={ALIGN_ITEMS.FLEX_START} justifyContent={JUSTIFY_CONTENT.SPACE_BETWEEN} + marginTop={1} > {/** * If you need a custom help text @@ -321,11 +322,11 @@ import { * import the HelpText component separately and handle the error * logic yourself */} - + Only enter a number that you're comfortable with the contract accessing now or in the future. You can always increase the token limit later. - + Max diff --git a/ui/components/component-library/form-text-field/form-text-field.stories.js b/ui/components/component-library/form-text-field/form-text-field.stories.js index a41bb1fb0..7c16b6b5e 100644 --- a/ui/components/component-library/form-text-field/form-text-field.stories.js +++ b/ui/components/component-library/form-text-field/form-text-field.stories.js @@ -441,12 +441,12 @@ export const CustomLabelOrHelpText = () => ( color={COLORS.ICON_ALTERNATIVE} /> - Use default + Use default Max} + rightAccessory={Max} marginBottom={4} type={TEXT_FIELD_TYPES.NUMBER} /> @@ -469,7 +469,7 @@ export const CustomLabelOrHelpText = () => ( accessing now or in the future. You can always increase the token limit later. - + Max diff --git a/ui/components/component-library/help-text/README.mdx b/ui/components/component-library/help-text/README.mdx index 663d16f30..27d330c36 100644 --- a/ui/components/component-library/help-text/README.mdx +++ b/ui/components/component-library/help-text/README.mdx @@ -41,7 +41,7 @@ import { HelpText, Icon, ICON_NAMES } from '../../component-library'; marginLeft={1} color={COLORS.INHERIT} name={ICON_NAMES.WARNING} - size={SIZES.AUTO} + size={SIZES.INHERIT} /> ``` diff --git a/ui/components/component-library/help-text/help-text.stories.js b/ui/components/component-library/help-text/help-text.stories.js index 54f1f62e2..95ec9ebb7 100644 --- a/ui/components/component-library/help-text/help-text.stories.js +++ b/ui/components/component-library/help-text/help-text.stories.js @@ -58,7 +58,7 @@ export const Children = (args) => ( marginLeft={1} color={COLORS.INHERIT} name={ICON_NAMES.WARNING} - size={SIZES.AUTO} + size={SIZES.INHERIT} /> diff --git a/ui/components/component-library/icon/README.mdx b/ui/components/component-library/icon/README.mdx index c26bc15ad..5b77046de 100644 --- a/ui/components/component-library/icon/README.mdx +++ b/ui/components/component-library/icon/README.mdx @@ -47,7 +47,7 @@ Possible sizes include: - `SIZES.MD` 20px - `SIZES.LG` 24px - `SIZES.XL` 32px -- `SIZES.AUTO` inherits the font-size from parent element. This is useful for inline icons in text. +- `SIZES.INHERIT` inherits the font-size from parent element. This is useful for inline icons in text. @@ -63,7 +63,7 @@ import { Icon, ICON_NAMES } from '../../components/component-library'; - Auto also exists and inherits the + inherits the font-size of the parent element. ``` diff --git a/ui/components/component-library/icon/icon.constants.js b/ui/components/component-library/icon/icon.constants.js index 8bf5139f3..bfa7174d8 100644 --- a/ui/components/component-library/icon/icon.constants.js +++ b/ui/components/component-library/icon/icon.constants.js @@ -20,5 +20,5 @@ export const ICON_SIZES = { MD: SIZES.MD, LG: SIZES.LG, XL: SIZES.XL, - AUTO: SIZES.AUTO, + AUTO: SIZES.INHERIT, }; diff --git a/ui/components/component-library/icon/icon.scss b/ui/components/component-library/icon/icon.scss index 3c2c86b8e..a9f7db629 100644 --- a/ui/components/component-library/icon/icon.scss +++ b/ui/components/component-library/icon/icon.scss @@ -37,7 +37,7 @@ --size: 32px; } - &--size-auto { + &--size-inherit { --size: 1em; // Inherits parent font-size position: relative; // Fixes vertical alignment diff --git a/ui/components/component-library/icon/icon.stories.js b/ui/components/component-library/icon/icon.stories.js index 3ddce7976..33b460226 100644 --- a/ui/components/component-library/icon/icon.stories.js +++ b/ui/components/component-library/icon/icon.stories.js @@ -203,7 +203,7 @@ export const DefaultStory = (args) => { No matches. Please try again or ask in the{' '} ( - Auto also exists and inherits the - font-size of the parent element. + inherits the font-size of the + parent element. ); diff --git a/ui/components/component-library/icon/icon.test.js b/ui/components/component-library/icon/icon.test.js index 341c630fb..1964d1ca8 100644 --- a/ui/components/component-library/icon/icon.test.js +++ b/ui/components/component-library/icon/icon.test.js @@ -96,7 +96,7 @@ describe('Icon', () => { /> , @@ -106,7 +106,7 @@ describe('Icon', () => { expect(getByTestId('icon-md')).toHaveClass('mm-icon--size-md'); expect(getByTestId('icon-lg')).toHaveClass('mm-icon--size-lg'); expect(getByTestId('icon-xl')).toHaveClass('mm-icon--size-xl'); - expect(getByTestId('icon-auto')).toHaveClass('mm-icon--size-auto'); + expect(getByTestId('icon-auto')).toHaveClass('mm-icon--size-inherit'); }); it('should render with icon colors', () => { const { getByTestId } = render( diff --git a/ui/components/component-library/label/README.mdx b/ui/components/component-library/label/README.mdx index 2f89a8259..57fe13621 100644 --- a/ui/components/component-library/label/README.mdx +++ b/ui/components/component-library/label/README.mdx @@ -40,7 +40,7 @@ import { Label, TextField, Icon, ICON_NAMES } from '../../component-library';