File tree Expand file tree Collapse file tree
design-system-react-native/src/components/BannerBase
design-system-react/src/components/BannerBase Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { hasContent , isTextContent } from '@metamask/design-system-shared' ;
12import React from 'react' ;
23import { GestureResponderEvent } from 'react-native' ;
34
@@ -18,12 +19,6 @@ import { Text } from '../Text';
1819
1920import type { BannerBaseProps } from './BannerBase.types' ;
2021
21- const isTextContent = ( content : React . ReactNode ) : content is string | number =>
22- typeof content === 'string' || typeof content === 'number' ;
23-
24- const hasContent = ( content : React . ReactNode ) =>
25- content !== null && content !== undefined ;
26-
2722export const BannerBase : React . FC < BannerBaseProps > = ( {
2823 title,
2924 titleProps,
@@ -64,8 +59,8 @@ export const BannerBase: React.FC<BannerBaseProps> = ({
6459 : undefined ;
6560
6661 const mergedCloseButtonTwClassName = closeButtonTwClassName
67- ? `ml-3 ${ closeButtonTwClassName } `
68- : 'ml-3' ;
62+ ? `ml-3 self-start ${ closeButtonTwClassName } `
63+ : 'ml-3 self-start ' ;
6964
7065 return (
7166 < Box
Original file line number Diff line number Diff line change 1+ import { hasContent , isTextContent } from '@metamask/design-system-shared' ;
12import React , { forwardRef } from 'react' ;
23
34import {
@@ -18,12 +19,6 @@ import { Text } from '../Text';
1819
1920import type { BannerBaseProps } from './BannerBase.types' ;
2021
21- const isTextContent = ( content : React . ReactNode ) : content is string | number =>
22- typeof content === 'string' || typeof content === 'number' ;
23-
24- const hasContent = ( content : React . ReactNode ) =>
25- content !== null && content !== undefined ;
26-
2722export const BannerBase = forwardRef < HTMLDivElement , BannerBaseProps > (
2823 (
2924 {
Original file line number Diff line number Diff line change 66 generateIconSeed ,
77} from './utils/caip-address' ;
88
9+ // BannerBase utils (ADR-0004)
10+ export { isTextContent , hasContent } from './utils/banner-base' ;
11+
912// BadgeCount types (ADR-0003 + ADR-0004)
1013export { BadgeCountSize , type BadgeCountPropsShared } from './types/BadgeCount' ;
1114
Original file line number Diff line number Diff line change 1+ import type { ReactNode } from 'react' ;
2+
3+ /**
4+ * Returns true when the provided ReactNode is plain text content that should be
5+ * wrapped with a Text component for consistent typography.
6+ */
7+ /**
8+ * @param content - The ReactNode to test.
9+ * @returns True if content is a string or number (textual), false otherwise.
10+ */
11+ export const isTextContent = (
12+ content : ReactNode ,
13+ ) : content is string | number => {
14+ return typeof content === 'string' || typeof content === 'number' ;
15+ } ;
16+
17+ /**
18+ * Returns true when the provided ReactNode is present (not null/undefined).
19+ * This intentionally allows values like 0 or empty string, which are valid content.
20+ */
21+ /**
22+ * @param content - The ReactNode to test for presence.
23+ * @returns True if content is neither null nor undefined.
24+ */
25+ export const hasContent = ( content : ReactNode ) : boolean => {
26+ return content !== null && content !== undefined ;
27+ } ;
You can’t perform that action at this time.
0 commit comments