UNPKG

ndla-ui

Version:

UI component library for NDLA.

108 lines (100 loc) 3.06 kB
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /** * Copyright (c) 2018-present, NDLA. * * This source code is licensed under the GPLv3 license found in the * LICENSE file in the root directory of this source tree. * */ // N.B This component is used to render static markup serverside // Any interactivty is added by scripts located in the ndla-article-scripts package import React from 'react'; import PropTypes from 'prop-types'; import BEMHelper from 'react-bem-helper'; import { uuid } from 'ndla-util'; import { ContributorShape, LicenseShape } from '../shapes'; import LicenseByline from '../LicenseByline'; export var classLicenses = new BEMHelper({ name: 'figure-license', prefix: 'c-' }); export var FigureLicenseCta = function FigureLicenseCta(_ref) { var children = _ref.children, messages = _ref.messages, authors = _ref.authors, origin = _ref.origin, title = _ref.title; return React.createElement( 'div', classLicenses('cta-wrapper'), React.createElement( 'ul', classLicenses('list'), title && React.createElement( 'li', classLicenses('item'), messages.title + ': ' + title ), authors.map(function (author) { return React.createElement( 'li', _extends({ key: uuid() }, classLicenses('item')), author.type + ': ' + author.name ); }), origin && React.createElement( 'li', classLicenses('item'), messages.source, ':', ' ', origin.startsWith('http') ? React.createElement( 'a', { href: origin, target: '_blank', rel: 'noopener noreferrer' }, origin ) : origin ) ), React.createElement( 'div', classLicenses('cta-block'), children ) ); }; FigureLicenseCta.propTypes = { children: PropTypes.node, origin: PropTypes.string, authors: PropTypes.arrayOf(ContributorShape), messages: PropTypes.shape({ source: PropTypes.string.isRequired, title: PropTypes.string.isRequired }).isRequired, title: PropTypes.string }; export var FigureLicenseByline = function FigureLicenseByline(_ref2) { var messages = _ref2.messages, license = _ref2.license; return [React.createElement(LicenseByline, { key: 'byline', withDescription: true, messages: messages, licenseRights: license.rights }), React.createElement( 'a', _extends({ key: 'link' }, classLicenses('link'), { target: '_blank', rel: 'noopener noreferrer', href: license.url }), license.linkText )]; }; FigureLicenseByline.propTypes = { messages: PropTypes.shape({ modelPremission: PropTypes.string, learnAboutLicenses: PropTypes.string.isRequired }).isRequired, license: LicenseShape.isRequired };