Skip to content

Commit

Permalink
docs: add migration guides, update docs (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladitasev authored Nov 27, 2019
1 parent eeeb414 commit bdfeb78
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 41 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,13 @@ Keep in mind that linking the same module with npm and Yarn may cause issues. Al
### Where are the npm packages?
- [UI5 Web Components](https://www.npmjs.com/package/@ui5/webcomponents)
- [UI5 Web Components Fiori](https://www.npmjs.com/package/@ui5/webcomponents-fiori)
- [UI5 Web Components Icons](https://www.npmjs.com/package/@ui5/webcomponents-icons)
- [UI5 Web Components Base](https://www.npmjs.com/package/@ui5/webcomponents-base)
- [UI5 Web Components Theme Base](https://www.npmjs.com/package/@ui5/webcomponents-theme-base)
- [UI5 Web Components Core](https://www.npmjs.com/package/@ui5/webcomponents-core)

## Limitations
- All input web components (ui5-input, ui5-datepicker and ui5-textarea) do not support the ```placeholder``` attribute on Internet Explorer 11
None as of 1.0.0-rc.5

## Known Issues
No major bugs known.
Expand Down
100 changes: 100 additions & 0 deletions docs/Assets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Assets and JSON module imports

UI5 Web Components aim to be feature rich and with a minimal code footprint at the same time. In order to achieve this,
most UI5 Web Components packages ship their assets as `.json` files while also providing respective public module imports for them.

The assets in question could be i18n texts, icons, additional themes parameters, CLDR, etc...

Currently our npm packages follow the scheme:

`@ui5/<PACKAGE_NAME>/dist/assets/*`
(for the assets themselves)

`@ui5/<PACKAGE_NAME>/dist/json-imports/*`
(for the modules that provide the assets)

<a name="packages"></a>
## Packages

### `base` package

Asset type | Asset path | Public Module Import
------|------------------|---
CLDR | `@ui5/webcomponents-base/dist/assets/cldr/*` | `@ui5/webcomponents-base/dist/json-imports/LocaleData.js`

Usually you don't need to import the CLDR assets from the `base` package, but rather from the package(s) containing the actual web components.

### `main` package

Asset type | Asset path | Public Module Import
------|------------------|---
i18n | `@ui5/webcomponents/dist/assets/i18n/*` | `@ui5/webcomponents/dist/json-imports/i18n.js`
Additional themes | `@ui5/webcomponents/dist/assets/themes/*` | `@ui5/webcomponents/dist/json-imports/Themes.js`
CLDR | N/A | `@ui5/webcomponents/dist/json-imports/LocaleData.js`

The `main` package does not have any additional CLDR assets besides the CLDR assets of the `base` project.

### `fiori` package

Asset type | Asset path | Public Module Import
------|------------------|---
i18n | `@ui5/webcomponents-fiori/dist/assets/i18n/*` | `@ui5/webcomponents-fiori/dist/json-imports/i18n.js`
Additional themes | `@ui5/webcomponents-fiori/dist/assets/themes/*` | `@ui5/webcomponents-fiori/dist/json-imports/Themes.js`

### `icons` package

Asset type | Asset path | Public Module Import
------|------------------|---
i18n | `@ui5/webcomponents-fiori/dist/assets/i18n/*` | `@ui5/webcomponents-fiori/dist/json-imports/i18n.js`
All icons | `@ui5/webcomponents-fiori/dist/assets/icon-collections/*` | `@ui5/webcomponents-fiori/dist/json-imports/Icons.js`

Normally applications are expected to import only the individual icons that are going to be used, for example:

`import "@ui5/webcomponents-icons/dist/icons/add.js`";`

However, sometimes it makes sense to import all icons, hence the `@ui5/webcomponents-fiori/dist/json-imports/Icons.js` JSON import.

Since some icons have translatable tooltips, you might need the `i18n` JSON import as well.

<a name="bundling"></a>
## Efficient asset bundling

You may notice that JSON imports, for example:

`import "@ui5/webcomponents/dist/json-imports/i18n.js"`

or

`import "@ui5/webcomponents/dist/json-imports/Themes.js"`

will produce warning messages in the browser's console, such as for example:
> Inefficient bundling detected: consider bundling i18n/theme proeprties imports as URLs instead of inlining them.
> See rollup-plugin-url or webpack file-loader for more information.
> Suggested pattern: "assets\/.*\.json"
What this means is that it's recommended to instruct your source code bundling software
(some of the most popular being Webpack and Rollup) not to include all the asset files or theming related files
(files that match the <code>assets\/.*\.json</code> pattern) in your applications's javascript bundle,
but rather to leave them out. At runtime, they will be fetched on demand, if ever requested.

[How to do it with Webpack](https://github.com/webpack-contrib/file-loader)

[How to do it with Rollup](https://github.com/rollup/rollup-plugin-url)

Rollup example:

```js
import url from "rollup-plugin-url";
...
plugins.push(url({
limit: 0,
include: [
/.*assets\/.*\.json/,
],
emitFiles: true,
fileName: "[name].[hash][extname]",
publicPath: YOUR_APPLICATION_PUBLIC_PATH + "/resources/",
}));
```

Please note that the code above is just sample snippet, and will not work on its own.
2 changes: 1 addition & 1 deletion docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ import { getTheme, setTheme } from "@ui5/webcomponents-base/dist/config/Theme.js
import { getNoConflict, setNoConflict } from "@ui5/webcomponents-base/dist/config/NoConflict.js";
import { getCompactSize } from "@ui5/webcomponents-base/dist/config/CompactSize.js";
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
import { getCompactSize } from "@ui5/webcomponents-base/dist/config/AnimationMode.js";
import { getAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js";
import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js";
Expand Down
11 changes: 4 additions & 7 deletions docs/How To Use.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ myButton.childNodes[0].nodeValue = "New text" // same result again
Usually you'll never have to do this manually either, as you'll bind the content of the button via the means
provided by the framework you're using, and the framework will be the one updating it for you.

Finally, there are UI5 Web Components that only accept other HTML elements (of any kind or specific ones - check the
documentation for each individual Web Component's requirements).
Finally, there are UI5 Web Components that only accept other HTML elements.

For example `<ui5-popover>` may contain any HTML element - standard elements and other custom elements alike.

Expand All @@ -134,7 +133,7 @@ popover.appendChild(newChild);

Again, normally you won't need to do this manually, but your framework will do it for you.

Now let's have a look at a Web Component that only accepts certain children:
Now let's have a look at a Web Component that is intended to have only certain children:

```html
<ui5-tabcontainer id="tc1" fixed collapsed show-overflow>
Expand All @@ -145,7 +144,7 @@ Now let's have a look at a Web Component that only accepts certain children:
</ui5-tabcontainer>
```

The `<ui5-tabcontainer>` may only contain `<ui5-tab>` and `<ui5-tab-separator>`.
The `<ui5-tabcontainer>` should only contain `<ui5-tab>` and `<ui5-tab-separator>`.

The manipulation is exactly the same as with the other Web Components. For example to add a new tab:

Expand Down Expand Up @@ -193,9 +192,7 @@ Here's a summary of `slot` types:
| ------------------------------ | --------------------------------------------- | ------------------------------------------------------------------------------ |
| `Node` | All HTML Elements and text | `ui5-button` default slot |
| `HTMLElement` | HTML Elements only (no text) | `ui5-popover` `header` slot |
| Base Class f.e. `TabBase` | Only HTML Elements of this class' descendents | `ui5-tabcontainer` `default` slot - accepts `ui5-tab`, `ui5-tabseparator` only |
| Specific Class f.e. `TableRow` | Only HTML Elements of this class | `ui5-table` `default` slot only accepts `ui5-table-row` |


<a name="events"></a>
## 4. How do I listen for events?

Expand Down
92 changes: 92 additions & 0 deletions docs/Migration-guides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Migration guides

## Migrating from `1.0.0-rc.4` to `1.0.0-rc.5`

### New npm package: `@ui5/webcomponents-icons`

All individual icons were moved to a new npm package called `@ui5/webcomponents-icons`.

If you are using icons in your project:

1. Add the new package as a dependency to your project

`npm i @ui5/webcomponents-icons --save`

or

`yarn add @ui5/webcomponents-icons`

depending on your package manager.

2. Change the imports for the individual icons (if you were importing them one by one):

Current code | Change to
-----|----
`@ui5/webcomponents/dist/icons/add.js` | `@ui5/webcomponents-icons/dist/icons/add.js`
`@ui5/webcomponents/dist/icons/search.js` | `@ui5/webcomponents-icons/dist/icons/search.js`
etc... | etc...

*Note:* The `ui5-icon` web component is not affected by this change, it is still in the `@ui5/webcomponents` package. Only the icons themselves (the icon assets) have been moved.


### New npm package: `@ui5/webcomponents-fiori`

The `ui5-shellbar` and `ui5-shellbar-item` web components were moved to a new npm package called `@ui5/webcomponents-fiori`.

If you are using `ui5-shellbar` in your project:

1. Add the new package as a dependency to your project

`npm i @ui5/webcomponents-fiori --save`

or

`yarn add @ui5/webcomponents-fiori`

depending on your package manager.

2. Change the imports:

Current code | Change to
-----|----
`@ui5/webcomponents/dist/ShellBar.js` | `@ui5/webcomponents-fiori/dist/ShellBar.js`
`@ui5/webcomponents/dist/ShellBarItem.js` | `@ui5/webcomponents-fiori/dist/ShellBarItem.js`

### `ui5-icon`

The `src` property was renamed to `name` and accepts icon name (such as `add`) instead of icon src (such as `sap-icon://add`).
Note: the `src` property will continue to work until the next release due to the impact of the change, but will produce a warning in the console.

Current code | Change to
-----|----
`<ui5-icon src="sap-icon://add">` | `<ui5-icon name="add">`

### `ui5-card`

The `avatar` property was removed.
Use the `avatar` slot instead - pass an icon(`<ui5-icon>`) or an image(`<img>`).
Example:

Current code | Change to
-----|----
`<ui5-card avatar="sap-icon://add"></ui5-card>` | `<ui5-card><ui5-icon name="add" slot="avatar"></ui5-icon></ui5-card>`
`<ui5-card avatar="http://url/to/my/image"></ui5-card>` | `<ui5-card><img src="http://url/to/my/image" slot="avatar"/></ui5-card>`

### `ui5-shellbar`

In addition to the fact that `ui5-shellbar` was moved to `@ui5/webcomponents-fiori`, the `icon` slot was renamed to `startButton`.

The `ui5-shellbar` CoPilot is now a static SVG by default. In order to have the animated SVG again, you need to manually import the following feature:
```js
import "@ui5/webcomponents-fiori/dist/features/CoPilotAnimation.js";
```


### `ui5-shellbar-item`

In addition to the fact that `ui5-shellbar-item` was moved to `@ui5/webcomponents-fiori`, the `src` property was renamed to `icon` and accepts icon name (such as `add`) instead of icon src (such as `sap-icon://add`)

Current code | Change to
-----|----
`<ui5-shellbar-item src="sap-icon://add">` | `<ui5-shellbar-item icon="add">`

67 changes: 35 additions & 32 deletions docs/Public Module Imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ For API documentation and samples, please check the [UI5 Web Components Playgrou

### Main package (```@ui5/webcomponents```)

The `main` package provides general purpose UI building blocks such as buttons, labels, inputs and popups.

| Web Component | Tag name | Module import |
| ------------------------ | -------------------- | ---------------------------------------------------------- |
| Badge | `ui5-badge` | `import "@ui5/webcomponents/dist/Badge.js";` |
Expand Down Expand Up @@ -48,10 +50,33 @@ For API documentation and samples, please check the [UI5 Web Components Playgrou

### Fiori package (```@ui5/webcomponents-fiori```)

The `fiori` package provide essential building blocks, necessary to implement the Fiori UX concept,
such as a common header (ShellBar).

| Web Component | Tag name | Module import |
| ------------------------ | -------------------- | ---------------------------------------------------------- |
| Shell Bar | `ui5-shellbar` | `import "@ui5/webcomponents-fiori/dist/ShellBar.js";` |
| Shell Bar Item | `ui5-shellbar-item` | `import "@ui5/webcomponents-fiori/dist/ShellBarItem.js";` |
| Product Switch | `ui5-product-switch` | `import "@ui5/webcomponents-fiori/dist/ProductSwitch.js";` |
| Product Switch Item | `ui5-product-switch-item` | `import "@ui5/webcomponents-fiori/dist/ProductSwitchItem.js";` |

### Icons package (```@ui5/webcomponents-icons```)

The `icons` package provides assets for the rich `SAP-icons` icon collection.

| Icon asset | Module import |
| ------------------------ | ---------------------------------------------------------- |
| All icons (~115KB zipped) | `import "@ui5/webcomponents-icons/dist/json-imports/Icons.js";` |
| Accelerated icon | `import "@ui5/webcomponents-fiori/dist/icons/accelerated.js";` |
| Accept icon | `import "@ui5/webcomponents-fiori/dist/icons/accept.js";` |
| ... | ... |
| Zoom out icon | `import "@ui5/webcomponents-fiori/dist/icons/zoom-out.js";` |

*Note:* The `@ui5/webcomponents-icons` package does not provide any web components per se, but rather icon assets,
usable by other web components such as `ui5-icon`. You could import all icons, but it's recommended to import
just the ones that your app will actually use.

For a full list of the icons in the `SAP-icons` collection, click [here](https://openui5.hana.ondemand.com/test-resources/sap/m/demokit/iconExplorer/webapp/index.html#/overview/SAP-icons).

## Additional public modules

Expand Down Expand Up @@ -157,16 +182,21 @@ import { setTheme } from "@ui5/webcomponents-base/dist/config/Theme.js";
setTheme("sap_belize_hcb");
```

For more general information on assets and JSON imports, click [here](Assets.md).

Find out how you can bundle your themes more efficiently [here](Assets.md#bundling).

<a name="internationalization"></a>
### 3. Internationalization

```js
import "@ui5/webcomponents/dist/json-imports/i18n.js";
import "@ui5/webcomponents-fiori/dist/json-imports/i18n.js"; // Only if using the @ui5/webcomponents-fiori package
import "@ui5/webcomponents-icons/dist/json-imports/i18n.js"; // Only if using the @ui5/webcomponents-icons package
```

Some UI5 Web Components contain texts (such as placeholders, tooltips, messages) that need translation.
All texts are in English by default. In order to get support for other languages, you should import the module above.
All texts are in English by default. In order to get support for other languages, you should import the module(s) above.

You can configure the language by setting the <code>language</code> key in the configuration object.

Expand All @@ -179,38 +209,9 @@ Example:
</script>
```

### Note: importing `import "@ui5/webcomponents/dist/json-imports/i18n.js"` or `import "@ui5/webcomponents/dist/json-imports/Themes.js"` will produce the following warning message in the browser's console:
> Inefficient bundling detected: consider bundling i18n/theme proeprties imports as URLs instead of inlining them.
> See rollup-plugin-url or webpack file-loader for more information.
> Suggested pattern: "assets\/.*\.json"
What this means is that it's recommended to instruct your source code bundling software
(some of the most popular being Webpack and Rollup) not to include all the internationalization files or theming related files
(files that match the <code>assets\/.*\.json</code> pattern) in your applications's javascript bundle,
but rather to leave them out. At runtime, they will be fetched on demand, if ever requested.

[How to do it with Webpack](https://github.com/webpack-contrib/file-loader)

[How to do it with Rollup](https://github.com/rollup/rollup-plugin-url)

Rollup example:

```js
import url from "rollup-plugin-url";
...
plugins.push(url({
limit: 0,
include: [
/.*assets\/.*\.json/,
],
emitFiles: true,
fileName: "[name].[hash][extname]",
publicPath: DEPLOY_PUBLIC_PATH + "/resources/",
}));
```
For more general information on assets and JSON imports, click [here](Assets.md).

Please note that the code above is just sample snippet, taken from the UI5 Web Components playground app
rollup configuration file and will not work on its own.
Find out how you can bundle your i18n texts more efficiently [here](Assets.md#bundling).

<a name="formsupport"></a>
### 4. Form Support
Expand Down Expand Up @@ -281,6 +282,8 @@ import { getCompactSize } from "@ui5/webcomponents-base/dist/config/CompactSize.
import { getRTL } from "@ui5/webcomponents-base/dist/config/RTL.js";
import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
import { getAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js";
import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js";
```

For more details, please check [Configuration](Configuration.md)

0 comments on commit bdfeb78

Please sign in to comment.