Giter Club home page Giter Club logo

ngl-viewer's Introduction

NGL Viewer for React

The following package allows the developer to use already built in components to embed NGL Viewer in React.JS in the easiest way possible. Currently, the best ways to use this is by passing the correct props.

Installing

To install this components library, use the following command with npm

npm install git+https://github.com/jowillianto/ngl-viewer#stable

Usage

A very simple example of using is :

import React from 'react'
import ProteinViewer, {ProteinStage} from "@jowillianto/ngl-viewer/dist"
import { 
  ComponentUIDataT 
} from "@jowillianto/ngl-viewer/dist/ngl-viewer/user-interface/component-data";

const App = () => {
  const component : ComponentUIDataT = {
    type : "file",
    props : {
      file : "http://files.rcsb.org/download/7RDR.pdb",
      fileSettings : {},
      viewSettings : [{
        type : 'cartoon', params : {}
      }]
    },
    config : {}
  }
  return (
    <ProteinViewer initialComponents = {[component]}>
      <ViewerStage height = "800px" width = "800px" />
    </ProteinViewer>
  )
}

export default App

Commonly Used APIs

1. ProteinViewer

ProteinViewer is a component that has to be written first as to allow its child component to function in the correct manner.

type ProteinViewerProps = {
  initialComponents : ComponentUIDataT[]
}

Note that initialComponents will only be read once when the component is rendered. Any changes applied to this variable will not be read by the ProteinViewer.

2. ViewerStage

ViewerStage renders the NGL Stage with corresponding height and width.

type ViewerStageProps = {
  height : string, width : string
}

3. ViewerPanel

ViewerPanel is a built in panel that allows the modification of components that has been added to the stage.

  type ViewerPanelProps = {}

4. ViewerSelector

ViewerSelector is a built in selector based on react-select that renders a selector that allows addition of objects to the stage.

  type ViewerSelectorProps = {
    options : OptionT
  }
  // Available Options
  type OptionT = 
    | "text" | "arrow" 
    | "box" | "cone" 
    | "ellipsoid" | "torus" 
    | "sphere" | "cylinder" 
    | "tetrahedron" | "octahedron" 
    | "file"

ngl-viewer's People

Contributors

hale2024 avatar jowillianto avatar nursultan2ch avatar

Watchers

 avatar

ngl-viewer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.