0.1.0-alpha.1 • Published 4 years ago

software-platforms-ui-components v0.1.0-alpha.1

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
4 years ago

PerkinElmer Component Library

This project was created to help PerkinElmer delivery teams provide rapid software development with a uniform approach to styling, themes and behaviors. Initially, these components are simple wrappers around the DevExtreme library that inject default PKI styling so that the library can be delivered quickly and provide a known API. Future iterations are envisioned to gradually replace exposed attributes with those more germane to PerkinElmer use-cases and user flows, and separate the tight coupling with the DevExtreme library.

Technologies used:

Development

Building

npm run build

or

yarn build

Storybook

To run a live-reload Storybook server on your local machine:

npm run storybook

or

yarn storybook

Installing the Component Library Locally

Let's say you have another project (test-app) on your machine that you want to try installing the component library into without having to first publish the component library. In the test-app directory, you can run:

npm i --save ../software-platforms-ui-components

which will install the local component library as a dependency in test-app. It'll then appear as a dependency in package.json like:

{
  ...
  "dependencies": {
    ...
    "software-platforms-ui-components": "file:../software-platforms-ui-components",
    ...
  },
  ...
}

Your components can then be imported and used in that project.

NOTE: After installing the component library locally, you may run into:

Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

You might have mismatching versions of React and the renderer (such as React DOM)
You might be breaking the Rules of Hooks
You might have more than one copy of React in the same app See for tips about how to debug and fix this problem.

This is the most commonly encountered problem people face when installing the library locally. This is most likely due to the third reason: You might have more than one copy of React in the app.

Normally when a library is published, dev dependencies are excluded. However, when the library is symlinked, all local dev dependencies are persisted in the libraries node_modules (includes React). Your bundler may see two versions of React, one in the consuming app and one in the symlinked library. The solution is to have the component library use the React version in the consuming app. So from your component library folder, run:

npm link ../test-app/node_modules/react

OR, if you are using Webpack in your app you can follow this GitHub comment.

Read more about this issue here.

Usage

To consume this library, run

npm i software-platforms-ui-components

or

yarn add software-platforms-ui-components

Usage of the component will be:

import React from 'react';
import { Button, ButtonProps } from 'software-platforms-ui-components';

const handleClick = (event) => {
  // My click action
};

const App: React.FunctionalComponent<ButtonProps> = (props) => (
  <div className="app-container">
    <h1>Hello I'm consuming the component library</h1>
    <Button className="primary" onClick={handleClick} {...props}>
      Click me
    </Button>
  </div>
);

export default App;
0.1.0-alpha.1

4 years ago

0.0.7-SNAPSHOT

4 years ago

0.0.6-SNAPSHOT

4 years ago

0.0.5-SNAPSHOT

4 years ago

0.0.4-SNAPSHOT

4 years ago

0.0.3-SNAPSHOT

4 years ago

0.0.2-SNAPSHOT

4 years ago

0.0.1-SNAPSHOT

4 years ago