Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Added the ability to import yaml/json files into the toolkit/scss #221

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var gulp = require('gulp');
var gutil = require('gulp-util');
var gulpif = require('gulp-if');
var imagemin = require('gulp-imagemin');
var importOnce = require('node-sass-import-once');
var prefix = require('gulp-autoprefixer');
var rename = require('gulp-rename');
var reload = browserSync.reload;
Expand Down Expand Up @@ -64,7 +65,14 @@ gulp.task('styles:fabricator', function () {
gulp.task('styles:toolkit', function () {
gulp.src(config.src.styles.toolkit)
.pipe(gulpif(config.dev, sourcemaps.init()))
.pipe(sass().on('error', sass.logError))
.pipe(sass({
importer: importOnce,
importOnce: {
index: true,
css: true,
bower: true
}
}).on('error', sass.logError))
.pipe(prefix('last 1 version'))
.pipe(gulpif(!config.dev, csso()))
.pipe(gulpif(config.dev, sourcemaps.write()))
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"gulp-sourcemaps": "^1.5.2",
"gulp-util": "^3.0.6",
"imports-loader": "^0.6.4",
"node-sass-import-once": "^1.2.0",
"run-sequence": "^1.1.2",
"script-loader": "^0.6.1",
"webpack": "^1.12.1"
Expand Down
13 changes: 13 additions & 0 deletions src/assets/toolkit/styles/functions/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* A simple deep-map-get function to load
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call this data.scss

nested map values from the yaml or json data files */

@function data($map, $keys...) {
$value: $map;
@each $key in $keys {
$value: map-get($value, $key);
}
$result: unquote(inspect($value));
// Inspect is used here to silence a warning about depricating
// none-string unquoting in future versions of sass
@return $result;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a toolkit() function shortcut that pulls in the toolkit map, eliminating the first argument.

e.g.:
color: toolkit(colors, primary, Dark)

6 changes: 6 additions & 0 deletions src/assets/toolkit/styles/toolkit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
* Toolkit styles
*/

@import "./functions";
@import "../../../data/toolkit.yml";

body {
font-family: sans-serif;
}

.f-menu a:hover {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this example. Helpful to see the demo, but maybe fits better as a comment in the functions dir.

color: data($toolkit, colors, primary, Dark) !important;
}