import React from 'react';
import PropTypes from 'prop-types';
import DecorativeLink from '../../atoms/links/DecorativeLink';
import RichText from '../../organisms/RichText';
import './style.css';

var PressTeaser = function PressTeaser(pressTeaser) {
  var imageClass = pressTeaser.image ? 'ma__press-teaser ma__press-teaser--image' : 'ma__press-teaser';
  var Element = 'h' + (pressTeaser.level || 2);
  if (process.env.NODE_ENV === 'development') {
    /* eslint-disable-next-line no-console */
    console.warn('This component is deprecated and will be archived in v10. Use the GenTeaser Organism instead.');
  }
  return React.createElement(
    'section',
    { className: imageClass },
    pressTeaser.image && pressTeaser.image.src && React.createElement(
      'a',
      {
        className: 'ma__press-teaser__image',
        href: pressTeaser.title.href,
        title: pressTeaser.title.text
      },
      React.createElement('span', {
        'aria-label': pressTeaser.image.alt,
        role: 'img',
        style: { backgroundImage: 'url(' + pressTeaser.image.src + ')' }
      })
    ),
    React.createElement(
      'div',
      { className: 'ma__press-teaser__details' },
      pressTeaser.eyebrow && React.createElement(
        'div',
        { className: 'ma__press-teaser__eyebrow' },
        React.createElement(
          'span',
          null,
          pressTeaser.eyebrow
        )
      ),
      React.createElement(
        Element,
        { className: 'ma__press-teaser__title' },
        React.createElement(DecorativeLink, pressTeaser.title)
      ),
      (pressTeaser.date || pressTeaser.org) && React.createElement(
        'div',
        { className: 'ma__press-teaser__details' },
        pressTeaser.date && React.createElement(
          'span',
          { className: 'ma__press-teaser__date' },
          pressTeaser.date
        ),
        pressTeaser.org && React.createElement(
          'span',
          { className: 'ma__press-teaser__org' },
          pressTeaser.org
        )
      ),
      pressTeaser.description && React.createElement(
        'div',
        { className: 'ma__press-teaser__description' },
        React.createElement(RichText, pressTeaser.description)
      )
    )
  );
};

PressTeaser.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The image to be displayed in the teaser
    src: The src url for the image
    alt: The alternate text explaining the image, required for accessibility */
  image: PropTypes.shape({
    src: PropTypes.string.isRequired,
    alt: PropTypes.string.isRequired
  }),
  /** The short for tag that will appear in the eyebrow, e.g. press release */
  eyebrow: PropTypes.string,
  /** A linked title for the teaser content, @atoms/links/DecorativeLink */
  title: PropTypes.shape(DecorativeLink.propTypes).isRequired,
  /** The heading level */
  level: PropTypes.number,
  /** The date the teaser content represents */
  date: PropTypes.string,
  /** The author/publishing entity of the teaser content */
  org: PropTypes.string,
  /** A short description of the teaser content, rendered as a paragraph */
  description: PropTypes.shape(RichText.propTypes)
} : {};

export default PressTeaser;