Skip to content

Commit 40bd570

Browse files
authored
feat(MessageBox): add emphasizedAction prop (#1690)
1 parent 573afca commit 40bd570

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

packages/main/src/components/MessageBox/__snapshots__/MessageBox.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ exports[`MessageBox Error 1`] = `
235235
>
236236
<ui5-button
237237
data-action="Close"
238-
design="Emphasized"
238+
design="Transparent"
239239
id="Close"
240240
ui5-button=""
241241
>
@@ -471,7 +471,7 @@ exports[`MessageBox Show 1`] = `
471471
>
472472
<ui5-button
473473
data-action="Yes"
474-
design="Emphasized"
474+
design="Transparent"
475475
id="Yes"
476476
ui5-button=""
477477
>

packages/main/src/components/MessageBox/index.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import '@ui5/webcomponents-icons/dist/hint';
12
import '@ui5/webcomponents-icons/dist/message-error';
23
import '@ui5/webcomponents-icons/dist/message-information';
34
import '@ui5/webcomponents-icons/dist/message-success';
45
import '@ui5/webcomponents-icons/dist/message-warning';
56
import '@ui5/webcomponents-icons/dist/question-mark';
6-
import '@ui5/webcomponents-icons/dist/hint';
77
import { useConsolidatedRef, useI18nBundle, usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/dist/hooks';
88
import { StyleClassHelper } from '@ui5/webcomponents-react-base/dist/StyleClassHelper';
99
import { enrichEventWithDetails } from '@ui5/webcomponents-react-base/dist/Utils';
@@ -33,6 +33,9 @@ import { MessageBoxTypes } from '@ui5/webcomponents-react/dist/MessageBoxTypes';
3333
import { Text } from '@ui5/webcomponents-react/dist/Text';
3434
import { Title } from '@ui5/webcomponents-react/dist/Title';
3535
import { TitleLevel } from '@ui5/webcomponents-react/dist/TitleLevel';
36+
import { CommonProps } from '@ui5/webcomponents-react/interfaces/CommonProps';
37+
import { Ui5CustomEvent } from '@ui5/webcomponents-react/interfaces/Ui5CustomEvent';
38+
import { Ui5DialogDomRef } from '@ui5/webcomponents-react/interfaces/Ui5DialogDomRef';
3639
import React, {
3740
FC,
3841
forwardRef,
@@ -45,9 +48,6 @@ import React, {
4548
useMemo
4649
} from 'react';
4750
import { createUseStyles } from 'react-jss';
48-
import { CommonProps } from '@ui5/webcomponents-react/interfaces/CommonProps';
49-
import { Ui5DialogDomRef } from '@ui5/webcomponents-react/interfaces/Ui5DialogDomRef';
50-
import { Ui5CustomEvent } from '@ui5/webcomponents-react/interfaces/Ui5CustomEvent';
5151
import { stopPropagation } from '../../internal/stopPropagation';
5252
import styles from './MessageBox.jss';
5353

@@ -70,6 +70,12 @@ export interface MessageBoxPropTypes extends CommonProps {
7070
* Array of actions of the MessageBox. Those actions will be transformed into buttons in the `MessageBox` footer.
7171
*/
7272
actions?: (MessageBoxActions | string)[];
73+
/**
74+
* Specifies which action of the created dialog will be emphasized.
75+
*
76+
* @since 0.16.3
77+
*/
78+
emphasizedAction?: MessageBoxActions | string;
7379
/**
7480
* A custom icon. If not present, it will be derived from the `MessageBox` type.
7581
*/
@@ -114,6 +120,7 @@ const MessageBox: FC<MessageBoxPropTypes> = forwardRef((props: MessageBoxPropTyp
114120
title,
115121
icon,
116122
actions,
123+
emphasizedAction,
117124
onClose,
118125
initialFocus,
119126
onBeforeOpen,
@@ -239,7 +246,7 @@ const MessageBox: FC<MessageBoxPropTypes> = forwardRef((props: MessageBoxPropTyp
239246
<Button
240247
id={action}
241248
key={`${action}-${index}`}
242-
design={index === 0 ? ButtonDesign.Emphasized : ButtonDesign.Transparent}
249+
design={emphasizedAction === action ? ButtonDesign.Emphasized : ButtonDesign.Transparent}
243250
onClick={handleOnClose}
244251
data-action={action}
245252
>
@@ -259,6 +266,7 @@ MessageBox.defaultProps = {
259266
title: null,
260267
icon: null,
261268
type: MessageBoxTypes.CONFIRM,
269+
emphasizedAction: MessageBoxActions.OK,
262270
actions: []
263271
};
264272

0 commit comments

Comments
 (0)