Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Modal Dialogs in React

import React from 'react';

class Modal extends React.Component {
  render() {
    // Render nothing if the "show" prop is false
    if(!this.props.show) {
      return null;
    }
    
    // The gray background
    const backdropStyle = {
      position: 'fixed',
      top: 0,
      bottom: 0,
      left: 0,
      right: 0,
      backgroundColor: 'rgba(0,0,0,0.3)',
      padding: 50
    };

    // The modal "window"
    const modalStyle = {
      backgroundColor: '#fff',
      borderRadius: 5,
      maxWidth: 500,
      minHeight: 300,
      margin: '0 auto',
      padding: 30
    };

    return (
      <div className="backdrop" style={backdropStyle}>
        <div className="modal" style={modalStyle}>
          {this.props.children}

          <div className="footer">
            <button onClick={this.props.onClose}>
              Close
            </button>
          </div>
        </div>
      </div>
    );
  }
}

Modal.propTypes = {
  onClose: React.PropTypes.func.isRequired,
  show: React.PropTypes.bool,
  children: React.PropTypes.node
};

export default Modal;
Comment

PREVIOUS NEXT
Code Example
Javascript :: pdf extract text nodejs 
Javascript :: @Scheduled cron expresssion 
Javascript :: how to use props data inside setup 
Javascript :: Mapping an Array to Elements with v-for 
Javascript :: vue js destroyed 
Javascript :: ameca face expression code xcode 
Javascript :: Get element inside iframe jQuery 
Javascript :: event on trible click in js 
Javascript :: extending classes javascript 
Javascript :: object empty or undefined 
Javascript :: how to get the index of an object inside of a map js 
Javascript :: add html symbols with javascript 
Javascript :: concatenate strings jsonata 
Javascript :: how to create image object in javascript 
Javascript :: remove json parameter 
Javascript :: Use ChainLink Feed Registry 
Javascript :: Set object Relation with Array objects javascript 
Javascript :: nuxt js index.html not found 
Javascript :: js particles without plugin 
Javascript :: kasthamandap college 
Javascript :: seperate array by comma in vue 
Javascript :: js The equivalent of destructuring arrays and objects 
Javascript :: how to difference of arrey object 
Javascript :: Using JSON As Parameter 
Javascript :: createTextRange code example 
Javascript :: pushReplacement Method 
Javascript :: js template literal avoid white spaces 
Javascript :: can we Plot observale for ejs 
Javascript :: map function usage in frontend 
Javascript :: Register Multiple Models In Admin 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =