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

Hard to debug style changes - breaks xkcd.com #126

Open
mcint opened this issue Oct 12, 2023 · 0 comments
Open

Hard to debug style changes - breaks xkcd.com #126

mcint opened this issue Oct 12, 2023 · 0 comments

Comments

@mcint
Copy link

mcint commented Oct 12, 2023

Broken site

https://xkcd.com breaks with vertical tabs installed. The page body elements float off to the right, with edges just off the page, varying by zoom level.

xkcd.com seems to use unusual centering or page sizing options, affected by all of these values.

body {
    ...
    left: 50%;
    width: 780px;
    margin-left: -390px;
}

Top and bottom, but not middle, containers set their own width for offsets.

It's just the addition of the margin-left: 0px style at issue.

Solution

I think this body adjustment is done in SidebarHelpers#L32-L69. Could we increment/decrement margin-left if it exists, instead of setting it? Would you like a PR?


Related Concern

The style changes added to the body element inline are hard to debug, instead of in a file specific to the extension.

Just style="transition: margin 0.25s cubic-bezier(0, 0, 0.3, 1) 0s; margin-left: 0px;" is added inline to the body element tag, in full: <body style="transition: margin 0.25s cubic-bezier(0, 0, 0.3, 1) 0s; margin-left: 0px;" class="vsc-initialized">, from <body class="vsc-initialized">, with no sign of the source.

Suggestion

You could instead add/remove a class specific to this extension from the body when you want to toggle the style and allow the page to move over with the extension acting as a sidebar.

I wish these could be added and adjusted with classes. I'm not sure if there are performance or web browser styling rendering optimizations that benefit from less abstracted dependecies.

vt.css:

.vt-body {
  transition: margin 0.25s cubic-bezier(0, 0, 0.3, 1) 0s;
  margin-left: 0px;  // (margin-left: [margin-left detected])
}

And toggle class addition with javascript, <body class="vsc-initialized"> <-> <body class="vsc-initialized vertical-tabs-body">, as suggested on Stack Overflow - inject css using content script.

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

No branches or pull requests

1 participant