From f191ba6e6990fec3f973ee78f75547e5a828785a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 7 Mar 2018 10:50:51 +0100 Subject: hide sidebar scrollbar unless onHover --- .../react-docs/src/ts/components/documentation.tsx | 23 +++++++++++++++++++++- .../src/ts/components/nested_sidebar_menu.tsx | 8 +++++++- 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/react-docs/src/ts/components/documentation.tsx b/packages/react-docs/src/ts/components/documentation.tsx index 8db9b34b4..58523a1a9 100644 --- a/packages/react-docs/src/ts/components/documentation.tsx +++ b/packages/react-docs/src/ts/components/documentation.tsx @@ -54,12 +54,20 @@ export interface DocumentationProps { topBarHeight?: number; } -export interface DocumentationState {} +export interface DocumentationState { + isHoveringSidebar: boolean; +} export class Documentation extends React.Component { public static defaultProps: Partial = { topBarHeight: 0, }; + constructor(props: DocumentationProps) { + super(props); + this.state = { + isHoveringSidebar: false, + }; + } public componentDidUpdate(prevProps: DocumentationProps, prevState: DocumentationState) { if (!_.isEqual(prevProps.docAgnosticFormat, this.props.docAgnosticFormat)) { const hash = window.location.hash.slice(1); @@ -106,7 +114,10 @@ export class Documentation extends React.Component ); } + private _onSidebarHover(event: React.FormEvent) { + this.setState({ + isHoveringSidebar: true, + }); + } + private _onSidebarHoverOff() { + this.setState({ + isHoveringSidebar: false, + }); + } } diff --git a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx index f907022d6..6a3cf2615 100644 --- a/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx +++ b/packages/react-shared/src/ts/components/nested_sidebar_menu.tsx @@ -59,12 +59,18 @@ export class NestedSidebarMenu extends React.Component{this._renderMenuItems(menuItems)}; } }); + const maxWidthWithScrollbar = 307; return (
{this.props.sidebarHeader} {!_.isUndefined(this.props.versions) && !_.isUndefined(this.props.selectedVersion) && ( - +
+ +
)}
{navigation}
-- cgit v1.2.3