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 b0b6dae commit ae3421d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# [`master`](https://github.com/elastic/eui/tree/master)

- Added `stop` and `stopFilled` icons ([#543](https://github.com/elastic/eui/pull/543))
- Added a `type` ('confirm' or 'destroy') prop to `EuiConfirmModal` ([#546](https://github.com/elastic/eui/pull/546))
- Added a `buttonColor` prop to `EuiConfirmModal` ([#546](https://github.com/elastic/eui/pull/546))
- Added ‘baseline’ as option to `EuiFlexGroup`'s `alignItems` prop ([#546](https://github.com/elastic/eui/pull/546))

**Bug fixes**
Expand Down
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 @@ -60,7 +53,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 @@ -115,7 +108,7 @@ export class EuiConfirmModal extends Component {
onClick={onConfirm}
fill
buttonRef={this.confirmRef}
color={typeToButtonColorMap[type]}
color={buttonColor}
>
{confirmButtonText}
</EuiButton>
Expand All @@ -134,9 +127,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 ae3421d

Please sign in to comment.