@uiw/react-shields
Version:
Shields.io for react component, Quality metadata badges for open source projects.
39 lines • 1.29 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["platform", "type", "base", "user", "repo", "tag", "path", "total"];
import React from 'react';
import { Internal } from '../common/Base';
import { jsx as _jsx } from "react/jsx-runtime";
var Downloads = /*#__PURE__*/React.forwardRef((props, ref) => {
var {
platform = 'github',
type = 'downloads',
base = 'https://img.shields.io',
user,
repo,
tag,
path,
total = true
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
var getUrl = () => {
if (platform !== 'github' || !/^(downloads|downloads-pre)/.test(type || '')) return '';
var baseData = [base, platform, type, user, repo];
if (path && tag) {
return [...baseData, tag, path].join('/');
}
if (total && tag || type === 'downloads-pre' && tag && total) {
return [...baseData, tag, 'total'].join('/');
}
if (total) {
return [...baseData, 'total'].join('/');
}
return '';
};
return /*#__PURE__*/_jsx(Internal, _extends({
imgSrc: getUrl(),
ref: ref
}, other));
});
Downloads.displayName = 'Downloads';
export default Downloads;