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

Design comments for initial OptionsList #8

Open
wants to merge 3 commits into
base: controls/initialOptionsListComponent
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
}

.optionsList--buttonOverride {
&:hover:not(:disabled),
&:focus:not(:disabled) {
// Remove underline from whole button so notifications don't get the underline
text-decoration: none;

.optionsList--title {
// Add put it only on the actual text part
text-decoration: underline;
}
}
}

.optionsList--buttonOverrideTwoLine {
height: auto !important;
width: 100%;

Expand All @@ -19,16 +32,6 @@
}
}

&:hover:not(:disabled),
&:focus:not(:disabled) {
// Remove underline from whole button so notifications don't get the underline
text-decoration: none;

.optionsList--title {
// Add put it only on the actual text part
text-decoration: underline;
}
}
}

.optionsList--items {
Expand All @@ -40,33 +43,37 @@
max-width: 100%;
}

.optionsList--twoLine {
flex-direction: column;
}

.optionsList {
background-color: $euiFormBackgroundColor;
border: 1px solid $euiFormBorderColor;
border-radius: $euiBorderRadius;
display: flex;
align-items: stretch;
font-size: $euiFontSizeS;
width: 100%;
height: 100%;

&.optionsList--twoLine {
border: 1px solid $euiFormBorderColor;
border-radius: $euiBorderRadius;
display: flex;
align-items: stretch;
font-size: $euiFontSizeS;
flex-direction: column;

.optionsList--control {
height: $euiFormControlHeight;
flex-direction: row;
}
}

.optionsList--title {
background-color: $euiFormBorderColor;
padding: $euiSizeXS $euiSizeS;
display: flex;
align-items: center;
font-weight: $euiFontWeightBold;
}

.optionsList--control {
flex-grow: 1;
display: flex;
flex-direction: row;
height: $euiFormControlHeight;
align-items: center;
height: 100%;

.optionsList--selections {
flex: 1;
Expand All @@ -87,4 +94,25 @@
padding: $euiSizeXS;
}
}
}

.optionsList--formControlLayout {
max-width: unset;
}

.optionsList--popoverOverride {
width: 100%;
height: 100%;
}

.optionsList--buttonOverrideSingle {
height: 100%;
width: 100%;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
overflow: hidden;
}

.optionsList--search {
padding: $euiSizeS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
EuiFilterSelectItem,
EuiPopoverTitle,
EuiSelectableProps,
EuiFormControlLayout,
} from '@elastic/eui';

import classNames from 'classnames';
Expand Down Expand Up @@ -46,7 +47,10 @@ export const OptionsListControl = ({ twoLine, title, options }: OptionsListContr
const button = (
<EuiButtonEmpty
color="text"
className="optionsList--buttonOverride"
className={classNames('optionsList--buttonOverride', {
'optionsList--buttonOverrideTwoLine': twoLine,
'optionsList--buttonOverrideSingle': !twoLine,
})}
textProps={{
className: classNames('optionsList', {
'optionsList--twoLine': twoLine,
Expand All @@ -55,7 +59,7 @@ export const OptionsListControl = ({ twoLine, title, options }: OptionsListContr
onClick={() => setIsPopoverOpen((open) => !open)}
contentProps={{ className: 'optionsList--buttonContentOverride' }}
>
<span className="optionsList--title">{startCase(title)}</span>
{twoLine ? <span className="optionsList--title">{startCase(title)}</span> : null}
<span className="optionsList--control">
<span
className={classNames('optionsList--selections', {
Expand All @@ -82,27 +86,71 @@ export const OptionsListControl = ({ twoLine, title, options }: OptionsListContr
);

return (
<EuiPopover
id="popoverExampleMultiSelect"
button={button}
isOpen={isPopoverOpen}
anchorClassName="optionsList--anchorOverride"
closePopover={() => setIsPopoverOpen(false)}
panelPaddingSize="none"
anchorPosition="upLeft"
ownFocus
repositionOnScroll
>
<EuiPopoverTitle paddingSize="s">
<EuiFieldSearch compressed />
</EuiPopoverTitle>
<div className="optionsList--items">
{selectableOptions.map((item, index) => (
<EuiFilterSelectItem checked={item.checked} key={index} onClick={() => updateItem(index)}>
{item.label}
</EuiFilterSelectItem>
))}
</div>
</EuiPopover>
<>
{twoLine ? (
<EuiPopover
id="popoverExampleMultiSelect"
button={button}
isOpen={isPopoverOpen}
anchorClassName="optionsList--anchorOverride"
closePopover={() => setIsPopoverOpen(false)}
panelPaddingSize="none"
anchorPosition="upLeft"
ownFocus
repositionOnScroll
>
<EuiPopoverTitle paddingSize="s">{title}</EuiPopoverTitle>
<div className="optionsList--search">
<EuiFieldSearch compressed />
</div>
<div className="optionsList--items">
{selectableOptions.map((item, index) => (
<EuiFilterSelectItem
checked={item.checked}
key={index}
onClick={() => updateItem(index)}
>
{item.label}
</EuiFilterSelectItem>
))}
</div>
</EuiPopover>
) : (
<EuiFormControlLayout
className="optionsList--formControlLayout"
prepend={
<EuiButtonEmpty color="text" size="s" iconSide="right">
{startCase(title)}
</EuiButtonEmpty>
}
>
<EuiPopover
id="popoverExampleMultiSelect"
button={button}
className="optionsList--popoverOverride"
anchorClassName="optionsList--anchorOverride"
isOpen={isPopoverOpen}
closePopover={() => setIsPopoverOpen(false)}
panelPaddingSize="none"
>
<EuiPopoverTitle paddingSize="s">{title}</EuiPopoverTitle>
<div className="optionsList--search">
<EuiFieldSearch compressed />
</div>
<div className="optionsList--items">
{selectableOptions.map((item, index) => (
<EuiFilterSelectItem
checked={item.checked}
key={index}
onClick={() => updateItem(index)}
>
{item.label}
</EuiFilterSelectItem>
))}
</div>
</EuiPopover>
</EuiFormControlLayout>
)}
</>
);
};