Skip to content

Commit

Permalink
fix(plugin-tab): defensively call addPanels
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuenzenmeyer committed Nov 12, 2019
1 parent c100bbc commit b82bd12
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions packages/plugin-tab/src/snippet.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
/* global Panels */
function addPanels() {
window.patternlab.panels.add({
id: 'sg-panel-scss',
name: 'SCSS',
default: false,
templateID: 'pl-panel-template-code',
httpRequest: true,
httpRequestReplace: '.scss',
httpRequestCompleted: false,
prismHighlight: true,
language: 'scss',
keyCombo: 'ctrl+shift+z',
});
}

window.patternlab.panels.add({
id: 'sg-panel-<<type>>',
name: '<<typeUC>>',
default: false,
templateID: 'pl-panel-template-code',
httpRequest: true,
httpRequestReplace: '.<<type>>',
httpRequestCompleted: false,
prismHighlight: true,
language: '<<type>>',
keyCombo: 'ctrl+shift+z',
});
if (window.patternlab && window.patternlab.panels) {
console.log('pl already ready');
addPanels();
} else {
console.log('waiting for PL to be ready');
document.addEventListener('patternLab.pageLoad', addPanels);
}

0 comments on commit b82bd12

Please sign in to comment.