compass-flex-box 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ $default-justify-content: flex-start !default;
20
20
  @mixin justify-content(
21
21
  $justification: $default-justify-content
22
22
  ) {
23
- @include flex-property(justify-content, $justification, flex-pack, box-pack);
23
+ @include _flex-property(justify-content, $justification, flex-pack, box-pack);
24
24
  }
25
25
 
26
26
  // Cross-axis alignment: specifying alignment of items along the cross-axis
@@ -30,7 +30,7 @@ $default-align-items: stretch !default;
30
30
  @mixin align-items(
31
31
  $alignment: $default-align-items
32
32
  ) {
33
- @include flex-property(align-items, $alignment, flex-align, box-align);
33
+ @include _flex-property(align-items, $alignment, flex-align, box-align);
34
34
  }
35
35
 
36
36
  // Individual cross-axis alignment: override to align individual items along the cross-axis
@@ -40,7 +40,7 @@ $default-align-self: stretch !default;
40
40
  @mixin align-self(
41
41
  $alignment: $default-align-self
42
42
  ) {
43
- @include flex-property(align-self, $alignment, flex-item-align, null);
43
+ @include _flex-property(align-self, $alignment, flex-item-align, null);
44
44
  }
45
45
 
46
46
  // Flex line alignment: specifying alignment of flex lines along the cross-axis
@@ -50,7 +50,7 @@ $default-align-content: stretch !default;
50
50
  @mixin align-content(
51
51
  $alignment: $default-align-content
52
52
  ) {
53
- @include flex-property(align-items, $alignment, flex-line-pack, null);
53
+ @include _flex-property(align-items, $alignment, flex-line-pack, null);
54
54
  }
55
55
 
56
56
  // Display order: specifying the order of flex items
@@ -60,7 +60,7 @@ $default-order: 1 !default;
60
60
  @mixin order(
61
61
  $order: $default-order
62
62
  ) {
63
- @include flex-property(order, $order, flex-order, box-ordinal-group);
63
+ @include _flex-property(order, $order, flex-order, box-ordinal-group);
64
64
  }
65
65
 
66
66
  // Flexibility: specifying how the size of items flex
@@ -70,7 +70,7 @@ $default-flex: 1 !default;
70
70
  @mixin flex(
71
71
  $amount: $default-flex
72
72
  ) {
73
- @include flex-property(flex, $amount, flex, box-flex);
73
+ @include _flex-property(flex, $amount, flex, box-flex);
74
74
  }
75
75
 
76
76
  $default-flex-grow: $default-flex !default;
@@ -78,7 +78,7 @@ $default-flex-grow: $default-flex !default;
78
78
  @mixin flex-grow(
79
79
  $amount: $default-flex-grow
80
80
  ) {
81
- @include flex-property(flex-grow, $amount);
81
+ @include _flex-property(flex-grow, $amount);
82
82
  }
83
83
 
84
84
  $default-flex-shrink: $default-flex !default;
@@ -86,7 +86,7 @@ $default-flex-shrink: $default-flex !default;
86
86
  @mixin flex-shrink(
87
87
  $amount: $default-flex-shrink
88
88
  ) {
89
- @include flex-property(flex-shrink, $amount);
89
+ @include _flex-property(flex-shrink, $amount);
90
90
  }
91
91
 
92
92
  $default-flex-basis: $default-flex !default;
@@ -94,7 +94,7 @@ $default-flex-basis: $default-flex !default;
94
94
  @mixin flex-basis(
95
95
  $amount: $default-flex-basis
96
96
  ) {
97
- @include flex-property(flex-basis, $amount);
97
+ @include _flex-property(flex-basis, $amount);
98
98
  }
99
99
 
100
100
  // Direction: specifying the direction of the main flexbox axis
@@ -104,7 +104,7 @@ $default-flex-direction: row !default;
104
104
  @mixin flex-direction(
105
105
  $direction: $default-flex-direction
106
106
  ) {
107
- @include flex-property(flex-direction, $direction, flex-direction, box-orient);
107
+ @include _flex-property(flex-direction, $direction, flex-direction, box-orient);
108
108
  }
109
109
 
110
110
  // Wrapping: specifying if and how flex items wrap along the cross-axis
@@ -114,7 +114,7 @@ $default-flex-wrap: nowrap !default;
114
114
  @mixin flex-wrap(
115
115
  $wrap: $default-flex-wrap
116
116
  ) {
117
- @include flex-property(flex-wrap, $wrap, flex-wrap, box-lines);
117
+ @include _flex-property(flex-wrap, $wrap, flex-wrap, box-lines);
118
118
  }
119
119
 
120
120
  // Shorthand for flex-direction & flex-wrap
@@ -124,61 +124,68 @@ $default-flex-flow: $default-flex-direction $default-flex-wrap !default;
124
124
  @mixin flex-flow(
125
125
  $flow: $default-flex-flow
126
126
  ) {
127
- @include flex-property(flex-flow, $flow, flex-flow, null);
127
+ @include _flex-property(flex-flow, $flow, flex-flow, null);
128
128
  }
129
129
 
130
- @mixin flex-property($standard-property, $value, $mid-property: null, $old-property: null) {
130
+ // Internal functions; not intended to be called directly
131
+
132
+ @mixin _flex-property($standard-property, $value, $ie-property: null, $legacy-property: null) {
131
133
  $standard-property: unquote($standard-property);
132
- $mid-property: unquote($mid-property);
133
- $old-property: unquote($old-property);
134
+ $ie-property: unquote($ie-property);
135
+ $legacy-property: unquote($legacy-property);
134
136
  $value: unquote($value);
135
137
  $standard-value: $value;
136
- $mid-value: flex-value($standard-property, $value, mid);
137
- $old-value: flex-value($standard-property, $value, old);
138
+ $ie-value: _flex-value($standard-property, $value, ie);
139
+ $legacy-value: _flex-value($standard-property, $value, legacy);
138
140
 
139
141
  // Safari, Firefox (buggy), iOS, Android browser, older WebKit browsers
140
- @if $old-property and $old-value {
141
-
142
- @if $standard-property == flex-direction and ($value == row-reverse or $value == column-reverse) {
143
- @include experimental(box-direction, reverse, -moz, -webkit, not -o, not -ms, not -khtml, not official);
142
+ @if $legacy-property {
143
+ @if $legacy-value {
144
+ @if $standard-property == flex-direction and ($value == row-reverse or $value == column-reverse) {
145
+ @include experimental(box-direction, reverse, -moz, -webkit, not -o, not -ms, not -khtml, not official);
146
+ }
147
+ @include experimental($legacy-property, $legacy-value, -moz, -webkit, not -o, not -ms, not -khtml, not official);
144
148
  }
145
- @include experimental($old-property, $old-value, -moz, -webkit, not -o, not -ms, not -khtml, not official);
149
+ } @else {
150
+ @warn _support-warning($standard-property, "legacy");
146
151
  }
152
+
147
153
  // IE 10
148
- @if $mid-property and $mid-value {
149
- @include experimental($mid-property, $mid-value, not -moz, not -webkit, not -o, -ms, not -khtml, not official);
154
+ @if $ie-property and $ie-value {
155
+ @include experimental($ie-property, $ie-value, not -moz, not -webkit, not -o, -ms, not -khtml, not official);
150
156
  }
157
+
151
158
  // Chrome 21+, Opera 12.1, Firefox 22+
152
159
  @include experimental($standard-property, $standard-value, not -moz, -webkit, not -o, not -ms, not -khtml, official);
153
160
  }
154
161
 
155
- @function flex-value($property, $value, $syntax) {
162
+ @function _flex-value($property, $value, $syntax) {
156
163
  $new-value: $value;
157
164
  $warning: false;
158
165
 
159
166
  @if $property == justify-content {
160
167
  @if $value == flex-start {
161
- @if $syntax == old or $syntax == mid {
168
+ @if $syntax == legacy or $syntax == ie {
162
169
  $new-value: start;
163
170
  }
164
171
  }
165
172
  @else if $value == flex-end {
166
- @if $syntax == old or $syntax == mid {
173
+ @if $syntax == legacy or $syntax == ie {
167
174
  $new-value: end;
168
175
  }
169
176
  }
170
177
  @else if $value == space-between {
171
- @if $syntax == old {
172
- $warning: "\"#{$property}: #{$value}\" does not work in the old Firefox implementation";
178
+ @if $syntax == legacy {
179
+ $warning: "\"#{$property}: #{$value}\" does not work in the legacy Firefox implementation";
173
180
  }
174
- @if $syntax == old or $syntax == mid {
181
+ @if $syntax == legacy or $syntax == ie {
175
182
  $new-value: justify;
176
183
  }
177
184
  }
178
185
  @else if $value == space-around {
179
- @if $syntax == old {
186
+ @if $syntax == legacy {
180
187
  $new-value: null;
181
- } @else if $syntax == mid {
188
+ } @else if $syntax == ie {
182
189
  $new-value: distribute;
183
190
  }
184
191
  }
@@ -186,12 +193,12 @@ $default-flex-flow: $default-flex-direction $default-flex-wrap !default;
186
193
 
187
194
  @if $property == align-items {
188
195
  @if $value == flex-start {
189
- @if $syntax == old or $syntax == mid {
196
+ @if $syntax == legacy or $syntax == ie {
190
197
  $new-value: start;
191
198
  }
192
199
  }
193
200
  @else if $value == flex-end {
194
- @if $syntax == old or $syntax == mid {
201
+ @if $syntax == legacy or $syntax == ie {
195
202
  $new-value: end;
196
203
  }
197
204
  }
@@ -199,12 +206,12 @@ $default-flex-flow: $default-flex-direction $default-flex-wrap !default;
199
206
 
200
207
  @if $property == align-self {
201
208
  @if $value == flex-start {
202
- @if $syntax == mid {
209
+ @if $syntax == ie {
203
210
  $new-value: start;
204
211
  }
205
212
  }
206
213
  @else if $value == flex-end {
207
- @if $syntax == mid {
214
+ @if $syntax == ie {
208
215
  $new-value: end;
209
216
  }
210
217
  }
@@ -212,36 +219,36 @@ $default-flex-flow: $default-flex-direction $default-flex-wrap !default;
212
219
 
213
220
  @if $property == align-content {
214
221
  @if $value == flex-start {
215
- @if $syntax == mid {
222
+ @if $syntax == ie {
216
223
  $new-value: start;
217
224
  }
218
225
  }
219
226
  @else if $value == flex-end {
220
- @if $syntax == mid {
227
+ @if $syntax == ie {
221
228
  $new-value: end;
222
229
  }
223
230
  }
224
231
  @else if $value == space-between {
225
- @if $syntax == mid {
232
+ @if $syntax == ie {
226
233
  $new-value: justify;
227
234
  }
228
235
  }
229
236
  @else if $value == space-around {
230
- @if $syntax == mid {
237
+ @if $syntax == ie {
231
238
  $new-value: distribute;
232
239
  }
233
240
  }
234
241
  }
235
242
 
236
243
  @if $property == order {
237
- @if $syntax == old and $value < 1 {
244
+ @if $syntax == legacy and $value < 1 {
238
245
  $warning: "\"#{$property}\" must be a positive integer in the \"#{$syntax}\" syntax";
239
246
  $new-value: null;
240
247
  }
241
248
  }
242
249
 
243
250
  @if $property == flex {
244
- @if $syntax == old and type_of($value) != number {
251
+ @if $syntax == legacy and type_of($value) != number {
245
252
  $warning: "\"#{$property}\" only accepts an integer in the \"#{$syntax}\" syntax";
246
253
  $new-value: null;
247
254
  }
@@ -249,12 +256,12 @@ $default-flex-flow: $default-flex-direction $default-flex-wrap !default;
249
256
 
250
257
  @if $property == flex-direction {
251
258
  @if $value == row or $value == row-reverse {
252
- @if $syntax == old {
259
+ @if $syntax == legacy {
253
260
  $new-value: horizontal;
254
261
  }
255
262
  }
256
263
  @else if $value == column or $value == column-reverse {
257
- @if $syntax == old {
264
+ @if $syntax == legacy {
258
265
  $new-value: vertical;
259
266
  }
260
267
  }
@@ -262,27 +269,29 @@ $default-flex-flow: $default-flex-direction $default-flex-wrap !default;
262
269
 
263
270
  @if $property == flex-wrap {
264
271
  @if $value == nowrap {
265
- @if $syntax == old {
272
+ @if $syntax == legacy {
266
273
  $new-value: single;
267
274
  }
268
275
  }
269
276
  @else if $value == wrap {
270
- @if $syntax == old {
277
+ @if $syntax == legacy {
271
278
  $new-value: multiple;
272
279
  }
273
280
  }
274
281
  @else if $value == wrap-reverse {
275
- @if $syntax == old {
282
+ @if $syntax == legacy {
276
283
  $new-value: null;
277
284
  }
278
285
  }
279
286
  }
280
287
 
281
288
  @if $new-value == null or $warning {
282
- @warn if($warning, $warning, "\"#{$property}: #{$value}\" not supported in the \"" + $syntax + "\" syntax");
289
+ @warn if($warning, $warning, _support-warning("#{$property}: #{$value}", $syntax));
283
290
  }
284
291
 
285
292
  @return $new-value;
286
293
  }
287
294
 
288
-
295
+ @function _support-warning($value, $syntax) {
296
+ @return "\"#{$value}\" not supported in the #{$syntax} syntax"
297
+ }
@@ -0,0 +1,52 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <title>Flex Box</title>
7
+ <meta name="description" content="">
8
+ <meta name="viewport" content="width=device-width">
9
+ <link rel="stylesheet" href="stylesheets/compass-flex-box.css">
10
+ </head>
11
+ <body>
12
+ <h1>FLEX BOX</h1>
13
+ <h2>Common Layouts</h2>
14
+ <h3>Horizontally &amp; Vertically Centered Box</h3>
15
+ <p>Hover to change height & width</p>
16
+ <div class="centered-box-container">
17
+ <div class="centered-box">HOLY SHIT</div>
18
+ </div>
19
+ <h3>Nav</h3>
20
+ <p>One item fills all remaining space</p>
21
+ <div class="flex-nav">
22
+ <div class="flex-nav-item">Home</div>
23
+ <div class="flex-nav-item">Shop</div>
24
+ <div class="flex-nav-item">Sports</div>
25
+ <div class="flex-nav-item--search"><label><input type="search" placeholder="Search"></label></div>
26
+ <div class="flex-nav-item">Help</div>
27
+ <div class="flex-nav-item">Cart</div>
28
+ <div class="flex-nav-item">Join</div>
29
+ </div>
30
+ <h3>Holy Grail</h3>
31
+ <h4>Desktop</h4>
32
+ <div class="holy-grail">
33
+ <header>Header</header>
34
+ <main class="holy-grail-body">
35
+ <article>Main</article>
36
+ <nav>Nav</nav>
37
+ <aside>Sidebar</aside>
38
+ </main>
39
+ <footer>Footer</footer>
40
+ </div>
41
+ <h4>Mobile (Same Markup)</h4>
42
+ <div class="holy-grail is-mobile">
43
+ <header>Header</header>
44
+ <main class="holy-grail-body">
45
+ <article>Main</article>
46
+ <nav>Nav</nav>
47
+ <aside>Sidebar</aside>
48
+ </main>
49
+ <footer>Footer</footer>
50
+ </div>
51
+ </body>
52
+ </html>
@@ -0,0 +1,293 @@
1
+ @import "flex-box";
2
+ @import "compass/css3/box-sizing";
3
+ @import "compass/css3/transition";
4
+
5
+ body {
6
+ font-family: Helvetica;
7
+ }
8
+
9
+ %flex-container {
10
+ background-color: rgba(skyblue, 0.2);
11
+ @include display-flex();
12
+ min-height: 250px;
13
+ width: 100%;
14
+ }
15
+
16
+ .flex {
17
+ @extend %flex-container;
18
+ }
19
+
20
+ .flex--justify-content--flex-start {
21
+ @extend %flex-container;
22
+ @include justify-content(flex-start);
23
+ }
24
+
25
+ .flex--justify-content--center {
26
+ @extend %flex-container;
27
+ @include justify-content(center);
28
+ }
29
+
30
+ .flex--justify-content--flex-end {
31
+ @extend %flex-container;
32
+ @include justify-content(flex-end);
33
+ }
34
+
35
+ .flex--justify-content--space-between {
36
+ @extend %flex-container;
37
+ @include justify-content(space-between);
38
+ }
39
+
40
+ .flex--justify-content--space-around {
41
+ @extend %flex-container;
42
+ @include justify-content(space-around);
43
+ }
44
+
45
+ %flex-container--align-items {
46
+ @extend %flex-container;
47
+ @include justify-content(space-around);
48
+ }
49
+
50
+ .flex--align-items--flex-start {
51
+ @extend %flex-container--align-items;
52
+ @include align-items(flex-start);
53
+ }
54
+
55
+ .flex--align-items--center {
56
+ @extend %flex-container--align-items;
57
+ @include align-items(center);
58
+ }
59
+
60
+ .flex--align-items--flex-end {
61
+ @extend %flex-container--align-items;
62
+ @include align-items(flex-end);
63
+ }
64
+
65
+ .flex--align-items--baseline {
66
+ @extend %flex-container--align-items;
67
+ @include align-items(baseline);
68
+
69
+ > .flex-item:first-child {
70
+ height: 100px;
71
+ line-height: 100px;
72
+ }
73
+ }
74
+
75
+ .flex--align-items--stretch {
76
+ @extend %flex-container--align-items;
77
+ @include align-items(stretch);
78
+ }
79
+
80
+ .flex--align-self {
81
+ @extend %flex-container;
82
+ @include justify-content(space-around);
83
+
84
+ > .flex-item--auto {
85
+ @extend .flex-item;
86
+ @include align-self(auto);
87
+ }
88
+
89
+ > .flex-item--flex-start {
90
+ @extend .flex-item;
91
+ @include align-self(flex-start);
92
+ }
93
+
94
+ > .flex-item--center {
95
+ @extend .flex-item;
96
+ @include align-self(center);
97
+ }
98
+
99
+ > .flex-item--flex-end {
100
+ @extend .flex-item;
101
+ @include align-self(flex-end);
102
+ }
103
+
104
+ > .flex-item--baseline {
105
+ @extend .flex-item;
106
+ @include align-self(baseline);
107
+ }
108
+
109
+ > .flex-item--stretch {
110
+ @extend .flex-item;
111
+ @include align-self(stretch);
112
+ }
113
+ }
114
+
115
+ .flex--flex-direction--row {
116
+ @extend %flex-container;
117
+ @include flex-direction(row);
118
+ }
119
+
120
+ .flex--flex-direction--row-reverse {
121
+ @extend %flex-container;
122
+ @include flex-direction(row-reverse);
123
+ }
124
+
125
+ .flex--flex-direction--column {
126
+ @extend %flex-container;
127
+ @include flex-direction(column);
128
+ }
129
+
130
+ .flex--flex-direction--column-reverse {
131
+ @extend %flex-container;
132
+ @include flex-direction(column-reverse);
133
+ }
134
+
135
+ .flex--flex-wrap--nowrap {
136
+ @extend %flex-container;
137
+ @include flex-wrap(nowrap);
138
+ }
139
+
140
+ .flex--flex-wrap--wrap {
141
+ @extend %flex-container;
142
+ @include flex-wrap(wrap);
143
+ }
144
+
145
+ .flex--flex-wrap--wrap-reverse {
146
+ @extend %flex-container;
147
+ @include flex-wrap(wrap-reverse);
148
+ }
149
+
150
+ $flex-item-dimension: 220px;
151
+
152
+ .flex-item {
153
+ @include display-flex();
154
+ @include justify-content(center);
155
+ @include align-items(center);
156
+ background-color: hotpink;
157
+ color: white;
158
+ height: $flex-item-dimension;
159
+ text-align: center;
160
+ width: $flex-item-dimension;
161
+ }
162
+
163
+ // Centered Box
164
+
165
+ .centered-box-container {
166
+ @extend %flex-container;
167
+ @include justify-content(center);
168
+ @include align-items(center);
169
+ height: 500px;
170
+ }
171
+
172
+ .centered-box {
173
+ @extend .flex-item;
174
+ @include single-transition();
175
+
176
+ &:hover {
177
+ height: 400px;
178
+ width: 500px;
179
+ }
180
+ }
181
+
182
+ // Holy Grail
183
+
184
+ $holy-grail-margin: 5px;
185
+
186
+ %holy-grail-item {
187
+ padding: 10px;
188
+
189
+ .is-mobile & {
190
+ @include flex(1);
191
+ @include order(1);
192
+ }
193
+ }
194
+
195
+ .holy-grail {
196
+ @include display-flex();
197
+ @include flex-direction(column);
198
+ margin: 0 auto;
199
+ width: 800px;
200
+ text-align: center;
201
+
202
+ &.is-mobile {
203
+ max-width: 320px;
204
+ }
205
+
206
+ > header, > footer {
207
+ @extend %holy-grail-item;
208
+ background-color: Moccasin;
209
+ }
210
+ }
211
+
212
+ .holy-grail-body {
213
+ @include display-flex();
214
+ @include flex-direction(row);
215
+ margin: $holy-grail-margin 0;
216
+ width: 100%;
217
+
218
+ .is-mobile & {
219
+ @include flex-direction(column);
220
+ margin: 0;
221
+ }
222
+
223
+ article {
224
+ @extend %holy-grail-item;
225
+ @include flex(3);
226
+ @include order(2);
227
+ background-color: PaleTurquoise;
228
+ margin: 0 $holy-grail-margin;
229
+ min-height: 100px;
230
+
231
+ .is-mobile & {
232
+ margin: 0;
233
+ }
234
+ }
235
+
236
+ nav {
237
+ @extend %holy-grail-item;
238
+ @include flex(1);
239
+ @include order(1);
240
+ background-color: hotpink;
241
+ }
242
+
243
+ aside {
244
+ @extend %holy-grail-item;
245
+ @include flex(1);
246
+ @include order(3);
247
+ background-color: Thistle;
248
+ }
249
+ }
250
+
251
+ // Nav
252
+
253
+ %flex-nav-item {
254
+ @include align-items(center);
255
+ @include display-flex();
256
+ @include justify-content(center);
257
+ background-color: #ccc;
258
+ border: {
259
+ left: 1px solid #999;
260
+ };
261
+ padding: 5px 10px;
262
+ }
263
+
264
+ .flex-nav {
265
+ @include display-flex();
266
+ width: 100%;
267
+ }
268
+
269
+ .flex-nav-item {
270
+ @extend %flex-nav-item;
271
+
272
+ &:hover {
273
+ background-color: #aaa;
274
+ }
275
+ }
276
+
277
+ .flex-nav-item--search {
278
+ @extend %flex-nav-item;
279
+ @include flex(1);
280
+
281
+ label {
282
+ display: block;
283
+ margin: 0 auto;
284
+ max-width: 500px;
285
+ width: 100%;
286
+ }
287
+
288
+ input {
289
+ @include box-sizing(border-box);
290
+ display: block;
291
+ width: 100%;
292
+ }
293
+ }
@@ -1,2 +1 @@
1
- # Make sure you list all the project template files here in the manifest.
2
- stylesheet 'screen.scss', :media => 'screen, projection'
1
+ discover :all
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass-flex-box
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- version: "0.1"
8
+ - 2
9
+ version: "0.2"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tim Hettler
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2013-06-06 00:00:00 Z
17
+ date: 2013-06-07 00:00:00 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: sass
@@ -56,6 +56,8 @@ extra_rdoc_files: []
56
56
  files:
57
57
  - lib/compass-flex-box.rb
58
58
  - stylesheets/_flex-box.scss
59
+ - templates/example/compass-flex-box.html
60
+ - templates/example/compass-flex-box.scss
59
61
  - templates/example/manifest.rb
60
62
  homepage: https://github.com/timhettler/compass-flex-box
61
63
  licenses: []