Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
react-path-marker
Advanced tools
A simple, free marker for svgs with optional text The component detects the SVG and Path locations/sizes. The component also detects the display text width of the marker. Based on that information a calculation is done so that the rendering of the marker will be optimized and correctly oriented.
Note: In SVG, the rendering order is based on the document order. I.e. the first elements in the SVG document fragment getting "painted" first. Subsequent elements are painted on top of previously painted elements. To avoid issues with path elements rendered on top of markers, please place all markers below all content path elements.
Click here for live demo.
In order to install, run the following command:
$ npm install react-path-marker --save
A very simple `App.tsx' example:
import React from "react"
import "./App.css"
import { PathMarker } from "react-path-marker" // 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} />
<PathMarker svgRef={svgRef} pathRef={pathRef} bgColor={"blue"}/>
</svg>
</div>
</div>
)
}
export default App
The following parameters are passed to the marker component:
Prop | Type | Description |
---|---|---|
smallText | string | Optional. The text to be displayed on the side of the marker |
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 marker |
bgColor | string | Optional. Background color. Default: "black" |
textColor | string | Optional. Text color. Default: "black" |
fontFamily | string | Optional. The font family. Default: san-serif |
fontSize | number | Optional. The font size. Default 10 |
Notes:
pathRef
must be a valid reference to a path element. There are a number of such types such as SVGRectElement, SVGCircleElement, etc.MIT
FAQs
A marker for SVG paths in React
We found that react-path-marker 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.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.