ndla-ui
Version:
UI component library for NDLA.
64 lines (54 loc) • 1.98 kB
JavaScript
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) 2016-present, NDLA.
*
* This source code is licensed under the GPLv3 license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import BEMHelper from 'react-bem-helper';
import { getLicenseRightByAbbreviation } from 'ndla-licenses';
import LicenseIcon from './LicenseIcon';
var classes = new BEMHelper({
name: 'license-icons',
prefix: 'c-'
});
var LicenseIconItem = function LicenseIconItem(_ref) {
var licenseRight = _ref.licenseRight;
var _getLicenseRightByAbb = getLicenseRightByAbbreviation(licenseRight),
description = _getLicenseRightByAbb.description;
return React.createElement(
'li',
classes('item'),
React.createElement(LicenseIcon, _extends({
licenseRight: licenseRight,
description: description
}, classes('icon'))),
React.createElement(
'span',
{ className: 'c-license-icons__licenselabel' },
getLicenseRightByAbbreviation(licenseRight).description
)
);
};
LicenseIconItem.propTypes = {
licenseRight: PropTypes.string.isRequired
};
var LicenseIconDescriptionList = function LicenseIconDescriptionList(_ref2) {
var licenseRights = _ref2.licenseRights,
className = _ref2.className;
return React.createElement(
'ul',
classes('list', '', className),
licenseRights.map(function (licenseRight) {
return React.createElement(LicenseIconItem, { key: licenseRight, licenseRight: licenseRight });
})
);
};
LicenseIconDescriptionList.propTypes = {
licenseRights: PropTypes.arrayOf(PropTypes.string).isRequired,
className: PropTypes.string
};
export default LicenseIconDescriptionList;