Skip to content

Commit

Permalink
Refactor and add tests for KuiSideNav components. (elastic#13382)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Aug 16, 2017
1 parent 817274b commit 0940ea3
Show file tree
Hide file tree
Showing 30 changed files with 489 additions and 118 deletions.
6 changes: 3 additions & 3 deletions ui_framework/dist/ui_framework.css
Original file line number Diff line number Diff line change
Expand Up @@ -1295,12 +1295,12 @@ table {
margin-left: 0;
margin-top: 16px; } }

.kuiPageSidebar {
.kuiPageSideBar {
width: 192px;
margin-right: 24px; }

@media only screen and (max-width: 768px) {
.kuiPageSidebar {
.kuiPageSideBar {
width: 100%; } }

.kuiPageHeader {
Expand Down Expand Up @@ -1447,7 +1447,7 @@ table {
* 1. Animation doesn't work against height. Need max-height instead.
* We set a value larger than what is needed to fake "auto".
*/
.kuiSideNav.kuiSideNav-isOpenMobile .kuiSideNav__content {
.kuiSideNav-isOpenMobile .kuiSideNav__content {
visibility: visible;
opacity: 1;
margin: 24px;
Expand Down
118 changes: 98 additions & 20 deletions ui_framework/doc_site/src/views/kibana/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
KuiPageContentHeaderSection,
KuiPageHeader,
KuiPageHeaderSection,
KuiPageSidebar,
KuiPageSideBar,
KuiPopover,
KuiSideNav,
KuiSideNavItem,
Expand All @@ -38,6 +38,7 @@ export default class extends Component {
this.state = {
isUserMenuOpen: false,
isAppMenuOpen: false,
isSideNavOpenOnMobile: false,
};
}

Expand Down Expand Up @@ -65,6 +66,12 @@ export default class extends Component {
});
}

toggleOpenOnMobile() {
this.setState({
isSideNavOpenOnMobile: !this.state.isSideNavOpenOnMobile,
});
}

renderLogo() {
return (
<KuiHeaderLogo href="#" />
Expand Down Expand Up @@ -287,6 +294,94 @@ export default class extends Component {
);
}

renderSideNav() {
return (
<KuiPageSideBar>
<KuiSideNav
mobileTitle="Navigate within Management"
toggleOpenOnMobile={this.toggleOpenOnMobile.bind(this)}
isOpenOnMobile={this.state.isSideNavOpenOnMobile}
>
{/* Elasticsearch section */}

<KuiSideNavTitle>
Elasticsearch
</KuiSideNavTitle>

<KuiSideNavItem>
<button onClick={() => window.alert('Button clicked')}>
Data sources
</button>
</KuiSideNavItem>

<KuiSideNavItem>
<a href="http://www.elastic.co">
Users
</a>
</KuiSideNavItem>

<KuiSideNavItem>
<button>
Roles
</button>
</KuiSideNavItem>

<KuiSideNavItem isSelected>
<button>
Watches
</button>
</KuiSideNavItem>

<KuiSideNavItem>
<button>
Extremely long title will become truncated when the browser is narrow enough
</button>
</KuiSideNavItem>

{/* Kibana section */}

<KuiSideNavTitle>
<button>
Kibana
</button>
</KuiSideNavTitle>

<KuiSideNavItem>
<button>
Index Patterns
</button>
</KuiSideNavItem>

<KuiSideNavItem>
<button>
Saved Objects
</button>
</KuiSideNavItem>

<KuiSideNavItem>
<button>
Reporting
</button>
</KuiSideNavItem>

{/* Logstash section */}

<KuiSideNavTitle>
<button>
Logstash
</button>
</KuiSideNavTitle>

<KuiSideNavItem>
<button>
Pipeline Viewer
</button>
</KuiSideNavItem>
</KuiSideNav>
</KuiPageSideBar>
);
}

renderPage() {
return (
<KuiPage>
Expand All @@ -298,24 +393,7 @@ export default class extends Component {
</KuiPageHeaderSection>
</KuiPageHeader>
<KuiPageBody>
<KuiPageSidebar>
<KuiSideNav>
<KuiSideNavTitle>Elasticsearch</KuiSideNavTitle>
<KuiSideNavItem>Data sources</KuiSideNavItem>
<KuiSideNavItem>Users</KuiSideNavItem>
<KuiSideNavItem>Roles</KuiSideNavItem>
<KuiSideNavItem isSelected>Watches</KuiSideNavItem>
<KuiSideNavItem>Extremely long item is long</KuiSideNavItem>

<KuiSideNavTitle>Kibana</KuiSideNavTitle>
<KuiSideNavItem>Index Patterns</KuiSideNavItem>
<KuiSideNavItem>Saved Objects</KuiSideNavItem>
<KuiSideNavItem>Reporting</KuiSideNavItem>

<KuiSideNavTitle>Logstash</KuiSideNavTitle>
<KuiSideNavItem>Pipeline Viewer</KuiSideNavItem>
</KuiSideNav>
</KuiPageSidebar>
{this.renderSideNav()}
<KuiPageContent>
<KuiPageContentHeader>
<KuiPageContentHeaderSection>
Expand All @@ -326,7 +404,7 @@ export default class extends Component {
<KuiPageContentHeaderSection>
<KuiButton
fill
icon = "arrowDown"
icon="arrowDown"
onClick={() => window.alert('Button clicked')}
iconReverse
>
Expand Down
8 changes: 4 additions & 4 deletions ui_framework/doc_site/src/views/page/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
KuiPageContentHeaderSection,
KuiPageHeader,
KuiPageHeaderSection,
KuiPageSidebar,
KuiPageSideBar,
KuiTitle,
} from '../../../../components';

Expand All @@ -26,9 +26,9 @@ export default () => (
</KuiPageHeaderSection>
</KuiPageHeader>
<KuiPageBody>
<KuiPageSidebar>
Sidebar nav
</KuiPageSidebar>
<KuiPageSideBar>
SideBar nav
</KuiPageSideBar>
<KuiPageContent>
<KuiPageContentHeader>
<KuiPageContentHeaderSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
KuiPageContentHeaderSection,
KuiPageHeader,
KuiPageHeaderSection,
KuiPageSidebar,
KuiPageSideBar,
KuiTitle,
} from '../../../../components';

Expand All @@ -27,9 +27,9 @@ export default () => (
</KuiPageHeaderSection>
</KuiPageHeader>
<KuiPageBody>
<KuiPageSidebar>
Sidebar nav
</KuiPageSidebar>
<KuiPageSideBar>
SideBar nav
</KuiPageSideBar>
<KuiPageContent verticalPosition="center" horizontalPosition="center">
<KuiPageContentHeader>
<KuiPageContentHeaderSection>
Expand Down
12 changes: 6 additions & 6 deletions ui_framework/doc_site/src/views/page/page_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import PageContentCenter from './page_content_center';
const pageContentCenterSource = require('!!raw!./page_content_center');
const pageContentCenterHtml = renderToHtml(Page);

import PageContentCenterWithSidebar from './page_content_center_with_sidebar';
const PageContentCenterWithSidebarSource = require('!!raw!./page_content_center_with_sidebar');
const PageContentCenterWithSidebarHtml = renderToHtml(Page);
import PageContentCenterWithSideBar from './page_content_center_with_side_bar';
const PageContentCenterWithSideBarSource = require('!!raw!./page_content_center_with_side_bar');
const PageContentCenterWithSideBarHtml = renderToHtml(Page);

export default props => (
<GuidePage title={props.route.name}>
Expand Down Expand Up @@ -116,10 +116,10 @@ export default props => (
title="Page content centered in a full layout"
source={[{
type: GuideSectionTypes.JS,
code: PageContentCenterWithSidebarSource,
code: PageContentCenterWithSideBarSource,
}, {
type: GuideSectionTypes.HTML,
code: PageContentCenterWithSidebarHtml,
code: PageContentCenterWithSideBarHtml,
}]}
>
<GuideText>
Expand All @@ -128,7 +128,7 @@ export default props => (
</GuideText>

<GuideDemo>
<div className="guideDemo__highlightLayout"><PageContentCenterWithSidebar /></div>
<div className="guideDemo__highlightLayout"><PageContentCenterWithSideBar /></div>
</GuideDemo>
</GuideSection>

Expand Down
123 changes: 104 additions & 19 deletions ui_framework/doc_site/src/views/side_nav/side_nav.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,111 @@
import React from 'react';
import React, {
Component,
} from 'react';

import {
KuiSideNav,
KuiSideNavItem,
KuiSideNavTitle,
} from '../../../../components';

export default () => (
<KuiSideNav>
<KuiSideNavTitle>Elasticsearch</KuiSideNavTitle>
<KuiSideNavItem>Data sources</KuiSideNavItem>
<KuiSideNavItem>Users</KuiSideNavItem>
<KuiSideNavItem>Roles</KuiSideNavItem>
<KuiSideNavItem isSelected>Watches</KuiSideNavItem>
<KuiSideNavItem>Extremely long item is long</KuiSideNavItem>

<KuiSideNavTitle>Kibana</KuiSideNavTitle>
<KuiSideNavItem>Index Patterns</KuiSideNavItem>
<KuiSideNavItem>Saved Objects</KuiSideNavItem>
<KuiSideNavItem>Reporting</KuiSideNavItem>

<KuiSideNavTitle>Logstash</KuiSideNavTitle>
<KuiSideNavItem>Pipeline Viewer</KuiSideNavItem>
</KuiSideNav>
);
export default class extends Component {
constructor(props) {
super(props);

this.state = {
isSideNavOpenOnMobile: false,
};
}

toggleOpenOnMobile() {
this.setState({
isSideNavOpenOnMobile: !this.state.isSideNavOpenOnMobile,
});
}

render() {
return (
<KuiSideNav
mobileTitle="Navigate within $APP_NAME"
toggleOpenOnMobile={this.toggleOpenOnMobile.bind(this)}
isOpenOnMobile={this.state.isSideNavOpenOnMobile}
>
{/* Elasticsearch section */}

<KuiSideNavTitle>
Elasticsearch
</KuiSideNavTitle>

<KuiSideNavItem>
<button onClick={() => window.alert('Button clicked')}>
Data sources
</button>
</KuiSideNavItem>

<KuiSideNavItem>
<a href="http://www.elastic.co">
Users
</a>
</KuiSideNavItem>

<KuiSideNavItem>
<button>
Roles
</button>
</KuiSideNavItem>

<KuiSideNavItem isSelected>
<button>
Watches
</button>
</KuiSideNavItem>

<KuiSideNavItem>
<button>
Extremely long title will become truncated when the browser is narrow enough
</button>
</KuiSideNavItem>

{/* Kibana section */}

<KuiSideNavTitle>
<button>
Kibana
</button>
</KuiSideNavTitle>

<KuiSideNavItem>
<button>
Index Patterns
</button>
</KuiSideNavItem>

<KuiSideNavItem>
<button>
Saved Objects
</button>
</KuiSideNavItem>

<KuiSideNavItem>
<button>
Reporting
</button>
</KuiSideNavItem>

{/* Logstash section */}

<KuiSideNavTitle>
<button>
Logstash
</button>
</KuiSideNavTitle>

<KuiSideNavItem>
<button>
Pipeline Viewer
</button>
</KuiSideNavItem>
</KuiSideNav>
);
}
}
Loading

0 comments on commit 0940ea3

Please sign in to comment.