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

@onfido/castor-react

v2.4.8

Published

React component library for Castor.

Downloads

338

Readme

Castor React

npm version Bundle size

Castor React is Onfido's design system addition. It provides React component library.

Get started

Install packages

npm install @onfido/castor @onfido/castor-react

Follow Castor instructions for initial setup.

If you plan to use Icon component, also install Castor Icons package:

npm install @onfido/castor-icons

Then (only once) inline the SVG sprite in your app:

import { Icons } from '@onfido/castor-icons';
import React, { Fragment } from 'react';

const App = () => (
  <Fragment>
    <Icons />
    {/* ...anything else e.g. app routes */}
  </Fragment>
);

Use components

Include any Castor component and use it within JSX directly.

import { Button } from '@onfido/castor-react';

Then use within your JSX app. For example, as a "destructive" kind:

import React, { Fragment } from 'react';

const App = () => (
  <Fragment>
    <Button kind="destructive">Destructive Button</Button>
  </Fragment>
);

Please note that Castor is exported as an ECMAScript module targeting ECMAScript 2019.

You may wish to configure your bundler to transpile to a different module syntax, and/or to target a lower ECMAScript version.

For example, you might choose UMD module syntax targeting ES5 if your app needs to support IE11 (please note that Castor is not tested in Internet Explorer).

Use with TypeScript

Components extend base prop types with JSX additions.

When using with TypeScript, always import types from @onfido/castor-react.

Please note that the @onfido/castor-icons package is a peer dependency and is required to be installed for types to work properly. Yarn and newer versions of npm (using lockfile v2) will resolve it, otherwise it must be installed manually even if you don't plan to use icons.

Make custom styled components

You should use props for each component modifier, but it is also possible to create custom styled components.

For example, if you'd like a round button, you could create a component using "full" border-radius token:

import styled from '@emotion/styled';
import { borderRadius } from '@onfido/castor';
import { Button } from '@onfido/castor-react';

const RoundButton = styled(Button)({
  borderRadius: borderRadius('full'),
});

Use for prototyping

If you need to prototype with Castor, the quickest way is to use the generated single file global Castor exposed as IIFE module:

<script src="https://cdn.jsdelivr.net/npm/@onfido/castor-react/prototype.min.js"></script>

You can also use any previously released version (v1.2.0 and up), for example:

<script src="https://cdn.jsdelivr.net/npm/@onfido/[email protected]/prototype.min.js"></script>

The same prototype file (not minified) is located on each npm package version.

For modern browsers you may use ECMAScript modules directly via Skypack:

<script type="module">
  import { borderRadius } from 'https://cdn.skypack.dev/@onfido/castor';
  import { Button } from 'https://cdn.skypack.dev/@onfido/castor-react';

  // all other app code
</script>

Also it is easy to use Skypack distributions with Deno.