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

sass-utils

v2.0.1

Published

A light sass utility library, includes sass functions, mixins, placeholders and so on

Downloads

175

Readme

介绍

一个极简的 Sass 工具库,包括 Mixins、Functions、Variables、Utils 等。

命名规范

BEM 命名法。

使用方法

# 安装
$ npm install --save sass-utils
/* 在 Sass 文件中导入 */
@import "~sass-utils";

.selector {
  /* 调用 Mixin */
  @include position--relative;
}

Mixins

b

BEM block。

// sass
@include b(block) {
  // ...
  
  @include e(element) {
    // ...
  
    @include m(modifier) {
      // ...
    }
  }
}
// css
.block {
  // ...
}

.block__element {
  // ...
}

.block__element--modifier {
  // ...
}

e

BEM element。

m

BEM modifier。

text--middle

文字垂直居中。

// sass
.selector {
  @include text--middle(100px);
}
// css
.selector {
  height: 100px;
  line-height: 100px;
} 

block--center

块级元素水平居中。

// sass
.selector {
  @include block--center;
}
// css
.selector {
  margin-left: auto;
  margin-right: auto;
}

clearfix

清除浮动。

// sass
.selector {
  @include clearfix;
}
// css
.selector::before,
.selector::after {
  content: "";
  display: table;
}

.selector::after {
  clear: both;
}

margin

设置 margin。

// sass
.selector {
  @include margin(100px, 200px, 300px, 400px);  
}
// css
.selector {
  margin-top: 100px;
  margin-right: 200px;
  margin-bottom: 300px;
  margin-left: 400px;
}

padding

设置 padding。

// sass
.selector {
  @include padding(100px, 200px, null, 400px);
}
// css
.selector {
  padding-top: 100px;
  padding-right: 200px;
  padding-left: 400px;  
}

text--overflow

文字超出部分用省略号代替。

// sass
.selector {
  @include text--overflow;
}
// css
.selector {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;  
}

only-ie8

仅 IE8 可用。

// sass
.selector {
  @include only-ie8(display, inline);
}
// css
.selector {
  display: inline\9;
}

position--relative

相对定位。

// sass
.selector {
  @include position--relative(100px, 200px);
}
// css
.selector {
  position: relative;
  top: 100px;
  right: 200px;
}

position--absolute

绝对定位。

// sass
.selector {
  @include position--absolute(100px, 200px);
}
// css
.selector {
  position: absolute;
  top: 100px;
  right: 200px;
}

position--fixed

固定定位。

// sass
.selector {
  @include position--fixed(100px, 200px);
}
// css
.selector {
  position: fixed;
  top: 100px;
  right: 200px;
}

size

设置宽高。

// sass
.selector {
  @include size(100px, 200px);
}
// css
.selector {
  width: 100px;
  height: 200px;
}

Functions

_px2rem

像素转 rem。

// sass
@function px2rem ($px) {
  @return _px2rem($px, 75);
}

.selector {
  width: px2rem(750px);
}
// css
.selector {
  width: 10rem;
}

Variables

$separator-element

BEM element 分隔符。

$separator-modifier

BEM modifier 分隔符。

$supports-ie8

是否兼容 IE8。

Utils

.u-fwb {
  font-weight: bold;
}

.u-tac {
  text-align: center;
}

.u-tal {
  text-align: left;
}

.u-tar {
  text-align: right;
}

.u-cf {
  @include clearfix;
}

.u-lt {
  text-decoration: line-through;
}

.u-pr {
  position: relative;
}

命名空间

BEM 命名空间