@carbon/ibm-security
Version:
Carbon for Cloud & Cognitive IBM Security UI components
49 lines (47 loc) • 2.5 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["className", "element", "title", "subtitle"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
* @file Trending card.
* @copyright IBM Security 2019
*/
import classnames from 'classnames';
import { elementType, node, string } from 'prop-types';
import React, { Fragment } from 'react';
import { getComponentNamespace } from '../../globals/namespace';
var namespace = getComponentNamespace('trending-card');
/**
* Trending cards provide summary information of trending items with the ability to navigate to the details.
*/
var TrendingCard = function TrendingCard(_ref) {
var className = _ref.className,
element = _ref.element,
title = _ref.title,
subtitle = _ref.subtitle,
other = _objectWithoutProperties(_ref, _excluded);
return /*#__PURE__*/React.createElement(element, _objectSpread({
className: classnames(namespace, className)
}, other), /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("h3", {
className: "".concat(namespace, "__title")
}, title), subtitle && /*#__PURE__*/React.createElement("span", {
className: "".concat(namespace, "__subtitle")
}, subtitle)));
};
TrendingCard.defaultProps = {
subtitle: null,
element: 'a',
className: null
};
TrendingCard.propTypes = {
/** Provide an optional class to be applied to the containing node */
className: string,
/** Specify the base element to use to build the link. This can also accept custom components like `Link` from `react-router` */
element: elementType,
/** Specify the content of the subtitle */
subtitle: node,
/** Specify the text of the title */
title: string.isRequired
};
export default TrendingCard;