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

Commit

Permalink
Add retrieve-neat-setting function
Browse files Browse the repository at this point in the history
`retrieve-neat-setting` takes the default map `$_neat-grid-default` and merges
it with the map passed in to it (typically `$neat-grid`) and then retrieves the
value for the key passed into it.
  • Loading branch information
whmii committed Feb 3, 2017
1 parent 98fd6e1 commit 7a87e0e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 16 deletions.
2 changes: 2 additions & 0 deletions core/_neat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

@import "neat/settings/settings";

@import "neat/functions/retrieve-neat-settings";

@import "neat/mixins/grid-column";
@import "neat/mixins/grid-container";
@import "neat/mixins/grid-push";
18 changes: 18 additions & 0 deletions core/neat/functions/_retrieve-neat-settings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@charset "UTF-8";
/// Return a Neat setting.
///
/// @argument {map} $grid
///
/// @argument {string} $setting
///
/// @return {boolean | color | list | number | string}
///
/// @example scss
/// _retrieve-neat-setting($neat-grid, columns)
///
/// @access private

@function _retrieve-neat-setting($grid, $setting) {
$_grid-settings: map-merge($_neat-grid-defaults, $grid);
@return map-get($_grid-settings, $setting);
}
8 changes: 4 additions & 4 deletions core/neat/mixins/_grid-column.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
///
/// @argument {number (unitless)} $columns [1]
///
/// @argument {map} $grid [$neat-default-grid]
/// @argument {map} $grid [$neat-grid]
/// The grid used to generate the column.
///
/// @example scss
Expand All @@ -18,9 +18,9 @@
/// margin-left: 20px;
/// }
@mixin grid-column($columns: 1, $grid: $neat-default-grid) {
$_grid-columns: map-get($grid, columns);
$_grid-gutter: map-get($grid, gutter);
@mixin grid-column($columns: 1, $grid: $neat-grid) {
$_grid-columns: _retrieve-neat-setting($grid, columns);
$_grid-gutter: _retrieve-neat-setting($grid, gutter);

$_column-ratio: $columns / $_grid-columns;

Expand Down
4 changes: 2 additions & 2 deletions core/neat/mixins/_grid-container.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@charset "UTF-8";
/// Creates a Neat grid container with clearfix.
///
/// @argument {map} $grid [$neat-default-grid]
/// @argument {map} $grid [$neat-grid]
/// The type of grid for this column.
///
/// @example scss
Expand All @@ -16,7 +16,7 @@
/// display: block;
/// }
@mixin grid-container($grid: $neat-default-grid) {
@mixin grid-container($grid: $neat-grid) {
&::after {
clear: both;
content: "";
Expand Down
18 changes: 9 additions & 9 deletions core/neat/mixins/_grid-push.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@charset "UTF-8";
/// Push or pull a Neat grid column.
///
/// @argument {number (unitless)} $push [false]
/// @argument {number (unitless)} $_push [false]
///
/// @argument {map} $grid [$neat-default-grid]
/// @argument {map} $_grid [$neat-grid]
/// The grid to be used to generate the column. By default, the global
/// `$neat-default-grid` will be used.
/// `$neat-grid` will be used.
///
/// @example scss
/// .element {
Expand All @@ -17,14 +17,14 @@
/// margin-left: calc((100% - (260px)) * 0.25 + 80px);
/// }
@mixin grid-push($push: false, $grid: $neat-default-grid) {
$_grid-columns: map-get($grid, columns);
$_grid-gutter: map-get($grid, gutter);
@mixin grid-push($_push: false, $_grid: $neat-grid) {
$_grid-columns: _retrieve-neat-setting($_grid, columns);
$_grid-gutter: _retrieve-neat-setting($_grid, gutter);

@if $push {
$_push-column-ratio: $push / $_grid-columns;
@if $_push {
$_push-column-ratio: $_push / $_grid-columns;
$_total-gutters: ($_grid-columns + 1) * $_grid-gutter;
$_gutter-affordance: $_grid-gutter * ($push + 1);
$_gutter-affordance: $_grid-gutter * ($_push + 1);
$_total-columns: "(100% - #{$_total-gutters})";
$_margin-value: calc(#{unquote($_total-columns)} * #{$_push-column-ratio} + #{$_gutter-affordance});

Expand Down
14 changes: 13 additions & 1 deletion core/neat/settings/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@
///
/// @access private

$neat-default-grid: (
$_neat-grid-defaults: (
columns: 12,
gutter: 20px
);

/// User overrides of Bourbon configuration settings.
///
/// @type map
///
/// @property {number (unitless)} columns [12]
/// Number of grid columns.
///
/// @property {number (with unit)} gutter [20px]
/// Grid gutter width.

$neat-grid: () !default;

0 comments on commit 7a87e0e

Please sign in to comment.