Skip to content

Commit 2cfd045

Browse files
Merge pull request #24270 from sap-tutorials/ui5-webcomponents-react-mods
minor mods and improvements to the ui5-webcomponents-react series
2 parents 3499138 + 4dacf8d commit 2cfd045

4 files changed

Lines changed: 57 additions & 58 deletions

File tree

‎tutorials/ui5-webcomponents-react-card/ui5-webcomponents-react-card.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ author_profile: https://github.com/Lukas742
1313

1414
## Prerequisites
1515

16-
- Complete the tutorial [Get Started with UI5 Web Components for React](ui5-webcomponents-react-introduction).
16+
- Complete the tutorial [Get Started with UI5 Web Components for React](tutorials/ui5-webcomponents-react-introduction).
1717

1818
## You will learn
1919
- How to import UI5 Web Components into your application

‎tutorials/ui5-webcomponents-react-charts/ui5-webcomponents-react-charts.md‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ UI5 Web Components for React also comes with a chart library. In this tutorial,
3232
```
3333

3434
> **Note:**
35-
When facing issues with installing, please ensure you're using the same [minor version](https://semver.org/#summary) as the other `@ui5/webcomponents*` packages. You might have to also manually pin `@ui5/webcomponents-react-base` to that minor version. In that case, the install command would be `npm install @ui5/webcomponents-react-charts@<version> @ui5/webcomponents-react-base@<version>`.
35+
> When facing issues with installing, please ensure you're using the same [minor version](https://semver.org/#summary) as the other `@ui5/webcomponents*` packages. You might have to also manually pin `@ui5/webcomponents-react-base` to that minor version. In that case, the install command would be `npm install @ui5/webcomponents-react-charts@<version> @ui5/webcomponents-react-base@<version>`.
36+
>
37+
> For example:
38+
>
39+
> ```shell
40+
> npm install @ui5/webcomponents-react-charts@2.27 @ui5/webcomponents-react-base@2.27
41+
> ```
3642
3743
2. Then, import `LineChart` and `BarChart` into `MyApp.tsx`.
3844
@@ -45,7 +51,7 @@ UI5 Web Components for React also comes with a chart library. In this tutorial,
4551
4652
_Charts only offer limited accessibility support with only basic built-in features, so it’s essential to ensure your implementation meets the accessibility standards of your application!_
4753
48-
1. Start with the `LineChart`. You can add it underneath the `Text` component. Then pass the `dimensions` and `measures` prop with an empty array as value.
54+
1. Start with the `LineChart`. You can add it underneath the `Text` component. Then pass the `dimensions` and `measures` props with empty arrays as values.
4955
5056
```TypeScript / TSX
5157
<Text style={{ padding: "var(--sapContent_Space_S)" }}>
@@ -56,7 +62,7 @@ _Charts only offer limited accessibility support with only basic built-in featur
5662
5763
In the application you should now see a placeholder for the `LineChart` within the `Card` content. The reason for this is that the chart has not received any data and therefore the placeholder is displayed.
5864
59-
2. Add data to your component. For this sample `dataset` is static you can define it outside the component, right above your `MyApp` component.
65+
2. Add data to your component. For this sample `dataset` is static, and you can define it outside the component, right above your `MyApp` component.
6066
6167
```TypeScript / TSX
6268
const dataset = [
@@ -101,11 +107,11 @@ _Charts only offer limited accessibility support with only basic built-in featur
101107
/>
102108
```
103109
104-
Congratulation, you implemented your first Chart component.
110+
Congratulations, you implemented your first Chart component.
105111
106112
![LineChart](01_linechart.png)
107113
108-
4. We now want to show same data just with a different representation. For that, you can use the same props as you did with the `LineChart` for a `BarChart` and add it to the `Card`.
114+
4. We now want to show the same data, just with a different representation. For that, you can use the same props as you did with the `LineChart` for a `BarChart` and add it to the `Card`.
109115
110116
```TypeScript / TSX
111117
<BarChart
@@ -115,7 +121,7 @@ _Charts only offer limited accessibility support with only basic built-in featur
115121
/>
116122
```
117123
118-
Two charts are rendered now with equal datasets but different representation.
124+
Two charts are rendered now with equal datasets but different representations.
119125
120126
Your `MyApp.tsx` component should look like this:
121127
@@ -194,14 +200,14 @@ export function MyApp() {
194200
195201
Two charts in one `Card` is a bit too much, don't you think? It would be nicer if the charts could be toggled by clicking on the header. Let's implement that!
196202
197-
1. First add a state. It should control, which chart is going to be rendered. Use the [State Hook logic](https://react.dev/reference/react/useState) to implement the state and set `"lineChart"` as default value. Don't forget to import `useState` from React, otherwise you will get an error.
203+
1. First add a state. It should control which chart is going to be rendered. Use the [State Hook logic](https://react.dev/reference/react/useState) to implement the state and set `"lineChart"` as default value. Don't forget to import `useState` from React, otherwise you will get an error.
198204
- Import the `useState` function in the header of the `MyApp.tsx` file.
199205
```TypeScript / TSX
200-
import { useState } from "react";
206+
import { useState } from "react";
201207
```
202208
- Use the `useState` function right after you start to define the `MyApp` function (before the click handler).
203209
```TypeScript / TSX
204-
const [toggleCharts, setToggleCharts] = useState("lineChart");
210+
const [toggleCharts, setToggleCharts] = useState("lineChart");
205211
```
206212
207213
2. By clicking on the `CardHeader` the state should be set corresponding to the chart which should be displayed.
@@ -256,7 +262,7 @@ Two charts in one `Card` is a bit too much, don't you think? It would be nicer i
256262
import { Card, CardHeader, Text, Icon } from "@ui5/webcomponents-react";
257263
```
258264
259-
The icons themselved can be imported altogether (`import '@ui5/webcomponents-icons/dist/AllIcons.js';`), but to reduce bundle size and for better maintainability, it's recommended importing each icon on its own:
265+
The icons themselves can be imported altogether (`import '@ui5/webcomponents-icons/dist/AllIcons.js';`), but to reduce bundle size and for better maintainability, it's recommended importing each icon on its own:
260266
261267
```TypeScript / TSX
262268
import lineChartIcon from '@ui5/webcomponents-icons/dist/line-chart.js';
@@ -395,7 +401,7 @@ One of React's main advantages is its efficient rendering mechanism: a component
395401
1. In order to demonstrate this behavior, add a new `state` (right after the definition of the chart state from the previous step).
396402
397403
```TypeScript / TSX
398-
const [loading, setLoading] = useState(false);
404+
const [loading, setLoading] = useState(false);
399405
```
400406
401407
2. Then edit your `handleHeaderClick` function like this:
@@ -438,9 +444,9 @@ One of React's main advantages is its efficient rendering mechanism: a component
438444
/>
439445
```
440446
441-
This updates the component every time you switch between charts and simulates a data call.
447+
This updates the component every time you switch between charts and simulates a data call with the 2000ms timeouts.
442448
443-
As you can see, only the component affected by the state is updated, and the rest stays the same: The `CardHeader` remains unchanged until the 2000ms timeout is over (and `setToggleCharts` is called), whereas the charts `loading` prop changes immediately (as `setLoading` is called immediately). If you're working with data, you most probably will need a loading indicator. All UI5 Web Components that are able to display data have a `loading` prop and therefore also a loading indicator.
449+
As you can see, only the component affected by the state is updated, and the rest stays the same: The `CardHeader` remains unchanged until the timeout is over (and `setToggleCharts` is called), whereas the charts `loading` prop changes immediately (as `setLoading` is called immediately). If you're working with data, you most probably will need a loading indicator. All UI5 Web Components that are able to display data have a `loading` prop and therefore also a loading indicator.
444450
445451
446452
### Add dynamic header and text
@@ -503,7 +509,7 @@ To make your `Card` look cleaner and to give the user the information that the h
503509
3. Add accessibility attributes to the `Icon`
504510
505511
If the `header` alone does not sufficiently describe the currently visible `Icon`, you can define an `accessibleName`. Its value will be applied as the `aria-label` of the internal element, which screen readers will pick up.
506-
In case the `header` already explains the content and the icon is purely decorative, you can set its `mode` to `"Decorative"`, so it will be ignored by screen readers.
512+
> In case the `header` already explains the content and the icon is purely decorative, you can set its `mode` to `"Decorative"`, so it will be ignored by screen readers.
507513
508514
```TypeScript / TSX
509515
<Icon

‎tutorials/ui5-webcomponents-react-dashboard/ui5-webcomponents-react-dashboard.md‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ The `ShellBar` is the central navigation element in your web application and sho
127127
</ShellBar>
128128
```
129129
130-
That is strange -- the `ShellBarItem` does not show an icon.
130+
But - something's not right. Nothing is rendering now.
131131
132132
Every `Icon` that is used in a component has to be imported manually. All available icons can be found [here](https://sapui5.hana.ondemand.com/test-resources/sap/m/demokit/iconExplorer/webapp/index.html#/overview/SAP-icons).
133133
@@ -137,7 +137,7 @@ The `ShellBar` is the central navigation element in your web application and sho
137137
import activateIcon from "@ui5/webcomponents-icons/dist/activate.js";
138138
```
139139
140-
Now your `ShellBarItem` shows up on the right side of the `ShellBar`.
140+
Now everything is back and your `ShellBarItem` shows up on the right side of the `ShellBar`.
141141
142142
![ShellBar](02_shellbar.png)
143143
@@ -453,7 +453,7 @@ For this, add two `Text` components above the `ProgressIndicator` of the first `
453453
import tableViewIcon from "@ui5/webcomponents-icons/dist/table-view.js";
454454
```
455455
456-
> At this point, the `AnalyticalTable` throws an error due to the missing required `data` prop. You will fix this in the next.
456+
> At this point, the `AnalyticalTable` throws an error due to the missing required `data` prop, and rendering is not complete. You will fix this next.
457457
458458
2. Add data and columns to the table. The `columns` prop expects an array of objects that include at least the `accessor` to the data or a unique `id` property. The value of `Header` will be shown as column header.
459459
@@ -504,7 +504,7 @@ For this, add two `Text` components above the `ProgressIndicator` of the first `
504504
You can add many more properties to the `AnalyticalTable` component. For example, you can allow sorting, filtering and grouping via `sortable`, `filterable` and `groupable`, enable different selection modes with `selectionMode`, control how the table splits up available space between the columns with `scaleWidthMode` and much more.
505505
Feel free to take a look at the [documentation](https://ui5.github.io/webcomponents-react/v2/?path=/docs/data-display-analyticaltable--docs) and explore the different examples before continuing.
506506
507-
The default visible rows count is at 15. This number is a bit to high for a dashboard table. Reduce the `visibleRows` count to 5 by setting the corresponding prop.
507+
The default visible rows count (before scrolling starts) is at 15. This number is a bit too high for a dashboard table. Reduce the `visibleRows` count to 5 by setting the corresponding prop.
508508
509509
```TypeScript / TSX
510510
<AnalyticalTable
@@ -566,7 +566,7 @@ At the moment, the dashboard doesn't really look like a dashboard. The component
566566
<FlexBox
567567
justifyContent={FlexBoxJustifyContent.Center}
568568
wrap={FlexBoxWrap.Wrap}
569-
style={{ padding: "var(--sapContent_Space_M)" }}
569+
style={{ padding: "var(--sapContent_Space_M)" }}>
570570
...
571571
</FlexBox>
572572
```
@@ -577,6 +577,8 @@ Your component should now look like this:
577577
578578
![Dashboard](05_dashboard.png)
579579
580+
The source should look like this:
581+
580582
```TypeScript / TSX
581583
import tableViewIcon from "@ui5/webcomponents-icons/dist/table-view.js";
582584
import listIcon from "@ui5/webcomponents-icons/dist/list.js";
@@ -839,8 +841,3 @@ export function MyApp() {
839841
);
840842
}
841843
```
842-
843-
844-
845-
846-
---

‎tutorials/ui5-webcomponents-react-styling/ui5-webcomponents-react-styling.md‎

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ In this step we will use [CSS Modules](https://github.com/css-modules/css-module
7373
};
7474
```
7575

76-
2. Explicitly import `@ui5/webcomponents-react-base` package:
76+
2. Explicitly install `@ui5/webcomponents-react-base` package:
7777

7878
`@ui5/webcomponents-react-base` is already installed by `@ui5/webcomponents-react`, but as we want to import the `ThemingParameters` in the following step, it's recommended adding the package to the dependencies as well.
7979

@@ -99,35 +99,35 @@ In this step we will use [CSS Modules](https://github.com/css-modules/css-module
9999
First, create a new file `MyCustomElement.module.css` in `src` with the following content:
100100

101101
```CSS
102-
.container {
103-
background-color: var(--sapBackgroundColor);
104-
font-family: var(--sapFontFamily);
105-
height: 50px;
106-
display: flex;
107-
justify-content: center;
108-
align-items: center;
109-
}
102+
.container {
103+
background-color: var(--sapBackgroundColor);
104+
font-family: var(--sapFontFamily);
105+
height: 50px;
106+
display: flex;
107+
justify-content: center;
108+
align-items: center;
109+
}
110110
```
111111
Then import the CSS file in your `MyCustomElement.tsx` file and add the class to the `div` element.
112112

113113
```TypeScript / TSX
114-
import { ThemingParameters } from '@ui5/webcomponents-react-base';
115-
import classes from './MyCustomElement.module.css';
116-
117-
export const MyCustomElement = () => {
118-
return (
119-
<div className={classes.container}>
120-
<span
121-
style={{
122-
color: ThemingParameters.sapNegativeColor,
123-
fontSize: ThemingParameters.sapFontHeader1Size,
124-
}}
125-
>
126-
My custom Text Element
127-
</span>
128-
</div>
129-
);
130-
};
114+
import { ThemingParameters } from '@ui5/webcomponents-react-base';
115+
import classes from './MyCustomElement.module.css';
116+
117+
export const MyCustomElement = () => {
118+
return (
119+
<div className={classes.container}>
120+
<span
121+
style={{
122+
color: ThemingParameters.sapNegativeColor,
123+
fontSize: ThemingParameters.sapFontHeader1Size,
124+
}}
125+
>
126+
My custom Text Element
127+
</span>
128+
</div>
129+
);
130+
};
131131
```
132132

133133
5. Import the custom component and add it to your `Home` component.
@@ -169,7 +169,7 @@ One example is applying a responsive content padding to the content of the dashb
169169
```
170170
3. Apply the classes on elements:
171171
172-
Add a `div` that is wrapping the outer `FlexBox` and apply the `sap-container-type-inline-size` class:
172+
Add a `div` that is wrapping the outer `FlexBox` and apply the `sap-container-type-inline-size` class (remembering to close it too):
173173
174174
```tsx
175175
<div className="sap-container-type-inline-size">
@@ -192,11 +192,7 @@ One example is applying a responsive content padding to the content of the dashb
192192
193193
### Conclusion
194194
195-
In this tutorial mission, you learned the basics of how to build a single page application using UI5 Web Components for React, with routing, styling, and general component behavior and modern React APIs.
195+
In this series of tutorials, you learned the basics of how to build a single page application using UI5 Web Components for React, with routing, styling, and general component behavior and modern React APIs.
196196
If you have questions about UI5 Web Components for React, or found something that isn't right, then please feel free to join the [OpenUI5 Slack community](https://ui5-slack-invite.cfapps.eu10.hana.ondemand.com/) and visit us in the [`#webcomponents-react`](https://openui5.slack.com/archives/CSQEJ2J04) channel, or come directly to our [GitHub page](https://github.com/UI5/webcomponents-react), where you can file [issues](https://github.com/UI5/webcomponents-react/issues/new/choose) or participate in [discussions](https://github.com/UI5/webcomponents-react/discussions).
197197
198-
If you enjoyed this tutorial, you can help us out a lot by starring our repo and become one of our wonderful [✨stargazers✨](https://github.com/UI5/webcomponents-react/stargazers)!
199-
200-
201-
202-
---
198+
If you enjoyed this series, you can help us out a lot by starring our repo and become one of our wonderful [✨stargazers✨](https://github.com/UI5/webcomponents-react/stargazers)!

0 commit comments

Comments
 (0)