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

@apolitical/styleguide2

v7.6.11

Published

Reusable React components for Apolitical UIs

Downloads

515

Readme

Apolitical Styleguide

This project was bootstrapped with Create React Library.

All library files are located inside src/lib folder.

Inside src/demo folder, you can test your library while developing.

Available Scripts

In the project directory, you can run:

yarn figmagic

Reads the styles defined in design system on figma and re-creates the Token folder in the src folder.

Before running this file, you would need to make sure you have correct values in your .env. This can be found on lastpass under "styleguide .env"

There are some files within the Tokens folder that are not auto-generated so when you run the command you have to recreate them. They are:

  • breakpoints.js file.
  • index.js file to export all the files within that folder.
  • mobileFontSizes.js export all mobile fonts

Tip: copy and paste these files somewhere before running the command

In the changelog, make a note of whats been added to the folder or removed so we can keep track. This is not created by default.

After the script is run, change the module.exports in the tokens directory to export default and fix any formatting changes.

yarn start

Runs the library in development mode. Open http://localhost:3000 to view it in the browser.

yarn run test

Runs the test watcher in an interactive mode.

yarn build

Builds the library for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.

yarn start:storybook

Starts the storybook components explorer on port 6006. Storybook is hosted at https://apolitical.gitlab.io/node-modules/apolitical-styleguide/

yarn publish

Publishes the library to NPM.

Troubleshooting

Developing locally

You will probably run into an error while developing saying you cannot have two Reacts in one app. This resource explains the issue in detail and how to solve it by linking react.

When you make changes in the Styleguide, you need to run yarn build in order for the changes to be reflected in the UI using Styleguide

Adding a dependency

  • Install the dependency with yarn add
  • Make sure it was added to the dependencies and it uses a strict version (without ^) in package.json file
  • Copy it to the peerDependencies section in package.json file
  • Add the dependency to the externals list in the /config/webpack.config.js file

Note: By default, only react, react-dom styled-components are defined as devDependencies and peerDependencies, and also listed in the externals. That means these are not part of the bundle but they are required for Styleguide to work. Also, if you are adding a dependency used only for development (not used for your components), make sure you install it as a devDependencies (with -D).

Configurations

Jest

"identity-obj-proxy" helps Jest understand and handle styling when running tests. It allows Jest to treat CSS Modules as objects with identity properties, making it easier to test components that import and use them.

    ".+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
    ".+/style.(css|sass|scss)$": "identity-obj-proxy"

These configurations are needed when we're testing components that use CSS Modules or stylesheets, as they ensure that the styles are correctly mocked and don't interfere with your unit tests.

Component library

The styleguide is being moved to frontend/modules/v2/packages/component-library.