Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-path-tooltip
Advanced tools
A simple yet beautiful react tooltip component for SVG-Paths. The component detects the SVG and Path locations/sizes. The component also detects the display text width of the tooltip. Based on that information a calculation is done so that the rendering of the tooltip will be optimized and correctly oriented.
Note: When generating SVG with multiple paths, make sure to add the tooltips at the bottom of the SVG element, after all the paths are already displays.
In order to install, run the following command:
$ npm install react-path-tooltip --save
A very simple `App.tsx' example:
import React from "react"
import "./App.css"
import { PathTooltip } from "ReactPathTooltip" // import the package
function App() {
const svgRef = React.createRef<SVGSVGElement>()
const pathRef = React.createRef<SVGCircleElement>()
return (
< div className="App" >
< div className="Main">
<svg width="400" height="400" ref={svgRef}>
<circle cx={50} cy={50} r={50} fill="red" ref={pathRef} />
<PathTooltip svgRef={svgRef} pathRef={pathRef} tip="Hello World!" />
</svg>
</div>
</div>
)
}
export default App
The following parameters are passed to the tooltip component:
Prop | Type | Description |
---|---|---|
tip | string | Mandatory. The text to be displayed inside the tooltip |
svgRef | React.RefObject | Mandatory. A React reference object to the SVG element |
pathRef | React.RefObject | Mandatory. A React reference object to the path element bounded to the tooltip |
bgColor | string | Optional. Background color. Default: "black" |
textColor | string | Optional. Text color. Default: "white" |
fontFamily | string | Optional. The font family. Default: san-serif |
fontSize | number | Optional. The font size. Default 12 |
Notes:
tip
must include simple text. No new lines, or html decoration.pathRef
must be a valid reference to a path element. There are a number of such types such as SVGRectElement, SVGCircleElement, etc.MIT
1.0.15
FAQs
A tooltip for SVG paths in React
The npm package react-path-tooltip receives a total of 3,195 weekly downloads. As such, react-path-tooltip popularity was classified as popular.
We found that react-path-tooltip demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.