package/LICENSE000644 0000002106 3560116604 010264 0ustar00000000 000000 The MIT License (MIT) Copyright 2015 Luis Rudge Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/bugs/bug4.js000644 0000001533 3560116604 011421 0ustar00000000 000000 var postcss = require('postcss'); function shouldSetZeroBasis(basisValue) { if (!basisValue) { return false; } return basisValue === '0' || basisValue.replace(/\s/g, '') === '0px'; } function properBasis(basis) { if (shouldSetZeroBasis(basis)) { return '0%'; } return basis; } module.exports = function(decl) { if (decl.prop === 'flex') { var values = postcss.list.space(decl.value); // set default values var flexGrow = '0'; var flexShrink = '1'; var flexBasis = '0%'; if (values[0]) { flexGrow = values[0]; } if (values[1]) { if (!isNaN(values[1])) { flexShrink = values[1]; } else { flexBasis = values[1]; } } if (values[2]) { flexBasis = values[2]; } decl.value = flexGrow + ' ' + flexShrink + ' ' + properBasis(flexBasis); } }; package/bugs/bug6.js000644 0000001212 3560116604 011415 0ustar00000000 000000 var postcss = require('postcss'); module.exports = function(decl) { if (decl.prop === 'flex') { var values = postcss.list.space(decl.value); var flexGrow = values[0]; var flexShrink = values[1] || '1'; var flexBasis = values[2] || '0%'; // Safari seems to hate '0%' and the others seems to make do with a nice value when basis is missing, // so if we see a '0%', just remove it. This way it'll get adjusted for any other cases where '0%' is // already defined somewhere else. if (flexBasis === '0%') flexBasis = null; decl.value = flexGrow + ' ' + flexShrink + (flexBasis ? ' ' + flexBasis : ''); } }; package/bugs/bug81a.js000644 0000001276 3560116604 011653 0ustar00000000 000000 var postcss = require('postcss'); module.exports = function(decl) { var regex = /(\d{1,}) (\d{1,}) (calc\(.*\))/g; var matches = regex.exec(decl.value); if (decl.prop === 'flex' && matches) { var grow = postcss.decl({ prop: 'flex-grow', value: matches[1], source: decl.source }); var shrink = postcss.decl({ prop: 'flex-shrink', value: matches[2], source: decl.source }); var basis = postcss.decl({ prop: 'flex-basis', value: matches[3], source: decl.source }); decl.parent.insertBefore(decl, grow); decl.parent.insertBefore(decl, shrink); decl.parent.insertBefore(decl, basis); decl.remove(); } }; package/index.js000644 0000001703 3560116604 010726 0ustar00000000 000000 var bug4 = require('./bugs/bug4'); var bug6 = require('./bugs/bug6'); var bug81a = require('./bugs/bug81a'); var doNothingValues = [ 'none', 'auto', 'content', 'inherit', 'initial', 'unset' ]; module.exports = function(opts) { var options = Object.assign({ bug4: true, bug6: true, bug81a: true }, opts); return { postcssPlugin: 'postcss-flexbugs-fixes', Once: function(css, postcss) { css.walkDecls(function(d) { if (d.value.indexOf('var(') > -1) { return; } if (d.value === 'none') { return; } var values = postcss.list.space(d.value); if (doNothingValues.indexOf(d.value) > 0 && values.length === 1) { return; } if (options.bug4) { bug4(d); } if (options.bug6) { bug6(d); } if (options.bug81a) { bug81a(d); } }) } }; }; module.exports.postcss = true; package/package.json000644 0000001472 3560116604 011552 0ustar00000000 000000 { "name": "postcss-flexbugs-fixes", "version": "5.0.2", "description": "PostCSS plugin This project tries to fix all of flexbug's issues", "keywords": [ "postcss", "css", "postcss-plugin", "flexbugs", "flexbox", "flex" ], "author": "Luis Rudge ", "license": "MIT", "repository": { "type": "git", "url": "https://github.com/luisrudge/postcss-flexbugs-fixes.git" }, "main": "index.js", "files": [ "bugs", "index.js" ], "peerDependencies": { "postcss": "^8.1.4" }, "devDependencies": { "chai": "^4.2.0", "gulp": "^4.0.2", "gulp-eslint": "^6.0.0", "gulp-mocha": "^7.0.2" }, "scripts": { "test": "gulp" } } package/CHANGELOG.md000644 0000003210 3560116604 011065 0ustar00000000 000000 ## 5.0.1 * Moving postcss to peer dependencies [#74](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/74) ## 5.0.1 * Adding postcss as dependency [#74](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/74) ## 5.0.0 * upgrade to postcss 8 [#71](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/71) ## 4.2.1 * Fix `calc` regex [#69](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/69) ## 4.2.0 * Don't change values that reference custom props [#64](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/64) ## 4.1.0 * Add option to disable bug fixes [#53](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/53) ## 4.0.0 * upgrade to postcss 7 ## 3.3.1 * Autoremoval of 0% Basis [#46](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/46). More context [here](https://github.com/luisrudge/postcss-flexbugs-fixes/issues/45#issuecomment-385070879) ## 3.3.0 * Revert Autoremoval of 0% Basis [#43](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/43) ## 3.2.0 * Set flex basis if second value is not a number [#41](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/41) ## 3.1.0 * Fix safari issues with flex-basis [#38](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/38) ## 3.0.0 * upgrade to postcss 6 ## 2.1.0 * Prevent mutating value when flex value is one of `['none', 'auto', 'content', 'inherit', 'initial', 'unset']` ## 2.0.0 * upgrade to postcss 5 ## 1.1.0 * Ignore flex set to none [#24](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/24) * The default value of flex-basis is 0% [#22](https://github.com/luisrudge/postcss-flexbugs-fixes/pull/22) ## 1.0 * Initial release package/README.md000644 0000003174 3560116604 010544 0ustar00000000 000000 # PostCSS Flexbugs Fixes [![Build Status][ci-img]][ci] [PostCSS] plugin This project tries to fix all of [flexbug's](https://github.com/philipwalton/flexbugs) issues. ## bug [4](https://github.com/philipwalton/flexbugs/blob/master/README.md#4-flex-shorthand-declarations-with-unitless-flex-basis-values-are-ignored) ### Input ```css .foo { flex: 1; } .bar { flex: 1 1; } .foz { flex: 1 1 0; } .baz { flex: 1 1 0px; } ``` ### Output ```css .foo { flex: 1 1; } .bar { flex: 1 1; } .foz { flex: 1 1; } .baz { flex: 1 1; } ``` ## bug [6](https://github.com/philipwalton/flexbugs/blob/master/README.md#6-the-default-flex-value-has-changed) ### Input ```css .foo { flex: 1; } ``` ### Output ```css .foo { flex: 1 1 0%; } ``` > This only fixes css classes that have the `flex` property set. To fix elements that are contained inside a flexbox container, use this global rule: ```css * { flex-shrink: 1; } ``` ## bug [8.1.a](https://github.com/philipwalton/flexbugs/blob/master/README.md#8-flex-basis-doesnt-support-calc) ### Input ```css .foo { flex: 1 0 calc(1vw - 1px); } ``` ### Output ```css .foo { flex-grow: 1; flex-shrink: 0; flex-basis: calc(1vw - 1px); } ``` ## Usage ```js postcss([require('postcss-flexbugs-fixes')]); ``` You can also disable bugs individually, possible keys `bug4`, `bug6` and `bug8a`. ```js var plugin = require('postcss-flexbugs-fixes'); postcss([plugin({ bug6: false })]); ``` See [PostCSS] docs for examples for your environment. [postcss]: https://github.com/postcss/postcss [ci-img]: https://travis-ci.org/luisrudge/postcss-flexbugs-fixes.svg [ci]: https://travis-ci.org/luisrudge/postcss-flexbugs-fixes