susy 1.0.9 → 2.0.0.alpha.1
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/CHANGELOG.mkdn +0 -27
- data/README.md +4 -87
- data/docs/BUGS.md +2 -0
- data/docs/Gemfile.lock +142 -0
- data/docs/README.md +54 -0
- data/docs/config.rb +120 -0
- data/docs/lib/guide_helpers.rb +19 -0
- data/docs/source/apple-touch-icon-114x114-precomposed.png +0 -0
- data/docs/source/apple-touch-icon-144x144-precomposed.png +0 -0
- data/docs/source/apple-touch-icon-72x72-precomposed.png +0 -0
- data/docs/source/apple-touch-icon-precomposed.png +0 -0
- data/docs/source/demos/grid-types.html.md +263 -0
- data/docs/source/demos/index.html.md +23 -0
- data/docs/source/demos/magic.html.md +320 -0
- data/docs/source/favicon.ico +0 -0
- data/docs/source/fonts/@Font-Face License.txt +18 -0
- data/docs/source/fonts/Baskerville-amp-webfont.eot +0 -0
- data/docs/source/fonts/Baskerville-amp-webfont.svg +241 -0
- data/docs/source/fonts/Baskerville-amp-webfont.ttf +0 -0
- data/docs/source/fonts/Baskerville-amp-webfont.woff +0 -0
- data/docs/source/fonts/CenturyOldStyle-Bold-webfont.eot +0 -0
- data/docs/source/fonts/CenturyOldStyle-Bold-webfont.svg +240 -0
- data/docs/source/fonts/CenturyOldStyle-Bold-webfont.ttf +0 -0
- data/docs/source/fonts/CenturyOldStyle-Bold-webfont.woff +0 -0
- data/docs/source/fonts/CenturyOldStyle-Italic-webfont.eot +0 -0
- data/docs/source/fonts/CenturyOldStyle-Italic-webfont.svg +240 -0
- data/docs/source/fonts/CenturyOldStyle-Italic-webfont.ttf +0 -0
- data/docs/source/fonts/CenturyOldStyle-Italic-webfont.woff +0 -0
- data/docs/source/fonts/CenturyOldStyle-Regular-webfont.eot +0 -0
- data/docs/source/fonts/CenturyOldStyle-Regular-webfont.svg +240 -0
- data/docs/source/fonts/CenturyOldStyle-Regular-webfont.ttf +0 -0
- data/docs/source/fonts/CenturyOldStyle-Regular-webfont.woff +0 -0
- data/docs/source/fonts/CenturyOldStyleCaps-Regular-webfont.eot +0 -0
- data/docs/source/fonts/CenturyOldStyleCaps-Regular-webfont.svg +240 -0
- data/docs/source/fonts/CenturyOldStyleCaps-Regular-webfont.ttf +0 -0
- data/docs/source/fonts/CenturyOldStyleCaps-Regular-webfont.woff +0 -0
- data/docs/source/fonts/FranklinGothic-Book-webfont.eot +0 -0
- data/docs/source/fonts/FranklinGothic-Book-webfont.svg +240 -0
- data/docs/source/fonts/FranklinGothic-Book-webfont.ttf +0 -0
- data/docs/source/fonts/FranklinGothic-Book-webfont.woff +0 -0
- data/docs/source/fonts/FranklinGothic-BookIt-webfont.eot +0 -0
- data/docs/source/fonts/FranklinGothic-BookIt-webfont.svg +240 -0
- data/docs/source/fonts/FranklinGothic-BookIt-webfont.ttf +0 -0
- data/docs/source/fonts/FranklinGothic-BookIt-webfont.woff +0 -0
- data/docs/source/fonts/FranklinGothic-Cd-webfont.eot +0 -0
- data/docs/source/fonts/FranklinGothic-Cd-webfont.svg +240 -0
- data/docs/source/fonts/FranklinGothic-Cd-webfont.ttf +0 -0
- data/docs/source/fonts/FranklinGothic-Cd-webfont.woff +0 -0
- data/docs/source/fonts/FranklinGothic-CdIt-webfont.eot +0 -0
- data/docs/source/fonts/FranklinGothic-CdIt-webfont.svg +240 -0
- data/docs/source/fonts/FranklinGothic-CdIt-webfont.ttf +0 -0
- data/docs/source/fonts/FranklinGothic-CdIt-webfont.woff +0 -0
- data/docs/source/fonts/FranklinGothic-Med-webfont.eot +0 -0
- data/docs/source/fonts/FranklinGothic-Med-webfont.svg +240 -0
- data/docs/source/fonts/FranklinGothic-Med-webfont.ttf +0 -0
- data/docs/source/fonts/FranklinGothic-Med-webfont.woff +0 -0
- data/docs/source/fonts/FranklinGothic-MedCd-webfont.eot +0 -0
- data/docs/source/fonts/FranklinGothic-MedCd-webfont.svg +240 -0
- data/docs/source/fonts/FranklinGothic-MedCd-webfont.ttf +0 -0
- data/docs/source/fonts/FranklinGothic-MedCd-webfont.woff +0 -0
- data/docs/source/fonts/FranklinGothic-MedCdIt-webfont.eot +0 -0
- data/docs/source/fonts/FranklinGothic-MedCdIt-webfont.svg +240 -0
- data/docs/source/fonts/FranklinGothic-MedCdIt-webfont.ttf +0 -0
- data/docs/source/fonts/FranklinGothic-MedCdIt-webfont.woff +0 -0
- data/docs/source/fonts/FranklinGothic-MedIt-webfont.eot +0 -0
- data/docs/source/fonts/FranklinGothic-MedIt-webfont.svg +240 -0
- data/docs/source/fonts/FranklinGothic-MedIt-webfont.ttf +0 -0
- data/docs/source/fonts/FranklinGothic-MedIt-webfont.woff +0 -0
- data/docs/source/fonts/License.txt +77 -0
- data/docs/source/fonts/susy.eot +0 -0
- data/docs/source/fonts/susy.svg +69 -0
- data/docs/source/fonts/susy.ttf +0 -0
- data/docs/source/fonts/susy.woff +0 -0
- data/docs/source/guides/getting-started.html.md +277 -0
- data/docs/source/guides/reference.html.md +658 -0
- data/docs/source/guides/upgrade-1-0.html.md +286 -0
- data/docs/source/humans.txt +45 -0
- data/docs/source/images/splash-iphone.png +0 -0
- data/docs/source/images/splash-iphone4.png +0 -0
- data/docs/source/images/splash-landscape.png +0 -0
- data/docs/source/images/splash-portrait.png +0 -0
- data/docs/source/index.html.md +87 -0
- data/docs/source/javascripts/jquery-1.7.1.min.js +4 -0
- data/docs/source/javascripts/jqwidont.js +5 -0
- data/docs/source/javascripts/modernizr-2.5.3.min.js +4 -0
- data/docs/source/javascripts/modernizr.selectors.js +55 -0
- data/docs/source/javascripts/viewport.js +9 -0
- data/docs/source/layouts/grid-types.haml +22 -0
- data/docs/source/layouts/layout.haml +34 -0
- data/docs/source/layouts/magic.haml +28 -0
- data/docs/source/partials/_contentinfo.haml +47 -0
- data/docs/source/partials/_demonav.haml +2 -0
- data/docs/source/partials/_google_analytics.haml +5 -0
- data/docs/source/partials/_head.haml +22 -0
- data/docs/source/partials/_javascripts.haml +4 -0
- data/docs/source/partials/_navigation.haml +15 -0
- data/docs/source/sites-using-susy.html.md +29 -0
- data/docs/source/stylesheets/_base/_base.scss +23 -0
- data/docs/source/stylesheets/_base/_colors.scss +47 -0
- data/docs/source/stylesheets/_base/_size.scss +49 -0
- data/docs/source/stylesheets/_base/_type.scss +19 -0
- data/docs/source/stylesheets/_demos/_demo.scss +28 -0
- data/docs/source/stylesheets/_demos/magic/_layout.scss +39 -0
- data/docs/source/stylesheets/_demos/magic/_style.scss +104 -0
- data/docs/source/stylesheets/_demos/types/_layouts.scss +88 -0
- data/docs/source/stylesheets/_demos/types/_template.scss +57 -0
- data/docs/source/stylesheets/_general/_century-oldstyle.scss +70 -0
- data/docs/source/stylesheets/_general/_font-license.scss +23 -0
- data/docs/source/stylesheets/_general/_fonts.scss +26 -0
- data/docs/source/stylesheets/_general/_franklin-gothic.scss +112 -0
- data/docs/source/stylesheets/_general/_icons.scss +86 -0
- data/docs/source/stylesheets/_general/_root.scss +79 -0
- data/docs/source/stylesheets/_general/_type.scss +114 -0
- data/docs/source/stylesheets/_layout.scss +48 -0
- data/docs/source/stylesheets/_modules/_ag-test.scss +59 -0
- data/docs/source/stylesheets/_modules/_banner.scss +61 -0
- data/docs/source/stylesheets/_modules/_contentinfo.scss +41 -0
- data/docs/source/stylesheets/_modules/_intro.scss +53 -0
- data/docs/source/stylesheets/_modules/_nav.scss +44 -0
- data/docs/source/stylesheets/_modules/_pages.scss +5 -0
- data/docs/source/stylesheets/_modules/_secondary.scss +22 -0
- data/docs/source/stylesheets/_modules/_toggle.scss +40 -0
- data/docs/source/stylesheets/_vendor/pygments/solarized.scss +65 -0
- data/docs/source/stylesheets/grid-types.css.scss +6 -0
- data/docs/source/stylesheets/magic.css.scss +6 -0
- data/docs/source/stylesheets/site.css.scss +27 -0
- data/lib/susy.rb +12 -1
- data/sass/README.md +33 -0
- data/sass/_susy.scss +55 -16
- data/sass/susy/_api.scss +39 -0
- data/sass/susy/_grids.scss +2 -0
- data/sass/susy/_gutters.scss +2 -0
- data/sass/susy/_helpers.scss +14 -0
- data/sass/susy/_language.scss +3 -0
- data/sass/susy/_math.scss +3 -0
- data/sass/susy/api/_float.scss +72 -0
- data/sass/susy/api/_isolation.scss +16 -0
- data/sass/susy/grids/_add.scss +10 -0
- data/sass/susy/grids/_find.scss +10 -0
- data/sass/susy/gutters/_add.scss +10 -0
- data/sass/susy/gutters/_find.scss +10 -0
- data/sass/susy/helpers/_background-grid.scss +65 -0
- data/sass/susy/helpers/_box-sizing.scss +25 -0
- data/sass/susy/helpers/_clearfix.scss +51 -0
- data/sass/susy/helpers/_columns.scss +15 -0
- data/sass/susy/helpers/_find.scss +63 -0
- data/sass/susy/helpers/_sass-lists.scss +71 -0
- data/sass/susy/helpers/_span-shared.scss +9 -0
- data/sass/susy/language/_parse-add.scss +19 -0
- data/sass/susy/language/_parse-list.scss +53 -0
- data/sass/susy/language/_span.scss +20 -0
- data/sass/susy/math/_columns.scss +70 -0
- data/sass/susy/math/_context.scss +3 -0
- data/sass/susy/math/_gutters.scss +11 -0
- data/templates/box-sizing/behaviors/box-sizing/boxsizing.htc +399 -0
- data/templates/box-sizing/behaviors/box-sizing/boxsizing.php +23 -0
- data/templates/box-sizing/manifest.rb +4 -0
- data/templates/project/README.md +59 -0
- data/templates/project/_base.scss +0 -10
- data/templates/project/behaviors/box-sizing/boxsizing.htc +399 -0
- data/templates/project/behaviors/box-sizing/boxsizing.php +23 -0
- data/templates/project/manifest.rb +3 -0
- data/templates/project/screen.scss +0 -8
- metadata +200 -43
- data/Manifest +0 -39
- data/Rakefile +0 -19
- data/VERSION +0 -1
- data/sass/susy/_background.scss +0 -18
- data/sass/susy/_functions.scss +0 -376
- data/sass/susy/_grid.scss +0 -286
- data/sass/susy/_isolation.scss +0 -51
- data/sass/susy/_margin.scss +0 -93
- data/sass/susy/_media.scss +0 -112
- data/sass/susy/_padding.scss +0 -92
- data/sass/susy/_settings.scss +0 -56
- data/sass/susy/_support.scss +0 -198
- data/sass/susy/_units.scss +0 -159
- data/susy.gemspec +0 -35
- data/test/config.rb +0 -10
- data/test/css/background.css +0 -16
- data/test/css/bleed.css +0 -20
- data/test/css/functions.css +0 -7
- data/test/css/grid.css +0 -134
- data/test/css/isolation.css +0 -46
- data/test/css/margin.css +0 -20
- data/test/css/media.css +0 -101
- data/test/css/padding.css +0 -12
- data/test/scss/background.scss +0 -11
- data/test/scss/bleed.scss +0 -19
- data/test/scss/functions.scss +0 -15
- data/test/scss/grid.scss +0 -77
- data/test/scss/isolation.scss +0 -19
- data/test/scss/margin.scss +0 -27
- data/test/scss/media.scss +0 -50
- data/test/scss/padding.scss +0 -19
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module GuideHelpers
|
|
2
|
+
def page_title
|
|
3
|
+
title = "Susy: "
|
|
4
|
+
if data.page.title
|
|
5
|
+
title << data.page.title
|
|
6
|
+
else
|
|
7
|
+
title << "Responsive grids for Compass"
|
|
8
|
+
end
|
|
9
|
+
title
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def page_side_content
|
|
13
|
+
side_content = false
|
|
14
|
+
if data.page.side_content
|
|
15
|
+
side_content = data.page.side_content
|
|
16
|
+
end
|
|
17
|
+
side_content
|
|
18
|
+
end
|
|
19
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Grid Types
|
|
3
|
+
stylesheet: "grid-types.css"
|
|
4
|
+
pagenav: >
|
|
5
|
+
<ul>
|
|
6
|
+
<li><a href="#demo-magic">Magic</a></li>
|
|
7
|
+
<li><a href="#demo-fluid">Fluid</a></li>
|
|
8
|
+
<li><a href="#demo-static">Static</a></li>
|
|
9
|
+
<li><a href="#demo-mix">Mixing <span class="amp">&</span> Matching</a></li>
|
|
10
|
+
</ul>
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Different Grid Types
|
|
14
|
+
|
|
15
|
+
You can build grids of all kinds with Susy.
|
|
16
|
+
Define you grid using any unit of measurement
|
|
17
|
+
(ems, pixels, percentages, inches, etc.)
|
|
18
|
+
and then determine how and when
|
|
19
|
+
you want that grid responding to the viewport.
|
|
20
|
+
|
|
21
|
+
Susy converts all internal grid-widths into percentages,
|
|
22
|
+
so that once you have a grid
|
|
23
|
+
it is **able** to respond and flex in any way you choose.
|
|
24
|
+
How the grid responds depends on the outer container.
|
|
25
|
+
|
|
26
|
+
Here are a few examples
|
|
27
|
+
of grids with different container styles.
|
|
28
|
+
|
|
29
|
+
### <a href="#demo-magic" id="demo-magic">The Magic Grid</a>
|
|
30
|
+
|
|
31
|
+
The default grid in Susy is what I call "the magic grid".
|
|
32
|
+
Fluid on the inside,
|
|
33
|
+
with an elastic container max-width.
|
|
34
|
+
The em-width makes it responsive to font sizes,
|
|
35
|
+
while the max-width setting makes it responsive to window sizes.
|
|
36
|
+
|
|
37
|
+
:::scss
|
|
38
|
+
// Setting up the Magic Grid
|
|
39
|
+
$total-columns: 12; // 12 columns
|
|
40
|
+
$column-width: 4em; // columns are 4em wide
|
|
41
|
+
$gutter-width: 1em; // with 1em gutters
|
|
42
|
+
$grid-padding: 1em; // and 1em padding on the grid container
|
|
43
|
+
|
|
44
|
+
.magic-container { @include container; }
|
|
45
|
+
|
|
46
|
+
<aside class="magic-container">
|
|
47
|
+
<h4>Magic grid: <b>.magic-container</b></h4>
|
|
48
|
+
<p>
|
|
49
|
+
12 columns,
|
|
50
|
+
4em width,
|
|
51
|
+
1em gutters,
|
|
52
|
+
1em padding.
|
|
53
|
+
Magic.
|
|
54
|
+
</p>
|
|
55
|
+
</aside>
|
|
56
|
+
|
|
57
|
+
What we've defined is a simple elastic grid,
|
|
58
|
+
but by default the outer container width
|
|
59
|
+
will be set as a max-width,
|
|
60
|
+
making this a magic grid.
|
|
61
|
+
|
|
62
|
+
You can also have px-based magic grids,
|
|
63
|
+
and so on,
|
|
64
|
+
though I find them somewhat less magical.
|
|
65
|
+
What make it a magic grid
|
|
66
|
+
is the fact that it collapses with the browser at smaller sizes,
|
|
67
|
+
but remains set-width at larger sizes.
|
|
68
|
+
|
|
69
|
+
There is a more complete
|
|
70
|
+
[mobile-first magic grid demo](/demos/magic/)
|
|
71
|
+
if you are interested.
|
|
72
|
+
|
|
73
|
+
### <a href="#demo-fluid" id="demo-fluid">The Fluid Grid</a>
|
|
74
|
+
|
|
75
|
+
There are many ways to build a fluid grid with Susy.
|
|
76
|
+
You could simply replace all the em-widths above
|
|
77
|
+
with percentage widths.
|
|
78
|
+
But that's actually the hard way,
|
|
79
|
+
unless you know exactly what percentages you want to use.
|
|
80
|
+
Let me show you some easier options.
|
|
81
|
+
|
|
82
|
+
Say you want to build a fluid grid
|
|
83
|
+
based on the [960gs](http://960.gs/) dimensions:
|
|
84
|
+
|
|
85
|
+
:::scss
|
|
86
|
+
// A Fluid Grid based on 960gs
|
|
87
|
+
$total-columns: 12;
|
|
88
|
+
$column-width: 60px;
|
|
89
|
+
$gutter-width: 20px;
|
|
90
|
+
$grid-padding: 10px;
|
|
91
|
+
|
|
92
|
+
That's a good start.
|
|
93
|
+
We now have a 960px magic grid.
|
|
94
|
+
Turning that into a fluid grid is simple:
|
|
95
|
+
|
|
96
|
+
:::scss
|
|
97
|
+
// Make it fluid!
|
|
98
|
+
$container-style: fluid;
|
|
99
|
+
|
|
100
|
+
.fluid-container { @include container; }
|
|
101
|
+
|
|
102
|
+
<aside class="fluid-container">
|
|
103
|
+
<h4>Fluid grid #1: <b>.fluid-container</b></h4>
|
|
104
|
+
<p>
|
|
105
|
+
12 columns,
|
|
106
|
+
60px initial width,
|
|
107
|
+
20px initial gutters,
|
|
108
|
+
10px initial padding.
|
|
109
|
+
Fluid.
|
|
110
|
+
</p>
|
|
111
|
+
</aside>
|
|
112
|
+
|
|
113
|
+
That's it.
|
|
114
|
+
You have a fluid grid
|
|
115
|
+
based on the dimensions of the 960gs.
|
|
116
|
+
By default the container is set to 100% width,
|
|
117
|
+
but you can override that as well:
|
|
118
|
+
|
|
119
|
+
:::scss
|
|
120
|
+
// Make it smaller
|
|
121
|
+
$container-width: 60%;
|
|
122
|
+
|
|
123
|
+
.fluid-60-container { @include container; }
|
|
124
|
+
|
|
125
|
+
<aside class="fluid-60-container">
|
|
126
|
+
<h4>Fluid grid #2: <b>.fluid-60-container</b></h4>
|
|
127
|
+
<p>Same as above, but contained at 60%.</p>
|
|
128
|
+
</aside>
|
|
129
|
+
|
|
130
|
+
### <a href="#demo-static" id="demo-static">The Static Grid</a>
|
|
131
|
+
|
|
132
|
+
Perhaps you don't want your grid to respond
|
|
133
|
+
to the size of the viewport at all.
|
|
134
|
+
By telling Susy you want a "static" grid,
|
|
135
|
+
Susy will apply your container-width
|
|
136
|
+
directly to the "width" property.
|
|
137
|
+
|
|
138
|
+
This is your more standard grid type.
|
|
139
|
+
Most "elastic" and "fixed" grids fit this category.
|
|
140
|
+
Unlike the magic grid, it doesn't collapse.
|
|
141
|
+
|
|
142
|
+
Let's take our first grid and make it static:
|
|
143
|
+
|
|
144
|
+
:::scss
|
|
145
|
+
// Setting up the Static Grid
|
|
146
|
+
$total-columns: 12;
|
|
147
|
+
$column-width: 4em;
|
|
148
|
+
$gutter-width: 1em;
|
|
149
|
+
$grid-padding: 1em;
|
|
150
|
+
|
|
151
|
+
$container-style: static;
|
|
152
|
+
|
|
153
|
+
.static-container { @include container; }
|
|
154
|
+
|
|
155
|
+
<aside class="static-container">
|
|
156
|
+
<h4>Static elastic grid: <b>.static-container</b></h4>
|
|
157
|
+
<p>
|
|
158
|
+
12 columns,
|
|
159
|
+
4em width,
|
|
160
|
+
1em gutters,
|
|
161
|
+
1em padding.
|
|
162
|
+
Static.
|
|
163
|
+
</p>
|
|
164
|
+
</aside>
|
|
165
|
+
|
|
166
|
+
### <a href="#demo-mix" id="demo-mix">Mixing and matching</a>
|
|
167
|
+
|
|
168
|
+
Using those same 4 basic settings,
|
|
169
|
+
and the two advanced override settings,
|
|
170
|
+
you can create nearly any grid without doing any math.
|
|
171
|
+
|
|
172
|
+
Want the 960 grid system
|
|
173
|
+
updated to 1140px?
|
|
174
|
+
|
|
175
|
+
:::scss
|
|
176
|
+
// The 960gs in 1140px
|
|
177
|
+
$total-columns: 12;
|
|
178
|
+
$column-width: 60px;
|
|
179
|
+
$gutter-width: 20px;
|
|
180
|
+
$grid-padding: 10px;
|
|
181
|
+
|
|
182
|
+
$container-style: static;
|
|
183
|
+
$container-width: 1140px;
|
|
184
|
+
|
|
185
|
+
.larger-960-container { @include container; }
|
|
186
|
+
|
|
187
|
+
<aside class="larger-960-container">
|
|
188
|
+
<h4>Larger 960-based grid: <b>.larger-960-container</b></h4>
|
|
189
|
+
<p>
|
|
190
|
+
12 columns,
|
|
191
|
+
60px width,
|
|
192
|
+
20px gutters,
|
|
193
|
+
10px padding.
|
|
194
|
+
Static,
|
|
195
|
+
1140px total width.
|
|
196
|
+
</p>
|
|
197
|
+
</aside>
|
|
198
|
+
|
|
199
|
+
Why not make it elastic and magic?
|
|
200
|
+
|
|
201
|
+
:::scss
|
|
202
|
+
// The 960gs in ems
|
|
203
|
+
$total-columns: 12;
|
|
204
|
+
$column-width: 60px;
|
|
205
|
+
$gutter-width: 20px;
|
|
206
|
+
$grid-padding: 10px;
|
|
207
|
+
|
|
208
|
+
$container-style: magic;
|
|
209
|
+
$container-width: 60em;
|
|
210
|
+
|
|
211
|
+
.elastic-960-container { @include container; }
|
|
212
|
+
|
|
213
|
+
<aside class="elastic-960-container">
|
|
214
|
+
<h4>Elastic 960 grid: <b>.elastic-960-container</b></h4>
|
|
215
|
+
<p>
|
|
216
|
+
12 columns,
|
|
217
|
+
60px width,
|
|
218
|
+
20px gutters,
|
|
219
|
+
10px padding.
|
|
220
|
+
Magic elastic,
|
|
221
|
+
60em total width.
|
|
222
|
+
</p>
|
|
223
|
+
</aside>
|
|
224
|
+
|
|
225
|
+
Or we can make a magic-elastic grid,
|
|
226
|
+
defined in percentages:
|
|
227
|
+
|
|
228
|
+
:::scss
|
|
229
|
+
// Elastic grid as percentages
|
|
230
|
+
$total-columns: 12;
|
|
231
|
+
$column-width: 6%;
|
|
232
|
+
$gutter-width: 2%;
|
|
233
|
+
$grid-padding: 1%;
|
|
234
|
+
|
|
235
|
+
$container-style: magic;
|
|
236
|
+
$container-width: 50em;
|
|
237
|
+
|
|
238
|
+
.elastic-percentage-container { @include container; }
|
|
239
|
+
|
|
240
|
+
<aside class="elastic-percentage-container">
|
|
241
|
+
<h4>Elastic magic grid, defined as percentages: <b>.elastic-percentage-container</b></h4>
|
|
242
|
+
<p>
|
|
243
|
+
12 columns,
|
|
244
|
+
6% width,
|
|
245
|
+
2% gutters,
|
|
246
|
+
1% padding.
|
|
247
|
+
Magic elastic,
|
|
248
|
+
50em total width.
|
|
249
|
+
</p>
|
|
250
|
+
</aside>
|
|
251
|
+
|
|
252
|
+
Play around.
|
|
253
|
+
Start to add breakpoints,
|
|
254
|
+
with different grids at different sizes,
|
|
255
|
+
or just pick the grid best suited for your site:
|
|
256
|
+
magic-elastic,
|
|
257
|
+
magic-fixed,
|
|
258
|
+
static-elastic,
|
|
259
|
+
static-fixed,
|
|
260
|
+
fluid,
|
|
261
|
+
defined as one but displayed as another...
|
|
262
|
+
The possibilities are endless.
|
|
263
|
+
Have fun!
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Demos
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Demos
|
|
6
|
+
|
|
7
|
+
- [Different grid types](grid-types)
|
|
8
|
+
- [Mobile-first "magic" grids](magic)
|
|
9
|
+
|
|
10
|
+
### Elsewhere
|
|
11
|
+
|
|
12
|
+
- [Off-Canvas layout with Susy][off-canvas]
|
|
13
|
+
- [Nettuts: Responsive Grids With Susy][nettuts]
|
|
14
|
+
|
|
15
|
+
[nettuts]: http://net.tutsplus.com/tutorials/html-css-techniques/responsive-grids-with-susy/
|
|
16
|
+
[off-canvas]: http://oddbird.net/2012/11/27/susy-off-canvas/
|
|
17
|
+
|
|
18
|
+
Have a tutorial you'd like to see?
|
|
19
|
+
[Contact us][twitter],
|
|
20
|
+
or [write it yourself][github].
|
|
21
|
+
|
|
22
|
+
[twitter]: http://twitter.com/compasssusy
|
|
23
|
+
[github]: https://github.com/ericam/susy/tree/master/docs/source/demos
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Demos
|
|
3
|
+
stylesheet: "magic.css"
|
|
4
|
+
aside: >
|
|
5
|
+
<h3>In this demo:</h3>
|
|
6
|
+
<p>
|
|
7
|
+
Build a mobile-first layout
|
|
8
|
+
with a combination fluid/elastic grid,
|
|
9
|
+
responding smoothly to font and browser sizes,
|
|
10
|
+
without doing any math.
|
|
11
|
+
</p>
|
|
12
|
+
pagenav: >
|
|
13
|
+
<h3>Skip to:</h3>
|
|
14
|
+
<ul>
|
|
15
|
+
<li><a href="#demo-settings">Basic Settings</a></li>
|
|
16
|
+
<li><a href="#demo-mobile">Mobile Layout</a></li>
|
|
17
|
+
<li><a href="#demo-breakpoints">Breakpoints</a></li>
|
|
18
|
+
<li><a href="#demo-screen">Large-Screens</a></li>
|
|
19
|
+
<li><a href="#demo-complete">Complete Layout</a></li>
|
|
20
|
+
</ul>
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Mobile-First Magic Grids
|
|
24
|
+
|
|
25
|
+
All Susy sites are fluid on the inside,
|
|
26
|
+
but my favorite of the Susy options is
|
|
27
|
+
what I call the Magic Grid.
|
|
28
|
+
Fluid on the inside and elastic on the outside,
|
|
29
|
+
the magic grid responds to both font and window size
|
|
30
|
+
while keeping you in control of typographic line lengths.
|
|
31
|
+
|
|
32
|
+
This demo will lay out the steps
|
|
33
|
+
for building its own mobile-first layout
|
|
34
|
+
based on Susy's default Magic Grid.
|
|
35
|
+
|
|
36
|
+
### <a href="#demo-settings" id="demo-settings">Basic Settings</a>
|
|
37
|
+
|
|
38
|
+
We'll start by defining
|
|
39
|
+
our mobile-first grid.
|
|
40
|
+
We'll keep the default grid sizes,
|
|
41
|
+
and just change the number of columns used:
|
|
42
|
+
|
|
43
|
+
:::scss
|
|
44
|
+
$total-columns : 7;
|
|
45
|
+
$column-width : 4em;
|
|
46
|
+
$gutter-width : 1em;
|
|
47
|
+
$grid-padding : $gutter-width;
|
|
48
|
+
|
|
49
|
+
In this case I decided that 7 columns
|
|
50
|
+
was a good line-length for the main content.
|
|
51
|
+
While that's larger than most mobile devices,
|
|
52
|
+
the site will flex to fit them as well.
|
|
53
|
+
|
|
54
|
+
We've set `$column-width: 4em`,
|
|
55
|
+
but Susy doesn't apply that directly.
|
|
56
|
+
That will be used to determine the outer container width
|
|
57
|
+
(using `max-width` unless [otherwise instructed][overrides]),
|
|
58
|
+
and then to figure out percentages internally.
|
|
59
|
+
|
|
60
|
+
Think of these settings as a max-width
|
|
61
|
+
for your initial layout.
|
|
62
|
+
|
|
63
|
+
[overrides]: http://susy.oddbird.net/guides/reference/#ref-container-override
|
|
64
|
+
|
|
65
|
+
### <a href="#demo-mobile" id="demo-mobile">Mobile Layout</a>
|
|
66
|
+
|
|
67
|
+
The first step in applying our Susy grid is to
|
|
68
|
+
define our [container][container]:
|
|
69
|
+
|
|
70
|
+
:::scss
|
|
71
|
+
.page { @include container; }
|
|
72
|
+
|
|
73
|
+
I wrote the source order in a way
|
|
74
|
+
that makes sense to me
|
|
75
|
+
even when the sidebars move inline with the main content.
|
|
76
|
+
|
|
77
|
+
:::yaml
|
|
78
|
+
- .page
|
|
79
|
+
- .banner
|
|
80
|
+
- .pagenav
|
|
81
|
+
- .main
|
|
82
|
+
- .summary
|
|
83
|
+
- .content
|
|
84
|
+
- .contentinfo
|
|
85
|
+
|
|
86
|
+
We're going to keep the mobile layout simple and linear,
|
|
87
|
+
but I want the footer to have a red background
|
|
88
|
+
that encompasses the [grid-padding][grid-padding].
|
|
89
|
+
In order to do that,
|
|
90
|
+
I apply negative margins equal to `$grid-padding`,
|
|
91
|
+
and add it back in as padding to the footer:
|
|
92
|
+
|
|
93
|
+
:::scss
|
|
94
|
+
.contentinfo {
|
|
95
|
+
margin: 0 0 - $grid-padding;
|
|
96
|
+
padding: 0 $grid-padding;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
Add in some style and typography,
|
|
100
|
+
and we're done with the mobile layout.
|
|
101
|
+
|
|
102
|
+
[container]: http://susy.oddbird.net/guides/reference/#ref-container
|
|
103
|
+
[grid-padding]: http://susy.oddbird.net/guides/reference/#ref-grid-padding
|
|
104
|
+
|
|
105
|
+
### <a href="#demo-breakpoints" id="demo-breakpoints">Breakpoints</a>
|
|
106
|
+
|
|
107
|
+
I'm only adding one layout [breakpoint][breakpoint] to this page,
|
|
108
|
+
although you can add as many as you want.
|
|
109
|
+
|
|
110
|
+
As soon as there is enough room for 12 columns,
|
|
111
|
+
we'll jump to a 12-column grid,
|
|
112
|
+
and bring our two sidebars into play.
|
|
113
|
+
|
|
114
|
+
Let's set that breakpoint as a variable,
|
|
115
|
+
since we'll need it several times:
|
|
116
|
+
|
|
117
|
+
:::scss
|
|
118
|
+
$break: 12;
|
|
119
|
+
|
|
120
|
+
We could get more complex,
|
|
121
|
+
switching to 12 columns at an arbitrary min-width (`$break: 40em 12`),
|
|
122
|
+
or adding a fallback class for older versions of IE (`$break: 12 lt-ie9`),
|
|
123
|
+
but I don't think we need either one in this case.
|
|
124
|
+
|
|
125
|
+
Let's update the container
|
|
126
|
+
to respond to our new breakpoint:
|
|
127
|
+
|
|
128
|
+
:::scss
|
|
129
|
+
.page {
|
|
130
|
+
@include container($total-columns, $break);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
We're using the shortcut here,
|
|
134
|
+
setting multiple containers in a single command.
|
|
135
|
+
The first argument uses the default layout (`$total-columns`)
|
|
136
|
+
which doesn't trigger any media-queries,
|
|
137
|
+
the second uses our 12-column breakpoint.
|
|
138
|
+
This serves the same function as the longhand
|
|
139
|
+
using [at-breakpoint][at-breakpoint]:
|
|
140
|
+
|
|
141
|
+
:::scss
|
|
142
|
+
.page {
|
|
143
|
+
@include container;
|
|
144
|
+
@include at-breakpoint($break) {
|
|
145
|
+
@include container;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
However, the shorthand also performs some optimizations for us,
|
|
150
|
+
using `set-container-width` instead of `container` inside the breakpoint.
|
|
151
|
+
Since we know the other container settings are already in place,
|
|
152
|
+
all we need to override is the container's width.
|
|
153
|
+
you can also do that longhand too, if you like:
|
|
154
|
+
|
|
155
|
+
:::scss
|
|
156
|
+
.page {
|
|
157
|
+
@include container;
|
|
158
|
+
@include at-breakpoint($break) {
|
|
159
|
+
@include set-container-width;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
The longhand can be useful
|
|
164
|
+
if you have other operations to perform inside the breakpoint.
|
|
165
|
+
In our case, we can move on to laying out our 12-column grid.
|
|
166
|
+
|
|
167
|
+
[breakpoint]: http://susy.oddbird.net/guides/reference/#ref-media-layouts
|
|
168
|
+
[at-breakpoint]: http://susy.oddbird.net/guides/reference/#ref-at-breakpoint
|
|
169
|
+
|
|
170
|
+
### <a href="#demo-screen" id="demo-screen">Large-Screen Layout</a>
|
|
171
|
+
|
|
172
|
+
Let's start with the banner.
|
|
173
|
+
It should span the full width,
|
|
174
|
+
but have 2 of 12 columns [prefixed][prefix] as padding on the left.
|
|
175
|
+
|
|
176
|
+
Since the banner didn't have any layout styles
|
|
177
|
+
in our mobile layout,
|
|
178
|
+
we can place the entire selector block
|
|
179
|
+
inside a breakpoint:
|
|
180
|
+
|
|
181
|
+
:::scss
|
|
182
|
+
@include at-breakpoint($break) {
|
|
183
|
+
.banner { @include prefix(2,$break); }
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
Notice that I'm using `$break` as the `context` argument.
|
|
187
|
+
That way if I decide to change it,
|
|
188
|
+
I won't have to worry about updating all the contexts.
|
|
189
|
+
|
|
190
|
+
Next comes the pagenav,
|
|
191
|
+
which we want to set as a sidebar
|
|
192
|
+
[spanning][span-columns] 2 of the available 12 columns.
|
|
193
|
+
We can add that to the same breakpoint block
|
|
194
|
+
we already created.
|
|
195
|
+
|
|
196
|
+
:::scss
|
|
197
|
+
@include at-breakpoint($break) {
|
|
198
|
+
.banner { @include prefix(2,$break); }
|
|
199
|
+
.pagenav { @include span-columns(2,$break); }
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
The main content will fill the remaining space,
|
|
203
|
+
spanning 10 of 12 columns,
|
|
204
|
+
including the final right-most "[omega][omega]" column.
|
|
205
|
+
Adding that to what we have:
|
|
206
|
+
|
|
207
|
+
:::scss
|
|
208
|
+
@include at-breakpoint($break) {
|
|
209
|
+
.banner { @include prefix(2,$break); }
|
|
210
|
+
.pagenav { @include span-columns(2,$break); }
|
|
211
|
+
.main { @include span-columns(10 omega, $break); }
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
Inside the main content
|
|
215
|
+
we have a summary (which becomes a second sidebar),
|
|
216
|
+
and content that occupies the main area.
|
|
217
|
+
The content spans 7 of the main 10,
|
|
218
|
+
while the summary spans the remaining 3 (omega) of 10:
|
|
219
|
+
|
|
220
|
+
:::scss
|
|
221
|
+
@include at-breakpoint($break) {
|
|
222
|
+
.banner { @include prefix(2,$break); }
|
|
223
|
+
.pagenav { @include span-columns(2,$break); }
|
|
224
|
+
.main {
|
|
225
|
+
$main-columns: 10;
|
|
226
|
+
@include span-columns($main-columns omega, $break);
|
|
227
|
+
.content { @include span-columns(7,$main-columns) }
|
|
228
|
+
.summary { @include span-columns(3 omega, $main-columns) }
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
(Again, notice I'm using `$main-columns` for defining columns and contexts.)
|
|
233
|
+
|
|
234
|
+
That works, even though the summary comes first in our source.
|
|
235
|
+
Applying `omega` to an element
|
|
236
|
+
automatically pushes it to the end.
|
|
237
|
+
|
|
238
|
+
All we have left is the footer.
|
|
239
|
+
With 12 columns available now,
|
|
240
|
+
we can replace the grid-padding trick
|
|
241
|
+
with a few columns of padding on either side.
|
|
242
|
+
Let's create a new breakpoint block for that
|
|
243
|
+
inside the footer block we already have.
|
|
244
|
+
We also need to clear the floated content above,
|
|
245
|
+
which is easy enough with plain CSS:
|
|
246
|
+
|
|
247
|
+
:::scss
|
|
248
|
+
.contentinfo {
|
|
249
|
+
margin: 0 0 - $grid-padding;
|
|
250
|
+
padding: 0 $grid-padding;
|
|
251
|
+
@include at-breakpoint($break) {
|
|
252
|
+
clear: both;
|
|
253
|
+
margin: 0;
|
|
254
|
+
@include pad(2,3,$break);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
And we're done. The rest is [stylish icing][styles].
|
|
259
|
+
|
|
260
|
+
[prefix]: http://susy.oddbird.net/guides/reference/#ref-prefix
|
|
261
|
+
[span-columns]: http://susy.oddbird.net/guides/reference/#ref-span-columns
|
|
262
|
+
[omega]: http://susy.oddbird.net/guides/reference/#ref-omega
|
|
263
|
+
[styles]: https://github.com/ericam/susy/blob/master/docs/source/stylesheets/_demos/magic/_style.scss
|
|
264
|
+
|
|
265
|
+
### <a href="#demo-complete" id="demo-complete">Complete Layout Styles</a>
|
|
266
|
+
|
|
267
|
+
In the end,
|
|
268
|
+
we have an entirely responsive layout
|
|
269
|
+
defined in just a few simple and meaningful lines,
|
|
270
|
+
without doing any math at all:
|
|
271
|
+
|
|
272
|
+
:::scss
|
|
273
|
+
// Settings
|
|
274
|
+
|
|
275
|
+
$total-columns : 7;
|
|
276
|
+
$column-width : 4em;
|
|
277
|
+
$gutter-width : 1em;
|
|
278
|
+
$grid-padding : $gutter-width;
|
|
279
|
+
|
|
280
|
+
$break : 12;
|
|
281
|
+
|
|
282
|
+
// Container
|
|
283
|
+
|
|
284
|
+
.page {
|
|
285
|
+
@include container($total-columns, $break);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Layout
|
|
289
|
+
|
|
290
|
+
@include at-breakpoint($break) {
|
|
291
|
+
.banner { @include prefix(2,$break); }
|
|
292
|
+
.pagenav { @include span-columns(2,$break); }
|
|
293
|
+
.main {
|
|
294
|
+
$main-columns: 10;
|
|
295
|
+
@include span-columns($main-columns omega, $break);
|
|
296
|
+
.content { @include span-columns(7,$main-columns) }
|
|
297
|
+
.summary { @include span-columns(3 omega, $main-columns) }
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.contentinfo {
|
|
302
|
+
clear: both;
|
|
303
|
+
margin: 0 0 - $grid-padding;
|
|
304
|
+
padding: 0 $grid-padding;
|
|
305
|
+
@include at-breakpoint($break) {
|
|
306
|
+
margin: 0;
|
|
307
|
+
@include pad(2,3,$break);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
**Note**:
|
|
312
|
+
Due to a known Sass bug,
|
|
313
|
+
if you are using an IE fallback class,
|
|
314
|
+
you can not apply `at-breakpoint` at the document root.
|
|
315
|
+
This should be fixed soon.
|
|
316
|
+
In the meantime,
|
|
317
|
+
breakpoints with fallback classes must be nested
|
|
318
|
+
inside another selector.
|
|
319
|
+
We're not using the fallback,
|
|
320
|
+
so we're ok.
|