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

react-dazzle

v1.4.0

Published

The simple yet flexible dashbording solution for React

Downloads

4,245

Readme

Looking for maintainers https://github.com/Raathigesh/dazzle/issues/41

Dazzle is a library for building dashboards with React JS. Dazzle does not depend on any front-end libraries but it makes it easier to integrate with them.

Dazzle's goal is to be flexible and simple. Even though there are some UI components readily available out of the box, you have the complete control to override them as you wish with your own styles and layout.

Features

  • Grid based layout
  • Add/Remove widgets
  • Drag and drop widget re-ordering
  • UI framework agnostic
  • Simple yet flexible
  • Well documented (It's a feature! Don't you think?)

Installation

$ npm install react-dazzle --save

Dazzle me

Here is a demo. Widgets shows fake data though but they look so damn cool (At least for me).

Repository of the demo is available here.

Usage

import React, { Component } from 'react';
import Dashboard from 'react-dazzle';

// Your widget. Just another react component.
import CounterWidget from './widgets/CounterWidget';

// Default styles.
import 'react-dazzle/lib/style/style.css';

class App extends Component {
  constructor() {
    this.state = {      
      widgets: {
        WordCounter: {
          type: CounterWidget,
          title: 'Counter widget',
        }
      },
      layout: {
        rows: [{
          columns: [{
            className: 'col-md-12',
            widgets: [{key: 'WordCounter'}],
          }],
        }],
      }
    };
  }

  render() {
    return <Dashboard  widgets={this.state.widgets} layout={this.state.layout}  />
  }
}

API

| Props | Type| Description | Required | | --- | --- | --- | --- | | layout | Object | Layout of the dashboard. | Yes | | widgets | Object| Widgets that could be added to the dashboard. | Yes | | editable | Boolean |Indicates whether the dashboard is in editable mode. | No | | rowClass | String |CSS class name(s) that should be given to the row div element. Default is row. | No | | editableColumnClass | String |CSS class name(s) that should be used when a column is in editable mode. | No | | droppableColumnClass | String |CSS class name(s) that should be used when a widget is about to be dropped in a column. | No | | frameComponent | Component | Customized frame component which should be used instead of the default frame. More on custom frame component. | No | | addWidgetComponent | Component | Customized add widget component which should be used instead of the default AddWidget component. More on custom add widget component. | No | | addWidgetComponentText | String | Text that should be displayed in the Add Widget component. Default is Add Widget. | No | | onAdd(layout, rowIndex, columnIndex) | function |Will be called when user clicks the AddWidget component.| No | | onRemove(layout) | function |Will be called when a widget is removed.| No | | onMove(layout) | function | Will be called when a widget is moved.| No |

Providing widgets

widgets prop of the dashboard component takes an object. A sample widgets object would look like below. This object holds all the widgets that could be used in the dashboard.

{
  HelloWorldWidget: {
    type: HelloWorld,
    title: 'Hello World Title',
    props: {
      text: 'Hello Humans!'
    }
  },
  AnotherWidget: {
    type: AnotherWidget,
    title: 'Another Widget Title'
  }
 }
  • type property - Should be a React component function or class.
  • title property - Title of the widget that should be displayed on top of the widget.
  • props property - Props that should be provided to the widget.

Dashboard layout

The layout prop takes the current layout of the dashboard. Layout could have multiple rows and columns. A sample layout object with a single row and two columns would look like below.

{
  rows: [{
    columns: [{
      className: 'col-md-6 col-sm-6 col-xs-12',
      widgets: [{key: 'HelloWorldWidget'}]
    }, {
      className: 'col-md-6 col-sm-6 col-xs-12',
      widgets: [{key: 'AnotherWidget'}]
    }]
  }]
}
  • className property - CSS class(es) that should be given to the column in the grid layout. Above sample layout uses the classes from bootstrap library. You could use the classes of your CSS library.
  • widgets property - An array of widgets that should be rendered in that particular column. key property of the widgets array should be a key from the widgets object.

Edit mode

Setting editable prop to true will make the dashboard editable.

Add new widget

When user tries to add a new widget, the onAdd callback will be called. More info here on how to handle widget addition.

Remove a widget

When a widget is removed, onRemove method will be called and new layout (The layout with the widget removed) will be available as an argument of onRemove method. Set the provided layout again to the dashboard to complete the widget removal. The Sample repository has the this feature implemented.

Customization

Implementing custom WidgetFrame component

A frame is the component which surrounds a widget. A frame has the title and the close button. Dazzle provides a default frame out of the box. But if you want, you can customize the frame as you like. More info here.

Implementing custom AddWidget component

Dazzle also allows you to customize the Add Widget component which appears when you enter edit mode. More info here.

Issues

  • Improve drag and drop experience (#1)

License

MIT © Raathigeshan