Skip to content

Commit

Permalink
♻️ Moves to the AtRule from PostCSS v8
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Ramsing committed Nov 8, 2020
1 parent 12053aa commit e682e55
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
56 changes: 26 additions & 30 deletions lib/lost-at-rule.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,32 @@
module.exports = function lostAtRule(css, Settings) {
css.walkAtRules('lost', function lostAtRuleFunction(Rule) {
var rule = Rule;
var settings = Settings;
module.exports = function lostAtRule(rule, settings) {
const breakoutPramams = rule.params.split(' ');

rule.params = rule.params.split(' ');
if (breakoutPramams[0] === 'gutter') {
settings.gutter = breakoutPramams[1];
}
if (breakoutPramams[0] === 'clearing') {
settings.clearing = breakoutPramams[1];
}

if (rule.params[0] === 'clearing') {
settings.clearing = rule.params[1];
}
if (rule.params[0] === 'gutter') {
settings.gutter = rule.params[1];
}
if (rule.params[0] === 'flexbox') {
settings.flexbox = rule.params[1];
}
if (rule.params[0] === 'rounder') {
settings.rounder = rule.params[1];
}
if (rule.params[0] === '--beta-direction') {
settings.direction = rule.params[1];
}
if (rule.params[0] === 'cycle') {
if (rule.params[1] !== 'auto') {
if (rule.params[1] === 'none' || rule.params[1] === '0') {
settings.cycle = 0;
} else {
settings.cycle = rule.params[1];
}
if (breakoutPramams[0] === 'flexbox') {
settings.flexbox = breakoutPramams[1];
}
if (breakoutPramams[0] === 'rounder') {
settings.rounder = breakoutPramams[1];
}
if (breakoutPramams[0] === '--beta-direction') {
settings.direction = breakoutPramams[1];
}
if (breakoutPramams[0] === 'cycle') {
if (breakoutPramams[1] !== 'auto') {
if (breakoutPramams[1] === 'none' || breakoutPramams[1] === '0') {
settings.cycle = 0;
} else {
settings.cycle = 'auto';
settings.cycle = breakoutPramams[1];
}
} else {
settings.cycle = 'auto';
}
rule.remove();
});
}
rule.remove();
};
7 changes: 4 additions & 3 deletions lost.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ const lostUtility = require('./lib/lost-utility');
const lostVars = require('./lib/lost-vars');
const lostWaffle = require('./lib/lost-waffle');

// Lost At Rules and Declarations
// NOTE: Order Matters
const libs = [
lostAtRule,
lostVars,
lostGutter,
lostMove,
Expand Down Expand Up @@ -51,7 +49,10 @@ module.exports = (settings = {}) => {
prepare() {
let runSettings = assign({}, defaultSettings, settings | {});
return {
Once(css, { result }) {
AtRule(atRule) {
lostAtRule(atRule, runSettings);
},
OnceExit(css, { result }) {
libs.forEach((lib) => {
lib(css, runSettings, result);
});
Expand Down

0 comments on commit e682e55

Please sign in to comment.