component: add Backdrop component
This commit is contained in:
		
							parent
							
								
									aa5fc21a5d
								
							
						
					
					
						commit
						670aeeccdf
					
				
							
								
								
									
										9
									
								
								src/components/UI/Backdrop/Backdrop.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/components/UI/Backdrop/Backdrop.css
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					.Backdrop {
 | 
				
			||||||
 | 
					    width: 100%;
 | 
				
			||||||
 | 
					    height: 100%;
 | 
				
			||||||
 | 
					    position: fixed;
 | 
				
			||||||
 | 
					    z-index: 100;
 | 
				
			||||||
 | 
					    left: 0;
 | 
				
			||||||
 | 
					    top: 0;
 | 
				
			||||||
 | 
					    background-color: rgba(0, 0, 0, 0.5);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										13
									
								
								src/components/UI/Backdrop/Backdrop.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/components/UI/Backdrop/Backdrop.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					import React from 'react';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import classes from './Backdrop.css';
 | 
				
			||||||
 | 
					const backdrop = (props) => {
 | 
				
			||||||
 | 
					    return (
 | 
				
			||||||
 | 
					        props.show ?
 | 
				
			||||||
 | 
					            <div className={classes.Backdrop} 
 | 
				
			||||||
 | 
					            onClick={props.clicked}>
 | 
				
			||||||
 | 
					            </div> : null
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export default backdrop;
 | 
				
			||||||
@ -1,16 +1,25 @@
 | 
				
			|||||||
import React from 'react';
 | 
					import React from 'react';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import Aux from '../../../hoc/Auxiliary';
 | 
				
			||||||
 | 
					import Backdrop from '../Backdrop/Backdrop';
 | 
				
			||||||
import classes from './Modal.css';
 | 
					import classes from './Modal.css';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const modal = (props) => {
 | 
					const modal = (props) => {
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
        <div
 | 
					        <Aux>
 | 
				
			||||||
            className={classes.Modal}
 | 
					            <Backdrop
 | 
				
			||||||
            style={{
 | 
					                show={props.show}
 | 
				
			||||||
                transform: props.show ? 'translateY(0)' : 'translateY(-100vh)'
 | 
					                clicked={props.modalClosed}></Backdrop>
 | 
				
			||||||
            }}>
 | 
					            <div
 | 
				
			||||||
            {props.children}
 | 
					                className={classes.Modal}
 | 
				
			||||||
        </div>
 | 
					                style={{
 | 
				
			||||||
 | 
					                    transform: props.show ? 'translateY(0)' : 'translateY(-100vh)',
 | 
				
			||||||
 | 
					                    opacity: props.show ? '1' : '0',
 | 
				
			||||||
 | 
					                }}>
 | 
				
			||||||
 | 
					                {props.children}
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        </Aux>
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -82,6 +82,10 @@ class BurgerBuilder extends Component {
 | 
				
			|||||||
        this.setState({ purchasing: true });
 | 
					        this.setState({ purchasing: true });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    purchaseCancelHandler = () => {
 | 
				
			||||||
 | 
					        this.setState({ purchasing: false });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    render() {
 | 
					    render() {
 | 
				
			||||||
        const disabledInfo = {
 | 
					        const disabledInfo = {
 | 
				
			||||||
            ...this.state.ingredients
 | 
					            ...this.state.ingredients
 | 
				
			||||||
@ -93,7 +97,9 @@ class BurgerBuilder extends Component {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return (
 | 
					        return (
 | 
				
			||||||
            <Aux>
 | 
					            <Aux>
 | 
				
			||||||
                <Modal show={this.state.purchasing}>
 | 
					                <Modal
 | 
				
			||||||
 | 
					                    show={this.state.purchasing}
 | 
				
			||||||
 | 
					                    modalClosed={this.purchaseCancelHandler}>
 | 
				
			||||||
                    <OrderSummary ingredients={this.state.ingredients}></OrderSummary>
 | 
					                    <OrderSummary ingredients={this.state.ingredients}></OrderSummary>
 | 
				
			||||||
                </Modal>
 | 
					                </Modal>
 | 
				
			||||||
                <Burger ingredients={this.state.ingredients} />
 | 
					                <Burger ingredients={this.state.ingredients} />
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user