Skip to content

Commit b7bd2c2

Browse files
committed
Merge branch 'docs/analytical-table' of github.com:SAP/ui5-webcomponents-react into docs/analytical-table
2 parents 50bcebd + 6440deb commit b7bd2c2

File tree

11 files changed

+208
-78
lines changed

11 files changed

+208
-78
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ For more info, check the [seed documentation](https://github.com/SAP/ui5-webcomp
112112

113113
```sh
114114
npx create-react-app my-app --template @ui5/webcomponents-react-seed
115+
npm run mock
116+
115117
# or if you want to use yarn
116118
yarn create react-app my-app --template @ui5/webcomponents-react-seed
119+
yarn mock
117120
```
118121

119122
### Add `@ui5/webcomponents-react` to an existing app

docs/1-Welcome.stories.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ For more info, check the [seed documentation](https://github.com/SAP/ui5-webcomp
5252

5353
```sh
5454
npx create-react-app my-app --template @ui5/webcomponents-react-seed
55+
npm run mock
56+
5557
# or if you want to use yarn
5658
yarn create react-app my-app --template @ui5/webcomponents-react-seed
59+
yarn mock
5760
```
5861

5962
### Add `@ui5/webcomponents-react` to an existing app

packages/cra-template-seed/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ This seed decrease’s the bootstrap time spent on new projects, POCs or MVPs wh
99
# Usage
1010
```shell script
1111
npx create-react-app my-app --template @ui5/webcomponents-react-seed
12+
npm run mock
1213

1314
# or if you prefer to use yarn
14-
1515
yarn create react-app my-app --template @ui5/webcomponents-react-seed
16+
yarn mock
1617
```
1718

1819
# Configuration Included

packages/main/src/components/Form/Form.stories.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import { DocsHeader } from '@shared/stories/DocsHeader';
3434
<Story name="Default">
3535
{(args) => (
3636
<Form {...args} title={args.title}>
37+
<FormItem label={'Sole Form Item'}>
38+
<Input type={InputType.Text} />
39+
</FormItem>
3740
<FormGroup title={'Personal Data'}>
3841
<FormItem label={'Name'}>
3942
<Input type={InputType.Text} />
@@ -52,9 +55,6 @@ import { DocsHeader } from '@shared/stories/DocsHeader';
5255
<CheckBox checked />
5356
</FormItem>
5457
</FormGroup>
55-
<FormItem label={'Sole Form Item'}>
56-
<Input type={InputType.Text} />
57-
</FormItem>
5858
<FormGroup title={'Company Data'}>
5959
<FormItem label={'Company Name'}>
6060
<Input type={InputType.Text} />
@@ -91,9 +91,9 @@ import { DocsHeader } from '@shared/stories/DocsHeader';
9191
</Story>
9292
</Canvas>
9393

94+
<ArgsTable story="." />
95+
9496
### Usage Notes
9597

9698
Please note that the `FormGroup` and `FormItem` components are only used for calculating the final layout of the `Form`,
97-
thus they don't accept any other props then the specified ones, especially no `className`, `style` or `ref`.
98-
99-
<ArgsTable story="." />
99+
thus they don't accept any other props than the specified ones, especially no `className`, `style` or `ref`.

packages/main/src/components/Form/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ export interface FormPropTypes extends CommonProps {
8282
}
8383

8484
const useStyles = createComponentStyles(styles, { name: 'Form' });
85-
85+
/**
86+
* The `Form` component arranges labels and fields into groups and rows. There are different ways to visualize forms for different screen sizes.
87+
*/
8688
const Form: FC<FormPropTypes> = forwardRef((props: FormPropTypes, ref: Ref<HTMLDivElement>) => {
8789
const {
8890
title,

packages/main/src/components/FormGroup/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ const useStyles = createComponentStyles(
2323
},
2424
{ name: 'FormGroup' }
2525
);
26-
26+
/**
27+
* The `FormGroup` encapsulates `FormItems` into groups.
28+
* __Note:__ `FormGroup` is only used for calculating the final layout of the `Form`, thus it doesn't accept any other props than `title` and `children`, especially no `className`, `style` or `ref`.
29+
*/
2730
const FormGroup: FC<FormGroupProps> = (props: FormGroupProps) => {
2831
const { title, children } = props;
2932

packages/main/src/components/FormItem/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ const renderLabel = (
7070

7171
return null;
7272
};
73-
73+
/**
74+
* The `FormItem` is only used for calculating the final layout of the `Form`, thus it doesn't accept any other props than `label` and `children`, especially no `className`, `style` or `ref`.
75+
*/
7476
const FormItem: FC<FormItemProps> = (props: FormItemProps) => {
7577
const { label, children, columnIndex, rowIndex, labelSpan } = props as InternalProps;
7678

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
2+
import { Loader } from '@ui5/webcomponents-react/lib/Loader';
3+
import { LoaderType } from '@ui5/webcomponents-react/lib/LoaderType';
4+
import { Card } from '@ui5/webcomponents-react/lib/Card';
5+
import { Text } from '@ui5/webcomponents-react/lib/Text';
6+
import { Icon } from '@ui5/webcomponents-react/lib/Icon';
7+
import { FlexBox } from '@ui5/webcomponents-react/lib/FlexBox';
8+
import { FlexBoxDirection } from '@ui5/webcomponents-react/lib/FlexBoxDirection';
9+
import { createSelectArgTypes } from '@shared/stories/createSelectArgTypes';
10+
import { DocsHeader } from '@shared/stories/DocsHeader';
11+
import { DocsCommonProps } from '@shared/stories/DocsCommonProps';
12+
import { spacing } from '@ui5/webcomponents-react-base';
13+
import '@ui5/webcomponents-icons/dist/icons/activate.js';
14+
import { useEffect, useRef, useState } from 'react';
15+
16+
<Meta
17+
title="Components / Loader"
18+
component={Loader}
19+
argTypes={{
20+
...createSelectArgTypes({ type: LoaderType }),
21+
...DocsCommonProps
22+
}}
23+
args={{
24+
type: LoaderType.Indeterminate,
25+
progress: '60%',
26+
style: {},
27+
className: '',
28+
tooltip: '',
29+
slot: '',
30+
ref: null
31+
}}
32+
/>
33+
34+
<DocsHeader />
35+
36+
<Canvas>
37+
<Story name="Default">
38+
{(args) => {
39+
return <Loader {...args} />;
40+
}}
41+
</Story>
42+
</Canvas>
43+
44+
<ArgsTable story="." />
45+
46+
<br />
47+
48+
# Stories
49+
50+
<br />
51+
52+
## Card with Loader
53+
54+
<Canvas>
55+
<Story name="with Card">
56+
{(args) => {
57+
const initialText =
58+
'This is a text that will be updated 5 seconds after the header is clicked. The text will be visible until the new text has been fetched. To let the user know that the text is updating, the Loader will be displayed.';
59+
const [text, setText] = useState(initialText);
60+
const [loading, setLoading] = useState(false);
61+
const counter = useRef(0);
62+
const onHeaderClick = () => {
63+
setLoading(true);
64+
};
65+
useEffect(() => {
66+
if (loading) {
67+
setTimeout(() => {
68+
if (counter.current < 10) {
69+
setText((prev) => (prev === initialText ? 'Updated (⌐■_■)' : initialText));
70+
} else {
71+
setText('You really must be bored ಠ_ಠ');
72+
}
73+
counter.current++;
74+
setLoading(false);
75+
}, 5000);
76+
}
77+
}, [loading]);
78+
return (
79+
<Card
80+
avatar={<Icon name="activate" />}
81+
heading="Click the header to update the text below."
82+
headerInteractive
83+
style={{ width: '400px' }}
84+
onHeaderClick={onHeaderClick}
85+
>
86+
<FlexBox direction={FlexBoxDirection.Column}>
87+
{loading && <Loader {...args} />}
88+
<Text style={spacing.sapUiContentPadding}>{text}</Text>
89+
</FlexBox>
90+
</Card>
91+
);
92+
}}
93+
</Story>
94+
</Canvas>
95+
96+
```jsx
97+
const LoaderComponent = () => {
98+
const initialText =
99+
'This is a text that will be updated 5 seconds after the header is clicked. The text will be visible until the new text has been fetched. To let the user know that the text is updating, the Loader will be displayed.';
100+
const [text, setText] = useState(initialText);
101+
const [loading, setLoading] = useState(false);
102+
const onHeaderClick = () => {
103+
setLoading(true);
104+
};
105+
useEffect(() => {
106+
if (loading) {
107+
setTimeout(() => {
108+
setText((prev) => (prev === initialText ? 'Updated (⌐■_■)' : initialText));
109+
setLoading(false);
110+
}, 5000);
111+
}
112+
}, [loading]);
113+
return (
114+
<Card
115+
avatar={<Icon name="activate" />}
116+
heading="Click the header to update the text below."
117+
headerInteractive
118+
style={{ width: '400px' }}
119+
onHeaderClick={onHeaderClick}
120+
>
121+
<FlexBox direction={FlexBoxDirection.Column}>
122+
{loading && <Loader />}
123+
<Text style={spacing.sapUiContentPadding}>{text}</Text>
124+
</FlexBox>
125+
</Card>
126+
);
127+
};
128+
```

packages/main/src/components/Loader/demo.stories.tsx

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

packages/main/src/components/Loader/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,27 @@ import { CommonProps } from '../../interfaces/CommonProps';
99
import { styles } from './Loader.jss';
1010

1111
export interface LoaderProps extends CommonProps {
12-
/*
12+
/**
1313
* Delay in ms until the Loader will be displayed
1414
*/
1515
delay?: number;
16+
/**
17+
* Defines the type of the `Loader`.
18+
* __Note:__ If the process completion rate can be detected the `Determinate` type should be used.
19+
*/
1620
type?: LoaderType;
21+
/**
22+
* Defines the progress of the Loader Bar. <br />
23+
* __Note:__ This prop has no effect if used with type `Indeterminate`.
24+
*/
1725
progress?: CSSProperties['width'];
1826
}
1927

2028
const useStyles = createComponentStyles(styles, { name: 'Loader' });
21-
29+
/**
30+
* 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 />
31+
* It can be used to signal a data update on an already existing dataset, or where an expansion will happen.
32+
*/
2233
const Loader: FC<LoaderProps> = forwardRef((props: LoaderProps, ref: RefObject<HTMLDivElement>) => {
2334
const { className, type, progress, tooltip, slot, style, delay } = props;
2435
const classes = useStyles(props);

0 commit comments

Comments
 (0)