susy 1.0.alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ require 'fileutils'
2
+ require 'sass'
3
+
4
+ begin
5
+ require 'echoe'
6
+
7
+ Echoe.new('susy', open('VERSION').read) do |p|
8
+ p.summary = "A responsive grid system plugin for Compass."
9
+ p.description = "Responsive web design with grids the quick and reliable way."
10
+ p.url = "http://susy.oddbird.net/"
11
+ p.author = "Eric Meyer"
12
+ p.email = "eric@oddbird.net"
13
+ p.dependencies = ["compass >=0.13.alpha.0"]
14
+ end
15
+
16
+ rescue LoadError => boom
17
+ puts "You are missing a dependency required for meta-operations on this gem."
18
+ puts "#{boom.to_s.capitalize}."
19
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.alpha.0
@@ -0,0 +1,4 @@
1
+ require 'compass'
2
+ Compass::Frameworks.register('susy',
3
+ :stylesheets_directory => File.join(File.dirname(__FILE__), '..', 'sass'),
4
+ :templates_directory => File.join(File.dirname(__FILE__), '..', 'templates'))
@@ -0,0 +1,10 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Partials
3
+
4
+ @import "susy/settings";
5
+ @import "susy/functions";
6
+ @import "susy/grid";
7
+ @import "susy/padding";
8
+ @import "susy/margin";
9
+ @import "susy/media";
10
+ @import "susy/background";
@@ -0,0 +1,16 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Imports
3
+
4
+ @import "compass/layout/grid-background";
5
+
6
+ // ---------------------------------------------------------------------------
7
+ // Susy Grid Background
8
+ //
9
+ // A wrapper for the compass "column-grid-background" mixin
10
+ // Uses all your settings to create a grid background for a container element.
11
+ // Note: Sub-pixel rounding can lead to several pixels of variation between browsers.
12
+ @mixin susy-grid-background (){
13
+ @include column-grid-background($total-columns, $column-width, $gutter-width, $column-width*0, $force-fluid: true);
14
+ @include background-origin(content-box);
15
+ @include background-clip(content-box);
16
+ }
@@ -0,0 +1,255 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Imports
3
+
4
+ // We need access to some basic font settings for handling media-queries.
5
+ @import "compass/typography/vertical_rhythm";
6
+
7
+ // For now, we also need this...
8
+ $browser-default-font-size : 16px;
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // Grid Functions
12
+
13
+ // Returns the full width of a grid based on your grid settings.
14
+ //
15
+ // $columns : The number of columns to get width for.
16
+ @function columns-width(
17
+ $columns : $total-columns
18
+ ) {
19
+ $columns : if($columns,$columns,$total-columns);
20
+ @return ($columns * $column-width) + (ceil($columns - 1) * $gutter-width);
21
+ }
22
+
23
+ // Return the full outer width of a Container element.
24
+ //
25
+ // $columns : The number of columns in the Grid Layout.
26
+ @function container-outer-width(
27
+ $columns : $total-columns
28
+ ) {
29
+ @return columns-width($columns) + $grid-padding*2;
30
+ }
31
+
32
+ // Return the percentage width of a single column in a given 'context'.
33
+ //
34
+ // $context : The grid context in columns, if nested.
35
+ @function column(
36
+ $context : $total-columns
37
+ ) {
38
+ @return percentage($column-width / columns-width($context));
39
+ }
40
+
41
+ // Return the percentage width of multiple 'columns' in a given 'context'.
42
+ //
43
+ // $columns : The number of columns to get relative width for.
44
+ // $context : The grid context in columns, if nested.
45
+ @function columns(
46
+ $columns,
47
+ $context : $total-columns
48
+ ) {
49
+ @return percentage(columns-width($columns) / columns-width($context));
50
+ }
51
+
52
+ // Return the percentage width of a single gutter in a given 'context'.
53
+ //
54
+ // $context : The grid context in columns, if nested.
55
+ @function gutter(
56
+ $context : $total-columns
57
+ ) {
58
+ @return percentage($gutter-width / columns-width($context));
59
+ }
60
+
61
+ // Return the total space occupied by multiple columns and associated gutters.
62
+ // Useful for adding padding or margins (preifx, suffix, push, pull, etc.)
63
+ //
64
+ // $columns : The number of columns to get relative space for.
65
+ // $context : The grid context in columns, if nested.
66
+ @function space(
67
+ $columns,
68
+ $context : $total-columns
69
+ ) {
70
+ @return columns($columns, $context) + gutter($context);
71
+ }
72
+
73
+ // Accept a list including column-count and (optional) position.
74
+ // Return either the column count or the position alone.
75
+ //
76
+ // $columns : the list to split and interprate.
77
+ // $request : The value to return, either 'columns' or 'position'.
78
+ @function split-columns-value(
79
+ $columns,
80
+ $request : columns
81
+ ) {
82
+ $pos : false;
83
+ $cols : false;
84
+
85
+ @each $var in $columns {
86
+ @if (type-of($var) == 'string') {
87
+ $pos: $var;
88
+ } @else {
89
+ @if (type-of($var) == 'number') and (unitless($var)) {
90
+ $cols: $var;
91
+ } @else {
92
+ @warn '"#{$var}" is not a valid part of "$columns: #{$columns}" in the columns() mixin.';
93
+ }
94
+ }
95
+ }
96
+
97
+ @if $request == 'columns' {
98
+ @return $cols;
99
+ } @else {
100
+ @if $request == 'position' {
101
+ @return $pos;
102
+ } @else {
103
+ @warn '"#{$request}"" is not a valid value for $request';
104
+ }
105
+ }
106
+ }
107
+
108
+ // ---------------------------------------------------------------------------
109
+ // Media Functions
110
+
111
+ // Return an em value adjusted to match the browser default font size.
112
+ // Note: This only works if actual sizes are set relative to browser defaults.
113
+ //
114
+ // $ems : The initial value to be converted.
115
+ // $font-size : The current font-size in px.
116
+ @function absolute-ems(
117
+ $ems,
118
+ $font-size: $base-font-size
119
+ ){
120
+ @if ($font-size != $browser-default-font-size) {
121
+ $ems: $ems * ($font-size / $browser-default-font-size);
122
+ }
123
+ @return $ems;
124
+ }
125
+
126
+ // Return a length, after any em-values have been sent through absolute-ems().
127
+ //
128
+ // $length : The length value to be checked and adjusted if necessary.
129
+ // $font-size : The current font-size in px.
130
+ @function fix-ems(
131
+ $length,
132
+ $font-size: $base-font-size
133
+ ){
134
+ @if $length {
135
+ @if (unit($length) == 'em') {
136
+ $length: absolute-ems($length,$font-size);
137
+ }
138
+ }
139
+ @return $length;
140
+ }
141
+
142
+ // Sort a list of arguments into "$min $layout $max $ie" order, and return the list.
143
+ //
144
+ // $media-layout : a list of values [$min $layout $max $ie] including...
145
+ // : - one unitless number (columns in a layout)
146
+ // : - two optional lengths (min and max-width media-query breakpoints).
147
+ // : - one optional boolian or string to trigger fallback support for IE.
148
+ // $font-size : [optional] The base font-size of your layout, if you are using ems.
149
+ // : - defaults to $base-font-size
150
+ @function medialayout(
151
+ $media-layout,
152
+ $font-size: $base-font-size
153
+ ) {
154
+ $media : false;
155
+ $min : false;
156
+ $layout : false;
157
+ $max : false;
158
+ $ie : false;
159
+ $has-layout : false;
160
+
161
+ @each $val in $media-layout {
162
+ @if (type-of($val) == "number") {
163
+ @if unitless($val) {
164
+ $layout : $val;
165
+ $has-layout : true;
166
+ } @else {
167
+ @if ($has-layout) and (not $media) {
168
+ $max: $val;
169
+ } @else {
170
+ @if $media {
171
+ $media: join($media,$val);
172
+ } @else {
173
+ $media: $val;
174
+ }
175
+ }
176
+ }
177
+ } @else {
178
+ $ie: $val;
179
+ }
180
+ }
181
+ @if (length($media) > 0) {
182
+ @if (length($media) == 1) {
183
+ $min: nth($media,1);
184
+ } @else {
185
+ $min: nth($media,1);
186
+ $max: nth($media,2);
187
+ @if comparable($min, $max) {
188
+ @if ($min > $max) {
189
+ $max: nth($media,1);
190
+ $min: nth($media,2);
191
+ }
192
+ } @else {
193
+ @warn "Can't compare incompatible units.
194
+ Using #{$min} for min-width, and #{$max} for max-width";
195
+ }
196
+ @if (length($media) > 2) {
197
+ @warn "You can only send two lengths: a min-width and an (optional) max-width.
198
+ You sent #{length($media)}: #{$media}";
199
+ }
200
+ }
201
+ }
202
+
203
+ // media-queries must be set in ems relative to the browser default
204
+ // rather than the font-size set in CSS.
205
+ $min: fix-ems($min,$font-size);
206
+ $max: fix-ems($max,$font-size);
207
+
208
+ @return $min $layout $max $ie;
209
+ }
210
+
211
+ // Return the nearest layout (column-count) above a given breakpoint.
212
+ //
213
+ // $min : The min-width media-query breakpoint above which to establish a new layout.
214
+ @function get-layout (
215
+ $min
216
+ ) {
217
+ $default-layout : $total-columns;
218
+ $total-columns : 1;
219
+ $layout-width : container-outer-width();
220
+ $return : false;
221
+ $min : fix-ems($min);
222
+
223
+ @if comparable($min, $layout-width) {
224
+ @while $min >= $layout-width {
225
+ $total-columns : $total-columns + 1;
226
+ $layout-width : container-outer-width();
227
+ }
228
+ $return : $total-columns;
229
+ }
230
+
231
+ $total-columns : $default-layout;
232
+
233
+ @return $return;
234
+ }
235
+
236
+ // Check to see if a given $media-layout list is simply the default.
237
+ //
238
+ // $media-layout : a list of values including -
239
+ // : One unitless number (columns in a layout)
240
+ // : Two optional lengths (min and max-width media-query breakpoints).
241
+ // : One optional boolian or string to trigger fallback support for IE.
242
+ @function is-default-layout(
243
+ $media-layout
244
+ ) {
245
+ $media-layout : medialayout($media-layout);
246
+ $min : nth($media-layout,1);
247
+ $layout-cols : nth($media-layout,2);
248
+ $max : nth($media-layout,3);
249
+
250
+ @if $min or $max {
251
+ @return false;
252
+ } @else {
253
+ @return if($layout-cols == $total-columns,true,false);
254
+ }
255
+ }
@@ -0,0 +1,143 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Imports
3
+
4
+ @import "compass/utilities/general/clearfix";
5
+
6
+ // ---------------------------------------------------------------------------
7
+ // Container
8
+
9
+ // Set the width of a container
10
+ @mixin set-container-width(){
11
+ $width: if($container-width, $container-width, columns-width());
12
+
13
+ @if $container-style == 'static' {
14
+ width: $width;
15
+ } @else {
16
+ @if $container-style == 'fluid' {
17
+ width: if(unit($width) == '%', $width, auto);
18
+ } @else {
19
+ max-width: $width;
20
+ @if $legacy-support-for-ie6 {
21
+ _width: $width;
22
+ }
23
+ }
24
+ }
25
+ }
26
+
27
+ // Set the outer grid-containing element(s).
28
+ @mixin apply-container(){
29
+ @include pie-clearfix;
30
+ @include set-container-width;
31
+ margin: { left: auto; right: auto; }
32
+ padding: { left: $grid-padding; right: $grid-padding; }
33
+ }
34
+
35
+ // Set one or more layouts on a grid-containing element at any number of media-query breakpoints.
36
+ //
37
+ // $media-layout-1 : [default:$total-columns] A list of values including -
38
+ // : One unitless number (representing columns in a layout)
39
+ // : Two optional lengths (representing min and max-width media-query breakpoints).
40
+ // $media-layout-2 ...-10 : [optional] Same as $media-layout-1
41
+ @mixin container(
42
+ $media-layout-1 : $total-columns,
43
+ $media-layout-2 : false,
44
+ $media-layout-3 : false,
45
+ $media-layout-4 : false,
46
+ $media-layout-5 : false,
47
+ $media-layout-6 : false,
48
+ $media-layout-7 : false,
49
+ $media-layout-8 : false,
50
+ $media-layout-9 : false,
51
+ $media-layout-10 : false
52
+ ){
53
+ $media-layouts : compact($media-layout-2,$media-layout-3,$media-layout-4,$media-layout-5,$media-layout-6,$media-layout-7,$media-layout-8,$media-layout-9,$media-layout-10);
54
+
55
+ @if is-default-layout($media-layout-1) {
56
+ @include apply-container();
57
+ } @else {
58
+ @include at-breakpoint($media-layout-1) {
59
+ @include apply-container();
60
+ }
61
+ }
62
+
63
+ @each $ml in $media-layouts {
64
+ @if $ml {
65
+ @include at-breakpoint($ml) {
66
+ @include set-container-width;
67
+ }
68
+ }
69
+ }
70
+ }
71
+
72
+ // ---------------------------------------------------------------------------
73
+ // Columns
74
+
75
+ // Create a grid element spanning any number of 'columns' in a grid 'context'.
76
+ // $columns : The number of columns to span.
77
+ // $context : [optional] The context (columns spanned by parent).
78
+ // : Context is required on any nested elements.
79
+ // : Context MUST NOT be declared on a root element.
80
+ // $from : The start direction of your layout (e.g. 'left' for ltr languages)
81
+ @mixin columns(
82
+ $columns,
83
+ $context : $total-columns,
84
+ $from : $from-direction
85
+ ) {
86
+ $to : opposite-position($from);
87
+ $pos : split-columns-value($columns,position);
88
+ $cols : split-columns-value($columns,columns);
89
+
90
+ width: columns($cols, $context);
91
+
92
+ @if ($pos == 'omega') {
93
+ @include omega($from);
94
+ } @else {
95
+ float: $from;
96
+ margin-#{$to}: gutter($context);
97
+ }
98
+
99
+ @if $legacy-support-for-ie6 {
100
+ display: inline;
101
+ }
102
+ }
103
+
104
+ // Apply to elements spanning the last column, to account for the page edge.
105
+ // Only needed as an override. Normally 'omega' can just be called by `columns`.
106
+ //
107
+ // $from : The start-direction for your document.
108
+ @mixin omega(
109
+ $from : $from-direction
110
+ ) {
111
+ $to : opposite-position($from);
112
+ $hack : opposite-position($omega-float);
113
+
114
+ float: $omega-float;
115
+ margin-#{$to}: 0;
116
+
117
+ @if $legacy-support-for-ie6 or $legacy-support-for-ie7 {
118
+ #margin-#{$hack}: - $gutter-width;
119
+ @if $legacy-support-for-ie6 { display: inline; }
120
+ }
121
+ }
122
+
123
+ // ---------------------------------------------------------------------------
124
+ // Reset Columns
125
+
126
+ // Reset a '+columns' grid element to default block behavior
127
+ //
128
+ // $from : The start direction of your layout (e.g. 'left' for ltr languages)
129
+ @mixin reset-columns(
130
+ $from: $from-direction
131
+ ) {
132
+ $to : opposite-position($from);
133
+ $hack : opposite-position($omega-float);
134
+
135
+ float: none;
136
+ width: auto;
137
+ margin-#{$to}: auto;
138
+
139
+ @if $legacy-support-for-ie6 or $legacy-support-for-ie7 {
140
+ #margin-#{$hack}: auto;
141
+ @if $legacy-support-for-ie6 { display: block; }
142
+ }
143
+ }