Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-computed

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-computed

A postcss plugin helps to write and call JavaScript functions in css for computed values.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by1000%
Maintainers
1
Weekly downloads
 
Created
Source

postcss-computed

A postcss plugin helps to write and call JavaScript functions in css for computed values.

How to use?

1. Define your function:

@func verticalPercent(num_h) {
  @stmt var full_h = 1336;
  @stmt if (num_h <=0) {
    @stmt return 0;
  }
  @stmt return (num_h / full_h * 100).toFixed(5) + "%";
}

@func show be placed before the function name and @stmt before each javascript statement. That's it!

2. Call your function:

.box {
  height: func.verticalPercent(250);
  top: func.verticalPercent(0);
}

=> And you get:

.box {
  height: 18.71257%;
  top: 0;
}

When calling functions, the function name need a func. prefix.

3. It is not necessary to write function definition before function calls.

.text {
  font-size: 15px;
  line-heigth: func.lineHeight(2, 15);
}

@func lineHeight(times, fS) {
  @stmt return times * fS + "px";
}

/* compiles to: */
.text {
  font-size: 15px;
  line-heigth: 30px;
}

Keywords

FAQs

Package last updated on 05 Nov 2016

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