EDUCAÇÃO E TECNOLOGIA

Part 1 – Starting with UI5 Web Components & React from scratch

Hey, how are you today.

In this blog series we will explore the capabilities of UI5 Web Components by creating some nice apps using React.

The idea here is to bring some industry best practices of concepts and combined strategies. We understand the urge of having efficient and high performance apps nowadays, by this reason the scope of this series is not only limited on SAP technologies. During this series, we will design and develop a Worklist App ready to run on production system.

Topics like SPA (single page application), SEO (search engine optimization), styled-components, Conventional Commits, Linter, GitHub Hooks, CI, and build/deploy will be discussed in the next post, so stay tune.

For such thing, we will be always using TypeScript on projects. In case you don’t know what TypeScript is, you can read more about here.

Let’s deep into the part 1 by creating our first app, and pushing into a GitHub repository.

Summary

Before start

Create React App with TypeScript Support

To start a new Create React App project with typescript support, you can run at console

npx create-react-app my-app --template typescript # or yarn create react-app with-worklist-template --template typescript

Add TypeScript to an existing Create React App

To add TypeScript to an existing Create React App project, first install it:

npm install --save typescript @types/node @types/react @types/react-dom @types/jest # or yarn add typescript @types/node @types/react @types/react-dom @types/jest

Add UI5 Web Components Wrapper

Let’s now add the UI5 Web Components React Wrapper. By using the wrapper, we will have all he UI5 support inside of the react context.

For this example, we will add a ShellBar at the top of the page, so let’s also add the webcomponents-fiori too in order to have all fiori experience enabled into our app. See more at Add @ui5/webcomponents-react to an existing app.

yarn add @ui5/webcomponents-react @ui5/webcomponents-fiori --save

Working with ShellBar

Now the project configuration is finally done let’s do some coding.

Open the App.tsx at src dir, and add the ShellBar, just like below

...
import { Avatar, ShellBar } from '@ui5/webcomponents-react';
import logo from './logo.svg';
... export default function App() { return ( <div> <ShellBar primaryTitle="Worklist App" notificationCount="99" showNotifications={true} showProductSwitch={true} > <Avatar slot="logo" image={logo} /> <Avatar slot="profile" image="https://github.com/afuscella.png" /> </ShellBar> </div> );

When done, run yarn start or npm start at the console. your browser window should open on localhost:3000 after a while. It should be similar to this, with the ShellBar at the top.

Notice that using only a few snippet of code, we’re able to delivery nice Fiori experience. At the next posts we will increase this experience with more elements.

Push project to GitHub

Let’s now push our code into GitHub. At the next sections, we will learn how to configure GitHub Actions to build a Continuous Integration pipeline.

  • Push your project into GitHub. In case you don’t how to do, access https://github.com/ and create your an account and follow steps.
  • Add topic scn-worklist-app at yourGitHub repository, and get to know all worklist projects built at this series. GitHub topics: scn-worklist-app.

Gist

The code of this section can be found at GitHub dist, implement it and test other features. Also, feel free to send any suggestion or comments.

Done

That’s it for today. Hope you’ve liked, and looking forward to see you at next blog post of this serie.

BTW, do not forget to leave a comment.