All files / src/ui EditorButtons.js

73.33% Statements 11/15
100% Branches 4/4
66.67% Functions 4/6
73.33% Lines 11/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 531x 1x 1x   200x                       300x     300x 300x 300x                     236x                 170x 170x                    
import React, {Component} from 'react';
import PropTypes from 'prop-types/prop-types';
import {logResults} from '../utils';
 
export class ToggleButton extends Component {
  static propTypes = {
    setBlockMode: PropTypes.func.isRequired,
    blockMode: PropTypes.bool.isRequired
  }
 
  // call setBlockMode on the opposite of the current mode
  handleToggle = () => {
    this.props.setBlockMode(!this.props.blockMode);
  }
 
  render() {
    const glyphClass = this.props.blockMode
      ? 'glyphicon glyphicon-pencil'
      : 'glyphicon glyphicon-align-left';
    const modeName = this.props.blockMode ? "text" : "blocks";
    const buttonAria = "Switch to " + modeName + " mode";
    return (
      <button className="blocks-toggle-btn btn btn-default btn-sm"
              aria-label={buttonAria}
              onClick={this.handleToggle}
              tabIndex="0">
        <span className={glyphClass}></span>
      </button>
    );
  }
}
 
export class BugButton extends Component {
 
  handleBugReport = () => {
    const history = JSON.stringify(window.reducerActivities);
    const description = prompt("Briefly describe what happened");
    logResults(history, "user-generated bug report", description);
  }
 
  render() {
    const glyphClass = 'glyphicon glyphicon-warning-sign';
    return (
      <button className="bug-btn btn btn-default btn-sm"
              aria-label="Report a bug" 
              onClick={this.handleBugReport}
              tabIndex="0">
        <span className={glyphClass}></span>
      </button>
    );
  }
}