Skip to content

Commit

Permalink
[EuiLoadingSpinner] Change s-size to match EuiIcon (#5440)
Browse files Browse the repository at this point in the history
* Fix xs-sized isLoading EuiButtonEmpty with icons

- widths would previously jump around due to the loading spinner being smaller than the icon

* Add changelog entry

* Revert "Fix xs-sized isLoading EuiButtonEmpty with icons"

This reverts commit 881277f.

* Increase the size of `s` EuiLoadingSpinner to match EuiIcon

* Fix changelog location after release

* Update `EuiFormControlLayoutIcons` to use a small loading spinner when compressed

* fix snapshot
  • Loading branch information
Constance authored Dec 7, 2021
1 parent b9f5dea commit 2126dd0
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
**Breaking changes**

- Changed prop name `applyRefreshInterval` to `onRefreshChange` in `EuiRefreshInterval` ([#5383](https://github.com/elastic/eui/pull/5383))
- Increased the size of `s`-sized `EuiLoadingSpinner`s to match `s`-sized `EuiIcon`s ([#5440](https://github.com/elastic/eui/pull/5440))

## [`42.1.0`](https://github.com/elastic/eui/tree/v42.1.0)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,47 @@ exports[`EuiFormControlLayout props clear onClick is rendered 1`] = `
</div>
`;

exports[`EuiFormControlLayout props compressed renders small-sized icon, clear button, and loading spinner 1`] = `
<div
class="euiFormControlLayout euiFormControlLayout--compressed"
>
<div
class="euiFormControlLayout__childrenWrapper"
>
<div
class="euiFormControlLayoutIcons"
>
<span
class="euiFormControlLayoutCustomIcon"
>
<span
aria-hidden="true"
class="euiFormControlLayoutCustomIcon__icon"
data-euiicon-type="alert"
/>
</span>
</div>
<div
class="euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
>
<button
aria-label="Clear input"
class="euiFormControlLayoutClearButton euiFormControlLayoutClearButton--small"
type="button"
>
<span
class="euiFormControlLayoutClearButton__icon"
data-euiicon-type="cross"
/>
</button>
<span
class="euiLoadingSpinner euiLoadingSpinner--small"
/>
</div>
</div>
</div>
`;

exports[`EuiFormControlLayout props fullWidth is rendered 1`] = `
<div
class="euiFormControlLayout euiFormControlLayout--fullWidth"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ describe('EuiFormControlLayout', () => {
expect(component).toMatchSnapshot();
});

describe('compressed', () => {
it('renders small-sized icon, clear button, and loading spinner', () => {
const component = render(
<EuiFormControlLayout
compressed
icon={{ type: 'alert' }}
clear={{ onClick: jest.fn() }}
isLoading
/>
);

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

test('fullWidth is rendered', () => {
const component = render(<EuiFormControlLayout fullWidth />);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ export class EuiFormControlLayoutIcons extends Component<
}

renderLoadingSpinner() {
const { isLoading } = this.props;
const { isLoading, compressed } = this.props;

if (!isLoading) {
return null;
}

return <EuiLoadingSpinner size="m" />;
return <EuiLoadingSpinner size={compressed ? 's' : 'm'} />;
}

renderClearButton() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/loading/_loading_spinner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
}

.euiLoadingSpinner--small {
width: $euiSizeS;
height: $euiSizeS;
width: $euiSizeM;
height: $euiSizeM;
border-width: 1px;
}

Expand Down

0 comments on commit 2126dd0

Please sign in to comment.