Skip to content

Commit

Permalink
hide and show Modal with animation
Browse files Browse the repository at this point in the history
  • Loading branch information
justmic007 committed Aug 2, 2018
1 parent 8602358 commit 25aab5c
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 4 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion src/components/Burger/BuildControls/BuildControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const buildControls = (props) => (
))}
<button
className={classes.OrderButton}
disabled={!props.purchasable}>
disabled={!props.purchasable}
onClick={props.ordered}>
<strong>ORDER NOW!</strong>
</button>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/components/UI/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import React from 'react';
import classes from './Modal.css';

const modal = (props) => (
<div className={classes.Modal}>
<div
className={classes.Modal}
style={{
transform: props.show ? 'translateY(0)' : 'translateY(-100vh)',
opacity: props.show ? '1': '0'
}}>
{props.children}
</div>
);
Expand Down
10 changes: 8 additions & 2 deletions src/containers/BurgerBuilder/BurgerBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class BurgerBuilder extends Component {
meat: 0
},
totalPrice: 4,
purchasable: false
purchasable: false,
purchasing: false
}

updatePurchaseState(ingredients){
Expand Down Expand Up @@ -75,6 +76,10 @@ class BurgerBuilder extends Component {

}

purchaseHandler = () => {
this.setState({purchasing: true});
}

render() {
const disabledInfo = {
...this.state.ingredients
Expand All @@ -85,7 +90,7 @@ class BurgerBuilder extends Component {
// {salad: false, meat: false; cheese: false, bacon: false ...}
return(
<Aux>
<Modal>
<Modal show={this.state.purchasing}>
<OrderSummary ingredients={this.state.ingredients} />
</Modal>
<Burger ingredients={this.state.ingredients}/>
Expand All @@ -94,6 +99,7 @@ class BurgerBuilder extends Component {
ingredientRemoved={this.removeIngredientHandler}
disabled={disabledInfo}
purchasable={this.state.purchasable}
ordered={this.purchaseHandler}
price={this.state.totalPrice} />

</Aux>
Expand Down

0 comments on commit 25aab5c

Please sign in to comment.