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

fix(ListBox): update listbox components to match spec #7518

Merged
merged 15 commits into from
Feb 1, 2021
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
8 changes: 8 additions & 0 deletions packages/components/src/components/combo-box/_combo-box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
/// @access private
/// @group combo-box
@mixin combo-box {
.#{$prefix}--combo-box:hover {
background-color: $field-01;
}

.#{$prefix}--combo-box.#{$prefix}--list-box--light:hover {
background-color: $field-02;
}

.#{$prefix}--combo-box .#{$prefix}--text-input::-ms-clear {
display: none;
}
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/components/dropdown/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@mixin dropdown {
.#{$prefix}--dropdown__wrapper--inline {
display: inline-grid;
grid-gap: rem(4px);
grid-gap: rem(24px);
grid-template: auto auto / auto min-content;
align-items: center;

Expand Down Expand Up @@ -140,6 +140,10 @@

.#{$prefix}--dropdown--light {
background-color: $field-02;

&:hover {
background-color: $hover-light-ui;
}
}

.#{$prefix}--dropdown--up .#{$prefix}--dropdown-list {
Expand Down
10 changes: 9 additions & 1 deletion packages/components/src/components/list-box/_list-box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ $list-box-menu-width: rem(300px);
// Light variation for 'list-box'
.#{$prefix}--list-box--light {
background-color: $field-02;

&:hover {
background-color: $hover-light-ui;
}
}

.#{$prefix}--list-box--light .#{$prefix}--list-box__menu {
Expand Down Expand Up @@ -440,7 +444,7 @@ $list-box-menu-width: rem(300px);
}

.#{$prefix}--list-box__selection > svg {
fill: $icon-02;
fill: $icon-01;

// Windows, Firefox HCM Fix
@media screen and (-ms-high-contrast: active),
Expand Down Expand Up @@ -587,6 +591,10 @@ $list-box-menu-width: rem(300px);
}
}

.#{$prefix}--list-box--light .#{$prefix}--list-box__menu-item:hover {
background-color: $hover-light-ui;
}

.#{$prefix}--list-box--sm .#{$prefix}--list-box__menu-item {
height: rem(32px);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
/// @access private
/// @group multi-select
@mixin multiselect {
.#{$prefix}--multi-select .#{$prefix}--tag {
min-width: auto;
margin: 0 $carbon--spacing-03 0 0;
}

.#{$prefix}--multi-select--filterable .#{$prefix}--tag {
margin: 0 $carbon--spacing-03 0 $carbon--spacing-05;
}

.#{$prefix}--multi-select .#{$prefix}--list-box__menu {
min-width: auto;
}
Expand Down Expand Up @@ -56,14 +65,6 @@
color: $text-01;
}

.#{$prefix}--multi-select--filterable .#{$prefix}--text-input {
padding-left: $spacing-03;
}

.#{$prefix}--multi-select--filterable:hover .#{$prefix}--text-input {
background-color: $hover-ui;
}

.#{$prefix}--multi-select--filterable.#{$prefix}--list-box--disabled:hover
.#{$prefix}--text-input {
background-color: $field-01;
Expand Down
6 changes: 6 additions & 0 deletions packages/react/src/components/Dropdown/Dropdown-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const directions = {
'Top ': 'top',
};

const types = {
Default: '',
Inline: 'inline',
};

const props = () => ({
id: text('Dropdown ID (id)', 'carbon-dropdown-example'),
size: select('Field size (size)', sizes, undefined) || undefined,
Expand All @@ -67,6 +72,7 @@ const props = () => ({
'Form validation UI content (invalidText)',
'A valid value is required'
),
type: select('Type (type)', types, ''),
warn: boolean('Show warning state (warn)', false),
warnText: text(
'Warning state text (warnText)',
Expand Down
29 changes: 27 additions & 2 deletions packages/react/src/components/ListBox/ListBoxSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,39 @@ const ListBoxSelection = ({
}
};
const description = selectionCount ? t('clear.all') : t('clear.selection');
return (
const tagClasses = cx(
`${prefix}--tag`,
`${prefix}--tag--filter`,
`${prefix}--tag--high-contrast`,
{
[`${prefix}--tag--disabled`]: disabled,
}
);
return selectionCount ? (
<div className={tagClasses}>
<span className={`${prefix}--tag__label`} title={selectionCount}>
{selectionCount}
</span>
<div
role="button"
tabIndex={disabled ? -1 : 0}
className={`${prefix}--tag__close-icon`}
onClick={handleOnClick}
onKeyDown={handleOnKeyDown}
disabled={disabled}
aria-label={t('clear.all')}
title={description}>
<Close16 />
</div>
</div>
) : (
<div
role="button"
className={className}
tabIndex={disabled ? -1 : 0}
onClick={handleOnClick}
onKeyDown={handleOnKeyDown}
aria-label="Clear Selection"
aria-label={description}
title={description}>
{selectionCount}
<Close16 />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports[`ListBoxField should render 1`] = `
translateWithId={[Function]}
>
<div
aria-label="Clear Selection"
aria-label="Clear selected item"
className="bx--list-box__selection"
onClick={[Function]}
onKeyDown={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ exports[`ListBoxSelection should render 1`] = `
Array [
"clear.all",
],
Array [
"clear.all",
],
],
"results": Array [
Object {
Expand All @@ -22,12 +25,16 @@ exports[`ListBoxSelection should render 1`] = `
"type": "return",
"value": "translation",
},
Object {
"type": "return",
"value": "translation",
},
],
}
}
>
<div
aria-label="Clear Selection"
aria-label="translation"
className="bx--list-box__selection"
onClick={[Function]}
onKeyDown={[Function]}
Expand Down Expand Up @@ -77,6 +84,9 @@ exports[`ListBoxSelection should render 2`] = `
Array [
"clear.all",
],
Array [
"clear.all",
],
],
"results": Array [
Object {
Expand All @@ -87,45 +97,58 @@ exports[`ListBoxSelection should render 2`] = `
"type": "return",
"value": "translation",
},
Object {
"type": "return",
"value": "translation",
},
],
}
}
>
<div
aria-label="Clear Selection"
className="bx--list-box__selection bx--tag--filter bx--list-box__selection--multi"
onClick={[Function]}
onKeyDown={[Function]}
role="button"
tabIndex={0}
title="translation"
className="bx--tag bx--tag--filter bx--tag--high-contrast"
>
3
<ForwardRef(Close16)>
<Icon
fill="currentColor"
height={16}
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 32 32"
width={16}
xmlns="http://www.w3.org/2000/svg"
>
<svg
aria-hidden={true}
<span
className="bx--tag__label"
title={3}
>
3
</span>
<div
aria-label="translation"
className="bx--tag__close-icon"
onClick={[Function]}
onKeyDown={[Function]}
role="button"
tabIndex={0}
title="translation"
>
<ForwardRef(Close16)>
<Icon
fill="currentColor"
focusable="false"
height={16}
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 32 32"
width={16}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M24 9.4L22.6 8 16 14.6 9.4 8 8 9.4 14.6 16 8 22.6 9.4 24 16 17.4 22.6 24 24 22.6 17.4 16 24 9.4z"
/>
</svg>
</Icon>
</ForwardRef(Close16)>
<svg
aria-hidden={true}
fill="currentColor"
focusable="false"
height={16}
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 32 32"
width={16}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M24 9.4L22.6 8 16 14.6 9.4 8 8 9.4 14.6 16 8 22.6 9.4 24 16 17.4 22.6 24 24 22.6 17.4 16 24 9.4z"
/>
</svg>
</Icon>
</ForwardRef(Close16)>
</div>
</div>
</ListBoxSelection>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,15 @@ describe('MultiSelect', () => {
Simulate.click(itemNode);

expect(
document.querySelector('[aria-label="Clear Selection"]')
document.querySelector('[aria-label="Clear all selected items"]')
).toBeTruthy();

Simulate.click(document.querySelector('[aria-label="Clear Selection"]'));
Simulate.click(
document.querySelector('[aria-label="Clear all selected items"]')
);

expect(
document.querySelector('[aria-label="Clear Selection"]')
document.querySelector('[aria-label="Clear all selected items"]')
).toBeFalsy();
});

Expand Down Expand Up @@ -250,7 +252,7 @@ describe('MultiSelect', () => {
);

expect(
document.querySelector('[aria-label="Clear Selection"]')
document.querySelector('[aria-label="Clear all selected items"]')
).toBeTruthy();

const labelNode = getByText(container, label);
Expand Down