From 286866aa55aa49bfe961870e00c06f98706bf58d Mon Sep 17 00:00:00 2001 From: Konstantin Gogov Date: Thu, 4 Sep 2025 11:21:03 +0300 Subject: [PATCH] docs: add custom illustrations guide for ui5-illustrated-message Add comprehensive documentation for registering and using custom illustrations in UI5 Web Components projects. Jira: BGSOFUIPIRIN-6913 --- .../18-using-custom-illustrations.md | 219 ++++++++++++++++++ .../src/asset-registries/Illustrations.ts | 64 +++++ 2 files changed, 283 insertions(+) create mode 100644 docs/2-advanced/18-using-custom-illustrations.md diff --git a/docs/2-advanced/18-using-custom-illustrations.md b/docs/2-advanced/18-using-custom-illustrations.md new file mode 100644 index 000000000000..2923ecae508a --- /dev/null +++ b/docs/2-advanced/18-using-custom-illustrations.md @@ -0,0 +1,219 @@ +# Using Custom Illustrations + +*Learn how to create and register custom illustrations for the UI5 Web Components IllustratedMessage component.* + +The [`ui5-illustrated-message`](https://ui5.github.io/webcomponents/components/fiori/IllustratedMessage/) component enhances user experience by displaying contextual illustrations in empty states, error conditions, onboarding flows, and other scenarios where visual communication improves usability. + +While UI5 Web Components includes a comprehensive set of [built-in illustrations](https://ui5.github.io/webcomponents/components/fiori/enums/IllustrationMessageType/), you can extend this collection by registering your own custom illustrations that match your application's brand and design requirements. + +## Overview + +Custom illustrations in UI5 Web Components consist of four size variants that automatically adapt to different container dimensions and [design contexts](https://ui5.github.io/webcomponents/components/fiori/enums/IllustrationMessageDesign/): + +| Variant | Size | Breakpoint | Container Width | Design Type | +|------------|-------------|------------|-----------------|-------------| +| **Scene** | Large | L | > 681px | Large | +| **Dialog** | Medium | M | ≤ 681px | Medium | +| **Spot** | Small | S | ≤ 360px | Small | +| **Dot** | Extra Small | XS | ≤ 260px | ExtraSmall | + +Each custom illustration must include all four variants to ensure optimal display across different use cases and responsive breakpoints. + +## Prerequisites + +Before implementing custom illustrations, ensure you have: + +### 1. Installed the required packages + +```bash +npm install @ui5/webcomponents @ui5/webcomponents-fiori +``` + +The [`@ui5/webcomponents`](https://www.npmjs.com/package/@ui5/webcomponents) package provides the base framework and asset registry functionality, while [`@ui5/webcomponents-fiori`](https://www.npmjs.com/package/@ui5/webcomponents-fiori) contains the `IllustratedMessage` component. + +### 2. Prepared SVG Assets + +Create four SVG files for each illustration following the naming convention: +``` +{set}-{Variant}-{IllustrationName}.js +``` + +**Example file structure:** +``` +assets/ +├── custom-Scene-EmptyCart.js # Large variant +├── custom-Dialog-EmptyCart.js # Medium variant +├── custom-Spot-EmptyCart.js # Small variant +└── custom-Dot-EmptyCart.js # Extra small variant +``` + +## Implementation + +### Registration + +Register your custom illustration using the `registerIllustration` function: + +**JavaScript:** +```js +import "@ui5/webcomponents-fiori/dist/IllustratedMessage.js"; +import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js"; + +// Import SVG assets +import sceneSvg from "./assets/custom-Scene-EmptyCart.js"; +import dialogSvg from "./assets/custom-Dialog-EmptyCart.js"; +import spotSvg from "./assets/custom-Spot-EmptyCart.js"; +import dotSvg from "./assets/custom-Dot-EmptyCart.js"; + +// Register the illustration +registerIllustration("EmptyCart", { + sceneSvg, + dialogSvg, + spotSvg, + dotSvg, + title: "Your cart is empty", + subtitle: "Add items to get started with your order", + set: "custom" +}); +``` + +**TypeScript:** +```ts +import "@ui5/webcomponents-fiori/dist/IllustratedMessage.js"; +import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js"; +import type { I18nText } from "@ui5/webcomponents-base/dist/i18nBundle.js"; + +// Import SVG assets +import sceneSvg from "./assets/custom-Scene-EmptyCart.js"; +import dialogSvg from "./assets/custom-Dialog-EmptyCart.js"; +import spotSvg from "./assets/custom-Spot-EmptyCart.js"; +import dotSvg from "./assets/custom-Dot-EmptyCart.js"; + +// Register the illustration with proper typing +registerIllustration("EmptyCart", { + sceneSvg, + dialogSvg, + spotSvg, + dotSvg, + title: "Your cart is empty" as I18nText, + subtitle: "Add items to get started with your order" as I18nText, + set: "custom" +}); +``` + +### SVG Asset Structure + +Each SVG asset file should export the SVG content as a string: + +**custom-Dialog-EmptyCart.js:** +```js +export default ` + + + + + + +`; +``` + +### Design Guidelines + +**SVG Requirements:** +- Include a unique `id` attribute: `{set}-{Variant}-{IllustrationName}` +- Use responsive dimensions appropriate for each variant + +**Theming Support:** +- Use CSS custom properties for colors +- Avoid hard-coded colors to ensure theme compatibility +- Test illustrations across different UI5 themes + +**Security Compliance:** +- ⚠️ **No inline JavaScript**: Avoid `