compass-flexbox 1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ require 'compass'
2
+
3
+ # This tells Compass what your Compass extension is called, and where to find
4
+ # its files
5
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
+ Compass::Frameworks.register('compass-flexbox', :path => extension_path)
@@ -0,0 +1,298 @@
1
+ @import "compass/css3/shared";
2
+
3
+ // Enabling flexbox: setting an element to be a flex container
4
+ @mixin display-flex() {
5
+ @include experimental-value(display, box, -moz, -webkit, not -o, not -ms, not -khtml, not official);
6
+ @include experimental-value(display, flexbox, not -moz, not -webkit, not -o, -ms, not -khtml, not official);
7
+ @include experimental-value(display, flex, not -moz, -webkit, not -o, not -ms, not -khtml, official);
8
+ }
9
+
10
+ @mixin display-inline-flex() {
11
+ @include experimental-value(display, inline-box, -moz, -webkit, not -o, not -ms, not -khtml, not official);
12
+ @include experimental-value(display, inline-flexbox, not -moz, not -webkit, not -o, -ms, not -khtml, not official);
13
+ @include experimental-value(display, inline-flex, not -moz, -webkit, not -o, not -ms, not -khtml, official);
14
+ }
15
+
16
+ // Axis alignment: specifying alignment of items along the main flexbox axis
17
+
18
+ $default-justify-content: flex-start !default;
19
+
20
+ @mixin justify-content(
21
+ $justification: $default-justify-content
22
+ ) {
23
+ @include _flex-property(justify-content, $justification, flex-pack, box-pack);
24
+ }
25
+
26
+ // Cross-axis alignment: specifying alignment of items along the cross-axis
27
+
28
+ $default-align-items: stretch !default;
29
+
30
+ @mixin align-items(
31
+ $alignment: $default-align-items
32
+ ) {
33
+ @include _flex-property(align-items, $alignment, flex-align, box-align);
34
+ }
35
+
36
+ // Individual cross-axis alignment: override to align individual items along the cross-axis
37
+
38
+ $default-align-self: stretch !default;
39
+
40
+ @mixin align-self(
41
+ $alignment: $default-align-self
42
+ ) {
43
+ @include _flex-property(align-self, $alignment, flex-item-align, null);
44
+ }
45
+
46
+ // Flex line alignment: specifying alignment of flex lines along the cross-axis
47
+
48
+ $default-align-content: stretch !default;
49
+
50
+ @mixin align-content(
51
+ $alignment: $default-align-content
52
+ ) {
53
+ @include _flex-property(align-items, $alignment, flex-line-pack, null);
54
+ }
55
+
56
+ // Display order: specifying the order of flex items
57
+
58
+ $default-order: 1 !default;
59
+
60
+ @mixin order(
61
+ $order: $default-order
62
+ ) {
63
+ @include _flex-property(order, $order, flex-order, box-ordinal-group);
64
+ }
65
+
66
+ // Flexibility: specifying how the size of items flex
67
+
68
+ $default-flex: 1 !default;
69
+
70
+ @mixin flex(
71
+ $amount: $default-flex
72
+ ) {
73
+ @include _flex-property(flex, $amount, flex, box-flex);
74
+ }
75
+
76
+ $default-flex-grow: $default-flex !default;
77
+
78
+ @mixin flex-grow(
79
+ $amount: $default-flex-grow
80
+ ) {
81
+ @include _flex-property(flex-grow, $amount);
82
+ }
83
+
84
+ $default-flex-shrink: $default-flex !default;
85
+
86
+ @mixin flex-shrink(
87
+ $amount: $default-flex-shrink
88
+ ) {
89
+ @include _flex-property(flex-shrink, $amount);
90
+ }
91
+
92
+ $default-flex-basis: $default-flex !default;
93
+
94
+ @mixin flex-basis(
95
+ $amount: $default-flex-basis
96
+ ) {
97
+ @include _flex-property(flex-basis, $amount);
98
+ }
99
+
100
+ // Direction: specifying the direction of the main flexbox axis
101
+
102
+ $default-flex-direction: row !default;
103
+
104
+ @mixin flex-direction(
105
+ $direction: $default-flex-direction
106
+ ) {
107
+ @include _flex-property(flex-direction, $direction, flex-direction, box-orient);
108
+ }
109
+
110
+ // Wrapping: specifying if and how flex items wrap along the cross-axis
111
+
112
+ $default-flex-wrap: nowrap !default;
113
+
114
+ @mixin flex-wrap(
115
+ $wrap: $default-flex-wrap
116
+ ) {
117
+ @include _flex-property(flex-wrap, $wrap, flex-wrap, box-lines);
118
+ }
119
+
120
+ // Shorthand for flex-direction & flex-wrap
121
+
122
+ $default-flex-flow: $default-flex-direction $default-flex-wrap !default;
123
+
124
+ @mixin flex-flow(
125
+ $flow: $default-flex-flow
126
+ ) {
127
+ @include _flex-property(flex-flow, $flow, flex-flow, null);
128
+ }
129
+
130
+ // Internal functions; not intended to be called directly
131
+
132
+ @mixin _flex-property($standard-property, $value, $ie-property: null, $legacy-property: null) {
133
+ $standard-property: unquote($standard-property);
134
+ $ie-property: unquote($ie-property);
135
+ $legacy-property: unquote($legacy-property);
136
+ $value: unquote($value);
137
+ $standard-value: $value;
138
+ $ie-value: _flex-value($standard-property, $value, ie);
139
+ $legacy-value: _flex-value($standard-property, $value, legacy);
140
+
141
+ // Safari, Firefox (buggy), iOS, Android browser, older WebKit browsers
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);
148
+ }
149
+ } @else {
150
+ @warn _support-warning($standard-property, "legacy");
151
+ }
152
+
153
+ // IE 10
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);
156
+ }
157
+
158
+ // Chrome 21+, Opera 12.1, Firefox 22+
159
+ @include experimental($standard-property, $standard-value, not -moz, -webkit, not -o, not -ms, not -khtml, official);
160
+ }
161
+
162
+ @function _flex-value($property, $value, $syntax) {
163
+ $new-value: $value;
164
+ $warning: false;
165
+
166
+ @if $property == justify-content {
167
+ @if $value == flex-start {
168
+ @if $syntax == legacy or $syntax == ie {
169
+ $new-value: start;
170
+ }
171
+ }
172
+ @else if $value == flex-end {
173
+ @if $syntax == legacy or $syntax == ie {
174
+ $new-value: end;
175
+ }
176
+ }
177
+ @else if $value == space-between {
178
+ @if $syntax == legacy {
179
+ $warning: "\"#{$property}: #{$value}\" does not work in the legacy Firefox implementation";
180
+ }
181
+ @if $syntax == legacy or $syntax == ie {
182
+ $new-value: justify;
183
+ }
184
+ }
185
+ @else if $value == space-around {
186
+ @if $syntax == legacy {
187
+ $new-value: null;
188
+ } @else if $syntax == ie {
189
+ $new-value: distribute;
190
+ }
191
+ }
192
+ }
193
+
194
+ @if $property == align-items {
195
+ @if $value == flex-start {
196
+ @if $syntax == legacy or $syntax == ie {
197
+ $new-value: start;
198
+ }
199
+ }
200
+ @else if $value == flex-end {
201
+ @if $syntax == legacy or $syntax == ie {
202
+ $new-value: end;
203
+ }
204
+ }
205
+ }
206
+
207
+ @if $property == align-self {
208
+ @if $value == flex-start {
209
+ @if $syntax == ie {
210
+ $new-value: start;
211
+ }
212
+ }
213
+ @else if $value == flex-end {
214
+ @if $syntax == ie {
215
+ $new-value: end;
216
+ }
217
+ }
218
+ }
219
+
220
+ @if $property == align-content {
221
+ @if $value == flex-start {
222
+ @if $syntax == ie {
223
+ $new-value: start;
224
+ }
225
+ }
226
+ @else if $value == flex-end {
227
+ @if $syntax == ie {
228
+ $new-value: end;
229
+ }
230
+ }
231
+ @else if $value == space-between {
232
+ @if $syntax == ie {
233
+ $new-value: justify;
234
+ }
235
+ }
236
+ @else if $value == space-around {
237
+ @if $syntax == ie {
238
+ $new-value: distribute;
239
+ }
240
+ }
241
+ }
242
+
243
+ @if $property == order {
244
+ @if $syntax == legacy and $value < 1 {
245
+ $warning: "\"#{$property}\" must be a positive integer in the \"#{$syntax}\" syntax";
246
+ $new-value: null;
247
+ }
248
+ }
249
+
250
+ @if $property == flex {
251
+ @if $syntax == legacy and type_of($value) != number {
252
+ $warning: "\"#{$property}\" only accepts an integer in the \"#{$syntax}\" syntax";
253
+ $new-value: null;
254
+ }
255
+ }
256
+
257
+ @if $property == flex-direction {
258
+ @if $value == row or $value == row-reverse {
259
+ @if $syntax == legacy {
260
+ $new-value: horizontal;
261
+ }
262
+ }
263
+ @else if $value == column or $value == column-reverse {
264
+ @if $syntax == legacy {
265
+ $new-value: vertical;
266
+ }
267
+ }
268
+ }
269
+
270
+ @if $property == flex-wrap {
271
+ @if $value == nowrap {
272
+ @if $syntax == legacy {
273
+ $new-value: single;
274
+ }
275
+ }
276
+ @else if $value == wrap {
277
+ @if $syntax == legacy {
278
+ @warn "\"#{$property}: #{$value}\" is not supported consistently in the \"#{$syntax}\" syntax";
279
+ $new-value: multiple;
280
+ }
281
+ }
282
+ @else if $value == wrap-reverse {
283
+ @if $syntax == legacy {
284
+ $new-value: null;
285
+ }
286
+ }
287
+ }
288
+
289
+ @if $new-value == null or $warning {
290
+ @warn if($warning, $warning, _support-warning("#{$property}: #{$value}", $syntax));
291
+ }
292
+
293
+ @return $new-value;
294
+ }
295
+
296
+ @function _support-warning($value, $syntax) {
297
+ @return "\"#{$value}\" not supported in the #{$syntax} syntax"
298
+ }
@@ -0,0 +1,57 @@
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-flexbox.css">
10
+ </head>
11
+ <body>
12
+ <h1>Compass Flexbox</h1>
13
+ <p></p>
14
+ <h2>Horizontally &amp; Vertically Centered Box</h2>
15
+ <p>Justify-content, the CSS property that launched a thousand blog posts</p>
16
+ <div class="centered-box-container">
17
+ <div class="centered-box">HOLY SHIT</div>
18
+ </div>
19
+ <h2>Nav</h2>
20
+ <p>One child item can be set up "fill" all remaining space in a container</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
+ <h2>Holy Grail Layout</h2>
31
+ <p>Flexbox finally gives use source-order independence</p>
32
+ <h3>Desktop</h3>
33
+ <div class="holy-grail">
34
+ <header>Header</header>
35
+ <main class="holy-grail-body">
36
+ <article>Main</article>
37
+ <nav>Nav</nav>
38
+ <aside>Sidebar</aside>
39
+ </main>
40
+ <footer>Footer</footer>
41
+ </div>
42
+ <h3>Mobile (Same Markup)</h3>
43
+ <div class="holy-grail is-mobile">
44
+ <header>Header</header>
45
+ <main class="holy-grail-body">
46
+ <article>Main</article>
47
+ <nav>Nav</nav>
48
+ <aside>Sidebar</aside>
49
+ </main>
50
+ <footer>Footer</footer>
51
+ </div>
52
+ <aside>
53
+ <a href="https://github.com/timhettler/compass-flexbox"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
54
+ </aside>
55
+ <script src="javascripts/libs/prism.js"></script>
56
+ </body>
57
+ </html>
@@ -0,0 +1,180 @@
1
+ @import "flexbox";
2
+ @import "compass/css3/box-sizing";
3
+ @import "compass/css3/transition";
4
+
5
+ @import "libs/prism";
6
+
7
+ body {
8
+ font-family: Helvetica;
9
+ }
10
+
11
+ %flex-container {
12
+ background-color: rgba(skyblue, 0.2);
13
+ @include display-flex();
14
+ min-height: 250px;
15
+ width: 100%;
16
+ }
17
+
18
+ $flex-item-dimension: 220px;
19
+
20
+ .flex-item {
21
+ @include display-flex();
22
+ @include justify-content(center);
23
+ @include align-items(center);
24
+ background-color: hotpink;
25
+ color: white;
26
+ height: $flex-item-dimension;
27
+ text-align: center;
28
+ width: $flex-item-dimension;
29
+ }
30
+
31
+ .code-comparison {
32
+ @include display-flex();
33
+ margin: 1.5em 0;
34
+ width: 100%;
35
+ }
36
+
37
+ .code-comparison--child {
38
+ @include flex(1);
39
+ min-height: 100px;
40
+
41
+ &:nth-child(1) {
42
+ margin-right: 5px;
43
+ }
44
+
45
+ &:nth-child(2) {
46
+ margin-left: 5px;
47
+ }
48
+ }
49
+
50
+ // Centered Box
51
+
52
+ .centered-box-container {
53
+ @extend %flex-container;
54
+ @include justify-content(center);
55
+ @include align-items(center);
56
+ height: 500px;
57
+ }
58
+
59
+ .centered-box {
60
+ @extend .flex-item;
61
+ @include single-transition();
62
+
63
+ &:hover {
64
+ height: 400px;
65
+ width: 500px;
66
+ }
67
+ }
68
+
69
+ // Holy Grail
70
+
71
+ $holy-grail-margin: 5px;
72
+
73
+ %holy-grail-item {
74
+ padding: 10px;
75
+
76
+ .is-mobile & {
77
+ @include flex(1);
78
+ @include order(1);
79
+ }
80
+ }
81
+
82
+ .holy-grail {
83
+ @include display-flex();
84
+ @include flex-direction(column);
85
+ margin: 0 auto;
86
+ text-align: center;
87
+ width: 100%;
88
+
89
+ &.is-mobile {
90
+ max-width: 320px;
91
+ }
92
+
93
+ > header, > footer {
94
+ @extend %holy-grail-item;
95
+ background-color: Moccasin;
96
+ }
97
+ }
98
+
99
+ .holy-grail-body {
100
+ @include display-flex();
101
+ @include flex-direction(row);
102
+ margin: $holy-grail-margin 0;
103
+ width: 100%;
104
+
105
+ .is-mobile & {
106
+ @include flex-direction(column);
107
+ margin: 0;
108
+ }
109
+
110
+ article {
111
+ @extend %holy-grail-item;
112
+ @include flex(3);
113
+ @include order(2);
114
+ background-color: PaleTurquoise;
115
+ margin: 0 $holy-grail-margin;
116
+ min-height: 100px;
117
+
118
+ .is-mobile & {
119
+ margin: 0;
120
+ }
121
+ }
122
+
123
+ nav {
124
+ @extend %holy-grail-item;
125
+ @include flex(1);
126
+ @include order(1);
127
+ background-color: hotpink;
128
+ }
129
+
130
+ aside {
131
+ @extend %holy-grail-item;
132
+ @include flex(1);
133
+ @include order(3);
134
+ background-color: Thistle;
135
+ }
136
+ }
137
+
138
+ // Nav
139
+
140
+ .flex-nav {
141
+ @include display-flex();
142
+ width: 100%;
143
+ }
144
+
145
+ %flex-nav-item {
146
+ @include align-items(center);
147
+ @include display-flex();
148
+ @include justify-content(center);
149
+ background-color: #ccc;
150
+ border: {
151
+ left: 1px solid #999;
152
+ };
153
+ padding: 5px 10px;
154
+ }
155
+
156
+ .flex-nav-item {
157
+ @extend %flex-nav-item;
158
+
159
+ &:hover {
160
+ background-color: #aaa;
161
+ }
162
+ }
163
+
164
+ .flex-nav-item--search {
165
+ @extend %flex-nav-item;
166
+ @include flex(1);
167
+
168
+ label {
169
+ display: block;
170
+ margin: 0 auto;
171
+ max-width: 500px;
172
+ width: 100%;
173
+ }
174
+
175
+ input {
176
+ @include box-sizing(border-box);
177
+ display: block;
178
+ width: 100%;
179
+ }
180
+ }
@@ -0,0 +1 @@
1
+ discover :all
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compass-flexbox
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ version: "1.0"
10
+ platform: ruby
11
+ authors:
12
+ - Tim Hettler
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-06-10 00:00:00 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: sass
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: compass
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ type: :runtime
46
+ version_requirements: *id002
47
+ description: A compass extension that provides variables & mixins for the latest Flexible Box Layout (flexbox) specification
48
+ email:
49
+ - me+github@timhettler.com
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ extra_rdoc_files: []
55
+
56
+ files:
57
+ - lib/compass-flexbox.rb
58
+ - stylesheets/_flexbox.scss
59
+ - templates/example/compass-flexbox.html
60
+ - templates/example/compass-flexbox.scss
61
+ - templates/example/manifest.rb
62
+ homepage: https://github.com/timhettler/compass-flexbox
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options: []
67
+
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 23
85
+ segments:
86
+ - 1
87
+ - 3
88
+ - 6
89
+ version: 1.3.6
90
+ requirements: []
91
+
92
+ rubyforge_project:
93
+ rubygems_version: 1.8.25
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: A compass extension that provides variables & mixins for the latest Flexible Box Layout (flexbox) specification
97
+ test_files: []
98
+