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

Commit

Permalink
Add display mixin
Browse files Browse the repository at this point in the history
- Closes #100
  • Loading branch information
Reda Lemeden committed Jul 20, 2014
1 parent 2615987 commit 4eb67b8
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/_neat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
@import "grid/media";
@import "grid/to-deprecate";
@import "grid/visual-grid";
@import "grid/display";
28 changes: 28 additions & 0 deletions app/assets/stylesheets/grid/_display.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Changes the display property used by other mixins called in the code block argument.
*
* @param {String} $display (block) - Display value to be used within the block. Can be `table` or `block`.
*
* @example scss
* @include display(table) {
* .display-table {
* @include span-columns(6);
* }
* }
*
* @example css
* // CSS
* .display-table {
* display: table-cell;
* ...
* }
*/

@mixin display($display: block) {
$scope-display: $container-display-table;
$container-display-table: if($display == table, true, false) !global;

@content;

$container-display-table: $scope-display !global;
}
6 changes: 5 additions & 1 deletion app/assets/stylesheets/grid/_row.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@mixin row($display: block, $direction: $default-layout-direction) {
@mixin row($display: default, $direction: $default-layout-direction) {
$layout-direction: $direction !global;

@if $display != default {
@warn "The $display argument will be deprecated in future versions in favor of the display(){...} mixin."
}

@if $display == table {
display: table;
@include fill-parent;
Expand Down
19 changes: 19 additions & 0 deletions spec/neat/display_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'

describe "@include display() {...}" do
before(:all) do
ParserSupport.parse_file("display")
end

context "with argument (table)" do
it "changes display value to table" do
expect('.display-table-block').to have_rule('display: table-cell')
end
end

context "whith nested call and argument (block)" do
it "changes display value to block" do
expect('.display-nested-block').to have_rule('display: block')
end
end
end
2 changes: 1 addition & 1 deletion spec/neat/media_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe "@include media()" do
describe "@include media() {...}" do
before(:all) do
ParserSupport.parse_file("media")
end
Expand Down
15 changes: 15 additions & 0 deletions test/display.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@import 'setup';

@include display(table) {
.display-table-block {
@include span-columns(6);
}
}

@include display(table) {
@include display(block) {
.display-nested-block {
@include span-columns(6);
}
}
}

0 comments on commit 4eb67b8

Please sign in to comment.