Skip to content

Commit b64c29d

Browse files
authored
Merge pull request #406 from peterramsing/370_max-width
370 max width
2 parents 7681e79 + b04ead9 commit b64c29d

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

lib/lost-waffle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ module.exports = function lostWaffleDecl(css, settings) {
280280

281281
cloneAllBefore({
282282
width: lgLogic.calcValue(lostWaffle, lostWaffleGutter, lostWaffleRounder, unit),
283+
'max-width': lgLogic.calcValue(lostWaffle, lostWaffleGutter, lostWaffleRounder, unit),
283284
height: lgLogic.calcValue(lostWaffle, lostWaffleGutter, lostWaffleRounder, unit)
284285
});
285286

test/lg-gutter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('lost-gutter-local', () => {
6666
it('works on shortcut lost-waffle', () => {
6767
check(
6868
'div { padding: $lost-gutter-local; lost-waffle: 1/3 3 20px;}',
69-
'div { padding: 20px; width: calc(99.9% * 1/3 - (20px - 20px * 1/3)); height: calc(99.9% * 1/3 - (20px - 20px * 1/3));}\n'+
69+
'div { padding: 20px; width: calc(99.9% * 1/3 - (20px - 20px * 1/3)); max-width: calc(99.9% * 1/3 - (20px - 20px * 1/3)); height: calc(99.9% * 1/3 - (20px - 20px * 1/3));}\n'+
7070
'div:nth-child(1n) { float: left; margin-right: 20px; margin-bottom: 20px; clear: none;}\n' +
7171
'div:last-child { margin-right: 0; margin-bottom: 0;}\n' +
7272
'div:nth-child(3n) { margin-right: 0;}\n' +

test/lost-vars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('lost-vars', function() {
6363
it('works on shortcut lost-waffle', () => {
6464
check(
6565
'div { padding: lost-vars(\'gutter-local\'); lost-waffle: 1/3 3 20px;}',
66-
'div { padding: 20px; width: calc(99.9% * 1/3 - (20px - 20px * 1/3)); height: calc(99.9% * 1/3 - (20px - 20px * 1/3));}\n'+
66+
'div { padding: 20px; width: calc(99.9% * 1/3 - (20px - 20px * 1/3)); max-width: calc(99.9% * 1/3 - (20px - 20px * 1/3)); height: calc(99.9% * 1/3 - (20px - 20px * 1/3));}\n'+
6767
'div:nth-child(1n) { float: left; margin-right: 20px; margin-bottom: 20px; clear: none;}\n' +
6868
'div:last-child { margin-right: 0; margin-bottom: 0;}\n' +
6969
'div:nth-child(3n) { margin-right: 0;}\n' +

test/lost-waffle.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('lost-waffle', function() {
88
check(
99
'a { lost-waffle: 1/3; }',
1010
'a { width: calc(99.9% * 1/3 - (30px - 30px * 1/3));' +
11+
' max-width: calc(99.9% * 1/3 - (30px - 30px * 1/3));\n' +
1112
' height: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' +
1213
'a:nth-child(1n) { float: left; margin-right: 30px;' +
1314
' margin-bottom: 30px; clear: none; }\n' +
@@ -22,6 +23,7 @@ describe('lost-waffle', function() {
2223
check(
2324
'a { lost-waffle: 2/4 2; }',
2425
'a { width: calc(99.9% * 2/4 - (30px - 30px * 2/4));' +
26+
' max-width: calc(99.9% * 2/4 - (30px - 30px * 2/4));\n' +
2527
' height: calc(99.9% * 2/4 - (30px - 30px * 2/4)); }\n' +
2628
'a:nth-child(1n) { float: left; margin-right: 30px;' +
2729
' margin-bottom: 30px; clear: none; }\n' +
@@ -33,6 +35,7 @@ describe('lost-waffle', function() {
3335
check(
3436
'a { lost-waffle: 2/4; lost-waffle-cycle: 2; }',
3537
'a { width: calc(99.9% * 2/4 - (30px - 30px * 2/4));' +
38+
' max-width: calc(99.9% * 2/4 - (30px - 30px * 2/4));' +
3639
' height: calc(99.9% * 2/4 - (30px - 30px * 2/4)); }\n' +
3740
'a:nth-child(1n) { float: left; margin-right: 30px;' +
3841
' margin-bottom: 30px; clear: none; }\n' +
@@ -45,6 +48,7 @@ describe('lost-waffle', function() {
4548
'@lost cycle 0;' +
4649
'a { lost-waffle: 2/4; }',
4750
'a { width: calc(99.9% * 2/4 - (30px - 30px * 2/4));' +
51+
' max-width: calc(99.9% * 2/4 - (30px - 30px * 2/4));' +
4852
' height: calc(99.9% * 2/4 - (30px - 30px * 2/4)); }' +
4953
'a:nth-child(1n) { float: left; margin-right: 30px;' +
5054
' margin-bottom: 30px; clear: none; }' +
@@ -53,7 +57,8 @@ describe('lost-waffle', function() {
5357
check(
5458
'a { lost-waffle: 2/4 0 0 flex; }',
5559
'a { flex-grow: 0; flex-shrink: 0; flex-basis: calc(99.9% * 2/4);' +
56-
'width: calc(99.9% * 2/4); height: calc(99.9% * 2/4) }' +
60+
'width: calc(99.9% * 2/4); max-width: calc(99.9% * 2/4); '+
61+
'height: calc(99.9% * 2/4)}' +
5762
'a:nth-child(1n) { margin-right: 0; margin-bottom: 0; margin-left:0; }' +
5863
'a:last-child { margin-right: 0; margin-bottom: 0;}'
5964
);
@@ -63,6 +68,7 @@ describe('lost-waffle', function() {
6368
check(
6469
'a { lost-waffle: 3/6 2 60px; }',
6570
'a { width: calc(99.9% * 3/6 - (60px - 60px * 3/6));' +
71+
'max-width: calc(99.9% * 3/6 - (60px - 60px * 3/6));'+
6672
' height: calc(99.9% * 3/6 - (60px - 60px * 3/6)); }\n' +
6773
'a:nth-child(1n) { float: left; margin-right: 60px;' +
6874
' margin-bottom: 60px; clear: none; }\n' +
@@ -74,6 +80,7 @@ describe('lost-waffle', function() {
7480
check(
7581
'a { lost-waffle: 3/6 2; lost-waffle-gutter: 60px; }',
7682
'a { width: calc(99.9% * 3/6 - (60px - 60px * 3/6));' +
83+
' max-width: calc(99.9% * 3/6 - (60px - 60px * 3/6));' +
7784
' height: calc(99.9% * 3/6 - (60px - 60px * 3/6)); }\n' +
7885
'a:nth-child(1n) { float: left; margin-right: 60px;' +
7986
' margin-bottom: 60px; clear: none; }\n' +
@@ -89,6 +96,7 @@ describe('lost-waffle', function() {
8996
'@lost clearing left; \n' +
9097
'a { lost-waffle: 1/3; }',
9198
'a { width: calc(99.9% * 1/3 - (30px - 30px * 1/3));' +
99+
' max-width: calc(99.9% * 1/3 - (30px - 30px * 1/3));' +
92100
' height: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' +
93101
'a:nth-child(1n) { float: left; margin-right: 30px;' +
94102
' margin-bottom: 30px; clear: none; }\n' +
@@ -104,7 +112,8 @@ describe('lost-waffle', function() {
104112
'a { lost-waffle: 2/5 3 0 flex; }',
105113
'a { flex-grow: 0; flex-shrink: 0; ' +
106114
'flex-basis: calc(99.9% * 2/5); ' +
107-
'width: calc(99.9% * 2/5); height: calc(99.9% * 2/5); }\n' +
115+
'width: calc(99.9% * 2/5); max-width: calc(99.9% * 2/5);' +
116+
'height: calc(99.9% * 2/5); }'+
108117
'a:nth-child(1n) { ' +
109118
'margin-right: 0; margin-bottom: 0; margin-left: 0; }\n' +
110119
'a:last-child { margin-right: 0; margin-bottom: 0; }\n' +
@@ -116,6 +125,7 @@ describe('lost-waffle', function() {
116125
'a { flex-grow: 0; flex-shrink: 0;' +
117126
'flex-basis: calc(99.9% * 2/5 - (30px - 30px * 2/5));' +
118127
'width: calc(99.9% * 2/5 - (30px - 30px * 2/5));' +
128+
'max-width: calc(99.9% * 2/5 - (30px - 30px * 2/5));' +
119129
'height: calc(99.9% * 2/5 - (30px - 30px * 2/5)) }' +
120130
'a:nth-child(1n) { margin-right: 30px; margin-bottom: 30px; margin-left:0; }' +
121131
'a:last-child{ margin-right: 0; margin-bottom: 0;}' +
@@ -132,7 +142,8 @@ describe('lost-waffle', function() {
132142
check(
133143
'a { lost-waffle: 2/5 3 0 no-flex; }',
134144

135-
'a { width: calc(99.9% * 2/5); height: calc(99.9% * 2/5); }\n' +
145+
'a { width: calc(99.9% * 2/5); max-width: calc(99.9% * 2/5); ' +
146+
'height: calc(99.9% * 2/5); }' +
136147
'a:nth-child(1n) { float: left; margin-right: 0; margin-bottom: 0; clear: none; }\n' +
137148
'a:last-child { margin-right: 0; margin-bottom: 0; }\n' +
138149
'a:nth-child(3n) { margin-right: 0; }\n' +
@@ -145,7 +156,8 @@ describe('lost-waffle', function() {
145156
check(
146157
'a { lost-waffle: 2/5 3 0 no-flex float-right; }',
147158

148-
'a { width: calc(99.9% * 2/5); height: calc(99.9% * 2/5); }\n' +
159+
'a { width: calc(99.9% * 2/5); max-width: calc(99.9% * 2/5); ' +
160+
'height: calc(99.9% * 2/5); }' +
149161
'a:nth-child(1n) { float: left; margin-right: 0; margin-bottom: 0; clear: none; }\n' +
150162
'a:last-child { margin-right: 0; margin-bottom: 0; }\n' +
151163
'a:nth-child(3n) { margin-right: 0; float: right; }\n' +
@@ -157,7 +169,8 @@ describe('lost-waffle', function() {
157169
it('Supports custom unit', function() {
158170
check(
159171
'a { lost-waffle: 2/5 3 0 no-flex float-right; lost-unit: vw; }',
160-
'a { width: calc(99.9vw * 2/5); height: calc(99.9vw * 2/5); }\n' +
172+
'a { width: calc(99.9vw * 2/5); max-width: calc(99.9vw * 2/5);' +
173+
'height: calc(99.9vw * 2/5); }\n' +
161174
'a:nth-child(1n) { float: left; margin-right: 0; margin-bottom: 0; clear: none; }\n' +
162175
'a:last-child { margin-right: 0; margin-bottom: 0; }\n' +
163176
'a:nth-child(3n) { margin-right: 0; float: right; }\n' +
@@ -175,7 +188,8 @@ describe('lost-waffle', function() {
175188
check(
176189
'a { lost-waffle: 2/5 3 0 no-flex; lost-waffle-rounder: 100; }',
177190

178-
'a { width: calc(100% * 2/5); height: calc(100% * 2/5); }\n' +
191+
'a { width: calc(100% * 2/5); max-width: calc(100% * 2/5);' +
192+
' height: calc(100% * 2/5); }\n' +
179193
'a:nth-child(1n) { float: left; margin-right: 0; margin-bottom: 0; clear: none; }\n' +
180194
'a:last-child { margin-right: 0; margin-bottom: 0; }\n' +
181195
'a:nth-child(3n) { margin-right: 0; }\n' +
@@ -188,7 +202,7 @@ describe('lost-waffle', function() {
188202
check(
189203
'a { lost-waffle: 2/5 3 0 no-flex; lost-waffle-rounder: 99.99999999999; }',
190204

191-
'a { width: calc(99.99999999999% * 2/5); height: calc(99.99999999999% * 2/5); }\n' +
205+
'a { width: calc(99.99999999999% * 2/5); max-width: calc(99.99999999999% * 2/5); height: calc(99.99999999999% * 2/5); }\n' +
192206
'a:nth-child(1n) { float: left; margin-right: 0; margin-bottom: 0; clear: none; }\n' +
193207
'a:last-child { margin-right: 0; margin-bottom: 0; }\n' +
194208
'a:nth-child(3n) { margin-right: 0; }\n' +
@@ -203,7 +217,8 @@ describe('lost-waffle', function() {
203217
check(
204218
'@lost --beta-direction rtl;\n'+
205219
'div { lost-waffle: 1/3; }',
206-
'div { width: calc(99.9% * 1/3 - (30px - 30px * 1/3)); height: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' +
220+
'div { width: calc(99.9% * 1/3 - (30px - 30px * 1/3));' +
221+
' max-width: calc(99.9% * 1/3 - (30px - 30px * 1/3)); height: calc(99.9% * 1/3 - (30px - 30px * 1/3)); }\n' +
207222
'div:nth-child(1n) { float: right; margin-left: 30px; margin-bottom: 30px; clear: none; }\n' +
208223
'div:last-child { margin-left: 0; margin-bottom: 0; }\n' +
209224
'div:nth-child(3n) { margin-left: 0; }\n' +
@@ -216,6 +231,7 @@ describe('lost-waffle', function() {
216231
'div { flex-grow: 0; flex-shrink: 0; ' +
217232
'flex-basis: calc(99.9% * 1/3 - (30px - 30px * 1/3));' +
218233
'width: calc(99.9% * 1/3 - (30px - 30px * 1/3));' +
234+
'max-width: calc(99.9% * 1/3 - (30px - 30px * 1/3));' +
219235
'height: calc(99.9% * 1/3 - (30px - 30px * 1/3)) }' +
220236
'div:nth-child(1n) { margin-left: 30px; margin-bottom: 30px; margin-right: 0; }' +
221237
'div:last-child{ margin-left: 0; margin-bottom: 0; }' +

0 commit comments

Comments
 (0)