piroor / treestyletab

Tree Style Tab, Show tabs like a tree.
http://piro.sakura.ne.jp/xul/treestyletab/
Other
3.5k stars 278 forks source link

[Bug] TST doesn't do dark theme anymore #3194

Closed Bert-Proesmans closed 2 years ago

Bert-Proesmans commented 2 years ago

EDIT; Sorry, this is related to my custom CSS

Abstract

After updating TST to version 3.9.0 just now, the sidebar doesn't render in dark theme. The dark theme worked as expected under version 3.8.26 until the sidebar reloaded/flashed because of the updated extension. I've checked the release notes and there isn't anything specific to dark theme mentioned that I should change.

I've tried switching the TST settings, and toggling light/dark mode in OS, and restarting Firefox which didn't change the outcome.

Steps to reproduce

Expected result

The toolbar is dark themed.

Actual result

The toolbar is white themed.

Environment

EDIT; I have some custom styling enabled on top of the Photon theme. I'm gonna check what changed and try to provide an updated custom styling tomorrow.

Without this custom CSS the dark theme is back.

afbeelding

Custom CSS ```css /* Make the new tab button stick to the bottom of the window */ #tabbar:not(.overflow) .after-tabs { margin-top: auto; } /* Change styling of pending (unloaded) tabs */ .tab.discarded { opacity: 0.45; } /* Add private browsing indicator per tab */ .tab.private-browsing .label:before { content: "🕶"; } /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is the Tree Style Tab. * * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi. * Portions created by the Initial Developer are Copyright (C) 2007-2019 * the Initial Developer. All Rights Reserved. * * Contributor(s): YUKI "Piro" Hiroshi * lv7777 (https://github.com/lv7777) * * ***** END LICENSE BLOCK ******/ :root { --shadow-color: transparent; --shadow-blur: 0; --toolbar-non-lwt-bgcolor: var(--grey-10); --toolbar-non-lwt-textcolor: var(--grey-90); --toolbar-non-lwt-inverted-textcolor: white; --toolbar-non-lwt-border-color: var(--grey-40); --tab-like-surface: var(--browser-bg-base, var(--toolbar-non-lwt-bgcolor)); --tab-surface-regular: var(--browser-bg-for-header-image, var(--tab-like-surface)); --tab-text-regular: var(--browser-fg, var(--toolbar-non-lwt-textcolor)); --tab-text-inverted: var(--browser-bg-lighter, var(--toolbar-non-lwt-inverted-textcolor)); --tab-active-text: var(--browser-fg-active, var(--toolbar-non-lwt-textcolor)); --tab-active-text-inverted: var(--browser-bg-more-lighter, var(--toolbar-non-lwt-inverted-textcolor)); --tab-border: var(--browser-border, var(--browser-bg-more-darker, var(--toolbar-non-lwt-border-color))); --tab-dropmarker: var(--browser-fg, var(--toolbar-non-lwt-textcolor)); --tab-surface-hover: var(--browser-bg-hover-for-header-image, var(--browser-bg-less-lighter, #e0e8f6 /* #grey-10 - #191104, (parseInt('f9f9fa', 16) - parseInt('191104', 16)).toString(16) */)); --tab-surface-active: var(--browser-bg-active-for-header-image, var(--browser-bg-lighter, #c1d2ee /* #grey-10 - #38270c, (parseInt('f9f9fa', 16) - parseInt('38270c', 16)).toString(16) */)); --tab-surface-active-hover: var(--browser-bg-active-for-header-image, var(--browser-bg-more-lighter, #d1e2fe /* #grey-10 - #281600 + #000004, (parseInt('f9f9fa', 16) - parseInt('281600', 16) + parseInt('000004', 16)).toString(16) */)); --tab-highlighted-highlight: var(--toolbar-non-lwt-inverted-textcolor); --tab-highlighted-glow: #3890f3; /* = rgb(56, 144, 243) */ --tab-highlighted-base: var(--tab-surface); --throbber-color: var(--browser-loading-indicator, var(--browser-bg-lightest, var(--tab-highlighted-glow))); --throbber-color-active: var(--browser-loading-indicator, var(--tab-highlighted-glow)); --multiselected-color-opacity: 0.25; } :root, #background { background-color: var(--browser-background, var(--tab-surface)); background-image: var(--browser-bg-url, var(--browser-header-url, none)); background-position: left; background-size: var(--browser-background-image-size, auto); } :root.right, :root.right #background { background-position: right; } @media not (prefers-color-scheme: dark) { :root[color-scheme="system-color"] { --toolbar-non-lwt-bgcolor: -moz-dialog; --toolbar-non-lwt-textcolor: -moz-dialogtext; --toolbar-non-lwt-inverted-textcolor: -moz-dialog; --toolbar-non-lwt-border-color: ThreeDShadow; --tab-surface-hover: var(--browser-bg-hover-for-header-image, var(--browser-bg-more-lighter, var(--face-highlight-more-more-lighter))); --tab-surface-active: var(--browser-bg-active-for-header-image, var(--browser-bg-lighter, var(--face-highlight-lighter))); --tab-surface-active-hover: var(--browser-bg-active-for-header-image, var(--browser-bg-more-lighter, var(--face-highlight-more-lighter))); } } tab-item-substance, .after-tabs button, .after-tabs [role="button"] { background: transparent; color: var(--tab-text); text-shadow: var(--browser-textshadow-for-header-image, none); } tab-item.active tab-item-substance, tab-item.bundled-active tab-item-substance, tab-item tab-item-substance:hover { background: var(--tab-surface); } tab-item * { color: var(--tab-text); } tab-item:not(.active):not(.bundled-active) tab-item-substance:hover, .after-tabs button:hover, .after-tabs [role="button"]:hover { --tab-surface: var(--tab-surface-hover); } tab-item.active, tab-item.bundled-active { --throbber-color: var(--throbber-color-active); --tab-text: var(--tab-active-text); --tab-text-inverted: var(--tab-active-text-inverted); } tab-item.active { --tab-surface: var(--tab-surface-active); } tab-item.active tab-item-substance:hover, tab-item.bundled-active { --tab-surface: var(--tab-surface-active-hover); } tab-item.bundled-active tab-item-substance:hover { --tab-surface: var(--tab-surface-hover); } tab-item:not(.active):not(.bundled-active):not(.highlighted) { --throbber-color: var(--browser-loading-indicator, ThreeDDarkShadow); } tab-item .burster { --throbber-color: var(--tab-loading-fill); } @media (prefers-color-scheme: dark) { :root { --toolbar-non-lwt-bgcolor: #252526; --toolbar-non-lwt-textcolor: #efefef; --toolbar-non-lwt-inverted-textcolor: black; --toolbar-non-lwt-border-color: #4a4a4d; --tab-highlighted-highlight: white; --tab-dropmarker: var(--toolbar-non-lwt-textcolor); --tab-surface-hover: var(--browser-bg-hover-for-header-image, var(--browser-bg-less-lighter, #29363f /* #252526 + #041119 (switched R and B from #191104), (parseInt('252526', 16) + parseInt('041119', 16)).toString(16) */)); --tab-surface-active: var(--browser-bg-active-for-header-image, var(--browser-bg-lighter, #314c5e /* #252526 + #0c2738 (switched R and B from #38270c), (parseInt('252526', 16) + parseInt('0c2738', 16)).toString(16) */)); --tab-surface-active-hover: var(--browser-bg-active-for-header-image, var(--browser-bg-more-lighter, #293b4e /* #252526 + #041628 (switched R and B from #281600 + #00004), (parseInt('252526', 16) + parseInt('041628', 16)).toString(16) */)); } tab-item:not(.active):not(.bundled-active):not(.highlighted) { --throbber-color: var(--browser-loading-indicator, #afafaf); } /* Firefox applies dark colors to scrollbars in its in-content UI, when a Dark theme is applied by the platform. On the other hand, dark colors aren't applied to scrollbars in the sidebar also by default. Thus we need to imitate dark scrollbar manually. See also: https://github.com/piroor/treestyletab/issues/2373 */ #tabbar { scrollbar-color: var(--in-content-button-background-active-mixed) var(--in-content-box-background); } } /* cancel border */ tab-item tab-item-substance, tab-item.pinned tab-item-substance, .after-tabs button, .after-tabs [role="button"] { border: none; } :root.have-pinned-tabs #tabbar { border-top: none; } :root.left tab-item:not(.pinned) tab-item-substance, :root.left tab-item:not(.pinned)[data-parent-id] tab-item-substance { border-left: none; } :root.right tab-item:not(.pinned) tab-item-substance, :root.right tab-item:not(.pinned)[data-parent-id] tab-item-substance { border-right: none; } .mutiple-highlighted tab-item:not(.highlighted) tab-item-substance { opacity: 0.5; } /* hide regular active tab marker */ .highlighter::before { display: none !important; } /* Put close box at the left side, always */ :root.left tab-item tab-twisty { order: 10000; } :root.left tab-item tab-closebox { order: -1; } ```
piroor commented 2 years ago

Sorry I couldn't understand what is the problem. Could you paste both expected and actual cases screenshots to describe what is the difference?

piroor commented 2 years ago

By the way TST 3.9.0 includes changes around the method to apply custom CSS. The change possibly affects to your case.

Bert-Proesmans commented 2 years ago

Sorry I couldn't understand what is the problem. Could you paste both expected and actual cases screenshots to describe what is the difference?

I've exported my config and downgraded my extension through the "Temporary add-in" functionality (learned something new today). What I'm encountering is this (same config, TST version 3.9.0) faulty light mode

Where I'm expecting this (same config, TST version 3.8.1 -- I notice now that there are no Github releases for versions >3.8.2) correct dark mode

By the way TST 3.9.0 includes changes around the method to apply custom CSS. The change possibly affects to your case.

"Apply" as in html entity identifiers changed, or html structure changed? AKA can I expect to fix this myself with some element inspection?
Or do you mean there is some programmatic automation that changed in the extension code that requires workarounds for my case?

irvinm commented 2 years ago

@Bert-Proesmans this is definitely self-solvable. I took your CSS and just removed the first block of ":root" CSS items and I got it to look like this:

image

Now, I don't know what you might be missing by doing this, but it is hard to know as there is:

All of this to say, obviously the "specificity" of the CSS items you have are being selected differently based on some TST changes. I think you just need to make changes on your end to get it to where you want it to look.

If I were to guess, maybe one of the @media sections are not being used now and leaving the default :root overwritten values in place which are "light" in nature.

Bert-Proesmans commented 2 years ago

Hi @irvinm Thanks for taking a look! I'm currently figuring out how TST is built and custom CSS styling is applied.
You're right that removing the top :root {} section is almost a complete fix! There are a few visual inconsistencies, but it's a good pointer for me to continue on.

For future reference because I had to dig in memory, the theme is a straight up copy from the old Vertigo (https://github.com/piroor/treestyletab/wiki/Vertigo-theme-%28patch-for-the-theme-%22Photon%22%29). That's the main chunk of the custom CSS I posted, the other fragments tweak visibility or positioning.

irvinm commented 2 years ago

@Bert-Proesmans ah, that explains why there are so many selectors to handle different environments and options. :)

There isn't a TST issue here. Can you close this item? If you have additional questions, you can still post them into this issue for people to review.

@piroor you do have some of the old themes documented ... did you want to update them or maybe place a comment that they might require some modification to support new versions of TST?

Bert-Proesmans commented 2 years ago

OK, so I guess I'm running into an effect caused by https://github.com/piroor/treestyletab/commit/48347b1512e8188cf26b8a89d99e20a8a3b38cdc

This is in line with irvinm's suggestion and I can confirm with the inspector that :root {} becomes :root:not(#NEVER#USED#ID) {}. The end result being that selectors not guarded by a @media query are applied before others. This effectively turns around the rule application order that my custom CSS is built around.

I'm not sure how I would approach changing the custom CSS robustly, given the new ordering. The first step would be getting rid of that :root {} element by creating non-duplicate key-values underneath each @media query, and seeing from there.

piroor commented 2 years ago

Thank you for investigation @irvinm ! Finally I've understood that TST failed to increase specificity of CSS selectors under @media. The commit d770679 should fix this.

Bert-Proesmans commented 2 years ago

Thanks for helping out guys! Much appreciated!