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

@sygniacoza/components

v0.0.1

Published

Sygnia UI Component Library

Downloads

3

Readme

Sygnia React Components

A React component library for Sygnia, powered by Storybook.

Table of contents

Library Usage

Import desired component into your project

import { ComponentName } from '@sygnia/components';

Development

Switch to the correct version of Node (using NVM)

nvm use

Install dependencies

yarn

Run Storybook

Storybook is a UI development environment we are using to power our component library. Using Storybook allows us to work on components in isolation.

yarn start

Using Storybook requires you to wrap your component in a story. Look in the src/components directory for an example .stories.js file. Storybook has been configured to automatically include any files with the .stories.js file extension.

Storybook is setup using its own Webpack configuration file located at tools/.storybook/webpack.config.js.

Component Structure:

  • Comments appear as documentation in Storybook
  • Use comments to describe Component and PropTypes
  • Ensure PropTypes and DefaultProps are added and up to date
  • Ensure Prettier set up as per Wiki: https://gitlab.com/plusplusminus/code-snippets/wikis/Prettier-ESLint-Setup-Create-react-app
  • Do not leave console.log in committed code unless comments explain why
  • Fix linting warnings and errors as you go
  • All components should be checked for responsive viewports

Storybook structure:

  • Use folders to group similar Components
  • Use group to organise individual stories
  • A generic story of a component with props can be made availible as the first story eg Hero
  • Ensure that each version of the Component with the collection of props as per design implementation exists as separate story eg Hero with title, intros and color to ensure we can get visual snapshot testing on each reuired version of the component

Example component directory structure

A component's directory should resemble the following:

YourComponent
├── index.js                 // A file for exporting your component
├── YourComponent.js         // Your React component
├── YourComponent.css        // Component styles
├── YourComponent.stories.js // Storybook for the component
└── YourComponent.test.js.   // Component tests

Component principles

We follow a number of principles when creating our components:

  1. A component is responsible for only its internal spacing

We follow the principle that a component should only be responsible for its own internal spacing - never external spacing. This means that we're flexible in where our components can be used without having to override margins.

  1. Use descriptive PropTypes

We recommend the following naming convention for PropTypes to make them as clear as possible:

  • Number - use a prefix or suffix to imply that the prop accepts a number. E.g. numItems, itemCount, itemIndex
  • Boolean - use the prefix 'is'/'can'/'has'. E.g. isVisible, canExpand, hasImage
  • Array - use a plural noun. E.g. items
  • Object - use a noun. E.g. item
  • Node - use the suffix 'Node'. E.g. containerNode
  • Element - use the suffix 'Element'. E.g. triggerElement
  • Event handler functions - use the prefix 'on'. E.g. onOpen, onClick

Adding a new component

You can use Plop to scaffold new components. Run yarn add-component and follow the steps in the CLI to create a component. Using your input here, Plop will generate the relevant files and add the relevant imports/exports to the main src/index.js file required to make the component available when publishing the library.

Here is the example output of running the yarn add-component command:

? What is the name of your component? button
[SUCCESS] add /src/components/Button/Button.js
[SUCCESS] add /src/components/Button/Button.css
[SUCCESS] add /src/components/Button/Button.test.js
[SUCCESS] add /src/components/Button/Button.stories.js
[SUCCESS] modify /src/index.js
[SUCCESS] modify /src/index.js

Adding new Storybook documentation

You can also use Plop to scaffold documentation sections in Storybook. Run yarn add-documentation and follow the steps in the CLI to create new documentation. Using your input here, Plop will generate the relevant files required to make the documentation show in Storybook.

Here is the example output of running the yarn add-documentation command:

? What is the title of your documentation? general
[SUCCESS] add /.storybook/docs/General/General.md
[SUCCESS] add /.storybook/docs/General/General.stories.js

Testing

Run tests

yarn test

It is recommended to run tests in development with the optional --watch flag.

yarn test --watch

Building (WIP)

We are using a combination of Webpack and Babel to create builds of our component library. We use Webpack with the tools/webpack.production.config.js

Create a build of the library

yarn build

Commits

This project uses the Angular JS Commit Message Conventions, via semantic-release. See the semantic-release Default Commit Message Format section for more details.

You can commit the changes by running

yarn commit