Skip to content

Commit

Permalink
Merge pull request #7 from rezemble/master
Browse files Browse the repository at this point in the history
Thank you! I will merge and update the apm package version with this one.
  • Loading branch information
inakineitor authored Sep 8, 2017
2 parents d40fac4 + f79fd59 commit af341e5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.jshintrc
npm-debug.log
node_modules
22 changes: 0 additions & 22 deletions .jshintrc

This file was deleted.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Touch Bar Utility

<div class="alert alert-warning" role="alert">
<strong>Beware</strong> This package only works with Atom Beta v1.19
<strong>Beware</strong> This package only works with Atom >=v1.19
</div>
<br>
An Atom package that allows you to assign custom actions to Touch Bar components.
Expand All @@ -10,7 +10,7 @@ An Atom package that allows you to assign custom actions to Touch Bar components
1. Go to File → Settings → Packages
2. Find touch-bar-utility and click on the card **but not on the name of the package**
3. Go to Settings and edit the Buttons entry with a JSON array of Touch Bar components
* A component has the following format: {type: <typeOfElement>\[, ...\]}
* A component has the following format: {"type": "&lt;typeOfElement&gt;"\[, ...\]}

## Touch Bar Components

Expand All @@ -22,7 +22,7 @@ An Atom package that allows you to assign custom actions to Touch Bar components
pathOfIcon | **String** | _Yes_ | Path to button icon.
iconPosition | **String** | _No_ | Can be left, right or overlay.
click | **Function** | _Yes_ | Function to call when the button is clicked.
clickDispatchAction | **String** | _Yes_ | Event from another package that you want to execute when button is clicked. It will override the click property. It must be in the following format: "<package-name>:<event-name>" without quotation marks.
clickDispatchAction | **String** | _Yes_ | Event from another package that you want to execute when button is clicked. It will override the click property. It must be in the following format: "&lt;package-name&gt;:&lt;event-name&gt;" without quotation marks.
dispatchActionTarget | **String** | _Yes_ | Can have a value of 'workspace' or 'editor'. It defaults to 'workspace'.

### TouchBarColorPicker (type: "color-picker")
Expand All @@ -46,8 +46,8 @@ An Atom package that allows you to assign custom actions to Touch Bar components
Name of variable | Type of variable | Optional | Description
-----------------|---------------------------|----------|--------------------------------------------------------------------------------------------------
label | **String** | _Yes_ | Popover button text.
<!-- pathOfIcon | **String** | _Yes_ | Popover button icon. -->
<!-- items | **Array of elements** | _Yes_ | Items to display in the popover. -->
pathOfIcon | **String** | _Yes_ | Popover button icon.
items | **Array of elements** | _Yes_ | Items to display in the popover.
showCloseButton | **Boolean** | _Yes_ | true to display a close button on the left of the popover, false to not show it. Default is true.

### TouchBarSlider (type: "slider")
Expand Down
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
## TODO
* Add Touch Bar screenshot with sample configuration
* Add TouchBarScrubber and TouchBarSegmentedControl to the list of supported Touch Bar elements
6 changes: 3 additions & 3 deletions lib/touch-bar-utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function configureButtons(configString, callback) {
} = TouchBar

try {
let itemsConfig = JSON.parse(configString);
let itemsConfig = (typeof configString==='string')?JSON.parse(configString):configString;
let items = [];

itemsConfig.forEach(function(element) {
Expand Down Expand Up @@ -190,7 +190,7 @@ function configureButtons(configString, callback) {
break;

case 'group':
if (!element.items || typeof element.items !== 'object' || element.items.name != 'TouchBar')
if (!element.items || typeof element.items !== 'object' || !Array.isArray(element.items))
return callback(new Error("The touch-bar-group's items must be an array of elements"));

configureButtons(element.items, function(err, items) {
Expand Down Expand Up @@ -223,7 +223,7 @@ function configureButtons(configString, callback) {
return callback(new Error("The popover's label must be a string"));
if (element.pathOfIcon && typeof element.pathOfIcon !== 'string')
return callback(new Error("The popover's pathOfIcon must be a a string path pointing to PNG or JPEG file"));
if (element.items && (typeof element.items !== 'object' || element.items.name != 'TouchBar'))
if (element.items && (typeof element.items !== 'object' || !Array.isArray(element.items)))
return callback(new Error("The popover's items must be an array of elements"));
if (element.showCloseButton && typeof element.showCloseButton !== 'boolean')
return callback(new Error("The popover's showCloseButton must be a boolean"));
Expand Down

0 comments on commit af341e5

Please sign in to comment.