react-speedometer
Version:
Cool speedometer for React
10 lines (9 loc) • 709 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useContext, useMemo } from 'react';
import Context from './context';
import { getCirclePath } from './utils';
export default function DangerPath({ color = '#FF3333', angle = 50, arcWidth = 4, lineCap, offset = 6, ...rest }) {
const { radius, angle: globalAngle, lineCap: globalLineCap, } = useContext(Context);
const circlePath = useMemo(() => getCirclePath(radius, radius, radius - arcWidth - offset, globalAngle - angle, globalAngle), [radius, globalAngle, angle, arcWidth, offset]);
return (_jsx("path", { d: circlePath, stroke: color, strokeWidth: arcWidth, strokeLinecap: lineCap || globalLineCap, fill: "transparent", ...rest }));
}