GoogleChromeLabs / ProjectVisBug

FireBug for designers β€Ί Edit any webpage, in any state https://a.nerdy.dev/gimme-visbug
https://visbug.web.app
Apache License 2.0
5.48k stars 289 forks source link

Adds z-index visualization plugin #418

Closed addyosmani closed 4 years ago

addyosmani commented 4 years ago

This change introduces a z-index visualization plugin. The idea is to render a box with the z-index value for each child, to help developers debug index stacking. Each box is given a random color to help distinguish what you're seeing.

Below you can see the plugin being used on a few sites:

Screen Shot 2019-12-12 at 12 26 33 PM

image

Screen Shot 2019-12-12 at 12 27 09 PM

Very open to additional commits being added by @argyleink to improve this. A few areas it could be improved:

Feel free to let me know if this isn't a great fit for this project :)

This work is inspired by a bookmarklet Mr. @paulirish wrote 10 years ago :)

Original gist Non-jQuery rewrite this is based on

argyleink commented 4 years ago

deployed PR to Glitch for QA and hands on testing: https://addy-zindex.glitch.me

worked as advertised! i do see 1 or 2 ui nudges i can make in a fork. i'll post a follow up comment with a new glitch link containing some mods.

awesome work!

argyleink commented 4 years ago

alright, spent 30m to see what i could improve! had a lot of fun playing. even tried some backdrop filter stuff lol. here's what i thought ended up being an improvement, watcha think?

Screen Shot 2019-12-12 at 2 00 37 PM

changes:

source
demo

addyosmani commented 4 years ago

alright, spent 30m to see what i could improve! had a lot of fun playing. even tried some backdrop filter stuff lol. here's what i thought ended up being an improvement, watcha think?

Love it! Thanks for spending time tweaking the implementation. Wdyt about us bumping up the font-size just a smidge for readability? Rest looks pretty ace. Also like the idea of centering the z-index to avoid clashes.

added additional styles so page styles dont leak in (might be good to shadow dom this eventually)

πŸ‘

argyleink commented 4 years ago

def down to bump up the font size, no prob! think we should filter out the visbug element? i dont think user's care about it's z-index.

addyosmani commented 4 years ago

Yeah, we should probably filter out the VisBug element. That makes sense. For the font size bump, do you have preferences here around units? (px, rem, em)

argyleink commented 4 years ago

I suggest pixels, since em's/rem's would inherit from rando page styles. but, you're also a plugin and not visbug, so there's some forgiveness.

addyosmani commented 4 years ago

How would you feel about 13-14px?

argyleink commented 4 years ago

i'd feel good about it! an overachiever would make a range of values from like 12 - 20, and would pick somewhere in the spectrum based on the size of the element the label will go into. lol, like a big node would get a bigger label, and tiny nodes would get the smallest label. but, honestly, i think the PR you submitted, even as it was originally, was totally acceptable. so whatever you wanna iron out is all icing on an already great cake.

argyleink commented 4 years ago

the label custom element from visbug had some css i wanted to reference for this labels, found it here https://github.com/GoogleChromeLabs/ProjectVisBug/blob/master/app/components/selection/label.element.css. i updated the demo with some of the resets and updated it to 14px and added a filter to check for visbug πŸ‘ things look great!

https://adm-zindex.glitch.me

then, i was curious about a plugin using visbug's web components.. and a few minutes later, made this demo!

https://ce-zindex.glitch.me

with the custom elements:

addyosmani commented 4 years ago

i updated the demo with some of the resets and updated it to 14px and added a filter to check for visbug πŸ‘ things look great!

image

Thanks for experimenting with 14px. This looks a lot more readable and I think the average user will find this an improvement over the original values.

then, i was curious about a plugin using visbug's web components.. and a few minutes later, made this demo!

Nice! I'm going to play around with this update, in particular how it would handle nested components with different z-index values. I have a feeling the UX is just a wee bit nicer than the original proposal.

addyosmani commented 4 years ago

Okay, I'm sold on the revisions. Even with slightly overlapping elements we're able to visualize their independent z-index values while keeping them readable. I also like that these additions kept the original logic pretty in tact πŸ‘ Thanks for collaborating on improving this, Adam! πŸ€—

image

The one shift these last sets of changes from the update introduce is that the snippet can no longer be pasted in FF/Safari DevTools and 'just work' the same. On the whole, I think that's fine and we can re-implement some of these tweaks in the gist for anyone that wishes to get this working in other browsers.

In short, I and the doggos approve of the direction here. If there's anything remaining from your Glitch you'd like to bring back in here, would you like to go ahead and commit those to the branch/PR? I wasn't sure if there were also docs changes needed so will defer to you to let me know :)

addyosmani commented 4 years ago

πŸŽ‰ Thanks for being open to this change and helping iterate towards a nicer version of it! SG on the Firefox support bits. Looking forward to how that comes together!

I have a few other ideas for VisBug plugins I may try to PR in the new year. Appreciate how straight-forward contributing was πŸ‘

nbd at all - could you let me know when this change makes its way to a release? ☺️