Skip to content

Commit

Permalink
[Feature branch] Compressed EuiSuperSelect dropdown (#2155)
Browse files Browse the repository at this point in the history
- Added truncation example
- Added max-height
  • Loading branch information
cchaos authored and cchaos committed Aug 29, 2019
1 parent eb5297a commit 89c9966
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src-docs/src/views/super_select/super_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ export default class extends Component {
},
{
value: 'option_three',
inputDisplay:
'Option three has a super long text to see if it will truncate or what',
inputDisplay: (
<span className="eui-textTruncate eui-displayBlock">
Option three has a super long text and added truncation
</span>
),
},
];

Expand Down
5 changes: 1 addition & 4 deletions src-docs/src/views/super_select/super_select_complex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component, Fragment } from 'react';

import { EuiSuperSelect, EuiSpacer, EuiText } from '../../../../src/components';
import { EuiSuperSelect, EuiText } from '../../../../src/components';

export default class extends Component {
constructor(props) {
Expand All @@ -13,7 +13,6 @@ export default class extends Component {
dropdownDisplay: (
<Fragment>
<strong>Option one</strong>
<EuiSpacer size="xs" />
<EuiText size="s" color="subdued">
<p className="euiTextColor--subdued">
Has a short description giving more detail to the option.
Expand All @@ -28,7 +27,6 @@ export default class extends Component {
dropdownDisplay: (
<Fragment>
<strong>Option two</strong>
<EuiSpacer size="xs" />
<EuiText size="s" color="subdued">
<p className="euiTextColor--subdued">
Has a short description giving more detail to the option.
Expand All @@ -43,7 +41,6 @@ export default class extends Component {
dropdownDisplay: (
<Fragment>
<strong>Option three</strong>
<EuiSpacer size="xs" />
<EuiText size="s" color="subdued">
<p className="euiTextColor--subdued">
Has a short description giving more detail to the option.
Expand Down
1 change: 1 addition & 0 deletions src/components/context_menu/_context_menu_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

.euiContextMenuItem__text {
flex-grow: 1;
overflow: hidden; // allows for text truncation
}

.euiContextMenuItem__arrow {
Expand Down
16 changes: 15 additions & 1 deletion src/components/form/super_select/_super_select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
}
}

.euiSuperSelect__listbox {
@include euiScrollBar;
max-height: 300px;
overflow: hidden;
overflow-y: auto;
}

.euiSuperSelect__popoverPanel[class*='bottom'] { /* 3 */
border-top-color: transparentize($euiBorderColor, .2);
border-top-right-radius: 0; /* 2 */
Expand All @@ -26,11 +33,18 @@
}

.euiSuperSelect__item {
&:hover,
@include euiFontSizeS;
padding: $euiSizeS;

&:hover:not(:disabled),
&:focus {
text-decoration: none;
background-color: $euiFocusBackgroundColor;
}

&:disabled {
cursor: not-allowed;
}
}

.euiSuperSelect__item--hasDividers:not(:last-of-type) {
Expand Down
5 changes: 4 additions & 1 deletion src/components/form/super_select/super_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class EuiSuperSelect extends Component {
itemLayoutAlign,
fullWidth,
popoverClassName,
compressed,
...rest
} = this.props;

Expand Down Expand Up @@ -206,6 +207,7 @@ export class EuiSuperSelect extends Component {
className={buttonClasses}
fullWidth={fullWidth}
isInvalid={isInvalid}
compressed={compressed}
{...rest}
/>
);
Expand All @@ -222,7 +224,6 @@ export class EuiSuperSelect extends Component {
onKeyDown={this.onItemKeyDown}
layoutAlign={itemLayoutAlign}
buttonRef={node => this.setItemNode(node, index)}
style={{ width: this.state.menuWidth }}
role="option"
id={value}
aria-selected={valueOfSelected === value}
Expand Down Expand Up @@ -256,8 +257,10 @@ export class EuiSuperSelect extends Component {
</p>
</EuiScreenReaderOnly>
<div
className="euiSuperSelect__listbox"
role="listbox"
aria-activedescendant={valueOfSelected}
style={{ width: this.state.menuWidth }}
tabIndex="0">
{items}
</div>
Expand Down
13 changes: 13 additions & 0 deletions src/components/form/super_select/super_select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ describe('EuiSuperSelect', () => {
expect(component).toMatchSnapshot();
});

test('compressed is rendered', () => {
const component = render(
<EuiSuperSelect
{...requiredProps}
options={options}
onChange={() => {}}
compressed
/>
);

expect(component).toMatchSnapshot();
});

test('select component is rendered', () => {
const component = render(
<EuiSuperSelect
Expand Down

0 comments on commit 89c9966

Please sign in to comment.