This project is just a playground to test how jsPanel4 can be integrated with React JS without altering the jsPanel4 library.
jsPanel4 is an amazing JS library written in vanilla javascript by Stefan Sträßer. It has no dependency.
Click here to see the live running application.
How to use
- Clone the repo
- yarn or npm install
- yarn start or npm start
- play with code to see how its implemented
App.js preview
;;;;;; // Normal components;;; // jsPanel default options; // lazy loaded componentsconst DisplayName = ;const Countries = ;const TodoApp = ;const SampleUsers = ;const RandomImage = ; // Top level React component { super; thisstate = panels: {} ; } { // keep Main component refrence const app = this; // check if its already mounted, bring it to front if appstatepanelsaction return appstatepanelsaction'panel'; const options = ...jsPanelOptions headerTitle: action { // remove closed jsPanel and its mounted component from state const appPanels = appstatepanels; if appPanelsaction delete appPanelsaction; app; } ; // create jsPanel const panel = modal ? jsPanelmodal : jsPanel; // save panel and compponent (this will be mounted later inside panel body) reference inside state app; }; { const panels = thisstatepanels; return Object; } { const jsPanels = Object; const actionButtonProps = className: 'btn btn-outline-primary ml-2 mb-2' handleClick: thiscreateJsPanel ; return <div className="container-fluid"> <div className="row bg-dark text-white shadow p-2"> <div className="col-md-12"> <h4 className="text-center">jsPanel with react</h4> </div> </div> <div className="row justify-content-center mt-4"> <div className="card"> <div className="card-body"> <ActionButton ...actionButtonProps title="Simple Example" comp=DisplayName /> <ActionButton ...actionButtonProps title=" Countries List" comp=Countries /> <ActionButton ...actionButtonProps title="Todo App" comp=TodoApp /> <ActionButton ...actionButtonProps title="Sample Users" comp=SampleUsers /> <ActionButton ...actionButtonProps title="Random Image" comp=RandomImage /> <ActionButton ...actionButtonProps title="Modal Example" comp=Clock modal=true /> <ActionButton ...actionButtonProps title="Multiple Components" comp=Clock DisplayName RandomImage Countries /> </div> </div> </div> jsPanelslength > 0 && this </div> ; } ;