compass-griddle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Compass Griddle
2
+ A Compass plugin to use Griddle in your Compass projects.
3
+
4
+ For usage of Griddle, see: http://necolas.github.com/griddle/
5
+
6
+ ## Installation
7
+ Installing is easy. It's a RubyGem, so just type this on your command line:
8
+
9
+ $ gem install compass-griddle
10
+
11
+ Then, add it to a project:
12
+
13
+ ```
14
+ // Add this to compass.config (rails) or config.rb (other):
15
+ require 'griddle'
16
+
17
+ // Type this on your command line:
18
+ $ compass install griddle
19
+ ```
data/lib/griddle.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'compass'
2
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
3
+ Compass::Frameworks.register('griddle', :path => extension_path)
@@ -0,0 +1,2 @@
1
+ @import "griddle/grid-helpers";
2
+ @import "griddle/grid-core";
@@ -0,0 +1,97 @@
1
+ /* =============================================================================
2
+ Grid
3
+ ========================================================================== */
4
+
5
+ /*
6
+ * Example uses:
7
+ *
8
+ * <div class="grid">
9
+ * <div class="grid__cell unit-1-2"></div>
10
+ * <div class="grid__cell unit-1-2"></div>
11
+ * <div class="grid__cell unit-1-3"></div>
12
+ * <div class="grid__cell unit-1-3 before-1-3"></div>
13
+ * </div>
14
+ *
15
+ * <div class="grid grid--center">
16
+ * <div class="grid__cell unit-1-3"></div>
17
+ * <div class="grid__cell unit-1-3"></div>
18
+ * </div>
19
+ */
20
+
21
+ /* Grid core
22
+ ========================================================================== */
23
+
24
+ /*
25
+ * Grid container
26
+ * Must only contain `.grid` or `.grid__cell` components as children.
27
+ */
28
+
29
+ .grid {
30
+ display: block;
31
+ padding: 0;
32
+ margin: 0 -0.5 * $grid-gutter;
33
+ /* Ensure consistent default alignment */
34
+ text-align: $grid-direction;
35
+ /* Remove inter-unit whitespace for all non-monospace font-families
36
+ * If you're using a monospace base font, you will need to set the `grid`
37
+ * font-family to `sans-serif` and then redeclare the monospace font on
38
+ * the `grid__cell` objects.
39
+ */
40
+ letter-spacing: -0.31em;
41
+ word-spacing: -0.43em;
42
+ /* Protect against WebKit bug with optimizelegibility */
43
+ text-rendering: optimizespeed;
44
+ }
45
+
46
+ /*
47
+ * Child `grid` object adjustments
48
+ * Used for more complex fixed-fluid hybrid grids
49
+ */
50
+
51
+ .grid > .grid {
52
+ overflow: hidden;
53
+ margin-right: 0;
54
+ margin-left: 0;
55
+ }
56
+
57
+ /*
58
+ * Grid units
59
+ * No explicit width by default. Apply `.unit-x-y` classes.
60
+ */
61
+
62
+ .grid__cell {
63
+ width: 100%;
64
+ display: inline-block;
65
+ @include box-sizing(border-box);
66
+ margin: 0;
67
+ padding: 0 0.5 * $grid-gutter;
68
+ /* controls vertical positioning of units */
69
+ vertical-align: top;
70
+ /* keeps unit content correctly aligned */
71
+ text-align: $grid-direction;
72
+ /* reset text defaults */
73
+ letter-spacing: normal;
74
+ word-spacing: normal;
75
+ text-rendering: auto;
76
+ }
77
+
78
+ /*
79
+ * Modifier: horizontally center all grid units
80
+ * Allows for automatic unit centering irrespective of the number of
81
+ * units in the grid.
82
+ */
83
+
84
+ .grid--center {
85
+ text-align: center;
86
+ }
87
+
88
+ /*
89
+ * Modifier: horizontally center one unit
90
+ * Set a specific unit to be horizontally centered. Doesn't affect
91
+ * any other units. Can still contain a child `grid` object.
92
+ */
93
+
94
+ .grid__cell--center {
95
+ display: block;
96
+ margin: 0 auto;
97
+ }
@@ -0,0 +1,117 @@
1
+ // =============================================================================
2
+ // Variables, Mixins, and Functions
3
+ // =============================================================================
4
+
5
+ // Variables
6
+ // =============================================================================
7
+
8
+ $grid-direction:left !default; // switch to 'right' for rtl
9
+ $grid-gutter:20px !default; // can be px, em, or %
10
+
11
+ // Functions
12
+ // =============================================================================
13
+
14
+ // Find the greatest common factor
15
+ // of two integers
16
+ @function gcf($a, $b) {
17
+ @if $b == 0 {
18
+ @return $a;
19
+ }
20
+ @else {
21
+ @return gcf($b, $a % $b)
22
+ }
23
+ }
24
+
25
+ // Check if a list contains a value
26
+ @function contains($list, $value) {
27
+ @if type-of($list) == list {
28
+ @return not not index($list, $value);
29
+ }
30
+ @else {
31
+ @return $list == $value;
32
+ }
33
+ }
34
+
35
+
36
+ // Mixins
37
+ // =============================================================================
38
+
39
+ @mixin box-sizing ($box) {
40
+ -webkit-box-sizing: $box;
41
+ -moz-box-sizing: $box;
42
+ box-sizing: $box;
43
+ }
44
+
45
+ // Fluid grid units & offsets
46
+
47
+ // USAGE: provide a space-separated list of integers, each of which represents
48
+ // the number of parts that make up a grid component. Optionally provide a
49
+ // modifier suffix that can be used to adjust grids in different contexts (e.g.
50
+ // viewport dimensions)
51
+
52
+ // TODO: work out how to combine rules for numbers that share a greatest common
53
+ // factor without the unit-list actually containing the fraction to which they
54
+ // can both be reduced.
55
+
56
+ @mixin grid-build-units($units, $modifier: '') {
57
+ /* Proportional units
58
+ ========================================================================== */
59
+
60
+ /*
61
+ * Specify the proportional width of an object.
62
+ * Primarily for, but not limited to, use with `.grid__cell` components.
63
+ * Intentional redundancy build into each set of unit classes.
64
+ */
65
+
66
+ // step through each value in the list of units
67
+ @each $n in $units {
68
+ // this means we can avoid creating rules like `.unit-12-12 {}`
69
+ $x: $n - 1;
70
+
71
+ @for $i from 1 through $x {
72
+ // find the greatest common factor
73
+ $g: gcf($i, $n);
74
+ // initialize variables
75
+ $i-r: ();
76
+ $n-r: ();
77
+
78
+ @if $g > 1 {
79
+ // reduced value of $i
80
+ $i-r: $i/$g;
81
+ // reduced value of $n
82
+ $n-r: $n/$g;
83
+ }
84
+
85
+ // check if the reduced value of $n was also supplied
86
+ // in the list of units to be built
87
+ $canreduce: contains($units, $n-r);
88
+
89
+ // create units based on fractions
90
+ .unit-#{$i}-#{$n}#{$modifier} {
91
+ // if this unit can be reduced
92
+ // then extend the previous rule
93
+ @if $i-r and $canreduce {
94
+ @extend .unit-#{$i-r}-#{$n-r}#{$modifier};
95
+ }
96
+ // otherwise create a new % width
97
+ @else {
98
+ width: percentage($i / $n);
99
+ }
100
+ }
101
+
102
+ // create unit offsets based on fractions
103
+ .before-#{$i}-#{$n}#{$modifier} {
104
+ // if this offset can be reduced
105
+ // then extend the previous rule
106
+ @if $i-r and $canreduce {
107
+ @extend .before-#{$i-r}-#{$n-r}#{$modifier};
108
+ }
109
+ // otherwise create a new % margin
110
+ @else {
111
+ margin-#{$grid-direction}: percentage($i / $n);
112
+ }
113
+ }
114
+ }
115
+ }
116
+ }
117
+
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: compass-griddle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Leon de Rijke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: compass
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0.11'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0.11'
30
+ description: This Compass extension lets you use Griddle (by @necolas) in your Compass
31
+ projects.
32
+ email: leon@leonderijke.nl
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - README.md
38
+ - lib/griddle.rb
39
+ - stylesheets/griddle/_grid-helpers.scss
40
+ - stylesheets/griddle/_grid-core.scss
41
+ - stylesheets/_griddle.scss
42
+ homepage: https://github.com/leonderijke/compass-griddle
43
+ licenses: []
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 1.8.24
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Griddle for Compass
66
+ test_files: []