Skip to content

Commit 8d0969d

Browse files
committed
react-native: add default accessibility label to BannerBase close button; merge closeButton classes on web/native; reorder BannerBase exports after BadgeWrapper for alphabetical grouping
1 parent 9979604 commit 8d0969d

5 files changed

Lines changed: 23 additions & 10 deletions

File tree

packages/design-system-react-native/src/components/BannerBase/BannerBase.constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export const DEFAULT_BANNERBASE_DESCRIPTION_VARIANT = TextVariant.BodyMd;
55
export const DEFAULT_BANNERBASE_ACTION_BUTTON_SIZE = ButtonSize.Md;
66
export const DEFAULT_BANNERBASE_CLOSE_BUTTON_SIZE = ButtonIconSize.Sm;
77
export const DEFAULT_BANNERBASE_CLOSE_BUTTON_ICON_NAME = IconName.Close;
8+
export const DEFAULT_BANNERBASE_CLOSE_BUTTON_ARIA_LABEL = 'Close banner';
89

910
export const TESTID_BANNERBASE_CLOSE_BUTTON = 'banner-base-close-button';

packages/design-system-react-native/src/components/BannerBase/BannerBase.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Text } from '../Text';
1414

1515
import {
1616
DEFAULT_BANNERBASE_ACTION_BUTTON_SIZE,
17+
DEFAULT_BANNERBASE_CLOSE_BUTTON_ARIA_LABEL,
1718
DEFAULT_BANNERBASE_CLOSE_BUTTON_ICON_NAME,
1819
DEFAULT_BANNERBASE_CLOSE_BUTTON_SIZE,
1920
DEFAULT_BANNERBASE_DESCRIPTION_VARIANT,
@@ -48,8 +49,13 @@ export const BannerBase: React.FC<BannerBaseProps> = ({
4849
...resolvedActionButtonProps
4950
} = actionButtonProps ?? {};
5051

51-
const { onPress: closeButtonPropsOnPress, ...resolvedCloseButtonProps } =
52-
closeButtonProps ?? {};
52+
const {
53+
accessibilityLabel:
54+
closeButtonAccessibilityLabel = DEFAULT_BANNERBASE_CLOSE_BUTTON_ARIA_LABEL,
55+
onPress: closeButtonPropsOnPress,
56+
twClassName: closeButtonTwClassName,
57+
...resolvedCloseButtonProps
58+
} = closeButtonProps ?? {};
5359

5460
const resolvedActionButtonLabel =
5561
actionButtonLabel ??
@@ -71,6 +77,10 @@ export const BannerBase: React.FC<BannerBaseProps> = ({
7177
}
7278
: undefined;
7379

80+
const mergedCloseButtonTwClassName = closeButtonTwClassName
81+
? `ml-3 ${closeButtonTwClassName}`
82+
: 'ml-3';
83+
7484
return (
7585
<Box
7686
flexDirection={BoxFlexDirection.Row}
@@ -128,9 +138,10 @@ export const BannerBase: React.FC<BannerBaseProps> = ({
128138
{shouldShowCloseButton && (
129139
<ButtonIcon
130140
testID={TESTID_BANNERBASE_CLOSE_BUTTON}
131-
twClassName="ml-3"
141+
twClassName={mergedCloseButtonTwClassName}
132142
iconName={DEFAULT_BANNERBASE_CLOSE_BUTTON_ICON_NAME}
133143
size={DEFAULT_BANNERBASE_CLOSE_BUTTON_SIZE}
144+
accessibilityLabel={closeButtonAccessibilityLabel}
134145
onPress={handleClosePress}
135146
{...resolvedCloseButtonProps}
136147
/>

packages/design-system-react-native/src/components/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ export type { AvatarNetworkProps } from './AvatarNetwork';
3030
export { AvatarToken, AvatarTokenSize } from './AvatarToken';
3131
export type { AvatarTokenProps } from './AvatarToken';
3232

33-
export { BannerBase } from './BannerBase';
34-
export type { BannerBaseProps } from './BannerBase';
35-
3633
export { BadgeCount, BadgeCountSize } from './BadgeCount';
3734
export type { BadgeCountProps } from './BadgeCount';
3835

@@ -55,6 +52,9 @@ export type {
5552
BadgeWrapperCustomPosition,
5653
} from './BadgeWrapper';
5754

55+
export { BannerBase } from './BannerBase';
56+
export type { BannerBaseProps } from './BannerBase';
57+
5858
export { BottomSheetFooter, ButtonsAlignment } from './BottomSheetFooter';
5959
export type {
6060
BottomSheetFooterProps,

packages/design-system-react/src/components/BannerBase/BannerBase.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const BannerBase = forwardRef<HTMLDivElement, BannerBaseProps>(
5757
ariaLabel:
5858
closeButtonAriaLabel = DEFAULT_BANNERBASE_CLOSE_BUTTON_ARIA_LABEL,
5959
onClick: closeButtonPropsOnClick,
60+
className: closeButtonClassName,
6061
...resolvedCloseButtonProps
6162
} = closeButtonProps ?? {};
6263

@@ -127,7 +128,7 @@ export const BannerBase = forwardRef<HTMLDivElement, BannerBaseProps>(
127128
{shouldShowCloseButton && (
128129
<ButtonIcon
129130
data-testid={TESTID_BANNERBASE_CLOSE_BUTTON}
130-
className="ml-3 self-start"
131+
className={twMerge('ml-3 self-start', closeButtonClassName)}
131132
iconName={DEFAULT_BANNERBASE_CLOSE_BUTTON_ICON_NAME}
132133
size={DEFAULT_BANNERBASE_CLOSE_BUTTON_SIZE}
133134
ariaLabel={closeButtonAriaLabel}

packages/design-system-react/src/components/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ export type { AvatarNetworkProps } from './AvatarNetwork';
2727
export { AvatarToken, AvatarTokenSize } from './AvatarToken';
2828
export type { AvatarTokenProps } from './AvatarToken';
2929

30-
export { BannerBase } from './BannerBase';
31-
export type { BannerBaseProps } from './BannerBase';
32-
3330
export { BadgeCount } from './BadgeCount';
3431
export type { BadgeCountProps } from './BadgeCount';
3532
export { BadgeCountSize } from './BadgeCount';
@@ -52,6 +49,9 @@ export {
5249
} from './BadgeWrapper';
5350
export type { BadgeWrapperCustomPosition } from './BadgeWrapper';
5451

52+
export { BannerBase } from './BannerBase';
53+
export type { BannerBaseProps } from './BannerBase';
54+
5555
export { Blockies } from './temp-components/Blockies';
5656
export type { BlockiesProps } from './temp-components/Blockies';
5757

0 commit comments

Comments
 (0)