All files / src/ui PrimitiveBlock.js

44.44% Statements 4/9
0% Branches 0/2
0% Functions 0/3
44.44% Lines 4/9

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 271x 1x 1x 1x                                              
import React, {Component} from 'react';
import PropTypes from 'prop-types/prop-types';
import {Primitive} from '../parsers/primitives';
import './PrimitiveBlock.less';
 
// TODO: Sorawee says this whole class can probably be removed.
export default class PrimitiveBlock extends Component {
  static propTypes = {
    primitive: PropTypes.instanceOf(Primitive),
    id: PropTypes.string,
  }
 
  static defaultProps = {
    primitive: null,
  }
 
  render() {
    const astNode = this.props.primitive.getASTNode();
    const elem = astNode ? astNode.reactElement({inToolbar: true}) : this.props.primitive.name;
    return (
      <span className="RenderedBlockNode" ref={root => this.root = root} key={this.props.id}>
        {elem}
      </span>
    );
  }
}