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

dd-react-lib

v1.0.1

Published

Djamma Dev React Library

Downloads

3

Readme

dd-react-lib

Djamma Dev React Library

NPM JavaScript Style Guide

Install

npm install --save dd-react-lib

Usage

import React, {useEffect, useState} from 'react'

import {DDAlert, DDChart, DDDataGrid, ExampleComponent, sendInfoAlert, sendSuccessAlert} from 'dd-react-lib'
import {Button, Container} from '@material-ui/core'
import {createMuiTheme, makeStyles, ThemeProvider} from '@material-ui/core/styles';
import {blue, green} from '@material-ui/core/colors';
import 'dd-react-lib/dist/index.css'

const useStyles = makeStyles((theme) => ({
  margin: {
    margin: theme.spacing(1),
  },
}));

const App = () => {

  const columns = [
    {field: 'col1', headerName: 'Column 1', width: 250},
    {field: 'col2', headerName: 'Column 2', width: 150, resizable: true},
  ];

  const rows = [
    {id: 1, col1: 'Hello', col2: 'World'},
    {id: 2, col1: 'XGrid', col2: 'is Awesome'},
    {id: 3, col1: 'Material-UI', col2: 'is Amazing'},
  ];

  const [gridApi, setGridApi] = useState(null);
  const [data, setData] = useState([]);

  const onGridReady = (params) => {
    console.log('--- params --- ', params);
    setGridApi(params.api);
    params.api.setRowData(rows)
    params.api.setColumnDefs(columns);
  }

  useEffect(() => {
    sendInfoAlert({
      title: 'This is an info',
      message: "I'm the best for ever...",
      timeout: 1000
    });
    fetch('/users.json')
      .then(res => res.json())
      .then(response => setData(response.entities))
  }, [gridApi]);

  const columnMapper = (column) => {
    let mapping = {
      "String": "text",
      "Integer": "number",
      "Short": "number",
      "Long": "number",
      "Double": "number",
      "Date": "date",
      "List": "array"
    }
    let myColumn = Object.assign({}, column);
    myColumn.type = mapping[myColumn.type] || myColumn.type;
    return myColumn;
  }

  const theme = createMuiTheme({
    palette: {
      primary: green,
      secondary: blue,
    },
  });

  const getLabels = (data) => {
    return ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'];
  }

  const getData = (data) => {
    return [12, 19, 3, 5, 2, 3];
  }

  const getLabelColor = (data) => {
    return [
      {r: 255, g: 99, b: 132, a: 0.2},
      {r: 54, g: 162, b: 235, a: 0.2},
      {r: 255, g: 206, b: 86, a: 0.2},
      {r: 75, g: 192, b: 192, a: 0.2},
      {r: 153, g: 102, b: 255, a: 0.2},
      {r: 255, g: 159, b: 64, a: 0.2}
    ]
  }

  const classes = useStyles();

  return <Container>
    <DDAlert show={true}/>
    <ExampleComponent text="Djamma Dev React Library Example 😄"/>
    <ThemeProvider theme={theme}>
      <Button variant="contained" color="secondary" className={classes.margin} onClick={(e) => {
        console.log('----');
        sendInfoAlert({
          title: 'This is an info notification',
          message: "I'm the best for ever...",
          timeout: 5000
        });
      }}>Alert Info</Button>
    </ThemeProvider>
    <ThemeProvider theme={theme}>
      <Button variant="contained" color="primary" className={classes.margin} onClick={(e) => {
        console.log('----');
        sendSuccessAlert({
          title: 'This is a success notification',
          message: "I'm the best for ever...",
          timeout: 5000
        });
      }}>Alert Success</Button>
    </ThemeProvider>

    <h2>Auto load data</h2>
    <DDDataGrid
      rowModelType={"infinite"}
      columnsPath={"descriptions/user.json"}
      dataPath={"users.json"}
      columns={columns}
      rows={rows}
      columnMapper={columnMapper}
      style={{height: 300, width: '100%', marginBottom: 20}}/>
    <h2>Passing data from parent</h2>
    <DDDataGrid
      onGridReady={onGridReady}
      columns={columns}
      rows={rows}
      style={{height: 300, width: '100%', marginBottom: 20}}/>
    <h2>Chart Js</h2>
    <DDChart getLabels={getLabels} getData={getData} getLabelColor={getLabelColor} height={100} width={400}/>
    <h2>Chart With Data</h2>
    <DDChart type={"doughnut"} labelKey={"promotion"} data={data} height={100} width={400}/>
  </Container>
}

export default App;

License

MIT © mcicheick