Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dim toolbar icon on unstyled tabs #115

Merged
merged 3 commits into from May 21, 2015
Merged

Dim toolbar icon on unstyled tabs #115

merged 3 commits into from May 21, 2015

Conversation

tophf
Copy link
Contributor

@tophf tophf commented May 14, 2015

Closes #100

  • Unstyled tab icon is dimmed:
    S remains the same, bg = 20%, outer border = 50% opacity. Transparent background should look good on non-bright themes, supposedly, unlike 100% white bg that would have been brighter than the default bg.

  • in disableAll mode the icon is also dimmed, style count badge is displayed on a lightgray background #aaa - should we have an option to customize this color to make it look good with dark themes?

  • The default 19x19 icon was recreated using SVG vector source:
    S and its outline were straightened a bit (check it out using GitHub's "Swipe" preview mode in diff)

  • 38x38 retina-aware icons were added. Not tested.

  • All icons were compressed with pngquant --quality 50-80

  • Default icon blinks for an instant here (usually less than 0.1s) when I navigate a styled site, this is what happens:

    1. onBeforeNavigate: updateIcon: OK
    2. Chrome resets the icon on a whim
      (particularly wacky when you navigate from an unstyled page to a styled one)
    3. onCommitted: updateIcon: OK

    The whim part apparently is incurable as there's nothing between onBeforeNavigate & onCommitted:

    events are fired in the following order:
    onBeforeNavigate -> onCommitted -> onDOMContentLoaded -> onCompleted

    Although we can leave the colored icon as default in manifest.json and not care about it being incorrect on about:blank and other chrome:// pages except for Edit and Manage.

    Other extensions are updating their icons after ~1 second or so, which makes them look not too smart in comparison.

@@ -11,19 +12,21 @@ function webNavigationListener(method, data) {
return;
}
getStyles({matchUrl: data.url, enabled: true, asHash: true}, function(styleHash) {
chrome.tabs.sendMessage(data.tabId, {method: method, styles: styleHash});
// Don't show the badge for frames
if (data.frameId == 0 && prefs.getPref("show-badge")) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data.frameId is 0 here because of line 11/12.

@JasonBarnabe
Copy link
Contributor

I've put the logo source at https://userstyles.org/newlogo.xcf . Not sure if that's helpful at this point.

@tophf
Copy link
Contributor Author

tophf commented May 18, 2015

To create the svg I've previously used the 128px icon (which is slightly distorted) as a source, so now I've fixed a few discrepancies using the real source and realigned all the icons on pixel grid.

@JasonBarnabe
Copy link
Contributor

It works inconsistently when enabling a style on the new tab page.

@tophf
Copy link
Contributor Author

tophf commented May 21, 2015

  • Fixed.
  • replaced that pesky try{} in background.js::chrome.contextMenus.create with chrome.runtime.lastError.

@tophf
Copy link
Contributor Author

tophf commented May 21, 2015

Rebased on master.

@JasonBarnabe
Copy link
Contributor

With two tabs and one global style:

  • Enable the style - icon is colourful, shows 1 in red box
  • Turn all styles off - icon is grey, shows 1 in grey box
  • Switch tabs - icon is grey, shows 1 in grey box
  • Turn all styles on - icon is colourful, shows 1 in grey box

Works because Chrome *overlays* user-specified badge color onto its own default color.
@tophf
Copy link
Contributor Author

tophf commented May 21, 2015

Fixed, hopefully.
However out of about 50 repetitions I was able to reproduce this only once in the very beginning.

JasonBarnabe added a commit that referenced this pull request May 21, 2015
Dim toolbar icon on unstyled tabs
@JasonBarnabe JasonBarnabe merged commit a19190b into stylish-userstyles:master May 21, 2015
@tophf tophf deleted the icon-no-styles branch May 21, 2015 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make icon act like Firefox
2 participants