Skip to content

Commit

Permalink
Allow EuiListGroupItem link text to wrap (#1459)
Browse files Browse the repository at this point in the history
* make side nav flyout links wrap

* adds prop to wrap EuiListItem text

* change isWrappable to displayType

* export types and move class to parent

* remove displayType, truncate long labels, add wrapText

* icon min-width, ie fixes
  • Loading branch information
Ryan Keairns authored Jan 23, 2019
1 parent 967ae85 commit 8f36ae1
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Adds `wrapText` prop that enables `EuiListGroupItem` text to wrap ([#1459](https://github.com/elastic/eui/pull/1459))
- Added `inputRef` prop to `EuiFieldNumber` and updated `EuiFieldText`'s to a Ref type ([#1434](https://github.com/elastic/eui/pull/1434))
- Added `snowflake` icon ([#1445](https://github.com/elastic/eui/pull/1445))
- Added `bell` icon ([#1447](https://github.com/elastic/eui/pull/1447))
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/list_group/list_group_links.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const myContent = [
size: 's',
},
{
label: 'Second link is active',
label: 'This is an active link with very long label that truncates',
href: '#/display/list-group',
isActive: true,
iconType: 'clock',
Expand Down
11 changes: 7 additions & 4 deletions src-docs/src/views/nav_drawer/nav_drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,12 @@ export default class extends Component {
},
},
{
label: 'My workpad',
label: 'Workpad with title that wraps',
href: '/#/layout/nav-drawer',
iconType: 'canvasApp',
size: 's',
style: { color: 'inherit' },
'aria-label': 'My workpad',
'aria-label': 'Workpad with title that wraps',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand Down Expand Up @@ -522,8 +522,10 @@ export default class extends Component {
}, 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);
setTimeout(() => {
document.getElementById('navDrawerMenu').scrollTop = 0;
document.getElementById('navDrawerFlyout').scrollTop = 0;
}, 300);
};

focusOut = () => {
Expand Down Expand Up @@ -635,6 +637,7 @@ export default class extends Component {
isCollapsed={flyoutIsCollapsed}
listItems={navFlyoutContent}
onMouseLeave={this.collapseFlyout}
wrapText={true}
/>
</EuiNavDrawer>
</EuiOutsideClickDetector>
Expand Down
1 change: 0 additions & 1 deletion src/components/header/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Components
@import '../header/variables';
@import 'variables';
@import 'header';
@import 'header_profile';
Expand Down
24 changes: 24 additions & 0 deletions src/components/list_group/_list_group_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@
align-items: center;
flex: 1 0 auto; // The flex-shrink and flex-basis values are needed for IE11
text-align: left;
max-width: 100%;

.euiListGroupItem-hasExtraAction & {
max-width: calc(100% - #{$euiSizeXL});
}
}

.euiListGroupItem__label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.euiListGroupItem__button:focus {
Expand All @@ -65,6 +76,7 @@
.euiListGroupItem__icon {
flex-grow: 0;
margin-right: $euiSizeM;
flex-shrink: 0;
}

.euiListGroupItem--xSmall {
Expand All @@ -79,6 +91,18 @@
font-size: $euiFontSizeL;
}

.euiListGroup-wrapText {
.euiListGroupItem__button,
.euiListGroupItem__text {
width: 100%;
word-break: break-word;
}

.euiListGroupItem__label {
white-space: initial;
}
}

// Layout alts from euiListGroup

.euiListGroup-flush .euiListGroupItem {
Expand Down
8 changes: 8 additions & 0 deletions src/components/list_group/list_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const EuiListGroup = ({
className,
flush,
bordered,
wrapText,
listItems,
maxWidth,
style,
Expand All @@ -31,6 +32,7 @@ export const EuiListGroup = ({
{
'euiListGroup-flush': flush,
'euiListGroup-bordered': bordered,
'euiListGroup-wrapText': wrapText,
},
widthClassName,
className
Expand Down Expand Up @@ -85,6 +87,11 @@ EuiListGroup.propTypes = {
*/
bordered: PropTypes.bool,

/**
* Allow link text to wrap
*/
wrapText: PropTypes.bool,

/**
* Sets the max-width of the page,
* set to `true` to use the default size,
Expand All @@ -102,5 +109,6 @@ EuiListGroup.propTypes = {
EuiListGroup.defaultProps = {
flush: false,
bordered: false,
wrapText: false,
maxWidth: true,
};
1 change: 1 addition & 0 deletions src/components/list_group/list_group_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const EuiListGroupItem = ({
'euiListGroupItem-isActive': isActive,
'euiListGroupItem-isDisabled': isDisabled,
'euiListGroupItem-isClickable': href || onClick,
'euiListGroupItem-hasExtraAction': extraAction,
},
className
);
Expand Down
1 change: 1 addition & 0 deletions src/components/nav_drawer/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import '../header/variables';
@import 'variables';

// Components
Expand Down
26 changes: 26 additions & 0 deletions src/components/nav_drawer/_nav_drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
transition: width $euiAnimSpeedFast $euiAnimSlightResistance;
transition-delay: $euiNavDrawerContractingDelay;

&.euiNavDrawer-isCollapsed {
.euiListGroupItem-hasExtraAction .euiListGroupItem__button {
max-width: 100%;
}
}

&.euiNavDrawer-isExpanded {
width: $euiNavDrawerWidthExpanded;
transition-delay: $euiNavDrawerExpandingDelay;
Expand Down Expand Up @@ -50,6 +56,18 @@
// sass-lint:disable no-vendor-prefixes
-ms-overflow-style: -ms-autohiding-scrollbar;
}

.euiListGroupItem__label {
line-height: $euiSize;
}

.euiListGroupItem__extraAction {
visibility: hidden;
}

&.euiNavDrawer-showScrollbar .euiListGroupItem__extraAction {
visibility: visible;
}
}

@include euiBreakpoint('xs', 's') {
Expand All @@ -72,6 +90,10 @@
.euiNavDrawerMenu {
width: $euiNavDrawerWidthCollapsed;
overflow-y: hidden;

.euiListGroupItem__extraAction {
visibility: hidden;
}
}

.euiNavDrawerMenu .euiListGroupItem__label {
Expand All @@ -88,6 +110,10 @@
.euiNavDrawerMenu .euiListGroupItem__label {
opacity: 1;
}

.euiListGroupItem__extraAction {
visibility: visible;
}
}
}

Expand Down
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 @@ -5,7 +5,7 @@ import classNames from 'classnames';
import { EuiTitle } from '../title';
import { EuiListGroup } from '../list_group';

export const EuiNavDrawerFlyout = ({ className, title, isCollapsed, listItems, ...rest }) => {
export const EuiNavDrawerFlyout = ({ className, title, isCollapsed, listItems, wrapText, ...rest }) => {
const classes = classNames(
'euiNavDrawerFlyout',
{
Expand All @@ -22,14 +22,15 @@ export const EuiNavDrawerFlyout = ({ className, title, isCollapsed, listItems, .
{...rest}
>
<EuiTitle tabIndex="-1" size="xxs"><h5 id="navDrawerFlyoutTitle">{title}</h5></EuiTitle>
<EuiListGroup className="euiNavDrawerFlyout__listGroup" listItems={listItems} />
<EuiListGroup className="euiNavDrawerFlyout__listGroup" listItems={listItems} wrapText={wrapText} />
</div>
);
};

EuiNavDrawerFlyout.propTypes = {
className: PropTypes.string,
listItems: EuiListGroup.propTypes.listItems,
wrapText: EuiListGroup.propTypes.wrapText,

/**
* Display a title atop the flyout
Expand Down

0 comments on commit 8f36ae1

Please sign in to comment.