@uiw/react-shields
Version:
Shields.io for react component, Quality metadata badges for open source projects.
41 lines • 1.23 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["base", "platform", "interval", "packageName", "scope"];
import React from 'react';
import { Internal } from '../common/Base';
import { jsx as _jsx } from "react/jsx-runtime";
/**
* Npm Downloads
*
* `/npm/:interval/:packageName`
* npm downloads: npm downloads per interval badge
*
* `/npm/:interval/:scope/:packageName`
* npm downloads (scoped): npm downloads per interval (scoped version) badge
*
*/
var Downloads = /*#__PURE__*/React.forwardRef((props, ref) => {
var {
base = 'https://img.shields.io',
platform = 'npm',
interval = 'dm',
packageName,
scope
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
var getUrl = () => {
if (platform !== 'npm' || !packageName) return '';
var url = [base, 'npm', interval];
if (scope) {
url.push(scope);
}
url.push(packageName);
return url.join('/');
};
return /*#__PURE__*/_jsx(Internal, _extends({
imgSrc: getUrl(),
ref: ref
}, other));
});
Downloads.displayName = 'Downloads';
export default Downloads;