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
* Add JS/TS switches to Step 1-10
* docs: add js parts to readme
* Fix visualization of JS/TS block switches
* docs: add missing js parts to readme
* Adapt links with current language; make dev server support URL params
This ensures that after navigating to another page the current language
is still active
* Let browsersync popup not cover the language switch
* Update README.md
* Update 01/README
* Update 02/README
* Update 16/README and 17/README
---------
Co-authored-by: Peter Muessig <peter.muessig@sap.com>
Co-authored-by: akudev <andreas.kunz@sap.com>
Copy file name to clipboardExpand all lines: steps/01/README.md
+15-4Lines changed: 15 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
## Step 1: Hello World!
2
2
3
-
As you know OpenUI5 is all about HTML5. Let's get started with building a first "Hello World" with only HTML. In addition we'll initialize the UI5 Tooling, so we can benefit from it from the beginning.
3
+
As you know, OpenUI5 is all about HTML5. Let's get started with building a first "Hello World" with only HTML. In addition we'll initialize the UI5 Tooling, so we can benefit from it from the beginning.
4
4
5
5
6
6
@@ -15,12 +15,23 @@ As you know OpenUI5 is all about HTML5. Let's get started with building a first
15
15
16
16
You can access the live preview by clicking on this link: [🔗 Live Preview of Step 1](https://sap-samples.github.io/ui5-typescript-walkthrough/build/01/index.html).
17
17
18
-
Download solution for step 1 in [📥 TypeScript](https://sap-samples.github.io/ui5-typescript-walkthrough/ui5-typescript-walkthrough-step-01.zip) or [📥 JavaScript](https://sap-samples.github.io/ui5-typescript-walkthrough/ui5-typescript-walkthrough-step-01-js.zip).
19
-
20
18
***
21
19
22
20
### Coding
23
21
22
+
<detailsclass="ts-only">
23
+
24
+
You can download the solution for this step here: [📥 Download step 1](https://sap-samples.github.io/ui5-typescript-walkthrough/ui5-typescript-walkthrough-step-01.zip).
25
+
26
+
</details>
27
+
28
+
<detailsclass="js-only">
29
+
30
+
You can download the solution for this step here: [📥 Download step 1](https://sap-samples.github.io/ui5-typescript-walkthrough/ui5-typescript-walkthrough-step-01-js.zip).
31
+
32
+
</details>
33
+
***
34
+
24
35
### webapp \(New\)
25
36
26
37
We create a folder on our local machine which will contain all the sources of the app we're going to build. We'll refer to this folder as the “app root directory".
@@ -154,7 +165,7 @@ This will open a new browser window hosting your newly created `index.html`.
154
165
155
166
### Conventions
156
167
157
-
- The `index.html` file is located in the `webapp` folder if it is used productively.
168
+
- The `index.html` file is located in the `webapp` folder.
Copy file name to clipboardExpand all lines: steps/02/README.md
+68-17Lines changed: 68 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,23 @@ Before we can do something with OpenUI5, we need to load and initialize it. This
15
15
16
16
You can access the live preview by clicking on this link: [🔗 Live Preview of Step 2](https://sap-samples.github.io/ui5-typescript-walkthrough/build/02/index-cdn.html).
17
17
18
-
Download solution for step 2 in [📥 TypeScript](https://sap-samples.github.io/ui5-typescript-walkthrough/ui5-typescript-walkthrough-step-02.zip) or [📥 JavaScript](https://sap-samples.github.io/ui5-typescript-walkthrough/ui5-typescript-walkthrough-step-02-js.zip).
18
+
***
19
+
### Coding
20
+
21
+
<detailsclass="ts-only">
22
+
23
+
You can download the solution for this step here: [📥 Download step 2](https://sap-samples.github.io/ui5-typescript-walkthrough/ui5-typescript-walkthrough-step-02.zip).
24
+
25
+
</details>
26
+
27
+
<detailsclass="js-only">
19
28
29
+
You can download the solution for this step here: [📥 Download step 2](https://sap-samples.github.io/ui5-typescript-walkthrough/ui5-typescript-walkthrough-step-02-js.zip).
30
+
31
+
</details>
20
32
***
21
33
22
-
### Tooling
34
+
### UI5 Tooling
23
35
24
36
First, let's set up our UI5 Tooling to use the OpenUI5 framework for our project. We also need to add the necessary OpenUI5 libraries as dependencies to the project's UI5 Tooling configuration.
The `ui5 add` command adds specific libraries as dependency to the projects UI5 Tooling configuration. In this case, we'e adding the `sap.ui.core` library, which provides core functionality of the OpenUI5 framework. This library is essential for bootstrapping OpenUI5. Additionally, we're adding the `themelib_sap_horizon` library which provides the visual styles for the Horizon theme. We'll use this theme with our application.
39
51
40
-
***
41
52
42
-
### package.json
53
+
<detailsclass="ts-only">
54
+
55
+
### TypeScript Setup
43
56
44
57
To work with TypeScript, we must install it in our project. To do this, we execute the following command in the terminal:
45
58
59
+
46
60
```sh
47
61
npm install typescript --save-dev
48
62
```
49
63
50
64
By running this command, npm will download the TypeScript package from the npm registry and install it in our project's "node_modules" directory. It will also add an entry for TypeScript in the "devDependencies" section of our package.json file, so that other developers working on the project can easily install the same version of TypeScript.
51
65
52
-
***
53
66
54
67
### tsconfig.json \(New\)
55
68
56
69
As a next step, we need to create the file `tsconfig.json` in the app root directory to indicate that this folder is the root of a TypeScript project. This file specifies various compiler options and project settings that affect how TypeScript code is compiled into JavaScript.
57
70
58
71
We specify the compiler options as follow:
59
72
73
+
60
74
```json
61
75
{
62
76
"compilerOptions": {
@@ -101,18 +115,16 @@ Let's go through the compiler options specified in the file:
101
115
102
116
***
103
117
104
-
### Coding
118
+
</details>
105
119
106
-
### webapp/index.ts\(New\)
120
+
### webapp/index.?s\(New\)
107
121
108
-
Now let's move on to the UI work. We create a new `index.ts` script in the webapp folder. In this script, we add a native `alert()` method with the message "UI5 is ready".
122
+
Now let's move on to the UI work. We create a new `index.?s` script in the webapp folder. In this script, we add a native `alert()` method with the message "UI5 is ready".
109
123
110
-
```ts
124
+
```js
111
125
alert("UI5 is ready");
112
126
```
113
127
114
-
***
115
-
116
128
### webapp/index.html
117
129
118
130
Next, we'll integrate the script we just created into the `index.html` page to signal when the OpenUI5 framework has finished loading. This process involves first incorporating the OpenUI5 framework into our HTML page by adding a script tag specifically for loading OpenUI5.
@@ -157,22 +169,30 @@ We initialize the core modules with the following configuration options:
157
169
</html>
158
170
```
159
171
160
-
> 📝 **Note:**
172
+
> 📝 **Note:**<br>
161
173
> The namespace is a unique identifier for your application file. It helps prevent naming conflicts with other modules or libraries.
162
174
163
175
***
164
176
165
-
### Tooling
166
-
167
-
### package.json
177
+
### UI5 Tooling
168
178
169
179
Let's enhance our tooling setup once again by installing some custom middleware for the ui5-server. This will help us handle our development project more efficiently.
170
180
171
181
We open a terminal and navigate to the root folder of our app. Then, we execute the following command:
When you run the command, npm will download the specified packages from the npm registry and store them in a folder called `node_modules` within your project directory. The `--save-dev` flag instructs npm to save these packages as development dependencies in the `devDependencies` section of the `package.json` file. Development dependencies are packages that are only needed during development and not in production. By separating them from production dependencies, we can keep our project clean and ensure that only the required packages are included when deploying the application.
178
198
@@ -182,21 +202,28 @@ Let's break down what each package does:
182
202
183
203
-`ui5-middleware-serveframework` is another middleware plugin for the UI5 Tooling that provides a web server to serve your OpenUI5 project during development. It allows you to easily serve the necessary OpenUI5 libraries and resources required by your application from your development environment.
184
204
205
+
<detailsclass="ts-only">
206
+
185
207
-`ui5-tooling-transpile` is a plugin for the UI5 Tooling that transpiles modern JavaScript (ES6+) and TypeScript into a compatible version for OpenUI5. OpenUI5 is based on older versions of JavaScript, so this plugin allows you to take advantage of the latest language features and syntax while ensuring that your code remains compatible with OpenUI5.
186
208
187
-
***
209
+
</details>
188
210
189
211
### ui5.yaml
190
212
191
213
Next, we have to configure the tooling extension we installed from npm to our UI5 Tooling setup, so we can use them in our project. To hook a custom task into a certain build phase of a project, it needs to reference another task that will get executed before or after it. The same applies for a custom middleware:
214
+
<detailsclass="ts-only">
192
215
193
216
- For the `ui5-tooling-transpile-task` we specify that this should happen after the`replaceVersion` task.
194
217
218
+
</details>
219
+
195
220
- All our custom middleware extensions will be called after the `compression` middleware.
196
221
197
222
> 📌 **Important:** <br>
198
223
> Middleware configurations are applied in the order in which they are defined.
199
224
225
+
<detailsclass="ts-only">
226
+
200
227
```yaml
201
228
framework:
202
229
name: OpenUI5
@@ -219,7 +246,31 @@ server:
219
246
```
220
247
Now you can benefit from live reload on changes, built framework resources at development time, and make use of TypeScript in OpenUI5.
221
248
222
-
> 📝 **Note:** <br>
249
+
</details>
250
+
251
+
<details class="js-only">
252
+
253
+
```yaml
254
+
framework:
255
+
name: OpenUI5
256
+
version: "1.132.1"
257
+
libraries:
258
+
- name: sap.ui.core
259
+
- name: themelib_sap_horizon
260
+
builder:
261
+
server:
262
+
customMiddleware:
263
+
- name: ui5-middleware-serveframework
264
+
afterMiddleware: compression
265
+
- name: ui5-middleware-livereload
266
+
afterMiddleware: compression
267
+
```
268
+
Now you can benefit from live reload on changes and built framework resources at development time.
269
+
270
+
</details>
271
+
272
+
<br>
273
+
> 📝 **Note:**<br>
223
274
> During its initial run, the `ui5-middleware-serveframework` middleware will build the framework, which can take a while. In all following steps, the build will not happen again and the framework is served from the built resources.
0 commit comments