@uiw/react-shields
Version:
Shields.io for react component, Quality metadata badges for open source projects.
45 lines • 1.33 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["platform", "type", "base", "user", "repo", "query"];
import React from 'react';
import { Internal } from '../common/Base';
import { jsx as _jsx } from "react/jsx-runtime";
var Analysis = /*#__PURE__*/React.forwardRef((props, ref) => {
var {
platform = 'github',
type = 'languages-count',
base = 'https://img.shields.io',
user,
repo,
query
} = props,
other = _objectWithoutPropertiesLoose(props, _excluded);
var getUrl = () => {
var typePath = '';
switch (type) {
case 'languages-count':
typePath = 'languages/count';
break;
case 'languages-top':
typePath = 'languages/top';
break;
case 'search':
typePath = 'search';
break;
default:
break;
}
if (platform !== 'github' || !typePath) return '';
var baseData = [base, platform, typePath, user, repo];
if (query) {
return [...baseData, query].join('/');
}
return baseData.join('/');
};
return /*#__PURE__*/_jsx(Internal, _extends({
imgSrc: getUrl(),
ref: ref
}, other));
});
Analysis.displayName = 'Analysis';
export default Analysis;