-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Store z-index values with sass, fixes overlapping issues #637
Conversation
Note that a flat array of Should we go ahead and adopt an approach like this? Much easier when the project is young. |
Thank you for working on this. The ticket to track it is #555. Can I help you with this branch? I can do some rebasing if need be.
May be a good idea, though I've always found the Calypso stacking mixin to be extremely obtuse and difficult to work with. That's not to say it's not the right approach — it very well may be, and it's just me that's daft. But just in case there's a simpler approach, @aduth do you have any ideas here? |
It's a complex solution to a complex problem, unfortunately. Nothing comes to my mind as a simpler alternative, but @nylen is right to point out that values don't always behave as you might expect depending on the context of the element, illustrated by the example referenced in his link: I'm on the fence whether this means we should consider adopting such a mixin, or be content to play |
Is it worth it to start with this SASS solution, and then revisit in the future if this becomes a bigger issue? |
I'm fine with an incremental approach here, but I'd prefer that we start with something that more closely resembles the "correct" solution. Namely, a
This serves two purposes to me: it's a mental reminder that "hey z-indices are complicated", and also it'll be pretty easy to refactor later if we end up needing the "full" solution. |
@@ -1,5 +1,6 @@ | |||
@import 'variables'; | |||
@import 'animations'; | |||
@import 'z-index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an older prototype. I doubt we need to import z-index
here.
blocks/library/image/style.scss
Outdated
@@ -2,7 +2,7 @@ | |||
&[data-align="left"], | |||
&[data-align="right"] { | |||
// Without z-index, won't be clickable as "above" adjacent content | |||
z-index: 10; | |||
z-index: z-index( '.editor-visual-editor__block' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general the names in the z-index
map should correspond very closely to the selectors that apply each rule. This one is not really .editor-visual-editor__block
- it should be something more like this:
.editor-visual-editor__block[data-type="core/image"][data-align]
In this case it might be a good idea to clarify the name a bit:
.editor-visual-editor__block {core/image aligned left or right}
Fixes issues with overlapping blocks/image on the header.
This prevents floated images from appearing on top of the header. To reproduce, float an image left/right and scroll down: https://wordpress.slack.com/archives/C02QB2JS7/p1494516062315338
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to test this, I did a comparison of the build before/after the z-index
function. Something like this:
npm run build
./node_modules/.bin/css-beautify -f editor/build/style.css > editor_style.css
GIT_DIR= git diff editor_master_style.css editor_style.css
This became much easier when I backed out all of the z-index changes (there were no changes to the build); then I re-added only the minimal change necessary to fix the issue described in dcec46b.
Let's ship this and refine later if needed.
Totally late to this, but a single dimensional map should work for most folks. Calypso just had a lot of weird contexts. If folks ever have trouble with figuring out z-index values, you may find this extension helpful: https://github.com/gwwar/z-context |
This fixes #555. Here is a before screenshot for reference: