diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..fd3a6351 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,29 @@ +*For support questions you might try tweeting me [@lostgrid](https://twitter.com/lostgrid) first.* + +----- + +**Is this a feature request or a bug report?** + + + +**What is the current behavior?** + + + +**If it's a bug please provide the steps to reproduce it and maybe some code samples.** + + + +**What is the behavior that you expect?** + + + +**What's the motivation or use-case behind changing the behavior?** + + + +**What version of LostGrid, browser and browser version are affected by this issue? Did this happen in previous versions?** + + + +**Anything else?** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..c06b5c44 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,18 @@ +**What kind of change is this? (Bug Fix, Feature...)** + + +**What is the current behavior (You can also link to an issue)** + + +**What is the new behavior this introduces (if any)** + + +**Does this introduce any breaking changes?** + + +**Does the PR fulfill these requirements?** +- [ ] Tests for the changes have been added +- [ ] Docs have been added or updated + + +**Other Comments** diff --git a/LICENSE b/LICENSE index e8623721..be2184f4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Cory Simmons +Copyright (c) 2016 Cory Simmons, Peter Ramsing, and LostGrid Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index ec7ba504..d49c7ef4 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,19 @@

- +

+

-Lost Grid is a powerful grid system built in [PostCSS](https://github.com/postcss/postcss) that works with any preprocessor and even vanilla CSS. You can think of it like the [Autoprefixer](https://github.com/postcss/autoprefixer) of grid systems. +LostGrid is a powerful grid system built in [PostCSS](https://github.com/postcss/postcss) that works with any preprocessor and even vanilla CSS. You can think of it like the [Autoprefixer](https://github.com/postcss/autoprefixer) of grid systems. -## This project is currently transitioning maintainers. - -[@corysimmons](https://github.com/corysimmons) Created this grid and has since moved on to other projects. [@peterramsing](https://github.com/peterramsing), is currently transitioning to maintaining this project. - ### Near Future Roadmap Outline: - [New documentation](https://github.com/peterramsing/lost/milestones/Site%20and%20Docs) to enhance learning and using Lost -- [6.7.0](https://github.com/peterramsing/lost/milestones/6.7.0%20-%20Minor%20Updates) - Some minor updates and fixes. -- [7.0.0](https://github.com/peterramsing/lost/milestones/7.0.0) - Looking to fix some issues and enable more ease of use. - A focusing of Lost Grid. With the ever-changing web, Lost wants to be a tool that allows one to dive deep and enable powerful grids, not be the "one tool fits all". With improved documentation and a keen focus, Lost plans on being a great grid option to stand alongside the rest of them. As always, if you have any questions, comments, or concerns please feel free to [open an issue](https://github.com/peterramsing/lost/issues/new). You're also welcome to tweet [@lostgrid](https://twitter.com/lostgrid) if an issue seems too formal. @@ -32,7 +27,6 @@ Lost makes use of [`calc()`](https://webdesign.tutsplus.com/tutorials/calc-grids ## Table of Contents - [Installation](https://github.com/peterramsing/lost/wiki/Installation) -- [Comparison Table](#better-than-x) - [Getting Started](#getting-started) - [Basic Columns](#basic-columns) - [Centering Elements](#centering-elements) @@ -63,37 +57,6 @@ Lost makes use of [`calc()`](https://webdesign.tutsplus.com/tutorials/calc-grids - [Gotchas](#gotchas) - [Thanks](#thanks) - -## General Grid Comparison - -Feature | Lost | [Bootstrap](http://getbootstrap.com/css/#grid) | [Foundation](http://foundation.zurb.com/grid.html) | [Jeet](http://jeet.gs/) | [Neat](http://neat.bourbon.io/) | [Susy](http://susy.oddbird.net/) -:-:|:-:|:-:|:-:|:-:|:-:|:-: -[Responsive](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#responsive) | | | | | | -[Small learning curve](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#small-learning-curve) | | | | | -[Easy-to-implement](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#easy-to-implement) | | | -[Works with Masonry](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#works-with-masonry) | | | | -[Terse markup](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#terse-markup) | | | | | | -[On-the-fly grids](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#on-the-fly-grids) | | | | | | -[Clean markup](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#clean-markup) | | | | | | -[Real gutters](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#real-gutters) | | | | | | -[Sass support](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#sass-support) | | | | | | -[Stylus support](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#stylus-support) | | | | -[LESS support](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#less-support) | | -[CSS support](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#css-support) | | | -[No Additional Ratio Context](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#no-additional-ratio-context) | | | -[Consistent Gutters on All Sides](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#consistent-gutters-on-all-sides) | -[Lightweight](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#lightweight) | -[Vertical Grids](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#vertical-grids) | -[Waffle Grids](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#waffle-grids) | -[Fixed Gutters](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#fixed-gutters) | -[Flexbox Grids](https://github.com/peterramsing/lost/wiki/Comparison-Explanation#flexbox-grids) | | | - -If you notice anything in this table is incorrect, please don't hesitate to [open an issue](https://github.com/peterramsing/lost/issues/new) or [tweet](https://twitter.com/lostgrid) - -**[:arrow_up: back to top](#table-of-contents)** - -  - ### Getting Started Lost Grid rules look like this: @@ -108,9 +71,9 @@ And the processed CSS looks like this: ```css div { - width: calc(99.99% * 1/3 - (30px - 30px * 1/3)); + width: calc(99.9% * 1/3 - (30px - 30px * 1/3)); } -div:nth-child(n) { +div:nth-child(1n) { float: left; margin-right: 30px; clear: none; @@ -119,14 +82,12 @@ div:last-child { margin-right: 0; } div:nth-child(3n) { - float: right; margin-right: 0; + float: right; } div:nth-child(3n + 1) { - clear: left; + clear: both; } - -/*# sourceMappingURL=style.css.map */ ``` **[:arrow_up: back to top](#table-of-contents)** @@ -494,15 +455,18 @@ Lost uses PostCSS which means to override global variables we need to use someth @lost gutter 60px; @lost flexbox flex; @lost cycle none; +@lost clearing left .foo { ... } ``` -- `gutter` accepts any unit value. `30px` by default. +- `gutter` accepts any unit value. `30px` (default). - `flexbox` accepts `flex` or `no-flex` (default). - `cycle` accepts `none` or any digit (although this is really weird). `auto` by default. +- `clearing` accepts `left` or `both` (default). + - See [#276](https://github.com/peterramsing/lost/issues/276) for details **[:arrow_up: back to top](#table-of-contents)** @@ -619,6 +583,7 @@ Creates a row that is a fraction of the size of its containing element's height - `fraction` - This is a simple fraction of the containing element's height. - `gutter` - The margin on the bottom of the element used to create a gutter. Typically this is left alone and settings.gutter will be used, but you can override it here if you want certain elements to have a particularly large or small gutter (pass 0 for no gutter at all). - `flex|no-flex` - Determines whether this element should use Flexbox or not. +- `none` - Resets the row (back to browser defaults) ```css section { @@ -775,7 +740,7 @@ div { - If you're using [Less](http://lesscss.org/) there are sometimes issues with fractions being divided before Lost can interpret them. - To fix, escape the math like so: `lost-column: ~"1/2";`. - See: [Lost issue 229](https://github.com/peterramsing/lost/issues/229), [Less issue 974](https://github.com/less/less.js/issues/974) -- If you're using [Less](http://lesscss.org/) you need to escape any `@lost` declarations like so: [See Issue 197](https://github.com/peterramsing/lost/issues/197#issuecomment-170324607) +- If you're using [Less](http://lesscss.org/) in version `<2.6` you need to escape any `@lost` declarations like so: [See Issue 197](https://github.com/peterramsing/lost/issues/197#issuecomment-170324607) ```less .escape-at-rules(@literal) { @@ -802,10 +767,9 @@ div { ### Thanks - [Cory Simmons](https://github.com/corysimmons) for creating this grid! -- [Alex Bass](http://abass.co) for letting me bounce ideas off of him. +- [Alex Bass](http://abass.co) for being available to bounce ideas off of. - [Maria Keller](https://dribbble.com/mariakeller) for the amazing logo. Be sure to hire her for all your design and motion graphic needs. - Everyone who files an [Issue](https://github.com/peterramsing/lost/issues) when something isn't working as expected. -- Everyone who is *actually* interested in my work on grids. **[:arrow_up: back to top](#table-of-contents)** diff --git a/lib/lost-at-rule.js b/lib/lost-at-rule.js index 96bb2861..ea5452b0 100644 --- a/lib/lost-at-rule.js +++ b/lib/lost-at-rule.js @@ -12,6 +12,9 @@ module.exports = function lostAtRule(css, settings) { css.walkAtRules('lost', function(rule) { rule.params = rule.params.split(' '); + if (rule.params[0] == 'clearing') { + settings.clearing = rule.params[1]; + } if (rule.params[0] == 'gutter') { settings.gutter = rule.params[1]; } diff --git a/lib/lost-center.js b/lib/lost-center.js index c811671c..725e12ac 100644 --- a/lib/lost-center.js +++ b/lib/lost-center.js @@ -61,11 +61,6 @@ module.exports = function lostCenterDecl(css, settings) { }); if (lostCenterFlexbox === 'no-flex') { - decl.cloneBefore({ - prop: '*zoom', - value: '1' - }); - newBlock( decl, ':after', diff --git a/lib/lost-column.js b/lib/lost-column.js index a583a817..626afde2 100644 --- a/lib/lost-column.js +++ b/lib/lost-column.js @@ -106,18 +106,11 @@ module.exports = function lostColumnDecl(css, settings) { newBlock( decl, ':nth-child('+ lostColumnCycle +'n)', - ['margin-right'], - [0] + ['margin-right', 'margin-left'], + [0, 'auto'] ); } - newBlock( - decl, - ':nth-child('+ lostColumnCycle +'n)', - ['float'], - ['right'] - ); - newBlock( decl, ':last-child', @@ -127,34 +120,45 @@ module.exports = function lostColumnDecl(css, settings) { newBlock( decl, - ':nth-child(n)', - ['margin-right'], - [lostColumnGutter] + ':nth-child(1n)', + ['margin-right', 'margin-left'], + [lostColumnGutter, 0] ); + } else { if (lostColumnCycle !== 0) { + + if (settings.clearing === 'left') { + newBlock( + decl, + ':nth-child('+ lostColumnCycle +'n + 1)', + ['clear'], + ['left'] + ); + } else { + newBlock( + decl, + ':nth-child('+ lostColumnCycle +'n + 1)', + ['clear'], + ['both'] + ); + } + newBlock( decl, - ':nth-child('+ lostColumnCycle +'n + 1)', - ['clear'], - ['left'] + ':nth-child('+ lostColumnCycle +'n)', + ['margin-right', 'float'], + [0, 'right'] ); - + } else { newBlock( decl, ':nth-child('+ lostColumnCycle +'n)', - ['margin-right'], - [0] + ['float'], + ['right'] ); } - newBlock( - decl, - ':nth-child('+ lostColumnCycle +'n)', - ['float'], - ['right'] - ); - newBlock( decl, ':last-child', @@ -164,7 +168,7 @@ module.exports = function lostColumnDecl(css, settings) { newBlock( decl, - ':nth-child(n)', + ':nth-child(1n)', ['float', 'margin-right', 'clear'], ['left', lostColumnGutter, 'none'] ); @@ -173,12 +177,12 @@ module.exports = function lostColumnDecl(css, settings) { if (lostColumnGutter !== '0') { decl.cloneBefore({ prop: 'width', - value: 'calc(99.99% * '+ lostColumn +' - ('+ lostColumnGutter +' - '+ lostColumnGutter +' * '+ lostColumn +'))' + value: 'calc(99.9% * '+ lostColumn +' - ('+ lostColumnGutter +' - '+ lostColumnGutter +' * '+ lostColumn +'))' }); } else { decl.cloneBefore({ prop: 'width', - value: 'calc(99.999999% * '+ lostColumn +')' + value: 'calc(99.9% * '+ lostColumn +')' }); } } else { @@ -188,13 +192,6 @@ module.exports = function lostColumnDecl(css, settings) { value: 'auto' }); - newBlock( - decl, - ':nth-child(1n)', - ['float', 'clear', 'margin-right', 'width'], - ['none', 'none', 0, 'auto'] - ); - newBlock( decl, ':nth-child(1n + 1)', @@ -204,7 +201,7 @@ module.exports = function lostColumnDecl(css, settings) { newBlock( decl, - ':nth-child(n)', + ':nth-child(1n)', ['float', 'clear', 'margin-right', 'width'], ['none', 'none', 0, 'auto'] ); diff --git a/lib/lost-masonry-column.js b/lib/lost-masonry-column.js index c4d5b83a..b27fe418 100644 --- a/lib/lost-masonry-column.js +++ b/lib/lost-masonry-column.js @@ -88,7 +88,7 @@ module.exports = function lostMasonryColumnDecl(css, settings) { if (lostMasonryColumnGutter !== '0') { cloneAllBefore({ - 'width': 'calc(99.99% * '+ lostMasonryColumn +' - '+ lostMasonryColumnGutter +')', + 'width': 'calc(99.9% * '+ lostMasonryColumn +' - '+ lostMasonryColumnGutter +')', 'margin-left': (parseInt(lostMasonryColumnGutter) / 2) + lostMasonryColumnGutterUnit, 'margin-right': (parseInt(lostMasonryColumnGutter) / 2) + lostMasonryColumnGutterUnit }); @@ -96,7 +96,7 @@ module.exports = function lostMasonryColumnDecl(css, settings) { } else { cloneAllBefore({ - 'width': 'calc(99.999999% * '+ lostMasonryColumn +')', + 'width': 'calc(99.9% * '+ lostMasonryColumn +')', 'margin-left': (parseInt(lostMasonryColumnGutter) / 2) + lostMasonryColumnGutterUnit, 'margin-right': (parseInt(lostMasonryColumnGutter) / 2) + lostMasonryColumnGutterUnit }); diff --git a/lib/lost-masonry-wrap.js b/lib/lost-masonry-wrap.js index a7eb53fd..13aa31c3 100644 --- a/lib/lost-masonry-wrap.js +++ b/lib/lost-masonry-wrap.js @@ -75,11 +75,6 @@ module.exports = function lostMasonryWrapDecl(css, settings) { }); if (lostMasonryWrapFlexbox !== 'flex') { - decl.cloneBefore({ - prop: '*zoom', - value: '1' - }); - newBlock( decl, ':after', diff --git a/lib/lost-move.js b/lib/lost-move.js index 4077405f..21ce3dde 100644 --- a/lib/lost-move.js +++ b/lib/lost-move.js @@ -66,7 +66,7 @@ module.exports = function lostMoveDecl(css, settings) { if (lostMoveGutter !== '0') { decl.cloneBefore({ prop: 'top', - value: 'calc(99.99% * '+ lostMove +' - ('+ lostMoveGutter +' - '+ lostMoveGutter +' * '+ lostMove +') + '+ lostMoveGutter +')' + value: 'calc(99.9% * '+ lostMove +' - ('+ lostMoveGutter +' - '+ lostMoveGutter +' * '+ lostMove +') + '+ lostMoveGutter +')' }); } else { decl.cloneBefore({ @@ -78,7 +78,7 @@ module.exports = function lostMoveDecl(css, settings) { if (lostMoveGutter !== '0') { decl.cloneBefore({ prop: 'left', - value: 'calc(99.99% * '+ lostMove +' - ('+ lostMoveGutter +' - '+ lostMoveGutter +' * '+ lostMove +') + '+ lostMoveGutter +')' + value: 'calc(99.9% * '+ lostMove +' - ('+ lostMoveGutter +' - '+ lostMoveGutter +' * '+ lostMove +') + '+ lostMoveGutter +')' }); } else { decl.cloneBefore({ diff --git a/lib/lost-offset.js b/lib/lost-offset.js index 6fc4490b..160e75f4 100644 --- a/lib/lost-offset.js +++ b/lib/lost-offset.js @@ -71,7 +71,7 @@ module.exports = function lostOffsetDecl(css, settings) { if (lostOffsetGutter !== '0') { decl.cloneBefore({ prop: 'margin-bottom', - value: 'calc(99.99% * '+ lostOffset +' - ('+ lostOffsetGutter +' - '+ lostOffsetGutter +' * '+ lostOffset +') + ('+ lostOffsetGutter +' * 2)) !important' + value: 'calc(99.9% * '+ lostOffset +' - ('+ lostOffsetGutter +' - '+ lostOffsetGutter +' * '+ lostOffset +') + ('+ lostOffsetGutter +' * 2)) !important' }); } else { decl.cloneBefore({ @@ -83,7 +83,7 @@ module.exports = function lostOffsetDecl(css, settings) { if (lostOffsetGutter !== '0') { decl.cloneBefore({ prop: 'margin-top', - value: 'calc(99.99% * ('+ lostOffset +' * -1) - ('+ lostOffsetGutter +' - '+ lostOffsetGutter +' * ('+ lostOffset +' * -1)) + '+ lostOffsetGutter +') !important' + value: 'calc(99.9% * ('+ lostOffset +' * -1) - ('+ lostOffsetGutter +' - '+ lostOffsetGutter +' * ('+ lostOffset +' * -1)) + '+ lostOffsetGutter +') !important' }); } else { decl.cloneBefore({ @@ -107,7 +107,7 @@ module.exports = function lostOffsetDecl(css, settings) { if (lostOffsetGutter !== '0') { decl.cloneBefore({ prop: 'margin-right', - value: 'calc(99.99% * '+ lostOffset +' - ('+ lostOffsetGutter +' - '+ lostOffsetGutter +' * '+ lostOffset +') + ('+ lostOffsetGutter +' * 2)) !important' + value: 'calc(99.9% * '+ lostOffset +' - ('+ lostOffsetGutter +' - '+ lostOffsetGutter +' * '+ lostOffset +') + ('+ lostOffsetGutter +' * 2)) !important' }); } else { decl.cloneBefore({ @@ -119,7 +119,7 @@ module.exports = function lostOffsetDecl(css, settings) { if (lostOffsetGutter !== '0') { decl.cloneBefore({ prop: 'margin-left', - value: 'calc(99.99% * ('+ lostOffset +' * -1) - ('+ lostOffsetGutter +' - '+ lostOffsetGutter +' * ('+ lostOffset +' * -1)) + '+ lostOffsetGutter +') !important' + value: 'calc(99.9% * ('+ lostOffset +' * -1) - ('+ lostOffsetGutter +' - '+ lostOffsetGutter +' * ('+ lostOffset +' * -1)) + '+ lostOffsetGutter +') !important' }); } else { decl.cloneBefore({ diff --git a/lib/lost-row.js b/lib/lost-row.js index f8944901..81fef470 100644 --- a/lib/lost-row.js +++ b/lib/lost-row.js @@ -16,6 +16,8 @@ var newBlock = require('./new-block.js'); * @param {string} [flex|no-flex] - Determines whether this element should * use Flexbox or not. * + * @param {string} [none] - Resets to a standard browser default. + * * @example * section { * height: 100%; @@ -31,74 +33,93 @@ module.exports = function lostRowDecl(css, settings) { lostRowGutter = settings.gutter, lostRowFlexbox = settings.flexbox; - declArr = decl.value.split(' '); - lostRow = declArr[0]; + if (decl.value !== 'none') { + declArr = decl.value.split(' '); + lostRow = declArr[0]; - if (declArr[1] !== undefined && declArr[1].search(/^\d/) !== -1) { - lostRowGutter = declArr[1]; - } + if (declArr[1] !== undefined && declArr[1].search(/^\d/) !== -1) { + lostRowGutter = declArr[1]; + } - if (declArr.indexOf('flex') !== -1) { - lostRowFlexbox = 'flex'; - } + if (declArr.indexOf('flex') !== -1) { + lostRowFlexbox = 'flex'; + } - if (declArr.indexOf('no-flex') !== -1) { - lostRowFlexbox = 'no-flex'; - } + if (declArr.indexOf('no-flex') !== -1) { + lostRowFlexbox = 'no-flex'; + } - decl.parent.nodes.forEach(function (decl) { - if (decl.prop == 'lost-row-gutter') { - lostRowGutter = decl.value; + decl.parent.nodes.forEach(function (decl) { + if (decl.prop == 'lost-row-gutter') { + lostRowGutter = decl.value; - decl.remove(); - } - }); + decl.remove(); + } + }); - decl.parent.nodes.forEach(function (decl) { - if (decl.prop == 'lost-row-flexbox') { - if (decl.prop == 'flex') { - lostRowFlexbox = 'flex'; + decl.parent.nodes.forEach(function (decl) { + if (decl.prop == 'lost-row-flexbox') { + if (decl.prop == 'flex') { + lostRowFlexbox = 'flex'; + } + + decl.remove(); } + }); - decl.remove(); + decl.cloneBefore({ + prop: 'width', + value: '100%' + }); + + if (lostRowFlexbox === 'flex') { + decl.cloneBefore({ + prop: 'flex', + value: '0 0 auto' + }); } - }); - decl.cloneBefore({ - prop: 'width', - value: '100%' - }); + if (lostRowGutter !== '0') { + decl.cloneBefore({ + prop: 'height', + value: 'calc(99.9% * '+ lostRow +' - ('+ lostRowGutter +' - '+ lostRowGutter +' * '+ lostRow +'))' + }); + } else { + decl.cloneBefore({ + prop: 'height', + value: 'calc(99.9% * '+ lostRow +')' + }); + } - if (lostRowFlexbox === 'flex') { decl.cloneBefore({ - prop: 'flex', - value: '0 0 auto' + prop: 'margin-bottom', + value: lostRowGutter }); - } - if (lostRowGutter !== '0') { + newBlock( + decl, + ':last-child', + ['margin-bottom'], + [0] + ); + } else { decl.cloneBefore({ - prop: 'height', - value: 'calc(99.99% * '+ lostRow +' - ('+ lostRowGutter +' - '+ lostRowGutter +' * '+ lostRow +'))' + prop: 'width', + value: 'auto' }); - } else { + decl.cloneBefore({ prop: 'height', - value: 'calc(99.999999% * '+ lostRow +')' + value: 'auto' + }); + + decl.cloneBefore({ + prop: 'margin-bottom', + value: '0' }); } - decl.cloneBefore({ - prop: 'margin-bottom', - value: lostRowGutter - }); - - newBlock( - decl, - ':last-child', - ['margin-bottom'], - [0] - ); + decl.remove(); }); diff --git a/lib/lost-utility.js b/lib/lost-utility.js index dc8d35df..e4d05a4d 100644 --- a/lib/lost-utility.js +++ b/lib/lost-utility.js @@ -31,11 +31,6 @@ module.exports = function lostUtilityDecl(css, settings) { } if (decl.value == 'clearfix') { - decl.cloneBefore({ - prop: '*zoom', - value: '1' - }); - newBlock( decl, ':after', diff --git a/lib/lost-waffle.js b/lib/lost-waffle.js index 7165649d..e9745acb 100644 --- a/lib/lost-waffle.js +++ b/lib/lost-waffle.js @@ -120,15 +120,8 @@ module.exports = function lostWaffleDecl(css, settings) { newBlock( decl, ':nth-child('+ lostWaffleCycle + 'n)', - ['float'], - ['right'] - ); - - newBlock( - decl, - ':nth-child('+ lostWaffleCycle +'n)', - ['margin-right'], - [0] + ['margin-right', 'margin-left'], + [0, 'auto'] ); } @@ -141,9 +134,9 @@ module.exports = function lostWaffleDecl(css, settings) { newBlock( decl, - ':nth-child(n)', - ['margin-right', 'margin-bottom'], - [lostWaffleGutter, lostWaffleGutter] + ':nth-child(1n)', + ['margin-right', 'margin-bottom', 'margin-left'], + [lostWaffleGutter, lostWaffleGutter, 0] ); } else { if (lostWaffleCycle !== 0) { @@ -154,25 +147,27 @@ module.exports = function lostWaffleDecl(css, settings) { [0] ); - newBlock( - decl, - ':nth-child('+ lostWaffleCycle +'n + 1)', - ['clear'], - ['left'] - ); + if (settings.clearing === 'left') { + newBlock( + decl, + ':nth-child('+ lostWaffleCycle +'n + 1)', + ['clear'], + ['left'] + ); + } else { + newBlock( + decl, + ':nth-child('+ lostWaffleCycle +'n + 1)', + ['clear'], + ['both'] + ); + } newBlock( decl, ':nth-child('+ lostWaffleCycle + 'n)', - ['float'], - ['right'] - ); - - newBlock( - decl, - ':nth-child('+ lostWaffleCycle +'n)', - ['margin-right'], - [0] + ['margin-right', 'float'], + [0, 'right'] ); } @@ -185,7 +180,7 @@ module.exports = function lostWaffleDecl(css, settings) { newBlock( decl, - ':nth-child(n)', + ':nth-child(1n)', ['float', 'margin-right', 'margin-bottom', 'clear'], ['left', lostWaffleGutter, lostWaffleGutter, 'none'] ); @@ -193,13 +188,13 @@ module.exports = function lostWaffleDecl(css, settings) { if (lostWaffleGutter !== '0') { cloneAllBefore({ - 'width': 'calc(99.99% * '+ lostWaffle +' - ('+ lostWaffleGutter +' - '+ lostWaffleGutter +' * '+ lostWaffle +'))', - 'height': 'calc(99.99% * '+ lostWaffle +' - ('+ lostWaffleGutter +' - '+ lostWaffleGutter +' * '+ lostWaffle +'))' + 'width': 'calc(99.9% * '+ lostWaffle +' - ('+ lostWaffleGutter +' - '+ lostWaffleGutter +' * '+ lostWaffle +'))', + 'height': 'calc(99.9% * '+ lostWaffle +' - ('+ lostWaffleGutter +' - '+ lostWaffleGutter +' * '+ lostWaffle +'))' }); } else { cloneAllBefore({ - 'width': 'calc(99.999999% * '+ lostWaffle +')', - 'height': 'calc(99.999999% * '+ lostWaffle +')' + 'width': 'calc(99.9% * '+ lostWaffle +')', + 'height': 'calc(99.9% * '+ lostWaffle +')' }); } diff --git a/lost.js b/lost.js index 7bc297f4..988e8544 100644 --- a/lost.js +++ b/lost.js @@ -21,11 +21,12 @@ var libs = [ var defaultSettings = { gutter: '30px', flexbox: 'no-flex', - cycle: 'auto' + cycle: 'auto', + clearing: 'both' }; module.exports = postcss.plugin('lost', function lost(settings) { - settings = assign(defaultSettings, settings || {}); + settings = assign({}, defaultSettings, settings || {}); return function (css) { libs.forEach(function(lib) { diff --git a/package.json b/package.json index cde78c8d..064e82dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lost", - "version": "6.7.0", + "version": "7.0.2", "description": "PostCSS fractional grid system built with calc() by the guy who built Jeet. Supports masonry, vertical, and waffle grids.", "main": "lost.js", "repository": { @@ -16,12 +16,12 @@ "fraction", "ratio" ], - "author": "Cory Simmons", + "author": "Cory Simmons & Peter Ramsing (http://peter.coffee)", "license": "MIT", "bugs": { "url": "https://github.com/peterramsing/lost/issues" }, - "homepage": "https://github.com/peterramsing/lost", + "homepage": "http://lostgrid.org", "devDependencies": { "chai": "^3.0.0", "coveralls": "^2.11.2", diff --git a/test/lost-center.js b/test/lost-center.js index f77316ed..10b2c6f4 100644 --- a/test/lost-center.js +++ b/test/lost-center.js @@ -6,7 +6,7 @@ describe('lost-center', function() { it('horizontally centers container', function() { check( 'a { lost-center: 980px }', - 'a { *zoom: 1; max-width: 980px; margin-left: auto; margin-right: auto }\n' + + 'a { max-width: 980px; margin-left: auto; margin-right: auto }\n' + 'a:before { content: \'\'; display: table }\n' + 'a:after { content: \'\'; display: table; clear: both }' ); @@ -15,7 +15,7 @@ describe('lost-center', function() { it('adds 30px padding', function() { check( 'a { lost-center: 980px 30px }', - 'a { *zoom: 1; max-width: 980px; margin-left: auto; margin-right: auto; padding-left: 30px; padding-right: 30px }\n' + + 'a { max-width: 980px; margin-left: auto; margin-right: auto; padding-left: 30px; padding-right: 30px }\n' + 'a:before { content: \'\'; display: table }\n' + 'a:after { content: \'\'; display: table; clear: both }' ); diff --git a/test/lost-column.js b/test/lost-column.js index 25c0e1d9..4747caf3 100644 --- a/test/lost-column.js +++ b/test/lost-column.js @@ -6,70 +6,77 @@ describe('lost-column', function() { it('provides 3 column layout', function() { check( 'a { lost-column: 1/3; }', - 'a { width: calc(99.99% * 1/3 - (30px - 30px * 1/3)); }\n' + - 'a:nth-child(n) { float: left; margin-right: 30px; clear: none; }\n' + + 'a { width: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 30px; clear: none; }\n' + 'a:last-child { margin-right: 0; }\n' + - 'a:nth-child(3n) { float: right; }\n' + - 'a:nth-child(3n) { margin-right: 0; }\n' + - 'a:nth-child(3n + 1) { clear: left; }' + 'a:nth-child(3n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(3n + 1) { clear: both; }' ); }); it('provides 2/5 column layout', function() { check( 'a { lost-column: 2/5; }', - 'a { width: calc(99.99% * 2/5 - (30px - 30px * 2/5)); }\n' + - 'a:nth-child(n) { float: left; margin-right: 30px; clear: none; }\n' + + 'a { width: calc(99.9% * 2/5 - (30px - 30px * 2/5)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 30px; clear: none; }\n' + 'a:last-child { margin-right: 0; }\n' + - 'a:nth-child(5n) { float: right; }\n' + - 'a:nth-child(5n) { margin-right: 0; }\n' + - 'a:nth-child(5n + 1) { clear: left; }' + 'a:nth-child(5n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(5n + 1) { clear: both; }' ); }); it('can support custom cycle', function() { check( 'a { lost-column: 2/4 2; }', - 'a { width: calc(99.99% * 2/4 - (30px - 30px * 2/4)); }\n' + - 'a:nth-child(n) { float: left; margin-right: 30px; clear: none; }\n' + + 'a { width: calc(99.9% * 2/4 - (30px - 30px * 2/4)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 30px; clear: none; }\n' + 'a:last-child { margin-right: 0; }\n' + - 'a:nth-child(2n) { float: right; }\n' + - 'a:nth-child(2n) { margin-right: 0; }\n' + - 'a:nth-child(2n + 1) { clear: left; }' + 'a:nth-child(2n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(2n + 1) { clear: both; }' ); }); it('supports no gutter', function() { check( 'a { lost-column: 2/5 3 0; }', - 'a { width: calc(99.999999% * 2/5); }\n' + - 'a:nth-child(n) { float: left; margin-right: 0; clear: none; }\n' + + 'a { width: calc(99.9% * 2/5); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 0; clear: none; }\n' + 'a:last-child { margin-right: 0; }\n' + - 'a:nth-child(3n) { float: right; }\n' + - 'a:nth-child(3n) { margin-right: 0; }\n' + - 'a:nth-child(3n + 1) { clear: left; }' + 'a:nth-child(3n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(3n + 1) { clear: both; }' ); }); it('supports flexbox', function() { check( 'a { lost-column: 2/6 3 60px flex; }', - 'a { flex: 0 0 auto; width: calc(99.99% * 2/6 - (60px - 60px * 2/6));' + + 'a { flex: 0 0 auto; width: calc(99.9% * 2/6 - (60px - 60px * 2/6));' + ' }\n' + - 'a:nth-child(n) { margin-right: 60px; }\n' + + 'a:nth-child(1n) { margin-right: 60px; margin-left: 0; }\n' + + 'a:last-child { margin-right: 0; }\n' + + 'a:nth-child(3n) { margin-right: 0; margin-left: auto; }' + ); + }); + + it('supports clearing fallback', function() { + check( + '@lost clearing left; \n' + + 'a { lost-column: 1/3; }', + 'a { width: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 30px; clear: none; }\n' + 'a:last-child { margin-right: 0; }\n' + - 'a:nth-child(3n) { float: right; }\n' + - 'a:nth-child(3n) { margin-right: 0; }' + 'a:nth-child(3n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(3n + 1) { clear: left; }' ); }); + it('provides none rule', function() { check( 'a { lost-column: none; }', 'a { width: auto; }\n' + 'a:last-child { float: none; clear: none; margin-right: 0; width: auto; }\n' + - 'a:nth-child(n) { float: none; clear: none; margin-right: 0; width: auto; }\n' + - 'a:nth-child(1n + 1) { float: none; clear: none; margin-right: 0; width: auto; }\n' + - 'a:nth-child(1n) { float: none; clear: none; margin-right: 0; width: auto; }' + 'a:nth-child(1n) { float: none; clear: none; margin-right: 0; width: auto; }\n' + + 'a:nth-child(1n + 1) { float: none; clear: none; margin-right: 0; width: auto; }' ); }); }); diff --git a/test/lost-global-settings.js b/test/lost-global-settings.js new file mode 100644 index 00000000..858e2a47 --- /dev/null +++ b/test/lost-global-settings.js @@ -0,0 +1,26 @@ +'use strict'; + +var check = require('./check'); + +describe('lost-global-settings', function() { + it('resets global settings between builds', function() { + check( + '@lost clearing left; \n' + + 'a { lost-column: 1/3; }', + 'a { width: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 30px; clear: none; }\n' + + 'a:last-child { margin-right: 0; }\n' + + 'a:nth-child(3n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(3n + 1) { clear: left; }' + ); + + check( + 'a { lost-column: 1/3; }', + 'a { width: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 30px; clear: none; }\n' + + 'a:last-child { margin-right: 0; }\n' + + 'a:nth-child(3n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(3n + 1) { clear: both; }' + ); + }); +}); diff --git a/test/lost-masonry-column.js b/test/lost-masonry-column.js index b3cf22ca..70e34b7c 100644 --- a/test/lost-masonry-column.js +++ b/test/lost-masonry-column.js @@ -6,7 +6,7 @@ describe('lost-masonry-column', function() { it('supports a custom gutter', function() { check( 'a { lost-masonry-column: 60px; }', - 'a { float: left; width: calc(99.99% * 60px - 30px); margin-left: 15px;' + + 'a { float: left; width: calc(99.9% * 60px - 30px); margin-left: 15px;' + ' margin-right: 15px; }' ); }); @@ -14,7 +14,7 @@ describe('lost-masonry-column', function() { it('supports no gutter', function() { check( 'a { lost-masonry-column: 0; }', - 'a { float: left; width: calc(99.99% * 0 - 30px); margin-left: 15px;' + + 'a { float: left; width: calc(99.9% * 0 - 30px); margin-left: 15px;' + ' margin-right: 15px; }' ); }); @@ -23,7 +23,7 @@ describe('lost-masonry-column', function() { it('supports a custom gutter', function() { check( 'a { lost-masonry-column: 60px flex; }', - 'a { flex: 0 0 auto; width: calc(99.99% * 60px - 30px);' + + 'a { flex: 0 0 auto; width: calc(99.9% * 60px - 30px);' + ' margin-left: 15px; margin-right: 15px; }' ); }); @@ -31,7 +31,7 @@ describe('lost-masonry-column', function() { it('supports no gutter', function() { check( 'a { lost-masonry-column: 0 flex; }', - 'a { flex: 0 0 auto; width: calc(99.99% * 0 - 30px);' + + 'a { flex: 0 0 auto; width: calc(99.9% * 0 - 30px);' + ' margin-left: 15px; margin-right: 15px; }' ); }); diff --git a/test/lost-masonry-wrap.js b/test/lost-masonry-wrap.js index acaf526c..195e96d4 100644 --- a/test/lost-masonry-wrap.js +++ b/test/lost-masonry-wrap.js @@ -14,7 +14,7 @@ describe('lost-masonry-wrap', function() { it('creates a non-flexbox wrapper', function() { check( 'a { lost-masonry-wrap: no-flex; }', - 'a { *zoom: 1; margin-left: -15px; margin-right: -15px; }\n' + + 'a { margin-left: -15px; margin-right: -15px; }\n' + 'a:before { content: \'\'; display: table; }\n' + 'a:after { content: \'\'; display: table; clear: both; }' ); diff --git a/test/lost-move.js b/test/lost-move.js index 896c1504..e1c6267f 100644 --- a/test/lost-move.js +++ b/test/lost-move.js @@ -6,7 +6,7 @@ describe('lost-move', function() { it('moves element to the left', function() { check( 'a { lost-move: 1/3; }', - 'a { position: relative; left: calc(99.99% * 1/3 - (30px - 30px * 1/3)' + + 'a { position: relative; left: calc(99.9% * 1/3 - (30px - 30px * 1/3)' + ' + 30px); }' ); }); @@ -14,7 +14,7 @@ describe('lost-move', function() { it('moves element to the right', function() { check( 'a { lost-move: -1/3; }', - 'a { position: relative; left: calc(99.99% * -1/3 -' + + 'a { position: relative; left: calc(99.9% * -1/3 -' + ' (30px - 30px * -1/3) + 30px); }' ); }); @@ -22,7 +22,7 @@ describe('lost-move', function() { it('moves element up', function() { check( 'a { lost-move: 1/3 column; }', - 'a { position: relative; top: calc(99.99% * 1/3 - (30px - 30px * 1/3)' + + 'a { position: relative; top: calc(99.9% * 1/3 - (30px - 30px * 1/3)' + ' + 30px); }' ); }); @@ -30,7 +30,7 @@ describe('lost-move', function() { it('moves element down', function() { check( 'a { lost-move: -1/3 column; }', - 'a { position: relative; top: calc(99.99% * -1/3 - (30px - 30px * -1/3)' + + 'a { position: relative; top: calc(99.9% * -1/3 - (30px - 30px * -1/3)' + ' + 30px); }' ); }); @@ -38,7 +38,7 @@ describe('lost-move', function() { it('supports custom gutter', function() { check( 'a { lost-move: 1/2 row 60px; }', - 'a { position: relative; left: calc(99.99% * 1/2 - (60px - 60px * 1/2)' + + 'a { position: relative; left: calc(99.9% * 1/2 - (60px - 60px * 1/2)' + ' + 60px); }' ); }); diff --git a/test/lost-offset.js b/test/lost-offset.js index 2d6c5274..2c8c9255 100644 --- a/test/lost-offset.js +++ b/test/lost-offset.js @@ -6,7 +6,7 @@ describe('lost-offset', function() { it('moves element to the left', function() { check( 'a { lost-offset: 1/3; }', - 'a { margin-right: calc(99.99% * 1/3 - (30px - 30px * 1/3) + (30px * 2)' + + 'a { margin-right: calc(99.9% * 1/3 - (30px - 30px * 1/3) + (30px * 2)' + ') !important; }' ); }); @@ -14,7 +14,7 @@ describe('lost-offset', function() { it('moves element to the right', function() { check( 'a { lost-offset: -1/3; }', - 'a { margin-left: calc(99.99% * (-1/3 * -1) - (30px - 30px * ' + + 'a { margin-left: calc(99.9% * (-1/3 * -1) - (30px - 30px * ' + '(-1/3 * -1)) + 30px) !important; }' ); }); @@ -22,7 +22,7 @@ describe('lost-offset', function() { it('moves element up', function() { check( 'a { lost-offset: 1/3 column; }', - 'a { margin-bottom: calc(99.99% * 1/3 - (30px - 30px * 1/3) + ' + + 'a { margin-bottom: calc(99.9% * 1/3 - (30px - 30px * 1/3) + ' + '(30px * 2)) !important; }' ); }); @@ -30,7 +30,7 @@ describe('lost-offset', function() { it('moves element down', function() { check( 'a { lost-offset: -1/3 column; }', - 'a { margin-top: calc(99.99% * (-1/3 * -1) - (30px - 30px * ' + + 'a { margin-top: calc(99.9% * (-1/3 * -1) - (30px - 30px * ' + '(-1/3 * -1)) + 30px) !important; }' ); }); @@ -38,7 +38,7 @@ describe('lost-offset', function() { it('supports custom gutter', function() { check( 'a { lost-offset: 1/2 row 60px; }', - 'a { margin-right: calc(99.99% * 1/2 - (60px - 60px * 1/2) + ' + + 'a { margin-right: calc(99.9% * 1/2 - (60px - 60px * 1/2) + ' + '(60px * 2)) !important; }' ); }); diff --git a/test/lost-row.js b/test/lost-row.js index fac81441..cd4ace06 100644 --- a/test/lost-row.js +++ b/test/lost-row.js @@ -6,7 +6,7 @@ describe('lost-row', function() { it('provides 3 row layout', function() { check( 'a { lost-row: 1/3; }', - 'a { width: 100%; height: calc(99.99% * 1/3 - (30px - 30px * 1/3));' + + 'a { width: 100%; height: calc(99.9% * 1/3 - (30px - 30px * 1/3));' + ' margin-bottom: 30px; }\n' + 'a:last-child { margin-bottom: 0; }' ); @@ -15,7 +15,7 @@ describe('lost-row', function() { it('provides 2/5 row layout', function() { check( 'a { lost-row: 2/5; }', - 'a { width: 100%; height: calc(99.99% * 2/5 - (30px - 30px * 2/5));' + + 'a { width: 100%; height: calc(99.9% * 2/5 - (30px - 30px * 2/5));' + ' margin-bottom: 30px; }\n' + 'a:last-child { margin-bottom: 0; }' ); @@ -24,7 +24,7 @@ describe('lost-row', function() { it('supports no gutter', function() { check( 'a { lost-row: 2/5 0; }', - 'a { width: 100%; height: calc(99.999999% * 2/5); margin-bottom: 0; }\n' + + 'a { width: 100%; height: calc(99.9% * 2/5); margin-bottom: 0; }\n' + 'a:last-child { margin-bottom: 0; }' ); }); @@ -33,9 +33,17 @@ describe('lost-row', function() { check( 'a { lost-row: 2/6 60px flex; }', 'a { width: 100%; flex: 0 0 auto;' + - ' height: calc(99.99% * 2/6 - (60px - 60px * 2/6));' + + ' height: calc(99.9% * 2/6 - (60px - 60px * 2/6));' + ' margin-bottom: 60px; }\n' + 'a:last-child { margin-bottom: 0; }' ); }); + + it('provides none rule', function() { + check( + 'a { lost-row: none; }', + 'a { width: auto; height: auto;' + + ' margin-bottom: 0; }' + ); + }); }); diff --git a/test/lost-utility.js b/test/lost-utility.js index 37b0d0e6..e0235e6d 100644 --- a/test/lost-utility.js +++ b/test/lost-utility.js @@ -15,9 +15,15 @@ describe('lost-utility', function() { it('applies clearfix', function() { check( 'a { lost-utility: clearfix }', - 'a { *zoom: 1 }\n' + - 'a:before { content: \'\'; display: table }\n' + - 'a:after { content: \'\'; display: table; clear: both }' + 'a:before {\n' + + ' content: \'\';\n' + + ' display: table\n' + + '}\n' + + 'a:after {\n' + + ' content: \'\';\n' + + ' display: table;\n' + + ' clear: both\n' + + '}' ); }); }); diff --git a/test/lost-waffle.js b/test/lost-waffle.js index 769dbea4..e057cb11 100644 --- a/test/lost-waffle.js +++ b/test/lost-waffle.js @@ -6,14 +6,13 @@ describe('lost-waffle', function() { it('provides 3 column layout', function() { check( 'a { lost-waffle: 1/3; }', - 'a { width: calc(99.99% * 1/3 - (30px - 30px * 1/3));' + - ' height: calc(99.99% * 1/3 - (30px - 30px * 1/3)); }\n' + - 'a:nth-child(n) { float: left; margin-right: 30px;' + + 'a { width: calc(99.9% * 1/3 - (30px - 30px * 1/3));' + + ' height: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 30px;' + ' margin-bottom: 30px; clear: none; }\n' + 'a:last-child { margin-right: 0; margin-bottom: 0; }\n' + - 'a:nth-child(3n) { margin-right: 0; }\n' + - 'a:nth-child(3n) { float: right; }\n' + - 'a:nth-child(3n + 1) { clear: left; }\n' + + 'a:nth-child(3n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(3n + 1) { clear: both; }\n' + 'a:nth-last-child(-n + 3) { margin-bottom: 0; }' ); }); @@ -21,14 +20,13 @@ describe('lost-waffle', function() { it('supports a custom cycle', function() { check( 'a { lost-waffle: 2/4 2; }', - 'a { width: calc(99.99% * 2/4 - (30px - 30px * 2/4));' + - ' height: calc(99.99% * 2/4 - (30px - 30px * 2/4)); }\n' + - 'a:nth-child(n) { float: left; margin-right: 30px;' + + 'a { width: calc(99.9% * 2/4 - (30px - 30px * 2/4));' + + ' height: calc(99.9% * 2/4 - (30px - 30px * 2/4)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 30px;' + ' margin-bottom: 30px; clear: none; }\n' + 'a:last-child { margin-right: 0; margin-bottom: 0; }\n' + - 'a:nth-child(2n) { margin-right: 0; }\n' + - 'a:nth-child(2n) { float: right; }\n' + - 'a:nth-child(2n + 1) { clear: left; }\n' + + 'a:nth-child(2n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(2n + 1) { clear: both; }\n' + 'a:nth-last-child(-n + 2) { margin-bottom: 0; }' ); }); @@ -36,27 +34,40 @@ describe('lost-waffle', function() { it('supports a custom gutter', function() { check( 'a { lost-waffle: 3/6 2 60px; }', - 'a { width: calc(99.99% * 3/6 - (60px - 60px * 3/6));' + - ' height: calc(99.99% * 3/6 - (60px - 60px * 3/6)); }\n' + - 'a:nth-child(n) { float: left; margin-right: 60px;' + + 'a { width: calc(99.9% * 3/6 - (60px - 60px * 3/6));' + + ' height: calc(99.9% * 3/6 - (60px - 60px * 3/6)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 60px;' + ' margin-bottom: 60px; clear: none; }\n' + 'a:last-child { margin-right: 0; margin-bottom: 0; }\n' + - 'a:nth-child(2n) { margin-right: 0; }\n' + - 'a:nth-child(2n) { float: right; }\n' + - 'a:nth-child(2n + 1) { clear: left; }\n' + + 'a:nth-child(2n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(2n + 1) { clear: both; }\n' + 'a:nth-last-child(-n + 2) { margin-bottom: 0; }' ); }); + it('supports clearing fallback', function() { + check( + '@lost clearing left; \n' + + 'a { lost-waffle: 1/3; }', + 'a { width: calc(99.9% * 1/3 - (30px - 30px * 1/3));' + + ' height: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' + + 'a:nth-child(1n) { float: left; margin-right: 30px;' + + ' margin-bottom: 30px; clear: none; }\n' + + 'a:last-child { margin-right: 0; margin-bottom: 0; }\n' + + 'a:nth-child(3n) { margin-right: 0; float: right; }\n' + + 'a:nth-child(3n + 1) { clear: left; }\n' + + 'a:nth-last-child(-n + 3) { margin-bottom: 0; }' + ); + }); + it('supports flexbox', function() { check( 'a { lost-waffle: 2/5 3 0 flex; }', - 'a { flex: 0 0 auto; width: calc(99.999999% * 2/5);' + - ' height: calc(99.999999% * 2/5); }\n' + - 'a:nth-child(n) { margin-right: 0; margin-bottom: 0; }\n' + + 'a { flex: 0 0 auto; width: calc(99.9% * 2/5);' + + ' height: calc(99.9% * 2/5); }\n' + + 'a:nth-child(1n) { margin-right: 0; margin-bottom: 0; margin-left: 0; }\n' + 'a:last-child { margin-right: 0; margin-bottom: 0; }\n' + - 'a:nth-child(3n) { margin-right: 0; }\n' + - 'a:nth-child(3n) { float: right; }\n' + + 'a:nth-child(3n) { margin-right: 0; margin-left: auto; }\n' + 'a:nth-last-child(-n + 3) { margin-bottom: 0; }' ); });