Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show "CSS" and "JS" tabs in code sections #330

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 2 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ module.exports = function (grunt) {
path.resolve(paths().source.styleguide + 'css/*.css'),
path.resolve(paths().source.patterns + '**/*.mustache'),
path.resolve(paths().source.patterns + '**/*.json'),
path.resolve(paths().source.patterns + '**/*.css'),
path.resolve(paths().source.patterns + '**/*.js'),
path.resolve(paths().source.fonts + '/*'),
path.resolve(paths().source.images + '/*'),
path.resolve(paths().source.data + '*.json'),
Expand Down
12 changes: 6 additions & 6 deletions core/lib/lineage_hunter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
12 changes: 6 additions & 6 deletions core/lib/list_item_hunter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
12 changes: 6 additions & 6 deletions core/lib/media_hunter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
12 changes: 6 additions & 6 deletions core/lib/object_factory.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
14 changes: 7 additions & 7 deletions core/lib/parameter_hunter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down Expand Up @@ -159,7 +159,7 @@ var parameter_hunter = function () {
values.push(paramString.match(regex)[0].trim());

//truncate the beginning from paramString and continue either
//looking for a key, or returning
//looking for a key, or returning
paramString = paramString.replace(regex, '').trim();

//exit do while if the final char is '}'
Expand Down
37 changes: 29 additions & 8 deletions core/lib/pattern_assembler.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down Expand Up @@ -149,8 +149,11 @@ var pattern_assembler = function () {
var filename = path.basename(file);
var ext = path.extname(filename);

//ignore dotfiles, underscored files, and non-variant .json files
if (filename.charAt(0) === '.' || (ext === '.json' && filename.indexOf('~') === -1)) {
//ignore dotfiles, underscored files, non-variant .json files, css and js files
if (filename.charAt(0) === '.' ||
(ext === '.json' && filename.indexOf('~') === -1) ||
ext === '.css' || ext === '.js'
) {
return;
}

Expand Down Expand Up @@ -199,6 +202,24 @@ var pattern_assembler = function () {
//add the raw template to memory
currentPattern.template = fs.readFileSync(file, 'utf8');

//look for a css file for this template
var cssPath = currentPattern.abspath.substr(0, currentPattern.abspath.lastIndexOf(".")) + ".css";
var cssExists = fs.existsSync(cssPath);

if (cssExists) {
currentPattern.cssExists = true;
currentPattern.css = fs.readFileSync(cssPath, 'utf8');
}

//look for a js file for this template
var jsPath = currentPattern.abspath.substr(0, currentPattern.abspath.lastIndexOf(".")) + ".js";
var jsExists = fs.existsSync(jsPath);

if (jsExists) {
currentPattern.jsExists = true;
currentPattern.js = fs.readFileSync(jsPath, 'utf8');
}

//find any stylemodifiers that may be in the current pattern
currentPattern.stylePartials = findPartialsWithStyleModifiers(currentPattern);

Expand Down
12 changes: 6 additions & 6 deletions core/lib/pattern_exporter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
22 changes: 16 additions & 6 deletions core/lib/patternlab.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down Expand Up @@ -227,6 +227,16 @@ var patternlab_engine = function (config) {

//write the encoded version too
fs.outputFileSync(paths.public.patterns + pattern.patternLink.replace('.html', '.escaped.html'), entity_encoder.encode(pattern.patternPartial));

//write the css file too
if(pattern.cssExists){
fs.outputFileSync(paths.public.patterns + pattern.patternLink.replace('.html', '.css'), pattern.css);
}

//write the js file too
if(pattern.jsExists){
fs.outputFileSync(paths.public.patterns + pattern.patternLink.replace('.html', '.js'), pattern.js);
}
});

//export patterns if necessary
Expand Down
12 changes: 6 additions & 6 deletions core/lib/patternlab_grunt.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
12 changes: 6 additions & 6 deletions core/lib/patternlab_gulp.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
12 changes: 6 additions & 6 deletions core/lib/pseudopattern_hunter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
12 changes: 6 additions & 6 deletions core/lib/style_modifier_hunter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v1.3.0 - 2016
*
/*
* patternlab-node - v1.3.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down
4 changes: 2 additions & 2 deletions core/styleguide/js/code-pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var codePattern = {
// if comments overlay is turned on add the has-comment class and pointer
if (codePattern.codeOverlayActive) {

var obj = JSON.stringify({ "codeOverlay": "on", "lineage": lineage, "lineageR": lineageR, "patternPartial": patternPartial, "patternState": patternState, "cssEnabled": cssEnabled });
var obj = JSON.stringify({ "codeOverlay": "on", "lineage": lineage, "lineageR": lineageR, "patternPartial": patternPartial, "patternState": patternState, "cssEnabled": cssEnabled, "jsEnabled": jsEnabled });
parent.postMessage(obj,codePattern.targetOrigin);

} else if (codePattern.codeEmbeddedActive) {
Expand Down Expand Up @@ -115,4 +115,4 @@ jwerty.key('esc', function (e) {
var obj = JSON.stringify({ "keyPress": "esc" });
parent.postMessage(obj,codePattern.targetOrigin);
return false;
});
});
Loading