Skip to content

Commit

Permalink
Add styles-from-map method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiewarb committed Nov 3, 2019
1 parent a012d43 commit 9086b97
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [1.0.8] - 2019-11-03

### New Features
- Added recursive map merge function
- Added styles-from-map mixin (and it's error suppressing companion, styles-from-map-quietly)

## [1.0.7] - 2018-06-15
### Bug Fixes
- Correct 'pixins' typo in example.main.scss
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inuitcss-hex",
"version": "1.0.7",
"version": "1.0.8",
"description": "Extension to the extensible, scalable, Sass-based, OOCSS framework for large and long-lasting UI projects.",
"main": "example.main.scss",
"scripts": {
Expand Down
24 changes: 24 additions & 0 deletions tools/_tools.mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,27 @@
}

}

/** You will usually want to use styles-from-map, unless you're trying to support a map that may not have the keys requested. */
@mixin styles-from-map-quietly($map) {
@each $style, $value in $map {
@if (type-of($value) == 'map') {
#{$style} {
@include styles-from-map($value);
}
} @else {
#{$style}: #{$value};
}
}
}

@mixin styles-from-map($map) {
@if type-of($map) == 'null' {
@warn 'Value passed to mixin styles-from-map is null. No styles will be outputted';
}
@if type-of($map) != 'map' and type-of($map) != 'null' {
@error 'Value passed to mixin styles-from-map must be a map - #{$map}';
}

@include styles-from-map-quietly($map);
}

0 comments on commit 9086b97

Please sign in to comment.