Skip to content

Commit

Permalink
export types and move class to parent
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankeairns committed Jan 22, 2019
1 parent c04cc9d commit 658e75c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
4 changes: 1 addition & 3 deletions src-docs/src/views/nav_drawer/nav_drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ export default class extends Component {
size: 's',
style: { color: 'inherit' },
'aria-label': 'My dashboard',
displayType: 'wrapText',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -344,7 +343,6 @@ export default class extends Component {
size: 's',
style: { color: 'inherit' },
'aria-label': 'Workpad with title that wraps',
displayType: 'wrapText',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand All @@ -359,7 +357,6 @@ export default class extends Component {
size: 's',
style: { color: 'inherit' },
'aria-label': 'My logs',
displayType: 'wrapText',
extraAction: {
color: 'subdued',
iconType: 'starEmpty',
Expand Down Expand Up @@ -638,6 +635,7 @@ export default class extends Component {
isCollapsed={flyoutIsCollapsed}
listItems={navFlyoutContent}
onMouseLeave={this.collapseFlyout}
displayType="wrapText"
/>
</EuiNavDrawer>
</EuiOutsideClickDetector>
Expand Down
5 changes: 3 additions & 2 deletions src/components/list_group/_list_group_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@
font-size: $euiFontSizeL;
}

.euiListGroupItem-wrapText {
.euiListGroupItem__button {
.euiListGroup-wrapText {
.euiListGroupItem__button,
.euiListGroupItem__text {
width: 100%;
word-break: break-word;
line-height: $euiSize;
Expand Down
13 changes: 13 additions & 0 deletions src/components/list_group/list_group.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import {
EuiListGroupItem,
} from './list_group_item';

const displayTypeToClassNameMap = {
wrapText: 'euiListGroup-wrapText',
};

export const DISPLAY_TYPES = Object.keys(displayTypeToClassNameMap);

export const EuiListGroup = ({
children,
className,
Expand All @@ -14,6 +20,7 @@ export const EuiListGroup = ({
listItems,
maxWidth,
style,
displayType,
...rest,
}) => {

Expand All @@ -28,6 +35,7 @@ export const EuiListGroup = ({

const classes = classNames(
'euiListGroup',
displayTypeToClassNameMap[displayType],
{
'euiListGroup-flush': flush,
'euiListGroup-bordered': bordered,
Expand Down Expand Up @@ -97,6 +105,11 @@ EuiListGroup.propTypes = {
PropTypes.number,
PropTypes.string,
]),

/**
* Allow link text to wrap
*/
displayType: PropTypes.oneOf(DISPLAY_TYPES),
};

EuiListGroup.defaultProps = {
Expand Down
7 changes: 0 additions & 7 deletions src/components/list_group/list_group_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const EuiListGroupItem = ({
label,
isActive,
isDisabled,
displayType,
href,
className,
iconType,
Expand All @@ -34,7 +33,6 @@ export const EuiListGroupItem = ({
'euiListGroupItem-isActive': isActive,
'euiListGroupItem-isDisabled': isDisabled,
'euiListGroupItem-isClickable': href || onClick,
'euiListGroupItem-wrapText': displayType === 'wrapText',
},
className
);
Expand Down Expand Up @@ -128,11 +126,6 @@ EuiListGroupItem.propTypes = {
*/
isDisabled: PropTypes.bool,

/**
* Allow link text to wrap
*/
displayType: PropTypes.oneOf(['wrapText']),

/**
* Make the list item label a link
*/
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, displayType, ...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} displayType={displayType} />
</div>
);
};

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

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

0 comments on commit 658e75c

Please sign in to comment.