Skip to content
UI5 Web Components Sample TODO Application built with React
JavaScript Shell CSS HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
deploy
docs
public
scripts
src
.gitignore
.travis.yml
LICENSE.txt
NOTICE.txt
README.md
package-lock.json
package.json

README.md

UI5 logo

UI5 Web Components React Sample Application

React sample application to demonstrate the usage of the UI5 Web Components. It shows how to bind properties, to subscribe to events, using nested components and the bootstrapped React build.

This project was bootstrapped with Create React App.

Prerequisites

  • Node.js (version 8.5 or higher ⚠️)
  • Yarn (Optional usage of yarn)

Getting started

  1. Clone this repository using the GitHub Command line tool and navigate into the downloaded directory.

    git clone https://github.com/SAP/ui5-webcomponents-sample-react.git
    cd ui5-webcomponents-sample-react
  2. Install all dependencies

    yarn

    or

    npm install
  3. Start a local server and run the application. (The running application can be found here: http://localhost:3000)

    npm start

Noteworthy

Consume UI5 Web Components

Import the desired component(s) in your app to define the UI5 Web Component.

For example, to use ui5-button you need to import it:

import "@ui5/webcomponents/dist/Button"; // loads ui5-button

Then, you can use the custom element in an HTML page:

<ui5-button>Hello world!</ui5-button>

Browser support

Currently only Chrome, Safari and Firefox support Web Components natively.

If your application should run on browsers without native Web Components support (Edge and/or IE11), import one the following modules before your first Web Component import:

Edge only

import "@ui5/webcomponents-base/src/base/browsersupport/Edge";

Edge and IE11

import "@ui5/webcomponents-base/src/browsersupport/IE11";

Note: Importing the module for IE11 support automatically enables Edge support as well, so there is no need to import them both explicitly.

Example:

import "@ui5/webcomponents-base/src/browsersupport/IE11"; // This will enable Edge and IE11 support for all Web Components below
import "@ui5/webcomponents/dist/Button"; // loads ui5-button
import "@ui5/webcomponents/dist/Label"; // loads ui5-label

Configure React Build

When UI5 Web Components are used they include all of their translation files and CLDR data files in the application bundle. In order to decrease the bundle size of the application a custom Webpack configuration should be provided.

  1. Eject the react build with npm run eject
  2. Open config/webpack.config.js file and add the following lines before the last loader:
{
  test: [/cldr\/.*\.json$/, /i18n\/.*\.json$/],
  loader: 'file-loader',
  options: {
    name: 'static/media/[name].[hash:8].[ext]',
  },
  type: 'javascript/auto'
},
// "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename.
// In production, they would get copied to the `build` folder.
// This loader doesn't use a "test" so it will catch all modules
// that fall through the other loaders.

Where is the npm package?

Limitations

No limitations known.

Known Issues

No major bugs known.

Support

We welcome all comments, suggestions, questions, and bug reports. Please follow our Support Guidelines on how to report an issue, or chat with us in the #webcomponents channel of the OpenUI5 Community Slack.

Contribute to UI5 Web Components

Please check our Contribution Guidelines.

License

Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the LICENSE file.

You can’t perform that action at this time.