longitude 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/.rvmrc +38 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +8 -0
- data/README.md +196 -0
- data/Rakefile +7 -0
- data/lib/longitude/version.rb +3 -0
- data/lib/longitude.rb +8 -0
- data/longitude.gemspec +27 -0
- data/spec/integration/columns_spec.rb +26 -0
- data/spec/integration/compatibility_mode_spec.rb +21 -0
- data/spec/integration/full_width_spec.rb +47 -0
- data/spec/integration/gutters_spec.rb +52 -0
- data/spec/integration/media_queries_spec.rb +42 -0
- data/spec/spec_helper.rb +20 -0
- data/stylesheets/longitude.scss +77 -0
- metadata +106 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p125@longitude"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
if [[ $- == *i* ]] # check for interactive shells
|
29
|
+
then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
|
30
|
+
else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
|
31
|
+
fi
|
32
|
+
else
|
33
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
34
|
+
rvm --create use "$environment_id" || {
|
35
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
36
|
+
return 1
|
37
|
+
}
|
38
|
+
fi
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Copyright (c) 2012 Johannes Edelstam
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
8
|
+
|
data/README.md
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
Longitude - Make a responsive SCSS grid
|
2
|
+
=======================================
|
3
|
+
|
4
|
+
Longitude lets you easily create responsive, mobile first layouts with
|
5
|
+
minimal footprint in an unobtrusive way!
|
6
|
+
|
7
|
+
Longitude is more a collection of calculations than just a normal CSS
|
8
|
+
grid. It lets you define how elements will be styled based on your
|
9
|
+
class hierarchy, not the framework's.
|
10
|
+
|
11
|
+
|
12
|
+
Install
|
13
|
+
-------
|
14
|
+
|
15
|
+
To use it together with SASS just do:
|
16
|
+
|
17
|
+
gem install jede-longitude --source http://gems.github.com
|
18
|
+
|
19
|
+
Or if you are using [Bundler](http://gembundler.com/) just type add it
|
20
|
+
to your Gemfile
|
21
|
+
|
22
|
+
gem 'longitude', git: 'git@github.com:jede/longitude.git'
|
23
|
+
|
24
|
+
Usage
|
25
|
+
-----
|
26
|
+
|
27
|
+
Start off by creating a stylesheet for the parts of your design that
|
28
|
+
will depend on the screen width. Let's place it in a directory called
|
29
|
+
stylesheets. Also create a folder named public where the compiled CSS
|
30
|
+
files will be placed.
|
31
|
+
|
32
|
+
./stylesheets/layout.scss
|
33
|
+
|
34
|
+
|
35
|
+
Longitude calculates responsive widths for you, but to make it easier to
|
36
|
+
relate to actual pixels at the different breakpoints, it uses base values
|
37
|
+
in pixels. Breakpoints are then calculated by different column counts.
|
38
|
+
Longitude defaults to 60px wide columns with 10px gutters on each side.
|
39
|
+
|
40
|
+
+------+-------------------------------+------+
|
41
|
+
| | | |
|
42
|
+
| | | |
|
43
|
+
| 10px | 60px | 10px |
|
44
|
+
| | | |
|
45
|
+
| | | |
|
46
|
+
+------+-------------------------------+------+
|
47
|
+
|
48
|
+
This can be changed by updating the following config variables:
|
49
|
+
|
50
|
+
```scss
|
51
|
+
$longitude-gutter-width: 5px; // Use 5px gutters instead of the standard 10px
|
52
|
+
$longitude-column-width: 70px; // Use 70px columns instead of the standard 60px
|
53
|
+
```
|
54
|
+
|
55
|
+
Let's say that you want two responsive breakpoints, one for devices up
|
56
|
+
to 320px wide and then one 960px breakpoint for larger screens. Between
|
57
|
+
these breakpoints we want the design to be fluid.
|
58
|
+
|
59
|
+
Then our layout.scss could look like this:
|
60
|
+
|
61
|
+
```scss
|
62
|
+
@import 'longitude';
|
63
|
+
|
64
|
+
@include longitude(4 12) {
|
65
|
+
article {
|
66
|
+
margin: 0 gutter();
|
67
|
+
width: columns(4);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
```
|
71
|
+
|
72
|
+
If you are running bundler you could now run the following
|
73
|
+
|
74
|
+
bundle exec sass --watch stylesheets:public -r longitude
|
75
|
+
|
76
|
+
This then translates to CSS, and public/layout.css will now look like:
|
77
|
+
|
78
|
+
```css
|
79
|
+
@media (max-width: 320px) {
|
80
|
+
article {
|
81
|
+
margin: 0 3.125%;
|
82
|
+
width: 93.75%; } }
|
83
|
+
@media (min-width: 321px) and (max-width: 960px) {
|
84
|
+
article {
|
85
|
+
margin: 0 1.042%;
|
86
|
+
width: 31.25%; } }
|
87
|
+
@media (min-width: 961px) {
|
88
|
+
article {
|
89
|
+
margin: 0 10px;
|
90
|
+
width: 300px; } }
|
91
|
+
```
|
92
|
+
|
93
|
+
Documentation
|
94
|
+
---------------
|
95
|
+
|
96
|
+
### columns($columns, $surrounding-gutters: false)
|
97
|
+
|
98
|
+
Calculates the width for the specified number of columns. You can choose
|
99
|
+
to include surrounding gutters, this is normally not preferred since you
|
100
|
+
add that as gutters with margin.
|
101
|
+
|
102
|
+
### gutter($gutters: 1)
|
103
|
+
|
104
|
+
Calculates the width for the specified number of gutters (normally one).
|
105
|
+
|
106
|
+
### column-count()
|
107
|
+
|
108
|
+
The column count for this breakpoint. If you call @include longitude(4 12)
|
109
|
+
then column-count() would return 4, 12 and then 12 again.
|
110
|
+
|
111
|
+
### full-width($outer-gutters: true)
|
112
|
+
|
113
|
+
Returns the "full-width" for the current breakpoint. This is
|
114
|
+
equivalent to calling columns(column-count(), $surrounding-gutters: true)
|
115
|
+
|
116
|
+
|
117
|
+
### absolute-width($columns)
|
118
|
+
|
119
|
+
The width in pixels for the specified columns. So with standard config
|
120
|
+
values absolute-width(12) would return 960px.
|
121
|
+
|
122
|
+
### @include gutters
|
123
|
+
|
124
|
+
This is a mixin to add gutters to a selector.
|
125
|
+
|
126
|
+
```scss
|
127
|
+
section {
|
128
|
+
@include gutters;
|
129
|
+
}
|
130
|
+
```
|
131
|
+
|
132
|
+
If the current gutter width is 5%, it will compile to:
|
133
|
+
|
134
|
+
```css
|
135
|
+
section {
|
136
|
+
margin-left: 5%;
|
137
|
+
margin-right: 5%;
|
138
|
+
}
|
139
|
+
```
|
140
|
+
|
141
|
+
### @include longitude($columns-list){ ... }
|
142
|
+
|
143
|
+
Creates breakpoints for the columns in the columns list. It also adds an
|
144
|
+
extra breakpoint for all width larger then the maximum provided with in
|
145
|
+
real pixels. This makes debugging and adjusting much easier and ensures
|
146
|
+
pixel perfectness when the largest breakpoint is used.
|
147
|
+
|
148
|
+
Compatibility mode (dealing with Internet Explorer)
|
149
|
+
---------------------------------------------------
|
150
|
+
|
151
|
+
Longitude uses the mobile first approach. This means that when you visit
|
152
|
+
the site with a browser that doesn't handle media queries the smallest
|
153
|
+
layout will be the default (i.e. we assume that it is a feature phone).
|
154
|
+
However IE 8 and down doesn't support media queries. This means that IE
|
155
|
+
8 will get the same layout as old mobile phones (which it maybe deserves
|
156
|
+
though). But fear not!
|
157
|
+
|
158
|
+
This solution is inspired from a solution that [Henrik Ekelöf](http://twitter.com/#!/henrikekelo)
|
159
|
+
presented in a [blog post](http://henrikekelof.se/2011/12/responsive-design-med-sass-for-alla-webblasare.html) (unfortunately in swedish).
|
160
|
+
|
161
|
+
In short the idea is to load different main stylesheets depending on if
|
162
|
+
the user uses IE 8 or lower. Say that you include your layout stylesheet
|
163
|
+
in your application.scss file like this. Then you could create an
|
164
|
+
application-ie.scss file that only loads in IE 8 and lower.
|
165
|
+
|
166
|
+
This will look something like this in your HTML:
|
167
|
+
|
168
|
+
```html
|
169
|
+
<!--[if (gte IE 9)|!(IE)]><!-->
|
170
|
+
<link rel="stylesheet" href="public/application.css">
|
171
|
+
<!--<![endif]-->
|
172
|
+
|
173
|
+
<!--[if (lte IE 8)]>
|
174
|
+
<link rel="stylesheet" href="public/application-ie.css">
|
175
|
+
<![endif]-->
|
176
|
+
```
|
177
|
+
|
178
|
+
The application-ie.scss would then set a config variable:
|
179
|
+
|
180
|
+
|
181
|
+
```scss
|
182
|
+
|
183
|
+
$longitude-compatibility-mode: true;
|
184
|
+
|
185
|
+
@import 'layout';
|
186
|
+
```
|
187
|
+
|
188
|
+
When setting this variable only the largest breakpoint without any media
|
189
|
+
queries will be rendered.
|
190
|
+
|
191
|
+
|
192
|
+
Author
|
193
|
+
------
|
194
|
+
|
195
|
+
Longitude is created by Johannes Edelstam. It is licensed under the MIT
|
196
|
+
License, just like SASS.
|
data/Rakefile
ADDED
data/lib/longitude.rb
ADDED
data/longitude.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "longitude/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "longitude"
|
7
|
+
s.version = Longitude::VERSION
|
8
|
+
s.authors = ["Johannes Edelstam"]
|
9
|
+
s.email = ["johannes@edelst.am"]
|
10
|
+
s.homepage = "http://github.com/jede.longitude"
|
11
|
+
s.summary = %q{A responsive, mobile first, unobtrusive SCSS grid!}
|
12
|
+
s.description = """Longitude lets you easily create responsive, mobile first layouts with minimal footprint in an unobtrusive way!
|
13
|
+
|
14
|
+
Longitude is more a collection of calculations than just a normal CSS grid. It lets you define how elements will be styled based on your class hierarchy, not the framework's."""
|
15
|
+
|
16
|
+
s.rubyforge_project = "longitude"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_development_dependency 'rake'
|
24
|
+
s.add_development_dependency "rspec"
|
25
|
+
|
26
|
+
s.add_runtime_dependency "sass", ">= 3.2.beta"
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Columns' do
|
4
|
+
describe 'standard column widths' do
|
5
|
+
before :each do
|
6
|
+
@css = render """
|
7
|
+
@include longitude(2 4) {
|
8
|
+
p { width: columns(2); }
|
9
|
+
}
|
10
|
+
"""
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'calculates width for maxed layout' do
|
14
|
+
#two columns 60px each, with two gutter widths of 10px in between
|
15
|
+
@css.should include("width: #{60 + 10 + 10 + 60}px;")
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'calculates width for 4 column layout' do
|
19
|
+
@css.should include("width: #{100.0 * 140/320}%;")
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'calculates width for 2 column layout' do
|
23
|
+
@css.should include("width: #{100.0 * 140/160}%;")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Compatibility mode' do
|
4
|
+
before :each do
|
5
|
+
@css = render """
|
6
|
+
$longitude-compatibility-mode: true;
|
7
|
+
|
8
|
+
@include longitude(2 4) {
|
9
|
+
p { width: columns(2); }
|
10
|
+
}
|
11
|
+
"""
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'disables media queries' do
|
15
|
+
@css.should_not include('@media')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'renders pixels' do
|
19
|
+
@css.should include('width: 140px;')
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Full width' do
|
4
|
+
describe 'and outer gutters' do
|
5
|
+
before :each do
|
6
|
+
@css = render """
|
7
|
+
@include longitude(2 4) {
|
8
|
+
p { width: full-width(); }
|
9
|
+
}
|
10
|
+
"""
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'calculates for maxed layout' do
|
14
|
+
@css.should include("width: 320px;")
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'calculates width for 4 column layout' do
|
18
|
+
@css.should include("width: 100%;")
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'calculates width for 2 column layout' do
|
22
|
+
@css.should include("width: 100%;")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'no outer gutters' do
|
27
|
+
before :each do
|
28
|
+
@css = render """
|
29
|
+
@include longitude(2 4) {
|
30
|
+
p { width: full-width($outer-gutters: false); }
|
31
|
+
}
|
32
|
+
"""
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'calculates for maxed layout' do
|
36
|
+
@css.should include("width: 300px;")
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'calculates width for 4 column layout' do
|
40
|
+
@css.should include("width: #{100 - 100.0 * 20/320}%;")
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'calculates width for 2 column layout' do
|
44
|
+
@css.should include("width: #{100 - 100.0 * 20/160}%;")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Gutters' do
|
4
|
+
describe 'function' do
|
5
|
+
before :each do
|
6
|
+
@css = render """
|
7
|
+
@include longitude(2 4) {
|
8
|
+
p { margin: 0 gutter(); }
|
9
|
+
}
|
10
|
+
"""
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'calculates correct gutter value for max layout' do
|
14
|
+
@css.should include("margin: 0 10px")
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'calculates correct gutter value for 4 column layout' do
|
18
|
+
@css.should include("margin: 0 #{100.0 * 10/320}%")
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'calculates correct gutter value for 2 column layout' do
|
22
|
+
@css.should include("margin: 0 #{100.0 * 10/160}%")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'mixin' do
|
27
|
+
before :each do
|
28
|
+
@css = render """
|
29
|
+
@include longitude(2 4) {
|
30
|
+
p { @include gutters; }
|
31
|
+
}
|
32
|
+
"""
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'calculates correct gutter value for max layout' do
|
36
|
+
@css.should include("margin-left: 10px")
|
37
|
+
@css.should include("margin-right: 10px")
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'calculates correct gutter value for 4 column layout' do
|
41
|
+
gutter = 100.0 * 10/320
|
42
|
+
@css.should include("margin-left: #{gutter}%")
|
43
|
+
@css.should include("margin-right: #{gutter}%")
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'calculates correct gutter value for 2 column layout' do
|
47
|
+
gutter = 100.0 * 10/160
|
48
|
+
@css.should include("margin-left: #{gutter}%")
|
49
|
+
@css.should include("margin-right: #{gutter}%")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Media queries' do
|
4
|
+
describe 'standard column widths' do
|
5
|
+
before :each do
|
6
|
+
@css = render """
|
7
|
+
@include longitude(2 4) {
|
8
|
+
p { color: blue; }
|
9
|
+
}
|
10
|
+
"""
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'includes lower bound' do
|
14
|
+
@css.should include('@media (max-width: 160px)')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'includes the middle step' do
|
18
|
+
@css.should include('@media (min-width: 161px) and (max-width: 320px)')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'includes the higher bound' do
|
22
|
+
@css.should include('@media (min-width: 321px)')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'custom column widths' do
|
27
|
+
before :each do
|
28
|
+
@css = render """
|
29
|
+
$longitude-gutter-width: 5px;
|
30
|
+
$longitude-column-width: 10px;
|
31
|
+
|
32
|
+
@include longitude(2 4) {
|
33
|
+
p { color: blue; }
|
34
|
+
}
|
35
|
+
"""
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'renders the middle stop according to the custom widths' do
|
39
|
+
@css.should include('@media (min-width: 41px) and (max-width: 80px)')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
|
8
|
+
require 'sass'
|
9
|
+
require 'longitude'
|
10
|
+
|
11
|
+
def render(template)
|
12
|
+
template = "@import 'longitude'; " + template
|
13
|
+
Sass::Engine.new(template, syntax: :scss).render
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
18
|
+
config.run_all_when_everything_filtered = true
|
19
|
+
config.filter_run :focus
|
20
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
$longitude-gutter-width: 10px !default;
|
2
|
+
$longitude-column-width: 60px !default;
|
3
|
+
$longitude-compatibility-mode: false !default;
|
4
|
+
|
5
|
+
$longitude-column-count: 0;
|
6
|
+
$longitude-base-width: 100%;
|
7
|
+
|
8
|
+
@function absolute-width($columns) {
|
9
|
+
@return $columns * ($longitude-gutter-width * 2 + $longitude-column-width)
|
10
|
+
}
|
11
|
+
|
12
|
+
@function full-width($outer-gutters: true) {
|
13
|
+
@return columns(column-count(), $outer-gutters);
|
14
|
+
}
|
15
|
+
|
16
|
+
@function column-count() {
|
17
|
+
@return $longitude-column-count;
|
18
|
+
}
|
19
|
+
|
20
|
+
@function column-width(){
|
21
|
+
@return relative-width($longitude-column-width);
|
22
|
+
}
|
23
|
+
|
24
|
+
@function gutter-width(){
|
25
|
+
@return relative-width($longitude-gutter-width);
|
26
|
+
}
|
27
|
+
|
28
|
+
@function relative-width($width){
|
29
|
+
@return $longitude-base-width * $width / absolute-width(column-count());
|
30
|
+
}
|
31
|
+
|
32
|
+
@function columns($columns, $surrounding-gutters: false) {
|
33
|
+
$gutters: ($columns - 1) * 2;
|
34
|
+
@if $surrounding-gutters {
|
35
|
+
$gutters: $gutters + 2;
|
36
|
+
}
|
37
|
+
@return $gutters * gutter-width() + $columns * column-width();
|
38
|
+
}
|
39
|
+
|
40
|
+
@function gutter($gutters: 1) {
|
41
|
+
@return gutter-width() * $gutters;
|
42
|
+
}
|
43
|
+
|
44
|
+
@mixin gutters {
|
45
|
+
margin-left: gutter();
|
46
|
+
margin-right: gutter();
|
47
|
+
}
|
48
|
+
|
49
|
+
@mixin longitude($columns-list) {
|
50
|
+
$prev-column-count: 0;
|
51
|
+
$max-width: 0;
|
52
|
+
@each $column-count in $columns-list {
|
53
|
+
$longitude-column-count: $column-count;
|
54
|
+
@if $longitude-compatibility-mode == false {
|
55
|
+
$min-width: absolute-width($prev-column-count);
|
56
|
+
$max-width: absolute-width($column-count);
|
57
|
+
$query: '(max-width: #{$max-width})';
|
58
|
+
@if $min-width > 0 {
|
59
|
+
$query: '(min-width: #{$min-width + 1px}) and #{$query}';
|
60
|
+
}
|
61
|
+
@media $query {
|
62
|
+
@content;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
$prev-column-count: $column-count
|
66
|
+
}
|
67
|
+
// Last step, use pixels
|
68
|
+
$longitude-base-width: absolute-width(column-count());
|
69
|
+
@if $longitude-compatibility-mode {
|
70
|
+
@content;
|
71
|
+
} @else {
|
72
|
+
@media (min-width: ($max-width + 1px)) {
|
73
|
+
@content;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: longitude
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Johannes Edelstam
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70114280662980 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70114280662980
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70114280662540 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70114280662540
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sass
|
38
|
+
requirement: &70114280661940 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.2.beta
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70114280661940
|
47
|
+
description: ! 'Longitude lets you easily create responsive, mobile first layouts
|
48
|
+
with minimal footprint in an unobtrusive way!
|
49
|
+
|
50
|
+
|
51
|
+
Longitude is more a collection of calculations than just a normal CSS grid. It lets
|
52
|
+
you define how elements will be styled based on your class hierarchy, not the framework''s.'
|
53
|
+
email:
|
54
|
+
- johannes@edelst.am
|
55
|
+
executables: []
|
56
|
+
extensions: []
|
57
|
+
extra_rdoc_files: []
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- .rspec
|
61
|
+
- .rvmrc
|
62
|
+
- Gemfile
|
63
|
+
- MIT-LICENSE
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- lib/longitude.rb
|
67
|
+
- lib/longitude/version.rb
|
68
|
+
- longitude.gemspec
|
69
|
+
- spec/integration/columns_spec.rb
|
70
|
+
- spec/integration/compatibility_mode_spec.rb
|
71
|
+
- spec/integration/full_width_spec.rb
|
72
|
+
- spec/integration/gutters_spec.rb
|
73
|
+
- spec/integration/media_queries_spec.rb
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
- stylesheets/longitude.scss
|
76
|
+
homepage: http://github.com/jede.longitude
|
77
|
+
licenses: []
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project: longitude
|
96
|
+
rubygems_version: 1.8.10
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: A responsive, mobile first, unobtrusive SCSS grid!
|
100
|
+
test_files:
|
101
|
+
- spec/integration/columns_spec.rb
|
102
|
+
- spec/integration/compatibility_mode_spec.rb
|
103
|
+
- spec/integration/full_width_spec.rb
|
104
|
+
- spec/integration/gutters_spec.rb
|
105
|
+
- spec/integration/media_queries_spec.rb
|
106
|
+
- spec/spec_helper.rb
|