Skip to content

Commit

Permalink
Store z-index values with sass, fixes overlapping issues (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulwilde authored and nylen committed May 11, 2017
1 parent ca6bd50 commit c541c16
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion blocks/library/image/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {core/image aligned left or right}' );
max-width: 370px;
}

Expand Down
14 changes: 14 additions & 0 deletions editor/assets/stylesheets/_z-index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$z-layers: (
'.editor-mode-switcher .dashicon': -1,
'.editor-block-switcher__arrow': 1,
'.editor-inserter__arrow': 1,
'.editor-inserter': 1,
'.editor-visual-editor__block:before': -1,
'.editor-visual-editor__block {core/image aligned left or right}': 10,
'.editor-visual-editor__block-controls': 1,
'.editor-header': 20,
);

@function z-index( $key ) {
@return map-get( $z-layers, $key );
}
2 changes: 1 addition & 1 deletion editor/header/mode-switcher/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

.dashicon {
position: relative;
z-index: -1;
z-index: z-index( '.editor-mode-switcher .dashicon' );
margin-left: -24px;
margin-top: -1px;
}
Expand Down
2 changes: 1 addition & 1 deletion editor/header/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
display: flex;
flex-direction: row;
align-items: center;
z-index: 2;
z-index: z-index( '.editor-header' );
top: $admin-bar-height-big;
left: 0;
right: 0;
Expand Down
4 changes: 2 additions & 2 deletions editor/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
font-family: $default-font;
font-size: $default-font-size;
line-height: $default-line-height;
z-index: 1;
z-index: z-index( '.editor-inserter' );
}

.editor-inserter__toggle {
Expand Down Expand Up @@ -96,7 +96,7 @@
line-height: 0;
position: absolute;
width: 0;
z-index: 1;
z-index: z-index( '.editor-inserter__arrow' );
}

.editor-inserter__content {
Expand Down
4 changes: 2 additions & 2 deletions editor/modes/visual-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
transition: 0.2s border-color;

&:before {
z-index: -1;
z-index: z-index( '.editor-visual-editor__block:before' );
content: '';
position: absolute;
top: 0;
Expand Down Expand Up @@ -75,7 +75,7 @@
@include animate_fade;
display: flex;
position: sticky;
z-index: 1;
z-index: z-index( '.editor-visual-editor__block-controls' );
margin-top: -$block-controls-height - $item-spacing;
margin-bottom: $item-spacing + 20px; // 20px is the offset from the bottom of the selected block where it stops sticking
height: $block-controls-height;
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const config = {
loader: 'sass-loader',
query: {
includePaths: [ 'editor/assets/stylesheets' ],
data: '@import "variables"; @import "mixins"; @import "animations";',
data: '@import "variables"; @import "mixins"; @import "animations";@import "z-index";',
outputStyle: 'production' === process.env.NODE_ENV ?
'compressed' : 'nested'
}
Expand Down

0 comments on commit c541c16

Please sign in to comment.