Skip to content

Commit

Permalink
Merge pull request #14 from pattern-lab/dev
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
bmuenzenmeyer committed Feb 23, 2018
1 parent dd60d89 commit 189d768
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
17 changes: 15 additions & 2 deletions packages/plugin-node-tab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,25 @@ To add the Tab Plugin to your project using [npm](http://npmjs.com/) type:

Or add it directly to your project's `package.json` file and run `npm install`

Post installation, the plugin will prompt you for what filetypes you want to add tabs for.
At time of installation, the plugin will prompt you for what filetypes you want to add tabs for.

```
$ Specify filetype(s) to create a tab for. Separate multiple filetypes with a space, pipe or comma. Example: js css >>>
```

Post-installation, the plugin should be added as a key to the `plugins` object in your main Pattern Lab project's `patternlab-config.json` file.

Example:

```
"plugins": {
"plugin-node-tab": {
"enabled": true,
"initialized": false
}
}
```

## Expected Structure

With the Tab Plugin installed, you can now accompany pattern template files with the file types of your choice and expect Pattern Lab to show them as tabs. The file structure would be similar to that of `pattern.json` or `pattern.md` files, except that it will be `pattern.<<type>>`.
Expand All @@ -38,4 +51,4 @@ For example, if we added a` css` tab:

## Enabling / Disabling the Plugin

After install, you may manually enable or disable the plugin by removing it from the `patternlab-config.json` file. Installation added a key called `plugin-node-tab` to it. In the future this will be possible via CLI.
After install, you may manually enable or disable the plugin by finding the `plugin-node-tab` key within your main Pattern Lab project's `patternlab-config.json` file and setting the `enabled` flag. In the future this will be possible via CLI.
15 changes: 11 additions & 4 deletions packages/plugin-node-tab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,21 @@ function pluginInit(patternlab) {
}
}

//setup listeners if not already active
if (patternlab.config[pluginName] !== undefined && !patternlab.config[pluginName]) {
//setup listeners if not already active. we also enable and set the plugin as initialized
if (!patternlab.config.plugins) {
patternlab.config.plugins = {};
}

//attempt to only register events once
if (patternlab.config.plugins[pluginName] !== undefined &&
patternlab.config.plugins[pluginName].enabled &&
!patternlab.config.plugins[pluginName].initialized) {

//register events
registerEvents(patternlab);

//set the plugin key to true to indicate it is installed and ready
patternlab.config[pluginName] = true;
//set the plugin initialized flag to true to indicate it is installed and ready
patternlab.config.plugins[pluginName].initialized = true;
}

}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-node-tab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plugin-node-tab",
"version": "1.0.0-alpha",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
Expand Down

0 comments on commit 189d768

Please sign in to comment.