You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2cfd045
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: tutorials/ui5-webcomponents-react-charts/ui5-webcomponents-react-charts.md
+20-14Lines changed: 20 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,13 @@ UI5 Web Components for React also comes with a chart library. In this tutorial,
32
32
```
33
33
34
34
> **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>`.
2. Then, import `LineChart` and `BarChart` into `MyApp.tsx`.
38
44
@@ -45,7 +51,7 @@ UI5 Web Components for React also comes with a chart library. In this tutorial,
45
51
46
52
_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!_
47
53
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.
@@ -56,7 +62,7 @@ _Charts only offer limited accessibility support with only basic built-in featur
56
62
57
63
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.
58
64
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.
60
66
61
67
```TypeScript / TSX
62
68
const dataset = [
@@ -101,11 +107,11 @@ _Charts only offer limited accessibility support with only basic built-in featur
101
107
/>
102
108
```
103
109
104
-
Congratulation, you implemented your first Chart component.
110
+
Congratulations, you implemented your first Chart component.
105
111
106
112

107
113
108
-
4. We now want to show same data just with a different representation. For that, you can use the same props asyoudidwiththe`LineChart`fora`BarChart`andaddittothe`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`.
109
115
110
116
```TypeScript / TSX
111
117
<BarChart
@@ -115,7 +121,7 @@ _Charts only offer limited accessibility support with only basic built-in featur
115
121
/>
116
122
```
117
123
118
-
Two charts are rendered now with equal datasets but different representation.
124
+
Two charts are rendered now with equal datasets but different representations.
119
125
120
126
Your `MyApp.tsx` component should look like this:
121
127
@@ -194,14 +200,14 @@ export function MyApp() {
194
200
195
201
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!
196
202
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.
198
204
- Import the `useState` function in the header of the `MyApp.tsx` file.
199
205
```TypeScript / TSX
200
-
import { useState } from"react";
206
+
import { useState } from "react";
201
207
```
202
208
- Use the `useState` function right after you start to define the `MyApp` function (before the click handler).
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
256
262
import { Card, CardHeader, Text, Icon } from "@ui5/webcomponents-react";
257
263
```
258
264
259
-
Theiconsthemselvedcanbeimportedaltogether (`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:
260
266
261
267
```TypeScript / TSX
262
268
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
395
401
1. In order to demonstrate this behavior, add a new `state` (right after the definition of the chart state from the previous step).
396
402
397
403
```TypeScript / TSX
398
-
const [loading, setLoading] = useState(false);
404
+
const [loading, setLoading] = useState(false);
399
405
```
400
406
401
407
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
438
444
/>
439
445
```
440
446
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.
442
448
443
-
As you can see, only the component affected by the state is updated, and the rest stays the same: The`CardHeader`remainsunchangeduntilthe2000mstimeoutisover (and`setToggleCharts`iscalled), 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.
444
450
445
451
446
452
### 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
503
509
3. Add accessibility attributes to the `Icon`
504
510
505
511
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.
Copy file name to clipboardExpand all lines: tutorials/ui5-webcomponents-react-dashboard/ui5-webcomponents-react-dashboard.md
+7-10Lines changed: 7 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,7 @@ The `ShellBar` is the central navigation element in your web application and sho
127
127
</ShellBar>
128
128
```
129
129
130
-
That is strange -- the `ShellBarItem` does not show an icon.
130
+
But - something's not right. Nothing is rendering now.
131
131
132
132
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).
133
133
@@ -137,7 +137,7 @@ The `ShellBar` is the central navigation element in your web application and sho
137
137
import activateIcon from "@ui5/webcomponents-icons/dist/activate.js";
138
138
```
139
139
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`.
141
141
142
142

143
143
@@ -453,7 +453,7 @@ For this, add two `Text` components above the `ProgressIndicator` of the first `
> 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.
457
457
458
458
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.
459
459
@@ -504,7 +504,7 @@ For this, add two `Text` components above the `ProgressIndicator` of the first `
504
504
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.
505
505
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.
506
506
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.
508
508
509
509
```TypeScript/TSX
510
510
<AnalyticalTable
@@ -566,7 +566,7 @@ At the moment, the dashboard doesn't really look like a dashboard. The component
566
566
<FlexBox
567
567
justifyContent={FlexBoxJustifyContent.Center}
568
568
wrap={FlexBoxWrap.Wrap}
569
-
style={{ padding: "var(--sapContent_Space_M)" }}
569
+
style={{ padding: "var(--sapContent_Space_M)" }}>
570
570
...
571
571
</FlexBox>
572
572
```
@@ -577,6 +577,8 @@ Your component should now look like this:
`@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.
79
79
@@ -99,35 +99,35 @@ In this step we will use [CSS Modules](https://github.com/css-modules/css-module
99
99
First, create a new file `MyCustomElement.module.css` in `src` with the following content:
100
100
101
101
```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
+
}
110
110
```
111
111
Then import the CSS file in your `MyCustomElement.tsx` file and add the class to the `div` element.
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
169
169
```
170
170
3. Apply the classes on elements:
171
171
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):
173
173
174
174
```tsx
175
175
<divclassName="sap-container-type-inline-size">
@@ -192,11 +192,7 @@ One example is applying a responsive content padding to the content of the dashb
192
192
193
193
### Conclusion
194
194
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.
196
196
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).
197
197
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