Skip to content

Commit

Permalink
Changed type prop to buttonColor on EuiConfirmModal
Browse files Browse the repository at this point in the history
  • Loading branch information
cchaos committed Mar 22, 2018
1 parent e52977b commit 26adabc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src-docs/src/views/modal/confirm_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class ConfirmModal extends Component {
onConfirm={this.closeDestroyModal}
cancelButtonText="No, don't do it"
confirmButtonText="Yes, do it"
type="destroy"
buttonColor="danger"
defaultFocusedButton={EUI_MODAL_CONFIRM_BUTTON}
>
<p>You&rsquo;re about to destroy something.</p>
Expand All @@ -92,7 +92,7 @@ export class ConfirmModal extends Component {
&nbsp;

<EuiButton onClick={this.showDestroyModal}>
Show destroy type of ConfirmModal
Show dangerous ConfirmModal
</EuiButton>

{modal}
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/modal/modal_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export const ModalExample = {
text: (
<p>
Use the <EuiCode>EuiConfirmModal</EuiCode> to ask the user to confirm a decision.
The default type is a positive or neutral confirmation. Change the <EuiCode>type</EuiCode>
property to <EuiCode>&quot;destroy&quot;</EuiCode> for those that are destructive and potentially regrettable.
The default type is a positive or neutral confirmation. To change the main button color
change the the <EuiCode>buttonColor</EuiCode> property to any of the button color options.
</p>
),
props: { EuiConfirmModal },
Expand Down
15 changes: 4 additions & 11 deletions src/components/modal/confirm_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ const CONFIRM_MODAL_BUTTONS = [
CANCEL_BUTTON,
];

const typeToButtonColorMap = {
'confirm': 'primary',
'destroy': 'danger',
};

export const MODAL_TYPES = Object.keys(typeToButtonColorMap);

export class EuiConfirmModal extends Component {
componentDidMount() {
// We have to do this instead of using `autoFocus` because React's polyfill for auto-focusing
Expand Down Expand Up @@ -61,7 +54,7 @@ export class EuiConfirmModal extends Component {
cancelButtonText,
confirmButtonText,
className,
type,
buttonColor,
defaultFocusedButton, // eslint-disable-line no-unused-vars
...rest
} = this.props;
Expand Down Expand Up @@ -116,7 +109,7 @@ export class EuiConfirmModal extends Component {
onClick={onConfirm}
fill
buttonRef={this.confirmRef}
color={typeToButtonColorMap[type]}
color={buttonColor}
>
{confirmButtonText}
</EuiButton>
Expand All @@ -135,9 +128,9 @@ EuiConfirmModal.propTypes = {
onConfirm: PropTypes.func,
className: PropTypes.string,
defaultFocusedButton: PropTypes.oneOf(CONFIRM_MODAL_BUTTONS),
type: PropTypes.oneOf(MODAL_TYPES),
buttonColor: PropTypes.string,
};

EuiConfirmModal.defaultProps = {
type: 'confirm',
buttonColor: 'primary',
};

0 comments on commit 26adabc

Please sign in to comment.