clientjs/packages/dashboard-components/src/ui/AnnotationQuote.jsx
author ymh <ymh.work@gmail.com>
Fri, 14 Sep 2018 17:57:34 +0200
changeset 0 5f4fcbc80b37
permissions -rw-r--r--
Create new repository to host all dashboard developments This project contains the commons components and all the dashboard instances


import React from 'react';
import PropTypes from 'prop-types';

import { getAnnotationStyle } from '../utils';

const AnnotationQuote = ({ annotation, metacategories }) => {
  let selector = false;

  if (annotation.target[0].selector) {
    selector = annotation.target[0].selector.find(s => s.type === 'TextQuoteSelector');
  }

  if (selector) {
    return (
      <div className="exact">
        <p>
          { selector.prefix }
          <span style={getAnnotationStyle(annotation, metacategories)}>{ selector.exact }</span>
          { selector.suffix }
        </p>
      </div>
    );
  }
  return null;
};


AnnotationQuote.propTypes = {
  annotation: PropTypes.object.isRequired,
  metacategories: PropTypes.arrayOf(PropTypes.object).isRequired,
};

export default AnnotationQuote;