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

atp-queue

v1.0.26

Published

Functional components build for RCM project

Downloads

2

Readme

React & Material UI NPM package boilerplate

A shareable Material UI component library with a playground folder to live-test components as you are developing them.

Technologies used

  • React
  • Rollup
  • Material UI
    • To Add
      • Prettier
      • Lint
      • Husky

Steps to bring the functional components to the UI Builder

  1. Customize the default theme of the package
  2. Create the functional component
    1. For the styling, only use material theme by using the useTheme() hook for both material ui components & also inline styles. Hence it can be customized based on the project
  3. Export the component in the index.js file
    1. export { default as CustLayout } from './components/layout'
  4. Run & test the functional component with the help of the playground project
  5. After testing, publish the npm package with the proper versioning
  6. Next, add the component JSON in the DB( ArangoDB) (Details Given Below)
  7. To show the component in the UI Builder, the package needs to be added to the UI Builder code, so contact the UI Builder team. (This is only required for newly created package, after that it won't be required)

Functional Component Structure

import React from 'react';
import Typography from '@material-ui/core/Typography';
import withStyleFix from '../stylefix';
import withTheme from '../themeProvider';
import { useTheme } from '@material-ui/core/styles';
import Container from '@material-ui/core/Container';

const HelloWorld=(props)=>{
    const theme = useTheme();
    const {name}=props;

    return(
        <Container disableGutters maxWidth="lg" style={{display:"grid",placeItems:"center",minHeight:"100vh"}}>
            <Typography variant="h2" style={{color:theme?.palette?.primary?.main,textAlign:"center",fontWeight:500}}>Hello {name}</Typography>
      </Container>
        )
}
     

HelloWorld.defaultProps={
    name:"React & Material UI NPM package boilerplate"
}

export default withStyleFix(withTheme(HelloWorld));

//withStyleFix -  It can be used to avoid class name collisions when using multiple generators in the same document.
// withTheme -  To Provide the theme object to the component as a property, which can be consumed by using useTheme() hook as shown above

Component Sample JSON to put in ArangoDB to show the component in UI Builder

{
  "componentName": "CustLayout",
  "componentId": "cmuc-comp-1",
  "frameWork": "custom-material-ui-component",
  "componentType": "Layout",
  "isLayout": true,
  "supported": [
    "web"
  ],
  "defaultProps": {
    "childComponent": true
  },
  "props": {
    "ProjectTitle": {
      "componentToRender": "messageCatalog"
    },
    "VersionNo": {
      "componentToRender": "text"
    },
    "Title": {
      "componentToRender": "messageCatalog"
    },
    "SubTitle": {
      "componentToRender": "text"
    },
    "ImageSrc": {
      "componentToRender": "imageUpload"
    },
    "HeaderBackgroundColor": {
      "componentToRender": "text"
    },
    "HeaderFontColor": {
      "componentToRender": "text"
    },
    "Header": {
      "componentToRender": "select",
      "options": [
        true,
        false
      ]
    },
    "Transtale": {
      "componentToRender": "select",
      "options": [
        true,
        false
      ]
    },
    "Menu": {
      "componentToRender": "select",
      "options": [
        true,
        false
      ]
    },
    "Language": {
      "componentToRender": "multiSelect",
      "options": []
    },
    "childComponent": {
      "componentToRender": "select",
      "options": [
        true,
        false
      ]
    },
    "navBarType": {
      "componentToRender": "select",
      "options": [
        "Normal",
        "Nested"
      ]
    },
    "pages": {
      "componentToRender": "pageSelect",
      "value": [
        {
          "name": {
            "componentToRender": "text"
          },
          "page": {
            "componentToRender": "text"
          },
          "childPageSelect": {
            "componentToRender": "childPageSelect"
          }
        }
      ]
    }
  },
  "active": true
}

Function Component Sample JSON Explanation

{
  "componentName": "CustLayout", //component Name
  "componentId": "cmuc-comp-1", // packagename(fullname or shortform in kebab case) +  Unique Id (Serial No)
  "frameWork": "functional-components-boilerplate", //Package Name
  "componentType": "Layout", // Possible Values ["Lab","Layout","Data Display","Lab","Inputs","Surfaces"]. Refer UI Builder 
  "isLayout": false, // For custom components isLayout always will be false
  "supported": [
    "web"
  ],  // Default web
  "defaultProps": {
    "childComponent": true
  }, // Pass the default props of the component
  "props": {

    // Basic Structure
    "key":{
    "componentToRender":"text" // This is for the UI Builder. It will render the property with the componentToRender type like text ,select, etc.. in the properties panel
    }
    //Possible Values for componentToRender ["text","number", "messageCatalog","select","icons","imageUpload","component","pageSelect","NestedNav","arrayOfObject","freeMultiSelect","multiSelect"];

    //For More details contact the UI Builder Team

    //Examples

    "ProjectTitle": {
      "componentToRender": "messageCatalog"
    },
    "VersionNo": {
      "componentToRender": "text"
    },
    "Title": {
      "componentToRender": "messageCatalog"
    },
    "SubTitle": {
      "componentToRender": "text"
    },
    "ImageSrc": {
      "componentToRender": "imageUpload"
    },
    "HeaderBackgroundColor": {
      "componentToRender": "text"
    },
    "HeaderFontColor": {
      "componentToRender": "text"
    },
    "Header": {
      "componentToRender": "select",
      "options": [
        true,
        false
      ]
    },
    "Transtale": {
      "componentToRender": "select",
      "options": [
        true,
        false
      ]
    },
    "Menu": {
      "componentToRender": "select",
      "options": [
        true,
        false
      ]
    },
    "Language": {
      "componentToRender": "multiSelect",
      "options": []
    },
    "childComponent": {
      "componentToRender": "select",
      "options": [
        true,
        false
      ]
    },
    "navBarType": {
      "componentToRender": "select",
      "options": [
        "Normal",
        "Nested"
      ]
    },
    "pages": {
      "componentToRender": "pageSelect",
      "value": [
        {
          "name": {
            "componentToRender": "text"
          },
          "page": {
            "componentToRender": "text"
          },
          "childPageSelect": {
            "componentToRender": "childPageSelect"
          }
        }
      ]
    }
  },
  "active": true // When false the component will not be shown in the UI Builder
}

Available Scripts

    "build": "rollup -c", // To build the package
    "start": "rollup -c -w", // To build & watch the package
    "start-playground": "cd playground && npm run start", // To start the playground
    "i-all": "npm i && cd playground && npm i", // To the install the dependencies after cloning this boilerplate
    "dev": "npm-run-all --parallel start start-playground" // To run both the package & playground project

To package and test the created component in the playground Project

  1. Run npm run dev to live-test the components

To package and test the created component in a external react project

To bundle and test in local follow below steps. Make sure you have run the npm run build command or npm start before testing.

  1. Run npm link. It will create a symlink in the global folder file.

  2. Then go the project you want to use the package. And run the below command npm link packagename(functional-components-boilerplate).

The above command just include the functional-components-boilerplate in the node_modules (not add anything in package.json).

import React from 'react';

import { HelloWorld } from 'functional-components-boilerplate';

const App = () => {
    return <HelloWorld />
}

export default App;

To publish the package to NPM

To publish the package to NPM follow the below setps

  1. First, build and commit the library
    npm run build git add . git commit -m 'your commit message'
  2. Then update the version of the package
    1. npm version patch - For a bug fix
    2. npm version minor - For a new component addition
    3. npm version major - For a completed feature.
  3. Then login to the NPM account using the below command (ignore if you already logged in) npm login It asks the NPM credentials
  4. Finally run npm publish --access public to publish
  5. Then, login into the NPM site and check the version update there.

For further more details refere the below link How to create,test and publish a NPM package in react.

Requirements Status

  • [x] Boilerplate Setup with playground
  • [x] Using components styles from the theme setup
  • [ ] Access control for the components
  • [ ] Multilingual setup for the components