New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lessfun

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lessfun

Provide some common less tool functions

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Lessz

Provide some common less tool functions

Loops

Simple keyframes

@import "lessfun/loop.less";
@keyframes frameName {
    .keyframe-loop(1, {
        transform: translate3d(0, 0, 0);
    });
}
// 上面👆结果
@keyframe frameName {
    0% {
        transform: translate3d(0, 0, 0);
    }
    100% {
        transform: translate3d(0, 0, 0);
    }
}

参数定义

.keyframe-loop(@length, @customCSSBlock: {}, @start: 0, @step: 1);
API解释备注变量名
@length最大边界从0开始, 传1会得到 0% 和 100%@end
@customCSSBlock自定义的代码块(和CSS写法相同)不可以传递一个class名或ID名@impl
@start从哪一个开始默认从1开始(代表元素位置,从1开始)@start
@step每次的增量默认为1@step

特殊环境变量

由于customCSSBlock执行时机的原因, 你可以在block里面使用环境中提供的变量名(即是上方API中的变量名),如:

@import "lessfun/loop.less";
@keyframes frameName {
    .keyframe-loop(2, @impl: {
        width: @keyframe;
        border: @start solid red;
    });
}
// 解析结果
@keyframes frameName {
  0% {
    width: 0%;
    border: 0 solid red;
  }
  50% {
    width: 50%;
    border: 1 solid red;
  }
  100% {
    width: 100%;
    border: 2 solid red;
  }
}

Loop Collections

你可以传递一个Collections用于快速生成CSS定义

@import "lessz/loop.less";

@colors: green, red, blue;
.text {
    .loop-collections(@colors, {
        color: @item;
    });
}
// 结果
.test-blue {
  color: blue;
}
.test-red {
  color: red;
}
.test-green {
  color: green;
}

参数定义

.loop-collections(@collections, @impl: {})
API解释备注变量名
@collections所有的集合, 使用逗号分隔@collections
@customCSSBlock自定义的代码块(和CSS写法相同)不可以传递一个class名或ID名@impl

特殊变量名

变量名解释备注
@index下标从0开始
@item每一项的值

Math

Other

Keywords

FAQs

Package last updated on 21 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc