
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
...makes it easy to convert relative and absolute units. Use the unit of your choice and don't worry about it.
See docs.
Just clone this project, or download it via npm.
$ npm install unit-styl
--saveor--save-devflags are recommended.
var stylus = require('stylus'),
unit = require('unit-styl');
function compile(str) {
return stylus(str)
.use(unit());
}
@import 'unit'
You can also import individual parts:
@import 'unit/_angle'
@import 'unit/_length'
@import 'unit/_resolution'
@import 'unit/_time'
@import 'node_modules/unit-styl/unit'
Check whether the
node_modulespath is correct.
Relative units can be absolute and absolute units can be relative! :-)
A context is required for relative units (
rem,%). Only conversions betweenpx⇔ptdon't require context.
.foo {
width: pt(500px); /* width: 375pt; */
height: px(12pt); /* height: 16px; */
}
context = 100%;
.foo {
width: rem(960px); /* height: 60rem; */
height: pct(3pt); /* height: 25%; */
font-size: px(1rem); /* font-size: 16px; */
}
context = 62.5%;
.foo {
width: px(8rem) /* width: 80px; */
height: rem(10px) /* height: 1rem; */
font-size: pct(5px) /* font-size: 50%; */
}
Tip: You can do fallbacks for IE to rem unit printing the results in pixels too, e.g. px(1.5rem)
--
deg ⇔ rad ⇔ turn ⇔ gradtransform: rotateY(deg(0.5turn)); /* transform: rotateY(180deg) */
transform: rotateX(rad(200grad)); /* transform: rotateX(3.14rad); */
--
ms ⇔ stransition-duration: millisec(1s); /* transition-duration: 500ms */
transition-duration: sec(5000ms); /* transition-duration: 0.5s; */
sec()takes a second parameter:leadingzero, an optional boolean -trueby default. Iffalse, leading zero is omitted.
transition-duration: sec(5000ms, false); /* transition-duration: .5s; */
FAQs
Unit conversion in Stylus made easy
We found that unit-styl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.