Skip to content
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

More cleanup #5

Merged
merged 2 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 1 addition & 69 deletions src-docs/src/views/nav_drawer/nav_drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,13 @@ export default class extends Component {
{
label: 'Recently viewed',
iconType: 'clock',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Recently viewed items',
flyoutMenu: {
title: 'Recent items',
listItems: [
{
label: 'My dashboard',
href: '/#/layout/nav-drawer',
iconType: 'dashboardApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'My dashboard',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -66,9 +60,6 @@ export default class extends Component {
label: 'Workpad with title that wraps',
href: '/#/layout/nav-drawer',
iconType: 'canvasApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Workpad with title that wraps',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -80,9 +71,7 @@ export default class extends Component {
label: 'My logs',
href: '/#/layout/nav-drawer',
iconType: 'loggingApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'My logs',
'aria-label': 'This is an alternate aria-label',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -96,19 +85,13 @@ export default class extends Component {
{
label: 'Favorites',
iconType: 'starEmpty',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Favorited items',
flyoutMenu: {
title: 'Favorite items',
listItems: [
{
label: 'My workpad',
href: '/#/layout/nav-drawer',
iconType: 'canvasApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'My workpad',
extraAction: {
color: 'subdued',
iconType: 'starFilled',
Expand All @@ -121,9 +104,6 @@ export default class extends Component {
label: 'My logs',
href: '/#/layout/nav-drawer',
iconType: 'loggingApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'My logs',
extraAction: {
color: 'subdued',
iconType: 'starFilled',
Expand All @@ -142,9 +122,6 @@ export default class extends Component {
label: 'Canvas',
href: '/#/layout/nav-drawer',
iconType: 'canvasApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Canvas',
isActive: true,
extraAction: {
color: 'subdued',
Expand All @@ -158,9 +135,6 @@ export default class extends Component {
label: 'Discover',
href: '/#/layout/nav-drawer',
iconType: 'discoverApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Discover',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -172,9 +146,6 @@ export default class extends Component {
label: 'Visualize',
href: '/#/layout/nav-drawer',
iconType: 'visualizeApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Visualize',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -186,9 +157,6 @@ export default class extends Component {
label: 'Dashboard',
href: '/#/layout/nav-drawer',
iconType: 'dashboardApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Dashboard',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -200,9 +168,6 @@ export default class extends Component {
label: 'Machine learning',
href: '/#/layout/nav-drawer',
iconType: 'machineLearningApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Machine learning',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -214,9 +179,6 @@ export default class extends Component {
label: 'Graph',
href: '/#/layout/nav-drawer',
iconType: 'graphApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Graph',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -231,9 +193,6 @@ export default class extends Component {
label: 'APM',
href: '/#/layout/nav-drawer',
iconType: 'apmApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'APM',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -245,9 +204,6 @@ export default class extends Component {
label: 'Infrastructure',
href: '/#/layout/nav-drawer',
iconType: 'infraApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Infra',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -259,9 +215,6 @@ export default class extends Component {
label: 'Log viewer',
href: '/#/layout/nav-drawer',
iconType: 'loggingApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Logs',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -273,9 +226,6 @@ export default class extends Component {
label: 'Uptime',
href: '/#/layout/nav-drawer',
iconType: 'upgradeAssistantApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Graph',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -287,9 +237,6 @@ export default class extends Component {
label: 'Maps',
href: '/#/layout/nav-drawer',
iconType: 'gisApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Maps',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -301,9 +248,6 @@ export default class extends Component {
label: 'SIEM',
href: '/#/layout/nav-drawer',
iconType: 'securityAnalyticsApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'SIEM',
extraAction: {
color: 'subdued',
iconType: 'pin',
Expand All @@ -317,19 +261,13 @@ export default class extends Component {
{
label: 'Admin',
iconType: 'managementApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Admin',
flyoutMenu: {
title: 'Tools and settings',
listItems: [
{
label: 'Dev tools',
href: '/#/layout/nav-drawer',
iconType: 'devToolsApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Dev tools',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -341,9 +279,6 @@ export default class extends Component {
label: 'Stack Monitoring',
href: '/#/layout/nav-drawer',
iconType: 'monitoringApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Monitoring',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -355,9 +290,6 @@ export default class extends Component {
label: 'Stack Management',
href: '/#/layout/nav-drawer',
iconType: 'managementApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'Management',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand Down
1 change: 1 addition & 0 deletions src/components/nav_drawer/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
// Components
@import 'nav_drawer';
@import 'nav_drawer_flyout';
@import 'nav_drawer_group';
14 changes: 0 additions & 14 deletions src/components/nav_drawer/_nav_drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,6 @@
&-hasFooter {
padding-bottom: $euiSizeXXL;
}

.euiListGroupItem__label {
transition: all $euiAnimSpeedExtraFast;
}
}

.euiListGroupItem__button:focus {
background-color: $euiFocusBackgroundColor;
border-radius: $euiBorderRadius;
}

.euiListGroupItem__label {
line-height: $euiSize;
}

.euiNavDrawer__expandButton {
Expand Down Expand Up @@ -101,7 +88,6 @@
width: 0;

&.euiNavDrawer-isExpanded .euiNavDrawerMenu {

.euiListGroupItem__icon {
margin-right: $euiSizeM;
}
Expand Down
16 changes: 16 additions & 0 deletions src/components/nav_drawer/_nav_drawer_group.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.euiNavDrawerGroup__item {
line-height: $euiSize;

.euiListGroupItem__label {
transition: all $euiAnimSpeedExtraFast;
}

.euiListGroupItem__button {
color: inherit; // Force color to inherit from regular text color in case it's an anchor tag

&:focus {
background-color: $euiFocusBackgroundColor;
border-radius: $euiBorderRadius;
}
}
}
5 changes: 3 additions & 2 deletions src/components/nav_drawer/nav_drawer_flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
import classNames from 'classnames';

import { EuiTitle } from '../title';
import { EuiListGroup } from '../list_group';
import { EuiNavDrawerGroup } from './nav_drawer_group';
import { EuiListGroup } from '../list_group/list_group';

export const EuiNavDrawerFlyout = ({ className, title, isCollapsed, listItems, wrapText, ...rest }) => {
const classes = classNames(
Expand All @@ -22,7 +23,7 @@ export const EuiNavDrawerFlyout = ({ className, title, isCollapsed, listItems, w
{...rest}
>
<EuiTitle className="euiNavDrawerFlyout__title" tabIndex="-1" size="xxs"><h5 id="navDrawerFlyoutTitle">{title}</h5></EuiTitle>
<EuiListGroup className="euiNavDrawerFlyout__listGroup" listItems={listItems} wrapText={wrapText} />
<EuiNavDrawerGroup className="euiNavDrawerFlyout__listGroup" listItems={listItems} wrapText={wrapText} />
</div>
);
};
Expand Down
13 changes: 10 additions & 3 deletions src/components/nav_drawer/nav_drawer_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export const EuiNavDrawerGroup = ({ className, listItems, flyoutMenuButtonClick,
className
);

// Create handlers if flyoutMenu exists
const newListItems = listItems.map((item) => {
const listItemsExists = listItems && listItems.length;

// Alter listItems object with prop flyoutMenu and extra props
const newListItems = listItemsExists && listItems.map((item) => {
// If the flyout menu exists, pass back the list of times and the title with the onClick handler of the item
const { flyoutMenu, ...itemProps } = item;
if (flyoutMenu && flyoutMenuButtonClick) {
Expand All @@ -20,6 +22,11 @@ export const EuiNavDrawerGroup = ({ className, listItems, flyoutMenuButtonClick,
itemProps.onClick = () => flyoutMenuButtonClick(items, title);
}

// Make some declarations of props for the side nav implementation
itemProps.className = classNames('euiNavDrawerGroup__item', item.className);
itemProps.size = item.size || 's';
itemProps['aria-label'] = item['aria-label'] || item.label;

// And return the item with conditional `onClick` and without `flyoutMenu`
return { ...itemProps };
});
Expand All @@ -37,7 +44,7 @@ EuiNavDrawerGroup.propTypes = {
title: PropTypes.string.isRequired,
listItems: EuiListGroup.propTypes.listItems.isRequired,
}),
})).isRequired,
})),
/**
* While not normally required, it is required to pass a function for handling
* of the flyout menu button click
Expand Down