| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9fc2f53 commit 2f3d39a
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -167,36 +167,57 @@ module.exports = function(pattern, patternlab) { | |||
| 167 | 167 | allFooterData.cacheBuster = patternlab.cacheBuster; | |
| 168 | 168 | allFooterData.patternLabFoot = footerPartial; | |
| 169 | 169 | ||
| 170 | - return render(patternlab.userFoot, allFooterData).then(footerHTML => { | ||
| 171 | - /////////////// | ||
| 172 | - // WRITE FILES | ||
| 173 | - /////////////// | ||
| 174 | - | ||
| 175 | - patternlab.events.emit( | ||
| 176 | - events.PATTERNLAB_PATTERN_WRITE_BEGIN, | ||
| 177 | - patternlab, | ||
| 178 | - pattern | ||
| 179 | - ); | ||
| 180 | - | ||
| 181 | - //write the compiled template to the public patterns directory | ||
| 182 | - patternlab.writePatternFiles( | ||
| 183 | - headHTML, | ||
| 184 | - pattern, | ||
| 185 | - footerHTML, | ||
| 186 | - uikit.outputDir | ||
| 187 | - ); | ||
| 188 | - | ||
| 189 | - patternlab.events.emit( | ||
| 190 | - events.PATTERNLAB_PATTERN_WRITE_END, | ||
| 191 | - patternlab, | ||
| 192 | - pattern | ||
| 193 | - ); | ||
| 194 | - | ||
| 195 | - // Allows serializing the compile state | ||
| 196 | - patternlab.graph.node(pattern).compileState = pattern.compileState = | ||
| 197 | - CompileState.CLEAN; | ||
| 198 | - logger.info('Built pattern: ' + pattern.patternPartial); | ||
| 199 | - }); | ||
| 170 | + return render(patternlab.userFoot, allFooterData).then( | ||
| 171 | + async footerHTML => { | ||
| 172 | + /////////////// | ||
| 173 | + // WRITE FILES | ||
| 174 | + /////////////// | ||
| 175 | + | ||
| 176 | + patternlab.events.emit( | ||
| 177 | + events.PATTERNLAB_PATTERN_WRITE_BEGIN, | ||
| 178 | + patternlab, | ||
| 179 | + pattern | ||
| 180 | + ); | ||
| 181 | + | ||
| 182 | + //write the compiled template to the public patterns directory | ||
| 183 | + patternlab.writePatternFiles( | ||
| 184 | + headHTML, | ||
| 185 | + pattern, | ||
| 186 | + footerHTML, | ||
| 187 | + uikit.outputDir | ||
| 188 | + ); | ||
| 189 | + | ||
| 190 | + patternlab.events.emit( | ||
| 191 | + events.PATTERNLAB_PATTERN_WRITE_END, | ||
| 192 | + patternlab, | ||
| 193 | + pattern | ||
| 194 | + ); | ||
| 195 | + | ||
| 196 | + console.log(196); | ||
| 197 | + | ||
| 198 | + (async function() { | ||
| 199 | + const hookHandlers = patternlab.hooks[ | ||
| 200 | + events.PATTERNLAB_PATTERN_WRITE_END | ||
| 201 | + ].forEach(h => h()); | ||
| 202 | + console.log(203, hookHandlers.length); | ||
| 203 | + | ||
| 204 | + const results = await Promise.all(hookHandlers); | ||
| 205 | + console.log(205, results); | ||
| 206 | + })(); | ||
| 207 | + | ||
| 208 | + console.log(208); | ||
| 209 | + | ||
| 210 | + await patternlab.hooks[events.PATTERNLAB_PATTERN_WRITE_END]; | ||
| 211 | + | ||
| 212 | + console.log(212); | ||
| 213 | + | ||
| 214 | + // Allows serializing the compile state | ||
| 215 | + patternlab.graph.node( | ||
| 216 | + pattern | ||
| 217 | + ).compileState = pattern.compileState = CompileState.CLEAN; | ||
| 218 | + logger.info('Built pattern: ' + pattern.patternPartial); | ||
| 219 | + } | ||
| 220 | + ); | ||
| 200 | 221 | }) | |
| 201 | 222 | .catch(reason => { | |
| 202 | 223 | console.log(reason); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,6 +64,9 @@ module.exports = class PatternLab { | |||
| 64 | 64 | // Make ye olde event emitter | |
| 65 | 65 | this.events = new PatternLabEventEmitter(); | |
| 66 | 66 | ||
| 67 | + this.hooks = {}; | ||
| 68 | + this.hooks[events.PATTERNLAB_PATTERN_WRITE_END] = []; | ||
| 69 | + | ||
| 67 | 70 | // Make a place for the pattern graph to sit | |
| 68 | 71 | this.graph = null; | |
| 69 | 72 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,7 @@ | |||
| 32 | 32 | "@pattern-lab/engine-handlebars": "^2.0.1", | |
| 33 | 33 | "@pattern-lab/engine-mustache": "^2.0.1-alpha.0", | |
| 34 | 34 | "@pattern-lab/starterkit-mustache-demo": "^5.0.0", | |
| 35 | - "@pattern-lab/uikit-workshop": "^1.0.3" | ||
| 35 | + "@pattern-lab/uikit-workshop": "^1.0.3", | ||
| 36 | + "@pattern-lab/plugin-tab": "2.0.3-beta.1" | ||
| 36 | 37 | } | |
| 37 | 38 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -90,5 +90,14 @@ | |||
| 90 | 90 | "handlebars": { | |
| 91 | 91 | "extend": "helpers/*.js" | |
| 92 | 92 | } | |
| 93 | + }, | ||
| 94 | + "plugins": { | ||
| 95 | + "pattern-lab-plugin-tab": { | ||
| 96 | + "enabled": true, | ||
| 97 | + "initialized": false, | ||
| 98 | + "options": { | ||
| 99 | + "tabsToAdd": ["scss"] | ||
| 100 | + } | ||
| 101 | + } | ||
| 93 | 102 | } | |
| 94 | 103 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,3 +3,4 @@ | |||
| 3 | 3 | <span class="sg-label {{#if inverted}}sg-label__inverted{{/if}} sg-label__bottom">hex: {{color.hex}}</span> | |
| 4 | 4 | <span class="sg-label {{#if inverted}}sg-label__inverted{{/if}} sg-label__bottom">cmyk: {{color.cmyk}}</span> | |
| 5 | 5 | </div> | |
| 6 | + swatch | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + * { | ||
| 2 | + color: rebeccapurple | ||
| 3 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,8 +34,8 @@ function writeConfigToOutput(patternlab, pluginConfig) { | |||
| 34 | 34 | } | |
| 35 | 35 | } | |
| 36 | 36 | ||
| 37 | - function onPatternIterate(patternlab, pattern) { | ||
| 38 | - tab_loader(patternlab, pattern); | ||
| 37 | + async function onPatternIterate(patternlab, pattern) { | ||
| 38 | + await tab_loader(patternlab, pattern); | ||
| 39 | 39 | } | |
| 40 | 40 | ||
| 41 | 41 | /** | |
@@ -48,6 +48,10 @@ function registerEvents(patternlab) { | |||
| 48 | 48 | patternlab.events.on('patternlab-pattern-write-end', onPatternIterate); | |
| 49 | 49 | } | |
| 50 | 50 | ||
| 51 | + function registerEventHandlers(patternlab) { | ||
| 52 | + patternlab.hooks['patternlab-pattern-write-end'].push(onPatternIterate); | ||
| 53 | + } | ||
| 54 | + | ||
| 51 | 55 | /** | |
| 52 | 56 | * A single place to define the frontend configuration | |
| 53 | 57 | * This configuration is outputted to the frontend explicitly as well as included in the plugins object. | |
@@ -169,7 +173,8 @@ function pluginInit(patternlab) { | |||
| 169 | 173 | !patternlab.config.plugins[pluginName].initialized | |
| 170 | 174 | ) { | |
| 171 | 175 | //register events | |
| 172 | - registerEvents(patternlab); | ||
| 176 | + //registerEvents(patternlab); | ||
| 177 | + registerEventHandlers(patternlab); | ||
| 173 | 178 | ||
| 174 | 179 | //set the plugin initialized flag to true to indicate it is installed and ready | |
| 175 | 180 | patternlab.config.plugins[pluginName].initialized = true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ const fs = require('fs-extra'); | |||
| 11 | 11 | * @param patternlab - the global data store | |
| 12 | 12 | * @param pattern - the pattern object being iterated over | |
| 13 | 13 | */ | |
| 14 | - function findTab(patternlab, pattern) { | ||
| 14 | + async function findTab(patternlab, pattern) { | ||
| 15 | 15 | //read the filetypes from the configuration | |
| 16 | 16 | const fileTypes = | |
| 17 | 17 | patternlab.config.plugins['@pattern-lab/plugin-tab'].options.tabsToAdd; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments