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

postcss-tools

v2.0.3

Published

postcss-tools 工具箱是一个能够帮助你更加写出更加简洁、优雅的CSS的样式解决方案。

Downloads

23

Readme

postcss-tools

postcss-tools 基于 postcss-salad 二次开发

Postcss-salad

Build Status Version

Postcss-salad 是一个基于 PostCSS 的 CSS 解决方案,它提供了一系列快捷的 at-rule 和默认语法声明来帮助你快速地搭建项目样式与类库,它只在调用时才输出代码,而不是直接提供 CSS 类库。 沙拉不仅提供了下一代css语法支持,还提供了基础的sass的语法、属性顺时针简写、rem填充、基础图形绘制、可定制样式的inline-svg以及bem类名自动转化等实用的功能。

Documents

Demo

input:

/* short property */
.box {
  position: fixed 0 0 *;
}
/* utils */
.ellipsis2 {
  @utils-ellipsis 3;
}
/* shape */
.circle-a {
  circle: 50px #ff0;
}

output:

.box {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
}
.ellipsis2 {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.circle-a {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: #ff0;
}

Usage

Add Postcss salad to your build tool:

npm install postcss-salad --save-dev

Node

require('postcss-salad').process(YOUR_CSS, { /* options */ });

PostCSS

Add PostCSS to your build tool:

npm install postcss --save-dev

Load Postcss salad as a PostCSS plugin:

postcss([
  require('postcss-salad')({ /* options */ })
]).process(YOUR_CSS, /* options */);

Gulp

Add Gulp PostCSS: to your build tool:

npm install gulp-postcss --save-dev

Enable Postcss salad within your Gulpfile:

var gulp = require('gulp');
var postcss = require('gulp-postcss');

gulp.task('css', function () {
  return gulp.src('./src/*.css').pipe(
    postcss([
      require('postcss-salad')({ /* options */ })
    ])
  ).pipe(
    gulp.dest('.')
  );
});

webpack

module.exports = {
  module: {
    loaders: [
      {
        test:   /\.css$/,
        loader: "style-loader!css-loader!postcss-loader"
      }
    ]
  },
  postcss: function () {
    return [require('postcss-salad')];
  }
}

options

沙拉里每一个特性都是依赖于对应的插件的,因此他们都有自己的配置。 你可以通过 features 属性类为每一个插件传入它的配置,假设某个特性传入的值为false,则该特性会被关闭:

example:

var options = {
  browser: ['ie > 8', 'last 2 version'],
  features: {
    "bem": false, //pass boolean false can disable the plugin
    "inlineSvg": {
      "path": "src/svgs"
    }
  }
}

Plugins

Postcss-salad powered by the following plugins (in this order):

  • precss: a tool that allows you to use Sass-like markup in your CSS files
  • postcss-css-reset: reset style is dependent on normalize.css and combined with best practice.
  • postcss-utils: help you create functional fragments quickly via at-rules.
  • postcss-bem: implementing BEM as at-rules
  • postcss-calc: plugin to reduce calc()
  • postcss-initial: fallback initial keyword
  • postcss-inline-svg: reference an SVG file and control its attributes with CSS syntax.
  • postcss-short: lets you write styles more logically by extending shorthand properties in CSS.
  • postcss-shape: draw basic shape with specified syntax in css rule
  • node-pixrem: generates pixel fallbacks for rem units.
  • autoprefixer: parse CSS and add vendor prefixes to CSS rules using values from Can I Use