Skip to content

Commit 961dec7

Browse files
feat(cra-template): add test setup and use latest version + docs (#433)
1 parent b088a19 commit 961dec7

File tree

3 files changed

+111
-93
lines changed

3 files changed

+111
-93
lines changed

README.md

Lines changed: 57 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,49 @@
77
<a href='https://coveralls.io/github/SAP/ui5-webcomponents-react'>
88
<img src='https://coveralls.io/repos/github/SAP/ui5-webcomponents-react/badge.svg' alt='Coverage Status' />
99
</a>
10+
<a href="https://ui5-slack-invite.cfapps.eu10.hana.ondemand.com/" target="_blank">
11+
<img alt="Slack Badge" src="https://badgen.net/badge/slack/Join OpenUI5 Slack workspace/blue?icon=slack">
12+
</a>
1013
<a href="https://openui5.slack.com/archives/CSQEJ2J04" target="_blank">
1114
<img alt="Slack Badge" src="https://badgen.net/badge/slack/webcomponents-react/orange?icon=slack">
1215
</a>
1316
<a href="https://github.com/prettier/prettier" target="_blank">
14-
<img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg">
17+
<img alt="code style: prettier" src="https://badgen.net/badge/code%20style/prettier?color=pink">
1518
</a>
1619
<a href="https://lernajs.io/" target="_blank">
17-
<img alt="lerna" src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg">
20+
<img alt="lerna" src="https://badgen.net/badge/maintained%20with/lerna?color=purple">
1821
</a>
19-
2022
</p>
2123

22-
<!-- *********************************************************************** -->
23-
<a name="description"></a>
24-
## Description
25-
26-
`ui5-webcomponents-react` is providing a Fiori-compliant React implementation by leveraging the [UI5 Web Components](https://github.com/SAP/ui5-webcomponents). This project was formerly known as `fiori-for-react`.
27-
28-
### Explore our components
29-
You can play around with our components by visiting our [Storybook](https://sap.github.io/ui5-webcomponents-react/).
24+
`ui5-webcomponents-react` is providing a Fiori-compliant React implementation by leveraging the [UI5 Web Components](https://github.com/SAP/ui5-webcomponents).
25+
This project was formerly known as `fiori-for-react`.
3026

31-
### Package Overview
27+
## Resources
3228

33-
#### [@ui5/webcomponents-react](https://github.com/SAP/ui5-webcomponents-react/tree/master/packages/main) - Fiori 3 Components<br />
34-
[![](https://img.shields.io/npm/v/@ui5/webcomponents-react/latest.svg)](https://www.npmjs.com/package/@ui5/webcomponents-react) [![](https://img.shields.io/npm/v/@ui5/webcomponents-react/next.svg)](https://www.npmjs.com/package/@ui5/webcomponents-react)
35-
[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@ui5/webcomponents-react)](https://bundlephobia.com/result?p=@ui5/webcomponents-react)
29+
You can find our documentation under the following links:
30+
- [Stable Release Documentation](https://sap.github.io/ui5-webcomponents-react/)
31+
- [Next Release Documentation](https://ui5-webcomponents-react.netlify.app/)
3632

37-
#### [@ui5/webcomponents-react-charts](https://github.com/SAP/ui5-webcomponents-react/tree/master/packages/charts) - Fiori Charts<br />
38-
[![](https://img.shields.io/npm/v/@ui5/webcomponents-react-charts/latest.svg)](https://www.npmjs.com/package/@ui5/webcomponents-react-charts) [![](https://img.shields.io/npm/v/@ui5/webcomponents-react-charts/next.svg)](https://www.npmjs.com/package/@ui5/webcomponents-react-charts)
39-
[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@ui5/webcomponents-react-charts)](https://bundlephobia.com/result?p=@ui5/webcomponents-react-charts)
4033

41-
#### [@ui5/webcomponents-react-base](https://github.com/SAP/ui5-webcomponents-react/tree/master/packages/base) - Utils<br />
42-
[![](https://img.shields.io/npm/v/@ui5/webcomponents-react-base/latest.svg)](https://www.npmjs.com/package/@ui5/webcomponents-react-base) [![](https://img.shields.io/npm/v/@ui5/webcomponents-react-base/next.svg)](https://www.npmjs.com/package/@ui5/webcomponents-react-base)
43-
[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@ui5/webcomponents-react-base)](https://bundlephobia.com/result?p=@ui5/webcomponents-react-base)
34+
## Package Overview
4435

36+
- [@ui5/webcomponents-react](https://github.com/SAP/ui5-webcomponents-react/tree/master/packages/main) - Fiori 3 Components<br/>
37+
[![](https://badgen.net/npm/v/@ui5/webcomponents-react?icon=npm)](https://www.npmjs.com/package/@ui5/webcomponents-react)
38+
[![](https://badgen.net/npm/v/@ui5/webcomponents-react/next?icon=npm)](https://www.npmjs.com/package/@ui5/webcomponents-react)
39+
[![npm bundle size (scoped)](https://badgen.net/bundlephobia/minzip/@ui5/webcomponents-react)](https://bundlephobia.com/result?p=@ui5/webcomponents-react)
40+
41+
- [@ui5/webcomponents-react-charts](https://github.com/SAP/ui5-webcomponents-react/tree/master/packages/charts) - Fiori Charts<br />
42+
[![](https://badgen.net/npm/v/@ui5/webcomponents-react-charts?icon=npm)](https://www.npmjs.com/package/@ui5/webcomponents-react-charts)
43+
[![](https://badgen.net/npm/v/@ui5/webcomponents-react-charts/next?icon=npm)](https://www.npmjs.com/package/@ui5/webcomponents-react-charts)
44+
[![npm bundle size (scoped)](https://badgen.net/bundlephobia/minzip/@ui5/webcomponents-react-charts)](https://bundlephobia.com/result?p=@ui5/webcomponents-react-charts)
45+
46+
- [@ui5/webcomponents-react-base](https://github.com/SAP/ui5-webcomponents-react/tree/master/packages/base) - Utils<br />
47+
[![](https://badgen.net/npm/v/@ui5/webcomponents-react-base?icon=npm)](https://www.npmjs.com/package/@ui5/webcomponents-react-base)
48+
[![](https://badgen.net/npm/v/@ui5/webcomponents-react-base/next?icon=npm)](https://www.npmjs.com/package/@ui5/webcomponents-react-base)
49+
[![npm bundle size (scoped)](https://badgen.net/bundlephobia/minzip/@ui5/webcomponents-react-base)](https://bundlephobia.com/result?p=@ui5/webcomponents-react-base)
50+
51+
- [@ui5/cra-template-webcomponents-react](https://github.com/SAP/ui5-webcomponents-react/tree/master/packages/cra-template) - Template for `create-react-app` <br/>
52+
[![](https://badgen.net/npm/v/@ui5/cra-template-webcomponents-react?icon=npm)](https://www.npmjs.com/package/@ui5/cra-template-webcomponents-react)
4553

4654
<!-- *********************************************************************** -->
4755
<a name="requirements"></a>
@@ -63,25 +71,43 @@ npm install @ui5/webcomponents-react --save
6371
<a name="configuration"></a>
6472
## Configuration
6573

66-
**Prerequisite: You have a React app.** In case you don't, we recommend to create one using [create-react-app](https://facebook.github.io/create-react-app/).<br/>
67-
In order to use `ui5-webcomponents-react` you have to wrap your application's root component into the `ThemeProvider`.<br/>
74+
### Creating a new React app
75+
76+
You can create a new react app by using [create-react-app](https://facebook.github.io/create-react-app/) with our template.
77+
This template is installing all required dependencies for you and is setting up the `App.js` file for you:
78+
```sh
79+
npx create-react-app my-app --template @ui5/webcomponents-react
80+
# or if you want to use yarn
81+
yarn create react-app my-app --template @ui5/webcomponents-react
82+
```
83+
84+
### Add `@ui5/webcomponents-react` to an existing app
85+
86+
First of all, you need to add the `@ui5/webcomponents-react` dependency to your project. Please also keep in mind installing the required peer dependencies:
87+
```sh
88+
npm install @ui5/webcomponents @ui5/webcomponents-react --save
89+
# if you want to use the ShellBar or the ProductSwitcher component, you also need to install this package as well
90+
npm install @ui5/webcomponents-fiori
91+
```
92+
93+
In order to use `@ui5/webcomponents-react` you have to wrap your application's root component into the `ThemeProvider`.<br/>
6894
You will find this component most likely in `src/App.js`:
6995
```jsx
7096
import { ThemeProvider } from '@ui5/webcomponents-react/lib/ThemeProvider';
7197
...
7298
render() {
7399
return (
74100
<div>
75-
<ThemeProvider withToastContainer>
101+
<ThemeProvider>
76102
<MyApp />
77103
</ThemeProvider>
78104
</div>
79105
);
80106
}
81107
```
82108

83-
Then, you are ready to use `ui5-webcomponents-react` and you can import the desired component(s) in your app:<br />
84-
For example, to use ```Button``` you need to import it:
109+
Then you are ready to use `@ui5/webcomponents-react` and you can import the desired component(s) in your app:<br />
110+
For example, to use the `Button` component you need to import it:
85111

86112
```jsx
87113
import { Button } from '@ui5/webcomponents-react/lib/Button'; // loads ui5-button wrapped in a ui5-webcomponents-react component
@@ -93,18 +119,12 @@ Then, you can use the Button in your app:
93119
<Button onClick={() => alert('Hello World!')}>Hello world!</Button>
94120
```
95121

96-
You could import all components also from `@ui5/webcomponents-react` directly, but this will have a negative impact on your bundle size.
97-
98-
### Configure Compact/Cozy setting
99-
UI5 Web Components supports ```Compact``` and ```Cozy``` mode. It is set to ```Cozy``` by default. To enable ```Compact``` globally, provide the option ```compactSize: true``` in the configuration ```script``` tag:
122+
You can also import all components from `@ui5/webcomponents-react` directly.
100123

101-
```html
102-
<script data-ui5-config type="application/json">
103-
{
104-
"compactSize": true
105-
}
106-
</script>
107-
```
124+
For Browser Support and the configuration of the UI5 Web Components, please take a look at the
125+
[Browser Support](https://github.com/SAP/ui5-webcomponents#browser-support) and the
126+
[Configure](https://github.com/SAP/ui5-webcomponents#browser-support) sections of the
127+
[UI5 Web Components Readme](https://github.com/SAP/ui5-webcomponents#ui5-web-components).
108128

109129
### Browser Support
110130
`@ui5/webcomponents-react` is supporting all modern major browsers. There is no support for Internet Explorer 11 built in.<br />
@@ -120,42 +140,12 @@ You can install `react-app-polyfill` and `@webcomponents/webcomponentsjs` with t
120140
npm install react-app-polyfill @webcomponents/webcomponentsjs --save
121141
```
122142

123-
For Browser Support and the configuration of the UI5 Web Components, please take a look at the
124-
[Browser Support](https://github.com/SAP/ui5-webcomponents#browser-support) and the
125-
[Configure](https://github.com/SAP/ui5-webcomponents#browser-support) sections of the
126-
[UI5 Web Components Readme](https://github.com/SAP/ui5-webcomponents#ui5-web-components).
127-
128-
### Improving Bundle Size
129-
If you are running a default `create-react-app`, you will have will huge bundle size after creating a production build.
130-
This is caused by the fact that the webpack bundler is including all UI5 Web Component translation files and CLDR data files in the application bundle.
131-
In order to decrease the bundle size of the application a custom Webpack configuration should be provided.
132-
1. Eject the react build with ```npm run eject```
133-
2. Open ```config/webpack.config.js``` file and add the following lines before the last loader:
134-
```js
135-
{
136-
test: [/cldr\/.*\.json$/, /i18n\/.*\.json$/],
137-
loader: 'file-loader',
138-
options: {
139-
name: 'static/media/[name].[hash:8].[ext]',
140-
},
141-
type: 'javascript/auto'
142-
},
143-
// "file" loader makes sure those assets get served by WebpackDevServer.
144-
// When you `import` an asset, you get its (virtual) filename.
145-
// In production, they would get copied to the `build` folder.
146-
// This loader doesn't use a "test" so it will catch all modules
147-
// that fall through the other loaders.
148-
```
149-
Please also refer to the [UI5 Web Components React Sample](https://github.com/SAP/ui5-webcomponents-sample-react#configure-react-build).
150-
151143
<!-- *********************************************************************** -->
152144
<a name="issues"></a>
153145
## Known Issues
154146

155147
Please look at our [GitHub Issues](https://github.com/SAP/ui5-webcomponents-react/issues) .
156148

157-
158-
159149
<!-- *********************************************************************** -->
160150
<a name="support"></a>
161151
## Support

docs/welcome/Welcome.stories.mdx

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import { Button } from '@ui5/webcomponents-react/lib/Button';
55
<Meta title="1 Welcome / Getting Started" />
66

77
# UI5 Web Components for React
8-
[![](https://img.shields.io/travis/SAP/ui5-webcomponents-react/master.svg)](https://travis-ci.org/SAP/ui5-webcomponents-react)
9-
[![Coverage Status](https://coveralls.io/repos/github/SAP/ui5-webcomponents-react/badge.svg)](https://coveralls.io/github/SAP/ui5-webcomponents-react)
10-
[![](https://img.shields.io/npm/v/@ui5/webcomponents-react/latest.svg)](https://www.npmjs.com/package/@ui5/webcomponents-react)
11-
[![](https://img.shields.io/npm/v/@ui5/webcomponents-react/next.svg)](https://www.npmjs.com/package/@ui5/webcomponents-react)
8+
[![](https://github.com/SAP/ui5-webcomponents-react/workflows/build/badge.svg)](https://github.com/SAP/ui5-webcomponents-react/actions?query=workflow:%22build%22)
9+
[![](https://coveralls.io/repos/github/SAP/ui5-webcomponents-react/badge.svg)](https://coveralls.io/github/SAP/ui5-web)
10+
[![](https://badgen.net/badge/slack/Join%20OpenUI5%20Slack%20workspace/blue?icon=slack)](https://ui5-slack-invite.cfapps.eu10.hana.ondemand.com/)
1211
[![](https://badgen.net/badge/slack/webcomponents-react/orange?icon=slack)](https://openui5.slack.com/archives/CSQEJ2J04)
13-
[![GitHub stars](https://img.shields.io/github/stars/SAP/ui5-webcomponents-react?style=social)](https://github.com/SAP/ui5-webcomponents-react/stargazers)
12+
[![](https://badgen.net/badge/code%20style/prettier?color=pink)](https://github.com/prettier/prettier)
13+
[![](https://badgen.net/badge/maintained%20with/lerna?color=purple)](https://lernajs.io/)
14+
[![](https://badgen.net/github/stars/SAP/ui5-webcomponents-react?icon=github&color=black)](https://github.com/SAP/ui5-webcomponents-react/stargazers)
1415

1516
[Open Github Project](https://github.com/SAP/ui5-webcomponents-react)
1617

@@ -26,38 +27,53 @@ In addition to that, UI5 Web Components for React is providing complex component
2627

2728
## Getting Started
2829

29-
**Prerequisite: You have a React app.** In case you don't, we recommend to create one using [create-react-app](https://facebook.github.io/create-react-app/).<br/>
30-
In order to use `ui5-webcomponents-react` you have to wrap your application's root component into the `ThemeProvider`.<br/>
31-
You will find this component most likely in `src/App.js`:
30+
### Creating a new React app
31+
32+
You can create a new react app by using [create-react-app](https://facebook.github.io/create-react-app/) with our template.
33+
This template is installing all required dependencies for you and is setting up the `App.js` file for you:
34+
```sh
35+
npx create-react-app my-app --template @ui5/webcomponents-react
36+
# or if you want to use yarn
37+
yarn create react-app my-app --template @ui5/webcomponents-react
38+
```
39+
40+
### Add `@ui5/webcomponents-react` to an existing app
41+
42+
First of all, you need to add the `@ui5/webcomponents-react` dependency to your project. Please also keep in mind installing the required peer dependencies:
43+
```sh
44+
npm install @ui5/webcomponents @ui5/webcomponents-react --save
45+
# if you want to use the ShellBar or the ProductSwitcher component, you also need to install this package as well
46+
npm install @ui5/webcomponents-fiori
47+
```
48+
49+
In order to use `@ui5/webcomponents-react` you have to wrap your application's root component into the `ThemeProvider`.<br/>
50+
You will find this component most likely in `src/App.js`:
3251
```jsx
3352
import { ThemeProvider } from '@ui5/webcomponents-react/lib/ThemeProvider';
3453
...
3554
render() {
3655
return (
3756
<div>
38-
<ThemeProvider withToastContainer>
57+
<ThemeProvider>
3958
<MyApp />
4059
</ThemeProvider>
4160
</div>
4261
);
4362
}
4463
```
4564

46-
Then, you are ready to use `ui5-webcomponents-react` and you can import the desired component(s) in your app:<br />
47-
For example, to use ```Button``` you need to import it:
65+
Then you are ready to use `@ui5/webcomponents-react` and you can import the desired component(s) in your app:<br />
66+
For example, to use the `Button` component you need to import it:
4867

4968
```jsx
50-
import { Button } from '@ui5/webcomponents-react/lib/Button';
69+
import { Button } from '@ui5/webcomponents-react/lib/Button'; // loads ui5-button wrapped in a ui5-webcomponents-react component
5170
```
5271

5372
Then, you can use the Button in your app:
5473

5574
```jsx
5675
<Button onClick={() => alert('Hello World!')}>Hello world!</Button>
5776
```
58-
<Button onClick={() => alert('Hello World!')}>Hello World</Button>
59-
60-
You could import all components also from `@ui5/webcomponents-react` directly, but this will have a negative impact on your bundle size.
6177

6278
### Theming
6379

@@ -81,14 +97,12 @@ Available Themes:
8197
- `sap_belize_hcw`
8298

8399
### Configure Compact/Cozy setting
84-
UI5 Web Components supports ```Compact``` and ```Cozy``` mode. It is set to ```Cozy``` by default. To enable ```Compact``` globally, provide the option ```compactSize: true``` in the configuration ```script``` tag:
100+
UI5 Web Components supports ```Compact``` and ```Cozy``` mode. It is set to ```Cozy``` by default. To enable ```Compact```, provide the css class ```ui5-content-density-compact``` to any of your HTML elements and it apply compact size to all of its children.
85101

86102
```html
87-
<script data-ui5-config type="application/json">
88-
{
89-
"compactSize": true
90-
}
91-
</script>
103+
<body class="ui5-content-density-compact">
104+
...
105+
</body>
92106
```
93107

94108
### Support

packages/cra-template/template.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
{
2-
"dependencies": {
3-
"@ui5/webcomponents-react": "^0.7.0",
4-
"@testing-library/react": "^9.3.2",
5-
"@testing-library/jest-dom": "^4.2.4",
6-
"@testing-library/user-event": "^7.1.2"
2+
"package": {
3+
"dependencies": {
4+
"@ui5/webcomponents": "1.0.0-rc.6",
5+
"@ui5/webcomponents-fiori": "1.0.0-rc.6",
6+
"@ui5/webcomponents-icons": "1.0.0-rc.6",
7+
"@ui5/webcomponents-react": "^0.9.0-rc.14",
8+
"@testing-library/react": "^9.3.2",
9+
"@testing-library/jest-dom": "^4.2.4",
10+
"@testing-library/user-event": "^7.1.2",
11+
"jest-environment-jsdom-sixteen": "^1.0.3"
12+
},
13+
"scripts": {
14+
"test": "react-scripts test --env jest-environment-jsdom-sixteen"
15+
},
16+
"jest": {
17+
"transformIgnorePatterns": [
18+
"node_modules/(?!(@ui5|lit-html)).*\\.js$"
19+
]
20+
}
721
}
822
}

0 commit comments

Comments
 (0)