neat 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.rspec +2 -0
  2. data/CONTRIBUTING.md +4 -2
  3. data/NEWS.md +17 -12
  4. data/README.md +7 -9
  5. data/Rakefile +20 -0
  6. data/app/assets/stylesheets/_neat.scss +8 -0
  7. data/app/assets/stylesheets/grid/_fill-parent.scss +7 -0
  8. data/app/assets/stylesheets/grid/_global-variables.scss +4 -0
  9. data/app/assets/stylesheets/grid/_grid.scss +0 -205
  10. data/app/assets/stylesheets/grid/_media.scss +51 -0
  11. data/app/assets/stylesheets/grid/_outer-container.scss +8 -0
  12. data/app/assets/stylesheets/grid/_pad.scss +8 -0
  13. data/app/assets/stylesheets/grid/_row.scss +16 -0
  14. data/app/assets/stylesheets/grid/_shift.scss +6 -0
  15. data/app/assets/stylesheets/grid/_span-columns.scss +58 -0
  16. data/app/assets/stylesheets/grid/_to-deprecate.scss +52 -0
  17. data/lib/neat/version.rb +1 -1
  18. data/lib/tasks/install.rake +0 -2
  19. data/neat.gemspec +4 -0
  20. data/spec/neat/columns_spec.rb +61 -0
  21. data/spec/neat/container_spec.rb +17 -0
  22. data/spec/neat/media_spec.rb +47 -0
  23. data/spec/neat/omega_spec.rb +57 -0
  24. data/spec/neat/pad_spec.rb +34 -0
  25. data/spec/neat/row_spec.rb +41 -0
  26. data/spec/neat/shift_spec.rb +37 -0
  27. data/spec/spec_helper.rb +25 -0
  28. data/spec/support/bourbon_support.rb +9 -0
  29. data/spec/support/matchers/be_contained_in.rb +10 -0
  30. data/spec/support/matchers/have_rule.rb +33 -0
  31. data/spec/support/parser_support.rb +9 -0
  32. data/spec/support/sass_support.rb +10 -0
  33. data/test/_setup.scss +4 -0
  34. data/test/media.scss +31 -0
  35. data/test/omega.scss +35 -0
  36. data/test/outer-container.scss +7 -0
  37. data/test/pad.scss +17 -0
  38. data/test/row.scss +26 -0
  39. data/test/shift.scss +27 -0
  40. data/test/span-columns.scss +17 -0
  41. metadata +108 -13
@@ -0,0 +1,6 @@
1
+ @mixin shift($n-columns: 1) {
2
+ margin-left: $n-columns * flex-grid(1, $parent-columns) + $n-columns * flex-gutter($parent-columns);
3
+
4
+ // Reset nesting context
5
+ $parent-columns: $grid-columns;
6
+ }
@@ -0,0 +1,58 @@
1
+ @mixin span-columns($span: $columns of $container-columns, $display: block) {
2
+
3
+ $columns: nth($span, 1);
4
+ $container-columns: container-span($span);
5
+ $display-table: false;
6
+
7
+ @if $container-columns != $grid-columns {
8
+ $parent-columns: $container-columns;
9
+ }
10
+
11
+ @else {
12
+ $parent-columns: $grid-columns;
13
+ }
14
+
15
+ @if $container-display-table == true {
16
+ $display-table: true;
17
+ }
18
+
19
+ @else if $display == table {
20
+ $display-table: true;
21
+ }
22
+
23
+ @else {
24
+ $display-table: false;
25
+ }
26
+
27
+ @if $display-table {
28
+ display: table-cell;
29
+ padding-right: flex-gutter($container-columns);
30
+ width: flex-grid($columns, $container-columns) + flex-gutter($container-columns);
31
+
32
+ &:last-child {
33
+ width: flex-grid($columns, $container-columns);
34
+ padding-right: 0;
35
+ }
36
+ }
37
+
38
+ @else if $display == inline-block {
39
+ @include inline-block;
40
+ margin-right: flex-gutter($container-columns);
41
+ width: flex-grid($columns, $container-columns);
42
+
43
+ &:last-child {
44
+ margin-right: 0;
45
+ }
46
+ }
47
+
48
+ @else {
49
+ display: block;
50
+ float: left;
51
+ margin-right: flex-gutter($container-columns);
52
+ width: flex-grid($columns, $container-columns);
53
+
54
+ &:last-child {
55
+ margin-right: 0;
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,52 @@
1
+ @mixin breakpoint($query:$feature $value $columns, $total-columns: $grid-columns) {
2
+ @warn "The breakpoint() mixin was renamed to media() in Neat 1.0. Please update your project with the new syntax before the next version bump.";
3
+
4
+ @if length($query) == 1 {
5
+ @media screen and ($default-feature: nth($query, 1)) {
6
+ $default-grid-columns: $grid-columns;
7
+ $grid-columns: $total-columns;
8
+ @content;
9
+ $grid-columns: $default-grid-columns;
10
+ }
11
+ }
12
+
13
+ @else if length($query) == 2 {
14
+ @media screen and (nth($query, 1): nth($query, 2)) {
15
+ $default-grid-columns: $grid-columns;
16
+ $grid-columns: $total-columns;
17
+ @content;
18
+ $grid-columns: $default-grid-columns;
19
+ }
20
+ }
21
+
22
+ @else if length($query) == 3 {
23
+ @media screen and (nth($query, 1): nth($query, 2)) {
24
+ $default-grid-columns: $grid-columns;
25
+ $grid-columns: nth($query, 3);
26
+ @content;
27
+ $grid-columns: $default-grid-columns;
28
+ }
29
+ }
30
+
31
+ @else if length($query) == 4 {
32
+ @media screen and (nth($query, 1): nth($query, 2)) and (nth($query, 3): nth($query, 4)) {
33
+ $default-grid-columns: $grid-columns;
34
+ $grid-columns: $total-columns;
35
+ @content;
36
+ $grid-columns: $default-grid-columns;
37
+ }
38
+ }
39
+
40
+ @else if length($query) == 5 {
41
+ @media screen and (nth($query, 1): nth($query, 2)) and (nth($query, 3): nth($query, 4)) {
42
+ $default-grid-columns: $grid-columns;
43
+ $grid-columns: nth($query, 5);
44
+ @content;
45
+ $grid-columns: $default-grid-columns;
46
+ }
47
+ }
48
+
49
+ @else {
50
+ @warn "Wrong number of arguments for breakpoint(). Read the documentation for more details.";
51
+ }
52
+ }
@@ -1,3 +1,3 @@
1
1
  module Neat
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -1,5 +1,3 @@
1
- # Needed for pre-3.1.
2
-
3
1
  require "fileutils"
4
2
  require "find"
5
3
 
@@ -26,4 +26,8 @@ Neat is an open source grid framework built on top of Bourbon with the aim of be
26
26
 
27
27
  s.add_development_dependency('aruba', '~> 0.4')
28
28
  s.add_development_dependency('rake')
29
+ s.add_development_dependency('css_parser')
30
+ s.add_development_dependency('rspec')
31
+ s.add_development_dependency('rdoc')
32
+ s.add_development_dependency('bundler')
29
33
  end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe "@include span-columns()" do
4
+ let (:identifier) {"span-columns"}
5
+
6
+ before(:all) do
7
+ ParserSupport.parse_file(identifier)
8
+ end
9
+
10
+ context "with argument '6' in a twelve-column grid" do
11
+ it "sets width in percentage" do
12
+ expect('.span-columns-default').to have_rule('width: 48.82117%')
13
+ end
14
+
15
+ it "sets gutter in percentage" do
16
+ expect('.span-columns-default').to have_rule('margin-right: 2.35765%')
17
+ end
18
+
19
+ it "sets display to block" do
20
+ expect('.span-columns-default').to have_rule('display: block')
21
+ end
22
+
23
+ it "sets float to left" do
24
+ expect('.span-columns-default').to have_rule('float: left')
25
+ end
26
+
27
+ it "removes gutter from last element" do
28
+ expect('.span-columns-default:last-child').to have_rule('margin-right: 0')
29
+ end
30
+ end
31
+
32
+ context "when nested" do
33
+ it "sets relative width in percentage" do
34
+ expect('.span-columns-default .span-columns-nested').to have_rule('width: 30.11389%')
35
+ end
36
+
37
+ it "sets relative gutter in percentage" do
38
+ expect('.span-columns-default .span-columns-nested').to have_rule('margin-right: 4.82916%')
39
+ end
40
+ end
41
+
42
+ context "with argument 'table'" do
43
+ it "sets display to table-cell" do
44
+ expect('.span-columns-table').to have_rule('display: table-cell')
45
+ end
46
+
47
+ it "sets padding in percentage" do
48
+ expect('.span-columns-table').to have_rule('padding-right: 2.35765%')
49
+ end
50
+
51
+ it "substracts gutter from width of last element" do
52
+ expect('.span-columns-table:last-child').to have_rule('width: 48.82117%')
53
+ end
54
+ end
55
+
56
+ context "with argument 'inline-block'" do
57
+ it "sets display to inline-block" do
58
+ expect('.span-columns-inline-block').to have_rule('display: inline-block')
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe "@include outer-container()" do
4
+ let (:identifier) {"outer-container"}
5
+
6
+ before(:all) do
7
+ ParserSupport.parse_file(identifier)
8
+ end
9
+
10
+ it "adds clearfix" do
11
+ expect('.container-default:after').to have_rule('clear: both')
12
+ end
13
+
14
+ it "sets max-width" do
15
+ expect('.container-default').to have_rule('max-width: 960px')
16
+ end
17
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe "@include media()" do
4
+ let (:identifier) {"media"}
5
+
6
+ before(:all) do
7
+ ParserSupport.parse_file(identifier)
8
+ end
9
+
10
+ context "with argument '481px'" do
11
+ it "outputs (min-width: 481px)" do
12
+ expect('.media-default').to be_contained_in('screen and (min-width: 481px)')
13
+ end
14
+ end
15
+
16
+ context "with argument 'max-width 480px'" do
17
+ it "outputs (max-width: 480px)" do
18
+ expect('.media-max-width').to be_contained_in('screen and (max-width: 480px)')
19
+ end
20
+ end
21
+
22
+ context "with argument 'min-width 320px max-width 480px'" do
23
+ it "outputs (min-width: 320px) and (max-width: 480px)" do
24
+ expect('.media-min-max-width').to be_contained_in('screen and (min-width: 320px) and (max-width: 480px)')
25
+ end
26
+ end
27
+
28
+ context "with argument '481px, 6'" do
29
+ it "outputs (min-width: 481px)" do
30
+ expect('.change-media-context').to be_contained_in('screen and (min-width: 481px)')
31
+ end
32
+
33
+ it "uses a 6-column grid" do
34
+ expect('.change-media-context').to have_rule('width: 100%')
35
+ end
36
+ end
37
+
38
+ context "with argument 'max-width 480px 6'" do
39
+ it "outputs (max-width: 480px)" do
40
+ expect('.change-media-context-shorthand').to be_contained_in('screen and (max-width: 480px)')
41
+ end
42
+
43
+ it "uses a 6-column grid" do
44
+ expect('.change-media-context').to have_rule('width: 100%')
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe "@include omega()" do
4
+ let (:identifier) {"omega"}
5
+
6
+ before(:all) do
7
+ ParserSupport.parse_file(identifier)
8
+ end
9
+
10
+ context "with no argument" do
11
+ it "removes right margin" do
12
+ expect('.omega-default').to have_rule('margin-right: 0')
13
+ end
14
+ end
15
+
16
+ context "with argument 'table'" do
17
+ it "removes right padding" do
18
+ expect('.omega-table').to have_rule('padding-right: 0')
19
+ end
20
+ end
21
+
22
+ context "with argument 'block, left'" do
23
+ it "removes left margin" do
24
+ expect('.omega-block-left').to have_rule('margin-left: 0')
25
+ end
26
+ end
27
+
28
+ context "with argument 'table, left'" do
29
+ it "removes left padding" do
30
+ expect('.omega-table-left').to have_rule('padding-left: 0')
31
+ end
32
+ end
33
+
34
+ context "with argument '4n'" do
35
+ it "removes right margin of nth-child(4n)" do
36
+ expect('.omega-nth-default:nth-child(4n)').to have_rule('margin-right: 0')
37
+ end
38
+ end
39
+
40
+ context "with argument '4n table'" do
41
+ it "removes right padding of nth-child(4n)" do
42
+ expect('.omega-nth-table:nth-child(4n)').to have_rule('padding-right: 0')
43
+ end
44
+ end
45
+
46
+ context "with argument '4n block, left'" do
47
+ it "removes left margin of nth-child(4n)" do
48
+ expect('.omega-nth-default-left:nth-child(4n)').to have_rule('margin-left: 0')
49
+ end
50
+ end
51
+
52
+ context "with argument '4n table, left'" do
53
+ it "removes left padding of nth-child(4n)" do
54
+ expect('.omega-nth-table-left:nth-child(4n)').to have_rule('padding-left: 0')
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe "@include pad()" do
4
+ let (:identifier) {"pad"}
5
+
6
+ before(:all) do
7
+ ParserSupport.parse_file(identifier)
8
+ end
9
+
10
+ context "with no argument" do
11
+ it "sets padding to gutter percentage" do
12
+ expect('.pad-default').to have_rule('padding: 2.35765%')
13
+ end
14
+ end
15
+
16
+ context "with argument '20px'" do
17
+ it "sets padding to '20px'" do
18
+ expect('.pad-explicit').to have_rule('padding: 20px')
19
+ end
20
+ end
21
+
22
+ context "with argument '30px 20px 10px 5px'" do
23
+ it "sets padding to '30px 20px 10px 5px'" do
24
+ expect('.pad-shorthand').to have_rule('padding: 30px 20px 10px 5px')
25
+ end
26
+ end
27
+
28
+ context "with argument 'default' keyword" do
29
+ it "replaces 'default' with gutter percentage" do
30
+ expect('.pad-shorthand-default').to have_rule('padding: 30px 2.35765% 10px 2.35765%')
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe "@include row()" do
4
+ let (:identifier) {"row"}
5
+
6
+ before(:all) do
7
+ ParserSupport.parse_file(identifier)
8
+ end
9
+
10
+ context "with no argument" do
11
+ it "adds clearfix" do
12
+ expect('.row-default:after').to have_rule('clear: both')
13
+ end
14
+
15
+ it "sets display to block" do
16
+ expect('.row-default').to have_rule('display: block')
17
+ end
18
+ end
19
+
20
+ context "with argument 'table'" do
21
+ it "sets display to table" do
22
+ expect('.row-table').to have_rule('display: table')
23
+ end
24
+
25
+ it "forces table-cell display on child elements" do
26
+ expect('.row-table-reset .block-child').to have_rule('display: table-cell')
27
+ end
28
+ end
29
+
30
+ context "with reset-display()" do
31
+ it "resets display to block" do
32
+ expect('.no-row').to have_rule('display: block')
33
+ end
34
+ end
35
+
36
+ context "with invalid display argument" do
37
+ it "sets display to block" do
38
+ expect('.row-invalid-display').to have_rule('display: block')
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe "@include shift()" do
4
+ let (:identifier) {"shift"}
5
+
6
+ before(:all) do
7
+ ParserSupport.parse_file(identifier)
8
+ end
9
+
10
+ context "with no argument" do
11
+ it "shifts element one column to the left" do
12
+ expect('.shift-default').to have_rule('margin-left: 8.5298%')
13
+ end
14
+ end
15
+
16
+ context "with argument '2'" do
17
+ it "shifts element 2 column to the left" do
18
+ expect('.shift-positive').to have_rule('margin-left: 17.05961%')
19
+ end
20
+ end
21
+
22
+ context "with argument '-3'" do
23
+ it "shifts element 3 column to the right" do
24
+ expect('.shift-negative').to have_rule('margin-left: -25.58941%')
25
+ end
26
+ end
27
+
28
+ context "when nested" do
29
+ it "shifts element relative to its parent" do
30
+ expect('.shifted-parent .shifted-child').to have_rule('margin-left: 34.94305%')
31
+ end
32
+
33
+ it "resets nesting context" do
34
+ expect('.post-nested-shift').to have_rule('margin-left: 17.05961%')
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'neat'
5
+ require 'aruba/api'
6
+ require 'css_parser'
7
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
8
+
9
+ RSpec.configure do |config|
10
+ config.include BourbonSupport
11
+ config.include SassSupport
12
+ config.include CssParser
13
+ config.include ParserSupport
14
+ config.include Aruba::Api
15
+
16
+ config.before(:all) do
17
+ install_bourbon_files
18
+ generate_css
19
+ end
20
+
21
+ config.after(:all) do
22
+ remove_bourbon_files
23
+ clean_up
24
+ end
25
+ end