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

@contentful/f36-components

v4.75.2

Published

Contentful UI Component Library

Downloads

162,690

Readme

Forma 36 React Components

A React component library for the Forma 36 design system created by Contentful.

Table of contents

Installing package

yarn add @contentful/f36-components

Or

npm install @contentful/f36-components

Usage

Import desired component into your project

import { Button } from '@contentful/f36-components';

Development

For local development, in the root of the repo run npm i to install all dependencies and then npm run-script build to build all packages. This package depends on several other Forma 36 packages so you will need to build all of them.

Storybook

We use Storybook to create a development environment for our component library. To start it locally run:

npm run-script storybook

When creating new component, before you start, please have a look at our contribution model for Forma 36.

Example component directory structure

A component's directory should resemble the following:

/my-component
  /examples
  /src
    index.ts // A file for exporting your component
    MyComponent.tsx  // Your React component
    MyComponent.test.tsx // Component tests
    MyComponent.styles.ts // Component styles
  /stories
    # stories for storybook of each component inside the package
  README.mdx
  package.json

For more detailes you can have a look in document that describes folder structure in details.

If you use npm run-script generate in the root of the repo, this structure will be created automatically for you

Code Style Guide

Our code style guide

Component principles

We follow a number of principles when creating our components:

  1. A component is responsible for only its internal spacing

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. The only outlier from this rule are typography components - they can manage their own margins. To handle margins and layout you can use our core components, like:

Adding documentation for component

We would like to make sure that every component contains a README file with recommendations and guidelines. Make sure that your documentation for the component contains following parts:

  1. A short summary of the component.
  2. Import - provide example how to import component.
  3. Examples - try to add couple of examples, both basic and more advanced, where component is used in the context with other components.
  4. Props (API reference) - Overview of properties
  5. Content guideliness - try to describe in best practices around content for your component
  6. Accessibility - If possible, we strongly recommend providing accessibility guidelines.

Testing

We are using Jest and Testing Library to test our components.

Tests are kept next to their components and use the .test.js file extension.

Run tests

npm run-script test

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

npm run-script test --watch

Building

We are using tsup and esbuild together with Microbundle to build our component library.

Each component builds to its own dist directory with:

  • index.d.ts – TypeScript type declaration file
  • index.js – CJS (CommonJS)
  • index.modern.mjsModern output (work in all modern browsers)
  • index.module.js – legacy ESM (ES Modules) output (for bundlers)
  • index.umd.js – legacy UMD (Universal Module Definition) output (for Node & CDN use)

Create a build of the library

npm run-script 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

npm run-script commit