<div id="app"></div>
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-color: #f9f9f9;
}
.wrapper {
  display: flex;
  width: 100vw;
  height: 100vh;
  justify-content: center;
  align-items: center;
}

.offer-modal {
  display: flex;
  position: relative;
  flex-direction: column;
  border: 1px solid black;
  background: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 350px;
  padding: 1.5rem;
  z-index: 1000;
}

.offer-modal-close-button {
  position: absolute;
  top: 5px;
  left: 5px;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
}
/*
* https://frontendeval.com/questions/modal-overlay
*
* Build a modal control and overlay
*/
const App = () => {
  const [offerState,setOfferState] = React.useState("hide")
  
  function handleShow(){
    setOfferState("show");
  }
  function handleAccept(){
    setOfferState("accept");
  }
   function handleClose(){
    setOfferState("hide");
  }
  function showCurrentScreen() {
    switch(offerState){
      case "hide":
      default:
        return <button onClick={handleShow}>Show Offer</button>
      case "show":
        return (
           <>
        <div className="modal-overlay" onClick={handleClose}></div>
        <div className="offer-modal">
          <button className="offer-modal-close-button" onClick={handleClose}>X</button>
          <div>Lorem ipsum dolor sit amet consectetur adipisicing                   elit. Pariatur impedit quos hic possimus earum                     eveniet nihil, nobis, ad magnam animi voluptatibus.                 Cumque consectetur facere officiis non quia enim                   alias quas!
          </div> 
          <button onClick={handleAccept}>Accept offer</button>
        </div>
          </>
        )
       
        case "accept":
        return <div>Offer accepted</div>
    }
  }
  return <div className="wrapper">
    {showCurrentScreen()}
  </div>;
}

ReactDOM.render(<App />, document.getElementById('app'));
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.1/umd/react-dom.production.min.js