diff --git a/ui/components/component-library/avatar-account/__snapshots__/avatar-account.test.js.snap b/ui/components/component-library/avatar-account/__snapshots__/avatar-account.test.js.snap index 4fb7ecbbe..0dfe9536f 100644 --- a/ui/components/component-library/avatar-account/__snapshots__/avatar-account.test.js.snap +++ b/ui/components/component-library/avatar-account/__snapshots__/avatar-account.test.js.snap @@ -3,7 +3,7 @@ exports[`AvatarAccount should render correctly 1`] = `
diff --git a/ui/components/component-library/avatar-base/__snapshots__/avatar-base.test.js.snap b/ui/components/component-library/avatar-base/__snapshots__/avatar-base.test.js.snap index 004fa7ead..91206391f 100644 --- a/ui/components/component-library/avatar-base/__snapshots__/avatar-base.test.js.snap +++ b/ui/components/component-library/avatar-base/__snapshots__/avatar-base.test.js.snap @@ -3,7 +3,7 @@ exports[`AvatarBase should render correctly 1`] = `
diff --git a/ui/components/component-library/avatar-base/avatar-base.js b/ui/components/component-library/avatar-base/avatar-base.js index 8b6da1f0e..22a1e9553 100644 --- a/ui/components/component-library/avatar-base/avatar-base.js +++ b/ui/components/component-library/avatar-base/avatar-base.js @@ -2,12 +2,20 @@ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -import Box from '../../ui/box/box'; import { BackgroundColor, BorderColor, TextColor, + DISPLAY, + JustifyContent, + AlignItems, + BorderRadius, + TextVariant, + TEXT_TRANSFORM, } from '../../../helpers/constants/design-system'; + +import { Text } from '../text'; + import { AVATAR_BASE_SIZES } from './avatar-base.constants'; export const AvatarBase = ({ @@ -18,19 +26,36 @@ export const AvatarBase = ({ color = TextColor.textDefault, className, ...props -}) => ( - - {children} - -); +}) => { + let fallbackTextVariant; + if (size === AVATAR_BASE_SIZES.LG || size === AVATAR_BASE_SIZES.XL) { + fallbackTextVariant = TextVariant.bodyLgMedium; + } else if (size === AVATAR_BASE_SIZES.SM || size === AVATAR_BASE_SIZES.MD) { + fallbackTextVariant = TextVariant.bodySm; + } else { + fallbackTextVariant = TextVariant.bodyXs; + } + return ( + + {children} + + ); +}; AvatarBase.propTypes = { /** * The size of the AvatarBase. @@ -62,8 +87,7 @@ AvatarBase.propTypes = { */ className: PropTypes.string, /** - * AvatarBase also accepts all Box props including but not limited to - * className, as(change root element of HTML element) and margin props + * AvatarBase also accepts all Text props including variant and all Box props */ - ...Box.propTypes, + ...Text.propTypes, }; diff --git a/ui/components/component-library/avatar-base/avatar-base.scss b/ui/components/component-library/avatar-base/avatar-base.scss index 257a897c7..28a094e01 100644 --- a/ui/components/component-library/avatar-base/avatar-base.scss +++ b/ui/components/component-library/avatar-base/avatar-base.scss @@ -25,10 +25,5 @@ width: var(--avatar-size); max-width: var(--avatar-size); flex: 0 0 var(--avatar-size); - border-radius: 100%; overflow: hidden; - display: flex; - align-items: center; - justify-content: center; - text-transform: uppercase; } diff --git a/ui/components/component-library/avatar-base/avatar-base.stories.js b/ui/components/component-library/avatar-base/avatar-base.stories.js index a2bfd45ba..9515ca09f 100644 --- a/ui/components/component-library/avatar-base/avatar-base.stories.js +++ b/ui/components/component-library/avatar-base/avatar-base.stories.js @@ -89,10 +89,11 @@ export default { color: TextColor.textDefault, backgroundColor: BackgroundColor.backgroundAlternative, borderColor: BorderColor.borderDefault, + children: 'B', }, }; -export const DefaultStory = (args) => B; +export const DefaultStory = (args) => ; DefaultStory.storyName = 'Default'; diff --git a/ui/components/component-library/avatar-base/avatar-base.test.js b/ui/components/component-library/avatar-base/avatar-base.test.js index 9137f3a75..cf0058dc9 100644 --- a/ui/components/component-library/avatar-base/avatar-base.test.js +++ b/ui/components/component-library/avatar-base/avatar-base.test.js @@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; -import { Color } from '../../../helpers/constants/design-system'; +import { Color, TextColor } from '../../../helpers/constants/design-system'; import { AvatarBase } from './avatar-base'; @@ -25,19 +25,19 @@ describe('AvatarBase', () => { , ); expect(getByTestId('avatar-base-xs')).toHaveClass( - 'mm-avatar-base--size-xs', + 'mm-avatar-base--size-xs mm-text--body-xs', ); expect(getByTestId('avatar-base-sm')).toHaveClass( - 'mm-avatar-base--size-sm', + 'mm-avatar-base--size-sm mm-text--body-sm', ); expect(getByTestId('avatar-base-md')).toHaveClass( - 'mm-avatar-base--size-md', + 'mm-avatar-base--size-md mm-text--body-sm', ); expect(getByTestId('avatar-base-lg')).toHaveClass( - 'mm-avatar-base--size-lg', + 'mm-avatar-base--size-lg mm-text--body-lg-medium', ); expect(getByTestId('avatar-base-xl')).toHaveClass( - 'mm-avatar-base--size-xl', + 'mm-avatar-base--size-xl mm-text--body-lg-medium', ); }); // className @@ -63,20 +63,20 @@ describe('AvatarBase', () => { const { getByTestId } = render( <> , ); - expect(getByTestId(Color.successDefault)).toHaveClass( - `box--color-${Color.successDefault}`, + expect(getByTestId(TextColor.successDefault)).toHaveClass( + `mm-text--color-${TextColor.successDefault}`, ); - expect(getByTestId(Color.errorDefault)).toHaveClass( - `box--color-${Color.errorDefault}`, + expect(getByTestId(TextColor.errorDefault)).toHaveClass( + `mm-text--color-${TextColor.errorDefault}`, ); }); // background color @@ -84,11 +84,11 @@ describe('AvatarBase', () => { const { getByTestId } = render( <> , diff --git a/ui/components/component-library/avatar-favicon/__snapshots__/avatar-favicon.test.js.snap b/ui/components/component-library/avatar-favicon/__snapshots__/avatar-favicon.test.js.snap index e6f2c07c4..f1c969961 100644 --- a/ui/components/component-library/avatar-favicon/__snapshots__/avatar-favicon.test.js.snap +++ b/ui/components/component-library/avatar-favicon/__snapshots__/avatar-favicon.test.js.snap @@ -3,7 +3,7 @@ exports[`AvatarFavicon should render correctly 1`] = `
{ />, ); - expect(getByTestId('success')).toHaveClass('box--color-success-default'); + expect(getByTestId('success')).toHaveClass( + 'mm-text--color-success-default', + ); expect(getByTestId('success')).toHaveClass( 'box--background-color-success-muted', ); diff --git a/ui/components/component-library/avatar-network/README.mdx b/ui/components/component-library/avatar-network/README.mdx index 92ad2e0e9..81a32c49e 100644 --- a/ui/components/component-library/avatar-network/README.mdx +++ b/ui/components/component-library/avatar-network/README.mdx @@ -30,6 +30,8 @@ Possible sizes include: Defaults to `md` +The fallback display of the `AvatarNetwork` is a circle with the initial letter of the network name. The size of the initial letter is calculated based on the size of the `AvatarNetwork` component. + @@ -48,6 +50,8 @@ import { AvatarNetwork } from '../../component-library'; Use the `name` prop to set the initial letter of the `AvatarNetwork`. This will be used as the fallback display if no image url is passed to the `src` prop. +Use `Text` component props to change the `variant`, `font-weight`, `font-family`, etc. + diff --git a/ui/components/component-library/avatar-network/__snapshots__/avatar-network.test.js.snap b/ui/components/component-library/avatar-network/__snapshots__/avatar-network.test.js.snap index 4ccac5bc5..60137e80c 100644 --- a/ui/components/component-library/avatar-network/__snapshots__/avatar-network.test.js.snap +++ b/ui/components/component-library/avatar-network/__snapshots__/avatar-network.test.js.snap @@ -3,7 +3,7 @@ exports[`AvatarNetwork should render correctly 1`] = `
? diff --git a/ui/components/component-library/avatar-network/avatar-network.stories.js b/ui/components/component-library/avatar-network/avatar-network.stories.js index 28ba38c7a..811864f69 100644 --- a/ui/components/component-library/avatar-network/avatar-network.stories.js +++ b/ui/components/component-library/avatar-network/avatar-network.stories.js @@ -12,12 +12,12 @@ import { import Box from '../../ui/box/box'; import README from './README.mdx'; + import { AvatarNetwork } from './avatar-network'; import { AVATAR_NETWORK_SIZES } from './avatar-network.constants'; export default { title: 'Components/ComponentLibrary/AvatarNetwork', - component: AvatarNetwork, parameters: { docs: { @@ -67,13 +67,27 @@ export const DefaultStory = Template.bind({}); DefaultStory.storyName = 'Default'; export const SizeStory = (args) => ( - - - - - - - + <> + + + + + + + + + + + + + + + ); SizeStory.storyName = 'Size'; diff --git a/ui/components/component-library/avatar-network/avatar-network.test.js b/ui/components/component-library/avatar-network/avatar-network.test.js index cded1d76a..6b2ee4f92 100644 --- a/ui/components/component-library/avatar-network/avatar-network.test.js +++ b/ui/components/component-library/avatar-network/avatar-network.test.js @@ -75,10 +75,10 @@ describe('AvatarNetwork', () => { , ); expect(getByTestId(TextColor.successDefault)).toHaveClass( - `box--color-${TextColor.successDefault}`, + `mm-text--color-${TextColor.successDefault}`, ); expect(getByTestId(TextColor.errorDefault)).toHaveClass( - `box--color-${TextColor.errorDefault}`, + `mm-text--color-${TextColor.errorDefault}`, ); }); // background color diff --git a/ui/components/component-library/avatar-token/README.mdx b/ui/components/component-library/avatar-token/README.mdx index 63e7e5b14..efe5375e9 100644 --- a/ui/components/component-library/avatar-token/README.mdx +++ b/ui/components/component-library/avatar-token/README.mdx @@ -30,6 +30,8 @@ Possible sizes include: Defaults to `md` +The fallback display of the `AvatarToken` is a circle with the initial letter of the network name. The size of the initial letter is calculated based on the size of the `AvatarToken` component. + @@ -48,6 +50,8 @@ import { AvatarToken } from '../../component-library'; Use the `name` prop to set the initial letter of the `AvatarToken`. This will be used as the fallback display if no image url is passed to the `src` prop. +Use `Text` component props to change the `variant`, `font-weight`, `font-family`, etc. + diff --git a/ui/components/component-library/avatar-token/__snapshots__/avatar-token.test.js.snap b/ui/components/component-library/avatar-token/__snapshots__/avatar-token.test.js.snap index 23dd22341..b67f6c466 100644 --- a/ui/components/component-library/avatar-token/__snapshots__/avatar-token.test.js.snap +++ b/ui/components/component-library/avatar-token/__snapshots__/avatar-token.test.js.snap @@ -3,7 +3,7 @@ exports[`AvatarToken should render correctly 1`] = `
( - - - - - - - + <> + + + + + + + + + + + + + + + + Sizes with{' '} + + AvatarNetwork + {' '} + and{' '} + + BadgeWrapper + {' '} + components + + + + } + > + + + + } + > + + + + } + > + + + + } + > + + + + } + > + + + + + + } + > + + + + } + > + + + + } + > + + + + } + > + + + + } + > + + + + ); SizeStory.storyName = 'Size'; diff --git a/ui/components/component-library/avatar-token/avatar-token.test.js b/ui/components/component-library/avatar-token/avatar-token.test.js index 3a711782d..53d8e8d87 100644 --- a/ui/components/component-library/avatar-token/avatar-token.test.js +++ b/ui/components/component-library/avatar-token/avatar-token.test.js @@ -73,10 +73,10 @@ describe('AvatarToken', () => { , ); expect(getByTestId(TextColor.successDefault)).toHaveClass( - `box--color-${TextColor.successDefault}`, + `mm-text--color-${TextColor.successDefault}`, ); expect(getByTestId(TextColor.errorDefault)).toHaveClass( - `box--color-${TextColor.errorDefault}`, + `mm-text--color-${TextColor.errorDefault}`, ); }); // background color diff --git a/ui/components/component-library/picker-network/__snapshots__/picker-network.test.js.snap b/ui/components/component-library/picker-network/__snapshots__/picker-network.test.js.snap index 25a318cad..bf7783940 100644 --- a/ui/components/component-library/picker-network/__snapshots__/picker-network.test.js.snap +++ b/ui/components/component-library/picker-network/__snapshots__/picker-network.test.js.snap @@ -7,7 +7,7 @@ exports[`PickerNetwork should render the label inside the PickerNetwork 1`] = ` data-testid="picker-network" >
I
diff --git a/ui/components/component-library/tag-url/__snapshots__/tag-url.test.js.snap b/ui/components/component-library/tag-url/__snapshots__/tag-url.test.js.snap index 3eea81879..4169c58f3 100644 --- a/ui/components/component-library/tag-url/__snapshots__/tag-url.test.js.snap +++ b/ui/components/component-library/tag-url/__snapshots__/tag-url.test.js.snap @@ -7,7 +7,7 @@ exports[`TagUrl should render the label inside the TagUrl 1`] = ` data-testid="tag-url" >