diff --git a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.figma.tsx b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.figma.tsx index 5a0e90be7..f0c07d12f 100644 --- a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.figma.tsx +++ b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.figma.tsx @@ -1,10 +1,9 @@ // import figma needs to remain as figma otherwise it breaks code connect // eslint-disable-next-line import-x/no-named-as-default import figma from '@figma/code-connect'; +import { IconName } from '@metamask/design-system-shared'; import React from 'react'; -import { IconName } from '../Icon'; - import { BadgeIcon } from './BadgeIcon'; /** diff --git a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.stories.tsx b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.stories.tsx index cb6c65ae4..c15fa3ddf 100644 --- a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.stories.tsx +++ b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.stories.tsx @@ -1,7 +1,6 @@ +import { IconName } from '@metamask/design-system-shared'; import type { Meta, StoryObj } from '@storybook/react-native'; -import { IconName } from '../Icon'; - import { BadgeIcon } from './BadgeIcon'; import type { BadgeIconProps } from './BadgeIcon.types'; diff --git a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.test.tsx b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.test.tsx index 354a35983..8638dd268 100644 --- a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.test.tsx +++ b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.test.tsx @@ -1,8 +1,8 @@ +import { IconColor, IconName, IconSize } from '@metamask/design-system-shared'; import { useTailwind } from '@metamask/design-system-twrnc-preset'; import { render } from '@testing-library/react-native'; import React from 'react'; -import { IconName, IconColor, IconSize } from '../Icon'; import { Text } from '../Text'; import { BadgeIcon } from './BadgeIcon'; diff --git a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.tsx b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.tsx index 52b710fce..fe873f835 100644 --- a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.tsx +++ b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.tsx @@ -1,8 +1,9 @@ +import { IconColor, IconSize } from '@metamask/design-system-shared'; import { useTailwind } from '@metamask/design-system-twrnc-preset'; import React from 'react'; import { View } from 'react-native'; -import { Icon, IconSize, IconColor } from '../Icon'; +import { Icon } from '../Icon'; import type { BadgeIconProps } from './BadgeIcon.types'; diff --git a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.types.ts b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.types.ts index a8c47f206..9170e62a2 100644 --- a/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.types.ts +++ b/packages/design-system-react-native/src/components/BadgeIcon/BadgeIcon.types.ts @@ -1,15 +1,13 @@ +import type { BadgeIconPropsShared } from '@metamask/design-system-shared'; import type { ViewProps } from 'react-native'; -import type { IconName, IconProps } from '../Icon'; +import type { IconProps } from '../Icon'; /** - * BadgeIcon component props. + * BadgeIcon component props (React Native platform-specific) + * Extends shared props from @metamask/design-system-shared with React Native specific platform concerns */ -export type BadgeIconProps = { - /** - * Required prop to specify an icon to show - */ - iconName: IconName; +export type BadgeIconProps = BadgeIconPropsShared & { /** * Optional prop to pass additional properties to the icon */ diff --git a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.figma.tsx b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.figma.tsx index 4a237ab23..f4503790d 100644 --- a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.figma.tsx +++ b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.figma.tsx @@ -1,10 +1,9 @@ // import figma needs to remain as figma otherwise it breaks code connect // eslint-disable-next-line import-x/no-named-as-default import figma from '@figma/code-connect'; +import { IconName } from '@metamask/design-system-shared'; import React from 'react'; -import { IconName } from '../Icon'; - import { BadgeIcon } from './BadgeIcon'; /** diff --git a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.stories.tsx b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.stories.tsx index 8148c0bad..ad479080f 100644 --- a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.stories.tsx +++ b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.stories.tsx @@ -1,8 +1,7 @@ +import { IconName } from '@metamask/design-system-shared'; import type { Meta, StoryObj } from '@storybook/react-vite'; import React from 'react'; -import { IconName } from '../Icon'; - import { BadgeIcon } from './BadgeIcon'; import type { BadgeIconProps } from './BadgeIcon.types'; import README from './README.mdx'; diff --git a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.test.tsx b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.test.tsx index d62a3e929..cf9147a27 100644 --- a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.test.tsx +++ b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.test.tsx @@ -1,8 +1,8 @@ // BadgeIcon.test.tsx +import { IconColor, IconName } from '@metamask/design-system-shared'; import { render, screen } from '@testing-library/react'; import React, { createRef } from 'react'; -import { IconName, IconColor } from '../Icon'; import { TWCLASSMAP_ICON_SIZE_DIMENSION } from '../Icon/Icon.constants'; import { BadgeIcon } from './BadgeIcon'; diff --git a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.tsx b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.tsx index d1915444e..36cbea193 100644 --- a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.tsx +++ b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.tsx @@ -1,7 +1,8 @@ +import { IconSize } from '@metamask/design-system-shared'; import React, { forwardRef } from 'react'; import { twMerge } from '../../utils/tw-merge'; -import { Icon, IconSize } from '../Icon'; +import { Icon } from '../Icon'; import type { BadgeIconProps } from './BadgeIcon.types'; diff --git a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.types.ts b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.types.ts index af47ec964..94e3e9283 100644 --- a/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.types.ts +++ b/packages/design-system-react/src/components/BadgeIcon/BadgeIcon.types.ts @@ -1,27 +1,26 @@ +import type { BadgeIconPropsShared } from '@metamask/design-system-shared'; import type { ComponentProps } from 'react'; -import type { IconName, IconProps } from '../Icon'; +import type { IconProps } from '../Icon'; /** - * BadgeIcon component props. + * BadgeIcon component props (React platform-specific) + * Extends shared props from @metamask/design-system-shared with React-specific platform concerns */ -export type BadgeIconProps = ComponentProps<'div'> & { - /** - * Required prop to specify an icon to show - */ - iconName: IconName; - /** - * Optional prop to pass additional properties to the icon - */ - iconProps?: Omit; - /** - * Optional prop for additional CSS classes to be applied to the BadgeIcon component. - * These classes will be merged with the component's default classes using twMerge. - */ - className?: string; - /** - * Optional CSS styles to be applied to the component. - * Should be used sparingly and only for dynamic styles that can't be achieved with className. - */ - style?: React.CSSProperties; -}; +export type BadgeIconProps = ComponentProps<'div'> & + BadgeIconPropsShared & { + /** + * Optional prop to pass additional properties to the icon + */ + iconProps?: Omit; + /** + * Optional prop for additional CSS classes to be applied to the BadgeIcon component. + * These classes will be merged with the component's default classes using twMerge. + */ + className?: string; + /** + * Optional CSS styles to be applied to the component. + * Should be used sparingly and only for dynamic styles that can't be achieved with className. + */ + style?: React.CSSProperties; + }; diff --git a/packages/design-system-shared/src/index.ts b/packages/design-system-shared/src/index.ts index 12cbcd367..6a6c02947 100644 --- a/packages/design-system-shared/src/index.ts +++ b/packages/design-system-shared/src/index.ts @@ -86,6 +86,9 @@ export { type AvatarTokenPropsShared, } from './types/AvatarToken'; +// BadgeIcon types (ADR-0004) +export { type BadgeIconPropsShared } from './types/BadgeIcon'; + // BannerAlert types (ADR-0003 + ADR-0004) export { BannerAlertSeverity, diff --git a/packages/design-system-shared/src/types/BadgeIcon/BadgeIcon.types.ts b/packages/design-system-shared/src/types/BadgeIcon/BadgeIcon.types.ts new file mode 100644 index 000000000..7c476aaec --- /dev/null +++ b/packages/design-system-shared/src/types/BadgeIcon/BadgeIcon.types.ts @@ -0,0 +1,13 @@ +import type { IconName } from '../Icon'; + +/** + * BadgeIcon component shared props (ADR-0004) + * Platform-independent properties shared across React and React Native + */ +export type BadgeIconPropsShared = { + /** + * Required prop to specify an icon to show. + * Uses shared IconName because the shared package owns icon names. + */ + iconName: IconName; +}; diff --git a/packages/design-system-shared/src/types/BadgeIcon/index.ts b/packages/design-system-shared/src/types/BadgeIcon/index.ts new file mode 100644 index 000000000..de9d68346 --- /dev/null +++ b/packages/design-system-shared/src/types/BadgeIcon/index.ts @@ -0,0 +1 @@ +export { type BadgeIconPropsShared } from './BadgeIcon.types';