Skip to content

Commit ddad308

Browse files
committed
feat: move depreacted Loader to compat package & replace with BusyIndicator
1 parent 0e6a326 commit ddad308

File tree

15 files changed

+209
-257
lines changed

15 files changed

+209
-257
lines changed

packages/charts/src/internal/ChartContainer.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { type CommonProps, Label, Loader } from '@ui5/webcomponents-react';
1+
import { type CommonProps, Label } from '@ui5/webcomponents-react';
22
import { useStylesheet } from '@ui5/webcomponents-react-base';
33
import { clsx } from 'clsx';
4-
import type { ComponentType, CSSProperties, ReactElement, ReactNode } from 'react';
4+
import type { ComponentType, ReactElement, ReactNode } from 'react';
55
import { Component, forwardRef } from 'react';
66
import { ResponsiveContainer } from 'recharts';
77
import { classNames, styleData } from './ChartContainer.module.css.js';
@@ -14,13 +14,6 @@ export interface ContainerProps extends CommonProps {
1414
resizeDebounce: number;
1515
}
1616

17-
const loaderStyles: CSSProperties = {
18-
position: 'absolute',
19-
top: 0,
20-
left: 0,
21-
right: 0
22-
};
23-
2417
class ErrorBoundary extends Component<{ children: ReactNode }, { errorCount: number }> {
2518
state = {
2619
errorCount: 0
@@ -49,7 +42,8 @@ const ChartContainer = forwardRef<HTMLDivElement, ContainerProps>((props, ref) =
4942
<div ref={ref} className={clsx(classNames.container, className)} slot={slot} {...rest}>
5043
{dataset?.length > 0 ? (
5144
<>
52-
{loading && <Loader style={loaderStyles} />}
45+
{/*todo replace with BusyIndicator*/}
46+
{loading && 'Loading...'}
5347
<ErrorBoundary>
5448
<ResponsiveContainer debounce={resizeDebounce}>{children}</ResponsiveContainer>
5549
</ErrorBoundary>

packages/compat/src/components/Loader/Loader.cy.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import { LoaderType } from '../../enums/index.js';
2+
import { Loader } from './index.js';
13
import { cypressPassThroughTestsFactory } from '@/cypress/support/utils';
2-
import type { LoaderType } from '@/packages/main';
3-
import { Loader } from '@/packages/main';
44

5-
// skip until component is moved to this package
6-
describe.skip('Loader', () => {
5+
describe('Loader', () => {
76
it('indeterminate', () => {
87
cy.mount(<Loader data-testid="loader" />);
98
cy.findByTestId('loader').should('have.css', 'animation-duration', '1.2s');
Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1-
.dummy {
2-
background-color: red;
1+
.loader {
2+
position: relative;
3+
height: 0.25rem;
4+
width: 100%;
5+
6+
&:before {
7+
content: '';
8+
position: absolute;
9+
left: 0;
10+
width: 100%;
11+
height: 100%;
12+
background-color: var(--sapContent_BusyColor);
13+
opacity: 0.15;
14+
}
15+
16+
&.loaderDeterminate {
17+
background: linear-gradient(to right, var(--sapContent_BusyColor), var(--sapContent_BusyColor)) repeat-y;
18+
}
19+
20+
&.loaderIndeterminate {
21+
background-size: 40%;
22+
background: linear-gradient(
23+
to right,
24+
transparent 0px,
25+
var(--sapContent_BusyColor) calc(50% - 2rem),
26+
var(--sapContent_BusyColor) calc(50% + 2rem),
27+
transparent 100%
28+
)
29+
repeat-y;
30+
animation: scroll 1.2s linear infinite;
31+
}
32+
}
33+
34+
@keyframes scroll {
35+
0% {
36+
background-position: -100% 0;
37+
}
38+
100% {
39+
background-position: 200% 0;
40+
}
341
}

packages/main/src/components/Loader/Loader.stories.tsx renamed to packages/compat/src/components/Loader/Loader.stories.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
import type { Meta, StoryObj } from '@storybook/react';
22
import activateIcon from '@ui5/webcomponents-icons/dist/activate.js';
3+
import { Card, CardHeader, FlexBox, FlexBoxDirection, Icon, Text } from '@ui5/webcomponents-react';
34
import { useEffect, useRef, useState } from 'react';
4-
import { FlexBoxDirection, LoaderType } from '../../enums/index.js';
5-
import { Card } from '../../webComponents/Card/index.js';
6-
import { CardHeader } from '../../webComponents/CardHeader/index.js';
7-
import { Icon } from '../../webComponents/Icon/index.js';
8-
import { Text } from '../../webComponents/Text/index.js';
9-
import { FlexBox } from '../FlexBox/index.js';
5+
import { LoaderType } from '../../enums/LoaderType.js';
106
import { Loader } from './index.js';
117

128
const meta = {
13-
title: 'User Feedback / Loader',
9+
title: 'Loader',
1410
component: Loader,
1511
argTypes: {},
1612
args: {
1713
type: LoaderType.Indeterminate,
1814
progress: '60%'
19-
}
15+
},
16+
tags: ['package:@ui5/webcomponents-compat']
2017
} satisfies Meta<typeof Loader>;
2118

2219
export default meta;

packages/main/src/components/Loader/index.tsx renamed to packages/compat/src/components/Loader/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
'use client';
22

3+
import type { CommonProps } from '@ui5/webcomponents-react';
34
import { deprecationNotice, useI18nBundle, useStylesheet } from '@ui5/webcomponents-react-base';
45
import { clsx } from 'clsx';
56
import type { CSSProperties } from 'react';
67
import { forwardRef, useEffect, useState } from 'react';
7-
import { LoaderType } from '../../enums/index.js';
8-
import { PLEASE_WAIT } from '../../i18n/i18n-defaults.js';
9-
import type { CommonProps } from '../../types/index.js';
8+
// todo: sb won't start with this (maybe because of vite.config alias paths?)
9+
// import { PLEASE_WAIT } from '@ui5/webcomponents-react/dist/i18n/i18n-defaults.js';
10+
import { PLEASE_WAIT } from '../../../../main/src/i18n/i18n-defaults.js';
11+
import { LoaderType } from '../../enums/LoaderType.js';
1012
import { classNames, styleData } from './Loader.module.css.js';
1113

1214
export interface LoaderPropTypes extends CommonProps {
@@ -35,12 +37,10 @@ export interface LoaderPropTypes extends CommonProps {
3537
}
3638

3739
/**
38-
* The `Loader` signals that an operation is currently being executed. It uses as little space as possible to allow the user to interact with the UI.<br />
39-
* It can be used to signal a data update on an already existing dataset, or where an expansion will happen.
40-
*
41-
* __Note:__ This component is __deprecated__ and will be removed with our next major release (v2.0.0)! Please use the [BusyIndicator](https://sap.github.io/ui5-webcomponents-react/?path=/docs/user-feedback-busyindicator--docs) instead.
40+
* __Note__: There is no longer a concept of a Loader component defined by the UX guidelines! To indicate a loading state, please use the `BusyIndicator` instead. For backwards compatibility, the Loader is still available in the `@ui5/webcomponents-react-compat` package, but it may lack accessibility features and no longer receives feature updates.
4241
*
43-
* @deprecated This component is deprecated and will be removed with our next major release (v2.0.0)! Please use the [BusyIndicator](https://sap.github.io/ui5-webcomponents-react/?path=/docs/user-feedback-busyindicator--docs) instead.
42+
* The `Loader` signals that an operation is currently being executed. It uses as little space as possible to allow the user to interact with the UI.
43+
* It can be used to signal a data update on an already existing dataset, or where an expansion will happen.
4444
*/
4545
const Loader = forwardRef<HTMLDivElement, LoaderPropTypes>((props, ref) => {
4646
const { className, type = LoaderType.Indeterminate, progress = '0px', slot, style, delay = 0, ...rest } = props;

packages/compat/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ export * from './components/TableCell/index.js';
33
export * from './components/TableColumn/index.js';
44
export * from './components/TableGroupRow/index.js';
55
export * from './components/TableRow/index.js';
6+
export * from './components/Loader/index.js';
7+
8+
export { LoaderType } from './enums/LoaderType.js';

packages/main/src/components/AnalyticalTable/defaults/LoadingComponent/DefaultLoadingComponent.module.css

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/main/src/components/AnalyticalTable/defaults/LoadingComponent/index.tsx

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)