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

@coorpacademy/components

v11.32.0

Published

This library provide sharable components for web applications, either :

Downloads

13,777

Readme

@Coorpacademy/Components

This library provide sharable components for web applications, either :

  • as CommonJS components
  • as a minified library

Components diagram

Goal

  • edit a component once, share it across all our platforms
  • provide a documentation referencing every component with its
    • available states (disabled, selected)
    • skinable properties
  • provide the smallest lib

Development

Seeing the components on Storybook

yarn
npm run start
# OR
npm run start:ie # for Internet Explorer

Then open http://localhost:3004.

Analyse your component

The props is the contract your app should fill in order to use the component. If the props are not properly set, it is not the role of you component to change them in order to render somehow. The propTypes are the representation of this contract.

Keep this workflow in mind:

props -> propTypes -> fixtures -> component

Then your app will just have to read propTypes to know which props to provide to render a view.

Adding a component

  • choose your atomic folder depending your component: template, organism, molecule, atom
  • add a folder having your component name: for example, for button you should have this tree:
atom
  └── button
        ├── index.js
        ├── style.css
        └── test
            └── fixtures
               └── default.js
               └── disabled.js
               └── hovered.js
  • index.js contains the React code + jsx, and exports your component
  • style.css contains the css module style for your component
  • test/fixtures/*.js are files representing all the possible states for your component, thus export props accordingly

note that whenever you add new component or new fixtures you have to generate the storybook index:

npm run generate

which is also launched automatically whenever you run npm start

Adding a locale

  • You need to add your locale in en/global.json file
  • Be sure to have translate: Provider.childContextTypes.translate in the contextTypes object of your component

example:

  ....

  const YourComponent = (props, context) => {
    const {translate} = context;

    return <p>{translate('your new locale')}</p>
  }

  YourComponent.contextTypes = {
    translate: Provider.childContextTypes.translate
};

  ...

Using a Lottie Animation

To use a lottie animation, you need to use the LottieWrapper Atom.

Among the Lottie Atom's props, there are two important props: animationSrc & ie11ImageBackup, that need an additional step, the ie11ImageBackup is needed as it's name implies because ie11 doesn't support Lottie (more specifically Web Components due to the Shadow DOM).

First, you must upload to AWS S3 any new animation, in one of the static buckets (depending on the desired env), ex: https://static-staging.coorpacademy.com/animations/review/.

This animation must be paired with a backup image (svg) that'll be used for the ie11 scenario.

Then, use the urls as props for animationSrc & ie11ImageBackup, ex:

const props = {
    'aria-label': 'aria lottie',
    'data-name': 'default-lottie',
    className: undefined,
    animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
    loop: true,
    height: 200,
    width: 200,
    ie11ImageBackup:
      'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',
    // autoplay: true // autoplay is true by default
}

If you need to control the animation (play/pause/stop), then you must set autoplay to false & add your desired state, among the available states: play, pause, stop, loading

const props = {
    'aria-label': 'aria lottie',
    'data-name': 'default-lottie',
    className: undefined,
    animationSrc: 'https://static-staging.coorpacademy.com/animations/review/rank.json',
    loop: true,
    height: 200,
    width: 200,
    ie11ImageBackup:
      'https://static-staging.coorpacademy.com/animations/review/rank_icon_congrats.svg',
    autoplay: false,
    animationControl: 'loading' // play can be passed directly without using loading first
}

Additional information

The props include classNames && size control to handle additional styling.

Locally use in an external project

Link your dependencies:

[@coorpacademy-components] > npm link
[your-app] > npm link @coorpacademy/components

Build modifications:

[@coorpacademy-components] > npm run build:es

Use in mobile app

Run npm run build:watch For more info see the mobile documentation

You may need to install these optional libs depending on which native components you use:

  • colorjs.io
  • react-native-modal
  • react-native-render-html
  • react-native-linear-gradient
  • @coorpacademy/react-native-slider
  • @react-native-community/blur

Troubleshooting

Error when trying to launch the storybook:

Try to delete your node_modules, go to the project's root and launch: yarn

Generating a Bundle Analyzer Report

To check the content of the bundle and optimize it if needed, we set up webpack-bundle-analyzer, which generates a bundle analysis report. This visualizes the size of webpack output files with an interactive zoomable treemap. To generate it, just run npm run build:stats.

Webpack Bundle Analyzer Report