Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

browserActionBackgroundImage per-tab support #5262

Merged
merged 1 commit into from
Oct 30, 2016
Merged
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
16 changes: 11 additions & 5 deletions app/common/state/extensionState.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@ const extensionState = {
}
},

browserActionBackgroundImage: (browserAction) => {
// TODO(bridiver) - handle icon single
if (browserAction.get('base_path') && browserAction.getIn(['path', '19']) && browserAction.getIn(['path', '38'])) {
return '-webkit-image-set(url(\'' + browserAction.get('base_path') + '/' + browserAction.getIn(['path', '19']) +
'\') 1x, url(\'' + browserAction.get('base_path') + '/' + browserAction.getIn(['path', '38']) + '\') 2x'
browserActionBackgroundImage: (browserAction, tabId) => {
tabId = tabId ? tabId.toString() : '-1'
if (browserAction.get('base_path')) {
if (browserAction.getIn(['tabs', tabId, 'path', '19']) && browserAction.getIn(['tabs', tabId, 'path', '38'])) {
return '-webkit-image-set(url(\'' + browserAction.get('base_path') + '/' + browserAction.getIn(['tabs', tabId, 'path', '19']) +
'\') 1x, url(\'' + browserAction.get('base_path') + '/' + browserAction.getIn(['tabs', tabId, 'path', '38']) + '\') 2x'
}
if (browserAction.getIn(['path', '19']) && browserAction.getIn(['path', '38'])) {
return '-webkit-image-set(url(\'' + browserAction.get('base_path') + '/' + browserAction.getIn(['path', '19']) +
'\') 1x, url(\'' + browserAction.get('base_path') + '/' + browserAction.getIn(['path', '38']) + '\') 2x'
}
}
return ''
},
Expand Down
2 changes: 1 addition & 1 deletion app/renderer/components/browserActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BrowserActionButton extends ImmutableComponent {
extensionButton: true
})}
inlineStyles={{
backgroundImage: extensionState.browserActionBackgroundImage(this.props.browserAction),
backgroundImage: extensionState.browserActionBackgroundImage(this.props.browserAction, this.props.tabId),
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center'
}}
Expand Down