Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Add full width default for grid-column on null
Browse files Browse the repository at this point in the history
`grid-column` now defaults to a full width grid object. This will likely also
help avoid people using private functions to retrive grid settings.
  • Loading branch information
whmii committed Jul 22, 2016
1 parent a4196a1 commit e2bd4df
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contrib/patterns/_grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
}

.grid__column {
@include grid-column;
@include grid-column(1);
}

.grid__column--thirds {
Expand Down
1 change: 1 addition & 0 deletions core/_neat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
@import "neat/settings/settings";

@import "neat/functions/retrieve-neat-settings";
@import "neat/functions/neat-column-default";
@import "neat/functions/neat-column-width";
@import "neat/functions/neat-column-ratio";
@import "neat/functions/neat-parse-columns";
Expand Down
23 changes: 23 additions & 0 deletions core/neat/functions/_neat-column-default.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@charset "UTF-8";
/// Determine if a column count has been given.
/// If no columns have been given return the grid's total column count.
///
/// @argument {map} $grid
///
/// @argument {number (unitless) | null} $columns
///
/// @return {number}
///
/// @example scss
/// _neat-column-default($neat-grid, 4)
///
/// @access private

@function _neat-column-default($grid, $columns) {
@if $columns == null {
$_grid-columns: _retrieve-neat-setting($grid, columns);
@return $_grid-columns;
} @else {
@return $columns;
}
}
5 changes: 3 additions & 2 deletions core/neat/mixins/_grid-column.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@charset "UTF-8";
/// Creates Neat a grid column of requested size.
///
/// @argument {number (unitless)} $columns [1]
/// @argument {number (unitless)} $columns [null]
///
/// @argument {map} $grid [$neat-grid]
/// The grid used to generate the column.
Expand All @@ -18,7 +18,8 @@
/// margin-left: 20px;
/// }
@mixin grid-column($columns: 1, $grid: $neat-grid) {
@mixin grid-column($columns: null, $grid: $neat-grid) {
$columns: _neat-column-default($grid, $columns);
$_grid-columns: _retrieve-neat-setting($grid, columns);
$_grid-gutter: _retrieve-neat-setting($grid, gutter);

Expand Down
22 changes: 22 additions & 0 deletions spec/fixtures/functions/neat-column-default.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@import "setup";

$eighteen-grid: (
columns: 18,
gutter: 33px,
);

.neat-column-default-grid {
content: _neat-column-default($neat-grid, null);
}

.neat-column-default-grid-custom-col {
content: _neat-column-default($neat-grid, 10);
}

.neat-column-custom-grid {
content: _neat-column-default($eighteen-grid, null);
}

.neat-column-custom-grid-custom-col {
content: _neat-column-default($eighteen-grid, 10);
}
35 changes: 35 additions & 0 deletions spec/neat/functions/neat_column_default_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "spec_helper"

describe "neat-column-default" do
before(:all) do
ParserSupport.parse_file("functions/neat-column-default")
end

context "called with default grid" do
it "gets default columns" do
rule = "content: 12"

expect(".neat-column-default-grid").to have_rule(rule)
end

it "gets custom columns" do
rule = "content: 10"

expect(".neat-column-default-grid-custom-col").to have_rule(rule)
end
end

context "called with custom grid" do
it "gets default columns" do
rule = "content: 18"

expect(".neat-column-custom-grid").to have_rule(rule)
end

it "gets custom columns" do
rule = "content: 10"

expect(".neat-column-custom-grid-custom-col").to have_rule(rule)
end
end
end

0 comments on commit e2bd4df

Please sign in to comment.