Skip to content

Commit

Permalink
Change spaces button loading design (#197922)
Browse files Browse the repository at this point in the history
Closes #197916 

## Summary

One less loading spinner. Instead, uses a skeleton loader for a
load-in-place effect that is visually less busy and jumpy.

*Before*
<img width="420"
src="https://github.com/user-attachments/assets/33ae37bf-c196-4bbf-a26e-ad469d7f3134"
/>

*After*


https://github.com/user-attachments/assets/33cc2d39-2895-4c53-8903-9c3b18d586f9
  • Loading branch information
ryankeairns authored Oct 30, 2024
1 parent f102ace commit b5d4601
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
visibility: hidden;
animation-play-state: paused;
}

.euiHeaderSectionItem .euiButtonEmpty__text {
// stop global header buttons from jumping during loading state
display: flex;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions x-pack/plugins/spaces/public/nav_control/nav_control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
* 2.0.
*/

import { EuiLoadingSpinner } from '@elastic/eui';
import { EuiSkeletonRectangle } from '@elastic/eui';
import { css } from '@emotion/react';
import React, { lazy, Suspense } from 'react';
import ReactDOM from 'react-dom';

import type { CoreStart } from '@kbn/core/public';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { euiThemeVars } from '@kbn/ui-theme';

import { initTour } from './solution_view_tour';
import type { EventTracker } from '../analytics';
Expand Down Expand Up @@ -40,7 +42,17 @@ export function initSpacesNavControl(

ReactDOM.render(
<KibanaRenderContextProvider {...core}>
<Suspense fallback={<EuiLoadingSpinner />}>
<Suspense
fallback={
<EuiSkeletonRectangle
css={css`
margin-inline: ${euiThemeVars.euiSizeS};
`}
borderRadius="m"
contentAriaLabel="Loading navigation"
/>
}
>
<LazyNavControlPopover
spacesManager={spacesManager}
serverBasePath={core.http.basePath.serverBasePath}
Expand Down
11 changes: 9 additions & 2 deletions x-pack/plugins/spaces/public/nav_control/nav_control_popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import type { PopoverAnchorPosition, WithEuiThemeProps } from '@elastic/eui';
import {
EuiHeaderSectionItemButton,
EuiLoadingSpinner,
EuiPopover,
EuiSkeletonRectangle,
withEuiTheme,
} from '@elastic/eui';
import React, { Component, lazy, Suspense } from 'react';
Expand Down Expand Up @@ -179,7 +179,14 @@ class NavControlPopoverUI extends Component<Props, State> {
}

private getAlignedLoadingSpinner() {
return <EuiLoadingSpinner size="m" className="eui-alignMiddle" />;
return (
<EuiSkeletonRectangle
borderRadius="m"
contentAriaLabel={i18n.translate('xpack.spaces.navControl.popover.loadingSpacesLabel', {
defaultMessage: 'Loading spaces navigation',
})}
/>
);
}

private getActiveSpaceButton = () => {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/spaces/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"@kbn/logging",
"@kbn/core-logging-browser-mocks",
"@kbn/core-http-router-server-mocks",
"@kbn/core-application-browser-mocks"
"@kbn/core-application-browser-mocks",
"@kbn/ui-theme"
],
"exclude": [
"target/**/*",
Expand Down

0 comments on commit b5d4601

Please sign in to comment.