npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vibbioinfocore/react-2d-molecule

v3.0.2

Published

A React component to display molecule structures in a 2D SVG

Downloads

12

Readme

Tests NPM

react-2d-molecule

@vibbioinfocore/react-2d-molecule is a React component to display molecule structures in a 2D SVG.

Installation

Typescript type definitions are included.

  • NPM
npm install @vibbioinfocore/react-2d-molecule
  • Yarn
yarn add @vibbioinfocore/react-2d-molecule

Usage

import React from 'react';
import { Molecule } from '@vibbioinfocore/react-2d-molecule';

// Biphenylene
const mol = {
  "width": 9.294,
  "height": 6.0,
  "atoms": [
    { "x": -3.348, "y": -0.75, "element": "C" },
    { "x": -2.049, "y": -1.5, "element": "C" },
    { "x": -0.75, "y": -0.75, "element": "C" },
    { "x": -0.75, "y": 0.75, "element": "C" },
    { "x": -2.049, "y": 1.5, "element": "C" },
    { "x": -3.348, "y": 0.75, "element": "C" },
    { "x": 0.75, "y": 0.75, "element": "C" },
    { "x": 2.049, "y": 1.5, "element": "C" },
    { "x": 3.348, "y": 0.75, "element": "C" },
    { "x": 3.348, "y": -0.75, "element": "C" },
    { "x": 2.049, "y": -1.5, "element": "C" },
    { "x": 0.75, "y": -0.75, "element": "C" },
    { "x": -4.647, "y": -1.5, "element": "H" },
    { "x": -2.049, "y": -3.0, "element": "H" },
    { "x": -2.049, "y": 3.0, "element": "H" },
    { "x": -4.647, "y": 1.5, "element": "H" },
    { "x": 2.049, "y": 3.0, "element": "H" },
    { "x": 4.647, "y": 1.5, "element": "H" },
    { "x": 4.647, "y": -1.5, "element": "H" },
    { "x": 2.049, "y": -3.0, "element": "H" }
  ],
  "bonds": [
    { "atoms": [[3, 6, "UNIMPL" ]] },
    { "atoms": [[11, 2, "SINGLE"]] },
    { "atoms": [[0, 12, "SINGLE"]] },
    { "atoms": [[1, 13, "SINGLE"]] },
    { "atoms": [[4, 14, "SINGLE"]] },
    { "atoms": [[5, 15, "SINGLE"]] },
    { "atoms": [[7, 16, "SINGLE"]] },
    { "atoms": [[8, 17, "SINGLE"]] },
    { "atoms": [[9, 18, "SINGLE"]] },
    { "atoms": [[10, 19, "SINGLE"]] },
    { "atoms": [[0, 1, "SINGLE"],
                [1, 2, "DOUBLE"],
                [2, 3, "SINGLE"],
                [3, 4, "DOUBLE"],
                [4, 5, "SINGLE"],
                [5, 0, "DOUBLE"]], "key": "RING" },
    { "atoms": [[6, 7, "SINGLE"],
                [7, 8, "DOUBLE"],
                [8, 9, "SINGLE"],
                [9, 10, "DOUBLE"],
                [10, 11, "SINGLE"],
                [11, 6, "DOUBLE"]], "key": "RING" }
  ]
};

export const ViewAMolecule = () => <Molecule molecule={mol} />;

This is rendered as:

Biphenylene

Component Attributes

Required

  • molecule: MoleculeData A description of the molecule to display.

Optional

  • translateX: number Translate the whole image on the X axis (default: 0).
  • translateY: number Translate the whole image on the Y axis (default: 0).
  • scale: number Scale the whole image by some fraction (default: 1).
  • width: number The width of the drawing area in pixels (default: 100).
  • height: number The height of the drawing area in pixels (default: 100).
  • labelTranslateX: number Translate each atom label, in the x direction, by this number of pixels (default: 0).
  • labelTranslateY: number Translate each atom label, in the y direction, by this number of pixels (default: 0).
  • atomClicked: (index: number) => void A callback function accepting the index of the clicked atom.
  • atomLabel: (atom: Atom, index: number) => string A callback function defining the text to display in the label for the given atom.
  • atomStyle: (element: string, selected: boolean): React.CSSProperties A hook specifying CSS styles for the SVG <circle>.
  • atomLabelStyle: (element: string, selected: boolean): React.CSSProperties A hook specifying CSS styles for the SVG <text>.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT