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

@factorial/stack-css

v0.7.0

Published

This is the CSS plugin for `@factorial/stack-core`.

Downloads

656

Readme

@factorial/stack-css

This is the CSS plugin for @factorial/stack-core.

It adds

Content

Installation

You can install it via:

yarn factorial init

or manually via:

yarn add @factorial/stack-css

Make sure it is added to your .factorialrc.js like this:

// .factorialrc.js

module.exports = {
  use: [require("@factorial/stack-css")],
}

And add a .stylelintrc.js:

// .stylelintrc.js

const stylelintConfig = require("@factorial/stack-css").stylelint

module.exports = stylelintConfig

Passing options to PostCSS plugins

If you need to pass options to one of the plugins, you can do that like this:

// .factorialrc.js

module.exports = {
  use: [
    [
      require("@factorial/stack-css"),
      { plugins: { "postcss-url": { url: "copy" } } },
    ],
  ],
}

Adding plugins to PostCSS

If you want to add another plugin to PostCSS, install it via yarn add -D plugin-name and then add it to the list of plugins the same way as in the previous step:

// .factorialrc.js

module.exports = {
  use: [[require("@factorial/stack-css"), { plugins: { "plugin-name": {} } }]],
}

Extending or overwriting linting rules

If you need to extend or overwrite the linting rules, you can do that like this:

const stylelintConfig = require("@factorial/stack-css").stylelint
const deepMerge = require("deepmerge")

module.exports = deepMerge(stylelintConfig, {
  rules: {
    "number-leading-zero": "never",
  },
})

Exclude files from linting

If you want to exclude files from linting, you can do it by adding a .stylelintignore file to your root where you reference all files that should be ignored.

Design token import

If you want to use the design token import from Figma, add the following options to your .factorialrc.js:

cssTokens: {
  figma: {
    token: "<YOUR_FIGMA_TOKEN>",
    id: "<THE_FIGMA_FILE_ID>",
  }
}

If you do not want to add the Figma token and ID to the repository (as the code might be publicly available), you can use node environment variables (FIGMA_TOKEN and FIGMA_ID) or create a .env file and add FIGMA_TOKEN and FIGMA_ID in there.

There are more options available, whose default values can be overwritten like this:

cssTokens: {
  file: "css/tokens.css", // the CSS file that will be created – relative to your rootFolder
  page: "Design tokens", // the name of the page in the Figma file
  layers: {
    // the name of the layers in the Figma File
    typography: "typography",
    spacings: "spacings",
    colors: "colors",
  },
  rootFontSize: 16 // The tokens will use the rem unit, so in case you changed the font-size of the `html` element, you need set the pixel value here
}

The values used here are the default values.

Figma setup

As the Figma API does not return the values of styles, you need to create a dedicated page. This page will then be parsed by this package. For this to work, you need to do the following:

  1. Create a page called "Design tokens" (or your value of cssTokens.figma.page)
  2. On that page, create a dedicated layer for typography, colors and spacings.
  3. Name these layers based on cssTokens.figma.layers.
  4. For typography, add text nodes and apply the correct styles. If a style should only be used for e.g. headlines or copy, prefix its name with "headline-", "copy-" etc.
  5. For colors, create rectangles for decoration colors and text nodes for typography colors. Use filling for the rectangles and text color for the text nodes to apply the correct colors. Prefix the names of decoration nodes with "decoration-" and the name of text nodes with "typo-".
  6. For spacings, create rectangles with the size of the spacing.