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.
@beautiful-tree/react
Advanced tools
Beautiful-Tree is a lightweight & flexible library to draw trees as SVG images.
Some of its hightlights:
# With NPM
npm install @beautiful-tree/react
# With Yarn
yarn add @beautiful-tree/react
# With PNPM
pnpm add @beautiful-tree/react
import { BeautifulTree } from '@beautiful-tree/react'
const tree = {
data: { v: 'A' },
children: [
{
node: {
/* node data can contain any kews we want */
data: { v: 'B' },
children: [
{
/* we can annotate edges with arbitrary metadata */
eData: { e: 0.5 },
node: { data: { v: 'C' } }
},
],
},
},
{
node: {
data: { v: 'D' },
children: [
{ node: { data: { v: 'E' } } },
{ node: { data: { v: 'F' } } },
],
},
},
],
}
// The 3 main properties that we must always set are:
// - `id`: the id for the tree component
// - `tree:`` the tree data structure that will be rendered
// - `svgProps``: the proportions of the SVG "canvas".
render(
<BeautifulTree
id={'my-tree'}
tree={tree}
svgProps={{
width: 400,
height: 400,
// sizeUnit?: '%' | 'em' | 'px' | 'rem'
}}
/>
)
beautiful-tree-react
: applies to the rendered SVG element.beautiful-tree-edge
: applies to all the rendered edges inside the SVG
element.beautiful-tree-node
: applies to all the rendered nodes inside the SVG
element.beautiful-tree-root
: applies only to the rendered root node.beautiful-tree-leaf
: applies to all the rendered leaf nodes inside the SVG
element.beautiful-tree-node-content
: applies to all the <div>
elements rendered
inside nodes when using the getNodeContent
prop.We won't go into very deep details because TypeScript's autocomplete is enough to discover the aspects not mentioned here.
nodeShape
Accepted values are 'circle'
and 'rect'
. It specifies which shape is used
to render the tree nodes.
getNodeShape
In case we want the shape of each node to depend on their associated metadata, we can pass a function that returns the desired shape for each individual node.
getNodeContent
We can pass a function to read what's inside the data
property of each node
and return either a string
value or a JSX.Element
object that will be
rendered inside the corresponding node.
computeLayout
It specifies the function that is used to compute the tree layout.
computeSmartLayout
.computeNaiveLayout
.getNodeClass
We can pass a function that takes each node object and returns a list of CSS classes that will be applied to it. This is useful if we want to make node styles depend on their associated data.
getEdgeClass
We can pass a function that takes edge metadata as input and returns a list of CSS classes that will be applied to it. This is useful if we want to make edge styles depend on their associated data.
hCoef
This parameter, mostly useful for the case when node's shape is 'rect'
, allows
us to control the ratio aspect between height and width of a node. It must be
between 0
and 1
, ideally above 0.5
.
FAQs
Unknown package
The npm package @beautiful-tree/react receives a total of 4 weekly downloads. As such, @beautiful-tree/react popularity was classified as not popular.
We found that @beautiful-tree/react 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.