Skip to content

Commit

Permalink
scroll to top, scroll styles, reuse header vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankeairns committed Jan 15, 2019
1 parent b57a360 commit 48cd803
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
13 changes: 11 additions & 2 deletions src-docs/src/views/nav_drawer/nav_drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,10 @@ export default class extends Component {
outsideClickDisaled: true,
});
}, 350);

// Scrolls the menu and flyout back to top when the nav drawer collapses
document.getElementById('navDrawerMenu').scroll(0, 0);
document.getElementById('navDrawerFlyout').scroll(0, 0);
};

focusOut = () => {
Expand Down Expand Up @@ -555,7 +559,11 @@ export default class extends Component {
this.setState({ flyoutIsAnimating: true });

setTimeout(() => {
this.setState({ flyoutIsCollapsed: true });
this.setState({
flyoutIsCollapsed: true,
navFlyoutTitle: null,
navFlyoutContent: null
});
}, 250);
};

Expand Down Expand Up @@ -611,7 +619,7 @@ export default class extends Component {
showScrollbar={showScrollbar}
style={{ position: 'absolute' }} // This is for the embedded docs example only
>
<EuiNavDrawerMenu>
<EuiNavDrawerMenu id="navDrawerMenu">
<EuiListGroup listItems={this.topLinks} />
<EuiHorizontalRule margin="none" />
<EuiListGroup listItems={this.exploreLinks} />
Expand All @@ -621,6 +629,7 @@ export default class extends Component {
<EuiListGroup listItems={this.adminLinks} />
</EuiNavDrawerMenu>
<EuiNavDrawerFlyout
id="navDrawerFlyout"
title={navFlyoutTitle}
isCollapsed={flyoutIsCollapsed}
listItems={navFlyoutContent}
Expand Down
9 changes: 2 additions & 7 deletions src/components/header/_index.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Themable colors
$euiHeaderBackgroundColor: $euiColorEmptyShade;
$euiHeaderBreadcrumbColor: $euiColorDarkestShade;

// Layout vars
$euiHeaderChildSize: $euiSizeXXL + $euiSizeS;

// Components
@import '../header/variables';
@import 'variables';
@import 'header';
@import 'header_profile';
@import 'header_links/index';
Expand Down
7 changes: 7 additions & 0 deletions src/components/header/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Note - these are also used by the EuiNavDrawer (/nav_drawer) component
// Themable colors
$euiHeaderBackgroundColor: $euiColorEmptyShade;
$euiHeaderBreadcrumbColor: $euiColorDarkestShade;

// Layout vars
$euiHeaderChildSize: $euiSizeXXL + $euiSizeS;
1 change: 0 additions & 1 deletion src/components/nav_drawer/_nav_drawer.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Nav drawer. Global application navigation.

.euiNavDrawer {
@include euiScrollBar;
width: $euiNavDrawerWidthCollapsed;
height: calc(100% - #{$euiHeaderSize});
position: fixed;
Expand Down
1 change: 1 addition & 0 deletions src/components/nav_drawer/_nav_drawer_flyout.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.euiNavDrawerFlyout {
@include euiScrollBar;
position: absolute;
left: $euiNavDrawerWidthExpanded;
top: 0;
Expand Down
1 change: 1 addition & 0 deletions src/components/nav_drawer/_nav_drawer_menu.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.euiNavDrawerMenu {
@include euiScrollBar;
max-width: $euiNavDrawerWidthExpanded;
}
8 changes: 4 additions & 4 deletions src/components/nav_drawer/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Themable colors
$euiNavDrawerBackgroundColor: $euiColorEmptyShade;
$euiNavDrawerBackgroundColor: $euiHeaderBackgroundColor;

// Drawer variables
$euiNavDrawerWidthExpanded: 240px;
$euiNavDrawerWidthCollapsed: 48px;
$euiNavDrawerWidthCollapsed: $euiHeaderChildSize;
$euiNavDrawerSideShadow: 2px 0 2px -1px rgba($euiShadowColor, .3);

// Layout variables
$euiHeaderSize: $euiSizeXXL + $euiSizeS + 1px;
$euiHeaderSizeMobile: $euiSizeXL + $euiSizeXS + 1px;
$euiHeaderSize: $euiHeaderChildSize + 1px;
$euiHeaderSizeMobile: ($euiHeaderChildSize * .75) + 1px;

This comment has been minimized.

Copy link
@cchaos

cchaos Jan 15, 2019

Contributor

Should these then actually be in the header/_variables.scss file?

This comment has been minimized.

Copy link
@ryankeairns

ryankeairns Jan 15, 2019

Author Contributor

The name suggests they would fit better over there, however they aren't used in EuiHeader so I left them here.

That said, I could remove these two variables here and do the $euiHeaderChildSize + 1px directly in the nav_drawer.scss. Another alternative would be to add these in the header variables.scss and use the $euiHeaderSize over there too (i.e. set euiHeaderSize = euiHeaderChildSize or vice-versa).

The thing I like about the latter is that the name better reflects what is happening. Currently, the header height is not explicitly set, it's just dependent upon the euiHeaderChildSize height.

I don't have a strong preference, do you?


// Animation variables
$euiNavDrawerExpandingDelay: $euiAnimSpeedNormal;
Expand Down

0 comments on commit 48cd803

Please sign in to comment.