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

@pinpt/uic.next

v2.0.0

Published

Pinpoint component library and styles for React

Downloads

248

Readme

Component Docs

Install

npm install @pinpt/uic.next

If you'd like to use FontAwesome pro, set an environment variable with your token for npm:

export UIC_NPM_TOKEN=<your_token_here>

Developing

In order to develop using uic.next, you'll need to link in React from the project you are developing on. Assuming they are siblings in a directory:

npm link ../<project_name>/node_modules/react

Then, you will need to link this library:

npm link

And finally, in your application, bring in the linked library:

npm link @pinpt/uic.next

If you need to add any third party libraries, add them to both dependencies and peerDependencies so that npm brings in the dependencies dependencies and so that rollup ignores them.

Creating Components

This library has a script for adding a component that handles all the tasks needed:

npm run create -- -c <componentName>

This script will create:

  • Component directory with uppercased componentName
  • Component stub
  • Storybook file stub
  • Test file stub
  • Less stylesheet stub
  • README template

This script will update:

  • Library exports
  • Main library README

If you pass the script the -s or --star argument, it will make the file use named exports, and write the imports as import * as <componentName> from './<componentName>';. Otherwise all components are default exported from their individual files.

Storybook

We use storybook for viewing the components in isolation:

npm run storybook 

Each component should have a <componentName>.stories.tsx file with:

  • A default export with the title
  • Named exports with each desired variation

For example:

import React from 'react';
import * as Tabs from './index';

export default {
	title: 'Tabs',
};

export const multiple = () => (
	<Tabs.Wrapper>
		<Tabs.Tab title="Hi" small="(Hello)">
			<div>
				Hello World
			</div>
		</Tabs.Tab>
		<Tabs.Tab title="Bye" small="(Goodbye)">
			<div>
				Goodbye
			</div>
		</Tabs.Tab>
		<Tabs.Tab title="Titles can be really long">
			<div>
				...and that is fine
			</div>
		</Tabs.Tab>
	</Tabs.Wrapper>
);

export const single = () => (
	<Tabs.Wrapper>
		<Tabs.Tab title=":(">
			<div>
				I am all alone
			</div>
		</Tabs.Tab>
	</Tabs.Wrapper>
);

This yields a Storybook entry with the structure

Tabs
├── Multiple
├── Single

Testing

This repo currently uses Jest snapshot testing to validate that components render successfully.

Running Tests

npm test

Writing Tests

Tests should be created in the folder of the components, in a file named <component_name>.test.tsx

Here is an example test suite for the Tabs component:

import React from 'react';
import renderer from 'react-test-renderer';
import * as Tabs from './index';

it('renders correctly with one tab', () => {
	const tree = renderer
		.create(
			<Tabs.Wrapper>
				<Tabs.Tab title="Hello">
					<div>
						Hello, world
					</div>
				</Tabs.Tab>
			</Tabs.Wrapper>
		)
		.toJSON();
	expect(tree).toMatchSnapshot();
});

Tests should cover an many variations as possible of the component, especially if it is dynamic based on props. Be sure to commit the snapshots generated by your new tests.

Updating Test Snapshops

npm run test:output -- -u