crispy-grid 0.1.3

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/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 Christian Peters
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Crispy Grid
2
+
3
+ ## Why should I use it?
4
+
5
+ In short, Crispy Grid closes the gap between easy-to-use grids for
6
+ simple web pages and doing everything by hand due to layout complexity.
7
+
8
+ ### Reason 1: No need for bending CSS layout semantics
9
+
10
+ CSS grid frameworks like Blueprint and 960.gs try to realize their
11
+ higher level concepts using only margins and relative positioning.
12
+
13
+ Often, this is in conflict with CSS box semantics.
14
+ In CSS, whitespace surrounding content should be expressed as padding of
15
+ the containing element. Margins should be used for defining whitespace
16
+ among sibling elements.
17
+
18
+ A common workaround for paddings and margins within a grid is using inner
19
+ wrapping elements which are save to style. This is unsemantic and
20
+ clutters up the template.
21
+
22
+ Crispy respects padding and border box properties.
23
+
24
+ Unlike [Lucid Grid](https://github.com/ezYZ/lucid) (which I recommend as
25
+ an alternative), padding and border width can be set along with the
26
+ column width in one statement. Crispy does the calculation for you.
27
+
28
+ ### Reason 2: There is no problem about being specific
29
+
30
+ Whenever you try to realize a page that simply does not fit into the
31
+ predefined columns, you are likely to catch yourself fighting with the grid.
32
+ Likewise, most grids are not meant to be applied on more than the big
33
+ containers (navigation, sidebar, main, etc.). Yet it would be nice to
34
+ have a tool for specifying the layout of the inner elements in a smart
35
+ way.
36
+
37
+ Crispy tries to support you even if you go beyond the main grid.
38
+
39
+ ## Usage
40
+
41
+ Pending. Please have a look at the source.
42
+
43
+ ## Installation
44
+
45
+ 1. In your Gemfile add:
46
+
47
+ gem 'crispy-grid'
48
+
49
+ 2. In your project configuration file (e.g. initializers/compass.rb)
50
+ add:
51
+
52
+ require 'crispy-grid'
53
+
54
+ 3. Customize and import the grid in your application stylesheet:
55
+
56
+ // Grid Configuration
57
+ $grid-column-width: 30px
58
+ $grid-gutter-width: 10px
59
+ $grid-columns: 25
60
+
61
+ @import crispy-grid
62
+
63
+ ## License
64
+
65
+ See MIT-LICENSE.
66
+
67
+ ## TODO
68
+
69
+ - Make use of @extend in order to reduce CSS output
70
+ - Return calculation of inner box width for further use as column width
71
+ of children
@@ -0,0 +1,3 @@
1
+ require 'compass'
2
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
3
+ Compass::Frameworks.register('crispy-grid', :path => extension_path)
@@ -0,0 +1,9 @@
1
+ // Crispy Grid Configuration
2
+ //==========================
3
+
4
+ // Grid Configuration
5
+ $grid-column-width: 30px !default
6
+ $grid-gutter-width: 10px !default
7
+ $grid-columns: 25 !default
8
+
9
+ @import crispy/grid
@@ -0,0 +1,126 @@
1
+ // Derived Variables
2
+ //==================
3
+ // Note that the gutter is only between the columns, i.e. you have 1 gutter less than columns
4
+ $grid-gutters: $grid-columns - 1
5
+ // These default settings result in a grid-width of 990 px
6
+ $grid-width: $grid-column-width * $grid-columns + $grid-gutter-width * $grid-gutters
7
+
8
+ // Public Methods
9
+ //===============
10
+
11
+ // Main Grid Helper Methods
12
+ //-------------------------
13
+ // $colspan should be the number of grid columns. You can override it with a fixed width if you must.
14
+ // You can also give a $padding and a $border-width, which is applied to both left and right by default.
15
+ // It is ensured that you do not break the grid by setting padding and a border.
16
+ // In order to differentiate between left and right padding/border-width you can set $different-right-padding/-border-width.
17
+ // Example: +grid(4, 10px, 15px) will set padding-left: 10px, padding-right: 15px and the element will have the same overall width as +grid(4).
18
+ // By default, the gutter is represented using margin-right, which can also be overridden.
19
+ =column($colspan, $padding: 0, $differing-right-padding: false, $border-width: 0, $differing-right-border-width: false, $gutter: $grid-gutter-width, $left-gutter: false, $subtract-border-from: false)
20
+ +column-behavior
21
+ +column-metrics($colspan, $padding, $differing-right-padding, $border-width, $differing-right-border-width, $gutter, $left-gutter, $subtract-border-from: $subtract-border-from)
22
+
23
+ // The last column should not have a gutter.
24
+ // Respectively, $gutter defaults to 0 in this mixin.
25
+ =last-column($colspan, $padding: 0, $differing-right-padding: false, $border-width: 0, $differing-right-border-width: false, $gutter: 0, $left-gutter: false, $subtract-border-from: false)
26
+ +column($colspan, $padding, $differing-right-padding, $border-width, $differing-right-border-width, $gutter, $left-gutter, $subtract-border-from)
27
+
28
+ // The only difference between the last and other columns is that the last column has margin-right set to 0.
29
+ =last
30
+ margin-right: 0
31
+
32
+ // A row spans the whole grid width, i.e. it is the only column in a row. This is just a more elegant way for writing +last-column($grid-columns).
33
+ =row($colspan: $grid-columns, $padding: 0, $differing-right-padding: false, $border-width: 0, $differing-right-border-width: false, $gutter: 0, $left-gutter: false, $subtract-border-from: false)
34
+ +last-column($colspan, $padding, $differing-right-padding, $border-width, $differing-right-border-width, $gutter, $left-gutter, $subtract-border-from)
35
+
36
+ // Use this mixin for your (none-floating) grid container.
37
+ // By default, it spans the whole grid-width and is centered.
38
+ // Unlike with columns, paddings and borders of a container do not affect its inner width
39
+ =grid-container($colspan: $grid-columns, $padding: 0, $differing-right-padding: false, $border-width: 0, $differing-right-border-width: false, $left-margin: auto, $right-margin: auto)
40
+ +column-metrics($colspan, $padding, $differing-right-padding, $border-width, $differing-right-border-width, $right-margin, $left-margin, true)
41
+ // As this grid system bases on the Float (Nearly) Everything method, this is necessary to enforce the container to enclose its content.
42
+ overflow: hidden
43
+
44
+ // Internal Methods
45
+ //=================
46
+ =column-behavior
47
+ float: left
48
+
49
+ =column-metrics($column-width, $padding: 0, $differing-right-padding: false, $border-width: 0, $differing-right-border-width: false, $gutter: $grid-gutter-width, $left-gutter: false, $container: false, $subtract-border-from: false)
50
+ // Convert column counts to widths with unit
51
+ $column-width: colspan-to-width($column-width)
52
+ $padding: colspan-to-width($padding, $include-last-gutter: true)
53
+ $differing-right-padding: colspan-to-width($differing-right-padding, $include-last-gutter: true)
54
+ $border-width: colspan-to-width($border-width, $include-last-gutter: true)
55
+ $differing-right-border-width: colspan-to-width($differing-right-border-width, $include-last-gutter: true)
56
+ @if is_column_count($gutter)
57
+ // It is assumed that the original gutter should also be preserved in addition to the one of the last column
58
+ $gutter: $grid-gutter-width + colspan-to-width($gutter, $include-last-gutter: true)
59
+ @if is_column_count($left-gutter)
60
+ $left-gutter: colspan-to-width($left-gutter, $include-last-gutter: true)
61
+
62
+ // Calculate derived metrics
63
+ $right-border-width: right-value($border-width, $differing-right-border-width)
64
+ $border-width-sum: left-and-right-sum($border-width, $differing-right-border-width)
65
+ $left-padding: if(($subtract-border-from == 'padding' or $subtract-border-from == 'left-padding') and $padding > 0, $padding - $border-width, $padding)
66
+ $right-padding: right-value($padding, $differing-right-padding)
67
+ $right-padding: if(($subtract-border-from == 'padding' or $subtract-border-from == 'right-padding') and $padding > 0, $right-padding - $right-border-width, $right-padding)
68
+ $padding-sum: left-and-right-sum($left-padding, $right-padding)
69
+
70
+ // Setting width
71
+ @if $container
72
+ // Paddings and borders do not affect the inner width of a container.
73
+ width: $column-width
74
+ @else
75
+ // Paddings and borders do not affect the outer width of a column.
76
+ width: $column-width - $padding-sum - $border-width-sum
77
+
78
+ // Setting other box attributes
79
+ padding:
80
+ left: $left-padding
81
+ right: $right-padding
82
+ border:
83
+ left-width: $border-width
84
+ right-width: $right-border-width
85
+ @if type_of($left-gutter) == number
86
+ margin-left: if(($subtract-border-from == 'gutter' or $subtract-border-from == 'left-gutter') and $left-gutter > 0, $gutter - $border-width, $left-gutter)
87
+ @else if $left-gutter
88
+ margin-left: $left-gutter
89
+ @if type_of($gutter) == number
90
+ margin-right: if(($subtract-border-from == 'gutter' or $subtract-border-from == 'right-gutter') and $gutter > 0, $gutter - $right-border-width, $gutter)
91
+ @else if $gutter
92
+ margin-right: $gutter
93
+
94
+ @function colspan-to-width($colspan, $include-last-gutter: false)
95
+ @if is_column_count($colspan)
96
+ @return column-count-to-width($colspan, $include-last-gutter)
97
+ @else
98
+ @return $colspan
99
+
100
+ @function is_column_count($colspan)
101
+ @if type_of($colspan) == 'number'
102
+ @if unitless($colspan) and $colspan > 0
103
+ @return true
104
+ @return false
105
+
106
+ @function column-count-to-width($column-count, $include-last-gutter: false)
107
+ @if $include-last-gutter
108
+ @return ($grid-column-width + $grid-gutter-width) * $column-count
109
+ @else
110
+ @return $grid-column-width * $column-count + $grid-gutter-width * ($column-count - 1)
111
+
112
+ // adds to comparable values or doubles the first one
113
+ @function left-and-right-sum($value, $differing-right-value)
114
+ @if type-of($differing-right-value) == number
115
+ @if comparable($value, $differing-right-value)
116
+ @return $value + $differing-right-value
117
+ @else
118
+ @warn "It is not possible to compute the sum of #{$value} and #{$differing-right-value}. Please make them comparable. Meanwhile, the result is set to #{$value * 2}."
119
+ @return $value * 2
120
+
121
+ // returns value unless numeric differing-right-value is given
122
+ @function right-value($value, $differing-right-value: false)
123
+ @if type-of($differing-right-value) == number
124
+ @return $differing-right-value
125
+ @else
126
+ @return $value
@@ -0,0 +1,18 @@
1
+ // Crispy Grid Configuration
2
+ //==========================
3
+ // Copy this into your app in order to customize the grid
4
+
5
+ // Grid Configuration
6
+ $grid-column-width: 30px
7
+ $grid-gutter-width: 10px
8
+ $grid-columns: 25
9
+
10
+ // Note that that there is always one gutter between two columns
11
+ // $grid-gutters: $grid-columns - 1
12
+
13
+ // The grid width is calculated from the values above
14
+ // $grid-width: $grid-column-width * $grid-columns + $grid-gutter-width * $grid-gutters
15
+ // For the default values, that is 30px * 25 + 10px * 24 = 990px
16
+
17
+ // This import statement has to be included in your application stylesheet
18
+ @import crispy-grid
@@ -0,0 +1,25 @@
1
+ stylesheet '_crispy-grid.sass', :media => 'screen, projection'
2
+
3
+ description "A Compass-based Grid that strives for lean & sane CSS and supports complex layouts"
4
+
5
+ help %Q{
6
+
7
+ --- Crispy Grid ---
8
+
9
+ A Compass-based Grid that strives for lean & sane CSS and supports complex layouts
10
+
11
+ For documentation, see crispy/_grid.sass
12
+
13
+ }
14
+
15
+ welcome_message %Q{
16
+
17
+
18
+ --- Crispy Grid ---
19
+
20
+ A Compass-based Grid that strives for lean & sane CSS and supports complex layouts
21
+
22
+ For documentation, see crispy/_grid.sass
23
+
24
+ }
25
+
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crispy-grid
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.3
6
+ platform: ruby
7
+ authors:
8
+ - Christian Peters
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-11-16 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: compass
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0.11"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: sass
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 3.1.0
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ description: In short, Crispy Grid closes the gap between easy-to-use grids for simple web pages and doing everything by hand due to layout complexity.
38
+ email: info@c-peters.net
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - README.md
47
+ - MIT-LICENSE
48
+ - lib/crispy-grid.rb
49
+ - stylesheets/_crispy-grid.sass
50
+ - stylesheets/crispy/_grid.sass
51
+ - templates/project/_crispy-grid.sass
52
+ - templates/project/manifest.rb
53
+ homepage: https://github.com/ChristianPeters/crispy-grid
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ requirements: []
74
+
75
+ rubyforge_project:
76
+ rubygems_version: 1.8.7
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: A Compass-based Grid that strives for lean & sane CSS and supports complex layouts
80
+ test_files: []
81
+