compass-susy-plugin 0.6.2

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.
data/lib/susy.rb ADDED
@@ -0,0 +1,2 @@
1
+ require File.join(File.dirname(__FILE__), 'susy', 'compass_plugin')
2
+ require File.join(File.dirname(__FILE__), 'susy', 'sass_extensions')
@@ -0,0 +1,5 @@
1
+ options = Hash.new
2
+ options[:stylesheets_directory] = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'sass'))
3
+ options[:templates_directory] = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'templates'))
4
+
5
+ Compass::Frameworks.register('susy', options)
@@ -0,0 +1,79 @@
1
+ require 'sass'
2
+
3
+ module Sass::Script::Functions
4
+ # set the Susy base font size (in pixels)
5
+ # return the percentage base font size
6
+ # this could be done in Sass, but we need to store the px_size so we
7
+ # can provide a px_to_em function
8
+ def base_font_size(base_font_size_px)
9
+ @@susy_base_font_size_px = Float(base_font_size_px.value)
10
+ Sass::Script::Number.new((@@susy_base_font_size_px / 16) * 100)
11
+ end
12
+
13
+ # approximate a given pixel size in ems
14
+ def px2em(size_in_px)
15
+ Sass::Script::Number.new((size_in_px.value / @@susy_base_font_size_px))
16
+ end
17
+
18
+ # set the Susy column and gutter widths and number of columns
19
+ # column, gutter and padding widths should be sent as unitless numbers,
20
+ # though they may "really" be ems or pixels (_grid.sass handles units).
21
+ # return total width of container (without units)
22
+ def container(total_columns, column_width, gutter_width, side_gutter_width)
23
+ @@susy_total_columns = total_columns.value
24
+ @@susy_column_width = Float(column_width.value)
25
+ @@susy_gutter_width = Float(gutter_width.value)
26
+ @@susy_side_gutter_width = Float(side_gutter_width.value)
27
+ context
28
+ end
29
+
30
+ # return the width of 'n' columns plus 'n - 1' gutters
31
+ # plus page padding in non-nested contexts
32
+ def context(n = nil)
33
+ begin
34
+ n = n.value
35
+ rescue NoMethodError
36
+ n = false
37
+ end
38
+ sg = 0
39
+ if !n
40
+ n = @@susy_total_columns
41
+ sg = @@susy_side_gutter_width
42
+ end
43
+ c, g = [@@susy_column_width, @@susy_gutter_width]
44
+ Sass::Script::Number.new(((n * c) + ((n - 1) * g)) + (sg * 2))
45
+ end
46
+
47
+ # return the percentage width of 'number' columns in a context of
48
+ # 'context_columns'
49
+ def columns(number, context_columns = nil)
50
+ n = number.value
51
+ context_width = context(context_columns).value
52
+ c, g = [@@susy_column_width, @@susy_gutter_width]
53
+ Sass::Script::Number.new((((n * c) + ((n - 1) * g)) / context_width) * 100)
54
+ end
55
+
56
+ # return the percentage width of a single gutter in a context of
57
+ # 'context_columns'
58
+ def gutter(context_columns = nil)
59
+ context_width = context(context_columns).value
60
+ g = @@susy_gutter_width
61
+ Sass::Script::Number.new((g / context_width) * 100)
62
+ end
63
+
64
+ # return the percentage width of a single side gutter in a context of
65
+ # 'context_columns'
66
+ def side_gutter(context_columns = nil)
67
+ context_width = context(context_columns).value
68
+ sg = @@susy_side_gutter_width
69
+ Sass::Script::Number.new((sg / context_width) * 100)
70
+ end
71
+
72
+ # return the percentage width of a single column in a context of
73
+ # 'context_columns'
74
+ def column(context_columns = nil)
75
+ context_width = context(context_columns).value
76
+ c = @@susy_column_width
77
+ Sass::Script::Number.new((c / context_width) * 100)
78
+ end
79
+ end
@@ -0,0 +1,115 @@
1
+ //** Grid Settings **//
2
+
3
+ //**
4
+ Your basic units for the grid
5
+ !grid_unit ||= "em"
6
+ !total_cols ||= 16
7
+ !col_width ||= 4
8
+ !gutter_width ||= 1
9
+ !side_gutter_width ||= !gutter_width
10
+ !container_width = container(!total_cols, !col_width, !gutter_width, !side_gutter_width)
11
+
12
+
13
+ //**
14
+ set on the outer grid containing element.
15
+ =container(!align = "left")
16
+ // clear all floated columns
17
+ +clearfix
18
+ // align the text back to the left (override for other alignments)
19
+ :text-align= !align
20
+ // use auto horizontal margins to center your page in the body
21
+ :margin
22
+ :left auto
23
+ :right auto
24
+ // set the page width based on column settings
25
+ :width= !container_width + !grid_unit
26
+ // never exceed 100% of the browser window (no side-scrolling)
27
+ :max-width 100%
28
+
29
+
30
+ //**
31
+ set on any column element, even nested ones.
32
+ the first agument [required] is the number of columns to span
33
+ the second argument is the context (columns spanned by parent)
34
+ this is required in any nested context
35
+ by default a grid-col is floated left with a right gutter
36
+ override that with +float("right"), +first or +last
37
+ =columns(!n, !context = false)
38
+ // the width of the column is set as a percentage of the context
39
+ :width= columns(!n, !context) + "%"
40
+ // the column is floated left
41
+ +float("left")
42
+ // the right gutter is added as a percentage of the context
43
+ :margin-right= gutter(!context) + "%"
44
+
45
+ //**
46
+ set on any column to add empty colums before or after
47
+ =prefix(!n, !context = false)
48
+ :padding-left= columns(!n, !context) + gutter(!context) + "%"
49
+
50
+ =suffix(!n, !context = false)
51
+ :padding-right= columns(!n, !context) + gutter(!context) + "%"
52
+
53
+ //**
54
+ set as shortcut for prefix and suffix
55
+ =pad(!p = 0, !s = 0, !c = false)
56
+ @if !p != 0
57
+ +prefix(!p,!c)
58
+ @if !s != 0
59
+ +suffix(!s,!c)
60
+
61
+ //**
62
+ set on any element spanning the first column in non-nested context
63
+ to take side-gutters into account
64
+ =alpha(!nested = false)
65
+ @if !nested == false
66
+ :margin-left= side_gutter() + "%"
67
+
68
+ //**
69
+ when global constant !hacks == true:
70
+ - this will be called automatically with hacks
71
+ when global constant !hacks == false:
72
+ - you can call it yourself in ie.sass without the hacks
73
+ =ie-omega(!nested = false, !right = false, !hack = false)
74
+ !s = side_gutter()
75
+ @if !right
76
+ @if !hack
77
+ :#margin-left -1%
78
+ @else
79
+ :margin-left -1%
80
+ @else
81
+ @if !nested
82
+ @if !hack
83
+ :#margin-right -1%
84
+ @else
85
+ :margin-right -1%
86
+ @else
87
+ @if !hack
88
+ :#margin-right= !s - 1 + "%"
89
+ @else
90
+ :margin-right= !s - 1 + "%"
91
+
92
+ //**
93
+ set on the last element of a row to take side-gutters into account
94
+ - set !nested for nested columns
95
+ - set !float for right-floated omega elements
96
+ =omega(!nested = false, !right = false)
97
+ !s = side_gutter()
98
+ @if !nested
99
+ :margin-right 0
100
+ @else
101
+ :margin-right= !s + "%"
102
+ @if !hacks
103
+ /* ugly hacks for IE6-7 */
104
+ +ie-omega(!nested, !right,"*")
105
+ /* end ugly hacks */
106
+
107
+ //**
108
+ set on an element that will span it's entire context
109
+ - no need for +columns, +alpha or +omega on a +full element
110
+ =full(!nested = false)
111
+ :clear both
112
+ @if !nested == false
113
+ !s = side_gutter() + "%"
114
+ margin-right= !s
115
+ margin-left= !s
@@ -0,0 +1,18 @@
1
+ //**
2
+ tell susy whether you are using hacks or conditional comments
3
+ !hacks ||= true
4
+
5
+ @import utils.sass
6
+ @import text.sass
7
+ @import grid.sass
8
+
9
+ //**
10
+ body font size set to browser default (usually 16px)
11
+ =susy(!align = "center")
12
+ // text-align set to center by default for auto-centering layouts
13
+ // (override !align for left/right-aligned designs)
14
+ :text-align= !align
15
+ // set your base font sizes
16
+ :font-size= !base_font_size
17
+ :line-height= !base_line_height
18
+
@@ -0,0 +1,21 @@
1
+ //** Text Settings **//
2
+
3
+ //**
4
+ You set the font and line heights in pixels
5
+ !base_font_size_px ||= 12
6
+ !base_line_height_px ||= 18
7
+
8
+
9
+ //**
10
+ Susy can do the math to make that relative
11
+ we call base_font_size function (even though we could do the math here)
12
+ because Susy needs to "remember" our base_font_size_px for px2em()
13
+ !base_font_size = base_font_size(!base_font_size_px) + "%"
14
+ !base_line_height = (!base_line_height_px / !base_font_size_px) * 100 + "%"
15
+
16
+ //**
17
+ Because some serif fonts add line-height when switching to italics inline:
18
+ =inline-italic
19
+ :font-style italic
20
+ :line-height .5
21
+
@@ -0,0 +1,211 @@
1
+ @import compass/utilities.sass
2
+
3
+ //**
4
+ removes all background images and colors from the element and offspring
5
+ then adds a grid image of your choosing. highlights divs on modern browsers
6
+ =show-grid(!src)
7
+ :background
8
+ :image= image_url(!src)
9
+ :repeat repeat
10
+ :position= side_gutter() + "% 0"
11
+ *
12
+ :background transparent
13
+ div
14
+ :background rgba(0,0,0,.125)
15
+
16
+ //**
17
+ brings IE in line with inline-block display
18
+ - using hacks if called automatically because !hacks == true
19
+ - or without if you call it from ie.sass
20
+ =ie-inline-block(!hack = false)
21
+ @if !hack
22
+ /* ugly hacks for IE6-7 */
23
+ :#display inline
24
+ // fixes alignment against native input/button on IE6
25
+ :#vertical-align auto
26
+ /* end ugly hacks */
27
+ @else
28
+ :display inline
29
+ // fixes alignment against native input/button on IE6
30
+ :vertical-align auto
31
+
32
+ //**
33
+ an override for compass inline-block that lets you take advantage
34
+ of Susys !hacks constant. if true, hacks. if false, use ie-inline-block
35
+ to help ie along in your ie.sass
36
+ =inline-block
37
+ :display -moz-inline-box
38
+ :-moz-box-orient vertical
39
+ :display inline-block
40
+ :vertical-align middle
41
+ @if !hacks
42
+ +ie-inline-block("*")
43
+
44
+ //**
45
+ an inline-block list that works in IE
46
+ for those awkward moments when a floated horizontal list just wont cut it
47
+ if global !hacks == false:
48
+ - you'll need to fix list items in ie.sass with +ie-inline-block
49
+ =inline-block-list(!hpad = 0)
50
+ +horizontal-list-container
51
+ li
52
+ +no-bullet
53
+ :white-space no-wrap
54
+ +inline-block
55
+ :padding
56
+ :left= !hpad
57
+ :right= !hpad
58
+
59
+ //**
60
+ hide an element from the viewport, but keep it around for accessability
61
+ =hide
62
+ :position absolute
63
+ :top -9999em
64
+
65
+ //**
66
+ a skip-to-content accessibility link that will appear on focus
67
+ set the location arguments if you care where it appears
68
+ =skip-link(!t = 0, !r = false, !b = false, !l = false)
69
+ +hide
70
+ :display block
71
+ &:focus
72
+ @if !t
73
+ :top= !t
74
+ @if !r
75
+ :right= !r
76
+ @if !b
77
+ :bottom= !b
78
+ @if !l
79
+ :left= !l
80
+ :z-index 999
81
+
82
+ // EXPERIMENTAL
83
+
84
+ //**
85
+ [Opacity rules based on those in Compass Core Edge as of 7.18.09]
86
+ - These will be removed from Susy once they enter a major Compass release.
87
+ Provides cross-browser css opacity.
88
+ @param !opacity
89
+ A number between 0 and 1, where 0 is transparent and 1 is opaque.
90
+ =opacity(!opacity)
91
+ :opacity= !opacity
92
+ :-moz-opacity= !opacity
93
+ :-khtml-opacity= !opacity
94
+ :-ms-filter= "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + round(!opacity*100) + ")"
95
+ :filter= "alpha(opacity=" + round(!opacity*100) + ")"
96
+
97
+ // Make an element completely transparent.
98
+ =transparent
99
+ +opacity(0)
100
+
101
+ // Make an element completely opaque.
102
+ =opaque
103
+ +opacity(1)
104
+
105
+ //**
106
+ rounded corners for Mozilla, Webkit and the future
107
+ =border-radius(!r)
108
+ /* Mozilla (FireFox, Camino)
109
+ -moz-border-radius = !r
110
+ /* Webkit (Safari, Chrome)
111
+ -webkit-border-radius = !r
112
+ /* CSS3
113
+ border-radius = !r
114
+
115
+ =border-corner-radius(!vert, !horz, !r)
116
+ /* Mozilla (FireFox, Camino)
117
+ -moz-border-radius-#{!vert}#{!horz}= !r
118
+ /* Webkit (Safari, Chrome)
119
+ -webkit-border-#{!vert}-#{!horz}-radius= !r
120
+ /* CSS3
121
+ border-#{!vert}-#{!horz}-radius= !r
122
+
123
+ =border-top-left-radius(!r)
124
+ +border-corner-radius("top", "left", !r)
125
+
126
+ =border-top-right-radius(!r)
127
+ +border-corner-radius("top", "right", !r)
128
+
129
+ =border-bottom-right-radius(!r)
130
+ +border-corner-radius("bottom", "right", !r)
131
+
132
+ =border-bottom-left-radius(!r)
133
+ +border-corner-radius("bottom", "left", !r)
134
+
135
+ =border-top-radius(!r)
136
+ +border-top-left-radius(!r)
137
+ +border-top-right-radius(!r)
138
+
139
+ =border-right-radius(!r)
140
+ +border-top-right-radius(!r)
141
+ +border-bottom-right-radius(!r)
142
+
143
+ =border-bottom-radius(!r)
144
+ +border-bottom-right-radius(!r)
145
+ +border-bottom-left-radius(!r)
146
+
147
+ =border-left-radius(!r)
148
+ +border-top-left-radius(!r)
149
+ +border-bottom-left-radius(!r)
150
+
151
+ //**
152
+ change the box model for Mozilla, Webkit, IE8 and the future
153
+ =box-sizing(!bs)
154
+ /* Mozilla (FireFox, Camino)
155
+ -moz-box-sizing= !bs
156
+ /* Webkit (Safari, Chrome)
157
+ -webkit-box-sizing= !bs
158
+ /* IE (8)
159
+ -ms-box-sizing= !bs
160
+ /* CSS3
161
+ box-sizing= !bs
162
+
163
+ //**
164
+ box shadow for Webkit and the future
165
+ - arguments are horizontal offset, vertical offset, blur and color
166
+ =box-shadow(!ho, !vo, !b, !c )
167
+ /* Webkit (Safari, Chrome)
168
+ -webkit-box-shadow= !ho !vo !b !c
169
+ /* Mozilla (Firefox, Camino)
170
+ -moz-box-shadow= !ho !vo !b !c
171
+ /* CSS3
172
+ box-shadow= !ho !vo !b !c
173
+
174
+
175
+ //**
176
+ CSS3 columns for Mozilla, Webkit and the Future
177
+
178
+ =column-count(!n)
179
+ :-moz-column-count= !n
180
+ :-webkit-column-count= !n
181
+ :column-count= !n
182
+
183
+ =column-gap(!u)
184
+ :-moz-column-gap= !u
185
+ :-webkit-column-gap= !u
186
+ :column-gap= !u
187
+
188
+ =column-width(!u)
189
+ :-moz-column-width= !u
190
+ :-webkit-column-width= !u
191
+ :column-width= !u
192
+
193
+ =column-rule-width(!w)
194
+ :-moz-column-rule-width= !w
195
+ :-webkit-column-rule-width= !w
196
+ :column-rule-width= !w
197
+
198
+ =column-rule-style(!s)
199
+ :-moz-column-rule-style= !s
200
+ :-webkit-column-rule-style= !s
201
+ :column-rule-style= !s
202
+
203
+ =column-rule-color(!c)
204
+ :-moz-column-rule-color= !c
205
+ :-webkit-column-rule-color= !c
206
+ :column-rule-color= !c
207
+
208
+ =column-rule(!w, !s = "solid", !c = " ")
209
+ +column-rule-width(!w)
210
+ +column-rule-style(!s)
211
+ +column-rule-color(!c)