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

@businessoptics/frontend-library

v0.11.4

Published

This library consists of modern and useful reusable components for React based BusinessOptics apps. It works best with apps that have been built using create-react-app version 2+. It consists of three primary sections:

Downloads

40

Readme

BusinessOptics Frontend Library

This library consists of modern and useful reusable components for React based BusinessOptics apps. It works best with apps that have been built using create-react-app version 2+. It consists of three primary sections:

  • Small but useful utilities
  • A resusable component library
  • SCSS based theme components

All modern BusinessOptics apps should use it, and abstract any common functionality to it. The library is a little disorganised right now, but we will strive to keep the external interfaces reasonably stable.

Usage

the library can be installed with npm straight off Github assuming you have the correct permissions, via:

npm install @businessoptics/frontend-library

Development usage

Use npm link to make devlopment usage easier (this is probably mandatory for now). This allows changes you make to automatically be picked up by projects using it on your local development machine.

  1. git clone the library

  2. Navigate to the root folder

  3. Run npm link (you may have to sudo)

  4. Run npm run build:watch (this will automatically build the library when you make changes)

  5. Navigate to a project that is using the library (and already has it installed)

  6. Run npm link @businessoptics/frontend-library

  7. Run npm start

Now if you make a change in this library, the application using it should automatically update, making for a great development cycle.

You will have to rerun the second part of the steps when you run npm install in an application.

Components

Utilities

These can be imported directly form the root module. They include a small set of helpers particularly useful for dealing with redux stores, without heavy weight dependencies like immutable.js.

Immutability helpers

These all work off iupdate

  • root is a nested object
  • path is an array of strings/numbers, or a single item
  • updateFn is a function that takes a single value and returns the value to replace it with
/* Given a nested data structure this will follow the path, and replace
 * the item at the end of the path with the result of calling the updateFn on it.
 * */
export const iupdate = (root, path, updateFn) => ..

/* Given a nested data structure this will follow the path, and replace
 *  the item at the end of the path with the value.
 */
export const iset = (root, path, value) => iupdate(root, path, () => value);

/* Given a nested data structure this will follow the path, and add the
 * given value to the end of the array at that path.
 */
export const ipush = (root, path, value) =>
  iupdate(root, path, list => list.concat([value]));

/* Given a nested data structure this will follow the path, and remove the
 * given idex in the array at that path
 */
export const iremove = (root, path, index) =>
  iupdate(root, path, list => [
    ...list.slice(0, index),
    ...list.slice(index + 1)
  ]);

Other useful helpers can be found in utilities.js.

General Input Component

The <Input/> component is a generalised input component that deals with many edge cases around the traditional inputs and has a unified styling system. Primarily it accepts a type prop which defines the data type (and default widget), and an optional widget prop which customises what widget is used. These are meant to be used as controlled components. The options are

  • type: text, number, currency, boolean
  • widget: text, number, currency, checkbox, toggle, select, radiogroup, radiogroup-vertical

Obviously only some types can support some widgets, use common sense. Null is correctly supported and the value is always of the correct type.

The input takes an onChange(value) event handler which is given the value of the control of the correct type.

Other props include:

  • value: The value
  • disabled: Disable the input
  • choices: a list of {value, label} pairs for use by select, radiogroup, radiogroup-vertical.
  • Other props are passed directly to the implementing component, look at the code for more details.

Additionally there is a list widget which takes a list of objects as it's value, and required a list of field definitions, which are props for the various columns field types.

SCSS based mixins

These assume a create-react-app v2+ is using the library. The scss can be included through:

@import "~@businessoptics/frontend-library/css/mixins.scss";

The following mixins are available.

// Only style the <Input/> component from this library
@include businessoptics-input-components($primaryColor, $secondaryColor);

//Applies styling to standard input components (to teh degree possible)
@include standard-input-components($primaryColor, $secondaryColor);

//Decent stying for tables with className="data-table"
@include data-tables($primaryColor, $secondaryColor);

//Some decent typography defaults
@include businessoptics-typography;

//A set of utility classes, this includes the whole of basscss, a small but useful library
//See utitily mixins for additional utility classes
@include utility-classes($primaryColor, $secondaryColor);