UNPKG

@uiw/react-shields

Version:

Shields.io for react component, Quality metadata badges for open source projects.

45 lines 1.61 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; var _excluded = ["platform", "base", "type", "user", "repo", "interval", "variant", "version", "branch"]; import React from 'react'; import { Internal } from '../common/Base'; import { jsx as _jsx } from "react/jsx-runtime"; var Activity = /*#__PURE__*/React.forwardRef((props, ref) => { var { platform = 'github', base = 'https://img.shields.io', type = 'commits-since', user, repo, interval, variant, version, branch } = props, other = _objectWithoutPropertiesLoose(props, _excluded); var getUrl = () => { if (platform !== 'github') return ''; if (type === 'commits-since' && version && branch) { return [base, platform, type, user, repo, version, branch].join('/'); } if (type === 'commit-activity' && interval) { return [base, platform, type, interval, user, repo].join('/'); } if (type === 'variant' && variant) { return [base, platform, type, variant, user, repo].join('/'); } if (type === 'last-commit') { return branch ? [base, platform, type, user, repo, branch].join('/') : [base, platform, type, user, repo].join('/'); } if (type && /^release-(date|date-pre)/.test(type)) { return [base, platform, type, user, repo].join('/'); } return ''; }; return /*#__PURE__*/_jsx(Internal, _extends({ imgSrc: getUrl(), ref: ref }, other)); }); Activity.displayName = 'Activity'; export default Activity;