Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                #root
              
            
!

CSS

              
                $display: #8E89B7;
$calculator: #392B58;
$border: #6C969D;
$numbers: #392B58;
$cuentas: #EDEBEF;
$body: #563891;
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: sans-serif;
}

body {
  background-color: $body;
}

.container {
  max-width: 300px;
  margin: 59px auto 0 auto;
  -webkit-box-shadow: 6px 4px 43px -4px rgba(0,0,0,1);
  -moz-box-shadow: 6px 4px 43px -4px rgba(0,0,0,1);
   box-shadow: 6px 4px 43px -4px rgba(0,0,0,.8);
  background-color: $body;
  border-radius: 20px;
}

h2 {
  text-align: right;
  font-size: 3rem;
  color: $numbers;
  text-shadow: 1px 1px 1px;
  font-weight: light;
} 

.display {
  width: 100%;
  height: 90px;
  padding: 10px;
  background-color: $display;
  -webkit-box-shadow: inset 6px 4px 58px -25px rgba(0,0,0,1);
  -moz-box-shadow: inset 6px 4px 58px -25px rgba(0,0,0,1);
  box-shadow: inset 6px 4px 58px -25px rgba(0,0,0,1);
  overflow:hidden;
  display: grid;
  align-content: center;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

.buttons {
  width: 100%;
  margin: 0 auto;
}

.left, rigth {
  display: inline-block;
}
.left {
  width: 75%;
}
.rigth {
  width: 25%;
  float: right;
}
.buttons-key {
  background-color: $calculator;
  width: 100%;
}


.button {
  width: 75px;
  height: 75px;
  padding: 20px;
  cursor: pointer;
  display: inline-block;
  font-size: 1.5rem;
  -webkit-box-shadow: inset 6px 4px 58px -25px rgba(0,0,0,1);
  -moz-box-shadow: inset 6px 4px 58px -25px rgba(0,0,0,1);
  box-shadow: inset 6px 4px 58px -25px rgba(0,0,0,1);
  border-radius: 1px;
}

.btnrg {
  background-color: $numbers;
  border: 1px solid transparent;
  color: white;
  border-top: 1px solid transparent;
} 

.btnrg:hover {
  background-color: $border;
}

.slash, .multi, .minus, .plus, .ce {
  background-color: $cuentas;
  border: 1px solid transparent;
  width: 75px;
  height: 60px; 
  padding: 0;
  
}

.slash:hover, .multi:hover, .minus:hover, .plus:hover, .ce:hover {
  background-color: #A292C3;

}


              
            
!

JS

              
                class Display extends React.Component {
  render() {
    return (<div className="display">
        <h2>
          {this.props.result}
        </h2>
    </div>)
  }
}

class ButtonsKey extends React.Component {
  render() {
    return (
      <div className="buttons-key">
        <div className="left">
        <button onClick={this.props.onClick} className="button btnrg seven" value="7">7</button>
        <button onClick={this.props.onClick} className="button btnrg eight" value="8">8</button>
        <button onClick={this.props.onClick} className="button btnrg nine" value="9">9</button>
        <button onClick={this.props.onClick} className="button btnrg four" value="4">4</button>
        <button onClick={this.props.onClick} className="button btnrg five" value="5">5</button>
        <button onClick={this.props.onClick} className="button btnrg six" value="6">6</button>
        <button onClick={this.props.onClick} className="button btnrg one" value="1">1</button>
        <button onClick={this.props.onClick} className="button btnrg two" value="2">2</button>
        <button onClick={this.props.onClick} className="button btnrg three" value="3">3</button>
        <button onClick={this.props.onClick} className="button btnrg zero" value="0">0</button>
        <button onClick={this.props.onClick} className="button btnrg point" value=".">.</button>
        <button onClick={this.props.onClick} className="button btnrg equal" value="=">=</button>
          </div>
        <div className="rigth">
          <button onClick={this.props.onClick} className="button ce" value="ce">CE</button>
          <button onClick={this.props.onClick} className="button slash" value="/">/</button>
          <button onClick={this.props.onClick} className="button multi" value="*">x</button>
          <button onClick={this.props.onClick} className="button minus" value="-">-</button>
          <button onClick={this.props.onClick} className="button plus" value="+">+</button>
        </div>
        </div>);
  }
}

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      result: ''
    }
    
    this.handleClick = this.handleClick.bind(this);
    
  }
    
  handleClick(event) {
    const value = event.target.value;
    let result = this.state.result;
     if (value === 'ce') {
       let stop = result.slice(0, result.length -1);
        this.setState({result: stop});
      } else if (value === "=") {
          let re = eval(result);
          if (re.toString().length >= 15) {
              re = re.toString().substring(0, 9);
              this.setState({result: re});
          } else {
                this.setState({result: re.toString()});
            }
    } else {
      this.setState({result: result + value});
    }
  }
  
  render() {
    return (
    <div className="container">
        <Display result={this.state.result} />
        <div className="buttons">
            <ButtonsKey onClick={this.handleClick}/>
          </div>
        </div>);
  }
}

ReactDOM.render(
 <App /> ,
  document.getElementById('root')
);
              
            
!
999px

Console