piroor / treestyletab

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

[Enhancement] setCSSVariable for open depth #3593

Closed faurehu closed 2 months ago

faurehu commented 2 months ago

setCSSVariable is a javascript function that sets CSS variables so that style sheets can respond to dynamic values. I request that this function is called everytime the tree changes its visible depth and then sets this in a variable.

If all parent nodes are closed, then the depth is 0, If there is one node that is open showing children that are all closed, then the depth would be 1, and so on. The maximum visible depth then, is the number of indentations the tab that is visible in the sidebar with most indentations has.

This would allow me and other users to calculate more appropriate widths for the sidebar. This is the code snippet I use to specify the width behavior of my sidebar:

:root {
    --thin-tab-width: 30px;
    --wide-tab-width: 300px;
}

#sidebar-box[sidebarcommand="treestyletab_piro_sakura_ne_jp-sidebar-action"]:hover,
#sidebar-box[sidebarcommand="treestyletab_piro_sakura_ne_jp-sidebar-action"] #sidebar {
    transition: all 200ms !important;
    min-width: var(--wide-tab-width) !important;
    max-width: var(--wide-tab-width) !important;
    z-index: 1;
}

As you can see, when I hove my mouse over the sidebar, the sidebar has a width of 300px, and when I don't it will shrink back to 30px.

I chose this setting so that when I can have the most screen space most of the time. 30px is enough for me to be able to identify tabs by their icons.

The issue with this is that since 30px is very thin, I can only see the tabs in the icons of the tabs in the first level of the tree. If any nodes in the tree have children and are open, I am not be able to identify these tabs without hovering my mouse over the sidebar.

Setting the dynamic variable for visible depth would allow me to calculate sensible values for --thin-tab-width, such that I am always able to see the deepest tab's icon when the sidebar is shrinked.

piroor commented 2 months ago

TST cannot expose any custom CSS variable to the chrome area (affected to userChrome.css) because it is a WebExtensions addon.

faurehu commented 2 months ago

I will write a feature request on the Mozilla forums to allow the WebExtension addons interface with userChrome.css

If it's accepted and implemented, I will re-open a new issue.

faurehu commented 2 months ago

Please support my request by giving thumbs up in this forum: https://connect.mozilla.org/t5/ideas/allow-userchrome-css-to-read-variables-set-by-webextension-add/idi-p/63241#M36448

piroor commented 2 months ago

Hmm, I'm negative to vote to such an idea injecting something information from WebExtensions addon to Firefox's chrome area, to keep the security and future maintainability of Firefox itself...

faurehu commented 2 months ago

That is fair, though I would say that those are concerns for the Firefox team to worry about. I doubt they'd sacrifice safety for such a niche request.