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

postcss-typescale

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-typescale - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

8

CHANGELOG.md
# Changelog
## 0.2.0 (2018.02.20)
## 0.3.0 (2021-01-05)
* feat: replace absolute value with calc() property. Allowing to use css variable in the input.
- feat: BREAKING CHANGE update to postcss 8
## 0.2.0 (2018-02-20)
- feat: replace absolute value with calc() property. Allowing to use css variable in the input.

@@ -21,40 +21,47 @@ "use strict";

Once(root) {
root.walk(node => {
if (node.type === 'atrule' && node.name.match(/^typescale/)) {
const name = node.params ? node.params : 'default';
options[name] = options[name] || {};
node.walkDecls(decl => {
if (decl.prop.match(/^scale$/)) {
options[name].scale = decl.value;
} else if (decl.prop.match(/^font-size$/)) {
options[name].fontSize = decl.value;
} else if (decl.prop.match(/^line-height$/)) {
options[name].lineHeight = decl.value;
}
});
node.remove();
} else if (node.type === 'decl' && node.prop.match(/^typescale/)) {
const values = node.value.split(/\s+(?![^[]*\]|[^(]*\)|[^{]*})/);
options.tmp = { ...options.default
};
if (values[0].match(/^[a-z]/i)) {
Object.assign(options.tmp, options[values.shift()]);
AtRule(node) {
if (node.name.match(/^typescale/)) {
const name = node.params ? node.params : 'default';
options[name] = options[name] || {};
node.walkDecls(decl => {
if (decl.prop.match(/^scale$/)) {
options[name].scale = decl.value;
} else if (decl.prop.match(/^font-size$/)) {
options[name].fontSize = decl.value;
} else if (decl.prop.match(/^line-height$/)) {
options[name].lineHeight = decl.value;
}
});
node.remove();
}
},
const [index, lineHeightFraction] = values;
Declaration(node, {
decl
}) {
if (node.prop.match(/^typescale/)) {
const values = node.value.split(/\s+(?![^[]*\]|[^(]*\)|[^{]*})/);
options.tmp = { ...options.default
};
if (index) {
options.tmp.index = index;
}
if (values[0].match(/^[a-z]/i)) {
Object.assign(options.tmp, options[values.shift()]);
}
if (lineHeightFraction) {
options.tmp.lineHeightFraction = lineHeightFraction;
}
const [index, lineHeightFraction] = values;
(0, _typescale.default)(node, options.tmp);
delete options.tmp;
if (index) {
options.tmp.index = index;
}
});
if (lineHeightFraction) {
options.tmp.lineHeightFraction = lineHeightFraction;
}
const declNew = (0, _typescale.default)(options.tmp, {
decl
});
node.replaceWith(declNew);
delete options.tmp;
}
}

@@ -61,0 +68,0 @@

@@ -8,17 +8,12 @@ "use strict";

var _postcss = _interopRequireDefault(require("postcss"));
var _default = (options, {
decl
}) => [decl({
prop: 'font-size',
value: `calc(${parseFloat(options.scale) ** parseFloat(options.index)} * ${options.fontSize})`
}), decl({
prop: 'line-height',
value: `calc(${options.lineHeightFraction} * ${options.lineHeight})`
})];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (rule, options) => {
const declNew = [_postcss.default.decl({
prop: 'font-size',
value: `calc(${parseFloat(options.scale) ** parseFloat(options.index)} * ${options.fontSize})`
}), _postcss.default.decl({
prop: 'line-height',
value: `calc(${options.lineHeightFraction} * ${options.lineHeight})`
})];
rule.replaceWith(declNew);
};
exports.default = _default;
{
"name": "postcss-typescale",
"version": "0.3.1",
"version": "0.3.2",
"description": "A PostCSS plugin to set type based on a typographic scale.",

@@ -5,0 +5,0 @@ "keywords": [

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