Skip to content

Conversation

kgogov
Copy link
Contributor

@kgogov kgogov commented Sep 4, 2025

This PR adds comprehensive documentation for registering custom illustrations with ui5-illustrated-message and introduces a safer template-based registration method.

What's New

1. Safe Registration API (registerIllustration)

  • Uses JSX template functions instead of raw SVG strings
  • Prevents XSS vulnerabilities
  • Note: Only works in projects scaffolded with npm init @ui5/webcomponents-package. Otherwise, use unsafeRegisterIllustration.

Example:

import { registerIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";

registerIllustration("MyCustomFigure", {
  sceneTemplate: () => (
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 200">
      <rect width="320" height="200" rx="14" fill="var(--sapContent_Illustrative_Color7)" />
      <circle cx="160" cy="100" r="50" fill="var(--sapContent_Illustrative_Color1)" />
    </svg>
  ),
  dialogTemplate: () => (
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 160">
      <circle cx="80" cy="80" r="50" fill="var(--sapContent_Illustrative_Color1)" />
      <path d="M60 70 Q80 50 100 70" stroke="var(--sapContent_Illustrative_Color3)" strokeWidth="3" fill="none" />
    </svg>
  ),
  spotTemplate: () => (
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120">
      <circle cx="60" cy="60" r="30" fill="var(--sapContent_Illustrative_Color1)" />
    </svg>
  ),
  dotTemplate: () => (
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
      <circle cx="30" cy="30" r="15" fill="var(--sapContent_Illustrative_Color1)" />
    </svg>
  ),
  title: "Custom Illustration",
  subtitle: "Registered with JSX templates",
  set: "custom"
});

2. Unsafe Registration API (unsafeRegisterIllustration)

  • Accepts raw SVG strings (with security warnings)
  • Use when JSX templates aren't available

Example:

import { unsafeRegisterIllustration } from "@ui5/webcomponents-base/dist/asset-registries/Illustrations.js";
import dialogSvg from "./assets/custom-Dialog-MyIllustration.js";
import sceneSvg from "./assets/custom-Scene-MyIllustration.js";
import spotSvg from "./assets/custom-Spot-MyIllustration.js";
import dotSvg from "./assets/custom-Dot-MyIllustration.js";

unsafeRegisterIllustration("MyIllustration", {
  dialogSvg,
  sceneSvg,
  spotSvg,
  dotSvg,
  title: "My Custom Title",
  subtitle: "My Custom Subtitle",
  set: "custom"
});

3. Documentation

  • Step-by-step instructions for both registration methods
  • Security guidelines and best practices
  • Examples for overriding title/subtitle

4. Usage

Example:

<ui5-illustrated-message name="custom/MyCustomFigure">
  <ui5-button design="Emphasized">Primary Action</ui5-button>
</ui5-illustrated-message>

@cla-assistant
Copy link

cla-assistant bot commented Sep 9, 2025

CLA assistant check
All committers have signed the CLA.

@kgogov kgogov force-pushed the using-custom-illus-docs branch from 30635c4 to 03f68af Compare September 9, 2025 13:41
@kgogov kgogov requested a review from Copilot September 9, 2025 13:42
Copilot

This comment was marked as outdated.

@kgogov kgogov marked this pull request as ready for review September 9, 2025 13:48
@kgogov kgogov force-pushed the using-custom-illus-docs branch from 03f68af to ac40098 Compare September 10, 2025 07:27
@kgogov kgogov force-pushed the using-custom-illus-docs branch from ac40098 to b69fe74 Compare September 10, 2025 08:55
@kgogov kgogov force-pushed the using-custom-illus-docs branch 2 times, most recently from e4b8285 to 286866a Compare September 17, 2025 06:48
@kgogov kgogov force-pushed the using-custom-illus-docs branch from 286866a to 8a9e4ab Compare October 13, 2025 14:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

@ui5-webcomponents-bot
Copy link
Collaborator

ui5-webcomponents-bot commented Oct 13, 2025

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview October 13, 2025 14:38 Inactive
@kgogov kgogov force-pushed the using-custom-illus-docs branch from 8a9e4ab to 9de80e3 Compare October 14, 2025 09:58
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview October 14, 2025 10:03 Inactive
@kgogov kgogov changed the title docs: add custom illustrations guide for ui5-illustrated-message feat(framework): Custom Illustrations Documentation & API Enhancement Oct 14, 2025
Add comprehensive documentation for registering and using custom illustrations
in UI5 Web Components projects.

Jira: BGSOFUIPIRIN-6913
- Rename registerIllustration to unsafeRegisterIllustration with security warnings
- Add new registerIllustration API that accepts template functions instead of raw SVG strings
- Update IllustratedMessage component to execute templates via executeTemplate()
- Add IllustratedMessageTemplate support for both safe (object) and unsafe (string) variants
- Update build tool to use unsafeRegisterIllustration for generated illustrations
- Add comprehensive documentation for both registration methods
- Create playground page demonstrating safe and unsafe approaches with working examples
- Export IllustrationData and UnsafeIllustrationData types for better TypeScript support

The safe variant (registerIllustration) uses template functions to prevent XSS vulnerabilities,
while the unsafe variant (unsafeRegisterIllustration) maintains backward compatibility for
raw SVG strings with explicit security warnings.
…tion

- Restructure documentation to follow the pattern from icons guide
- Clarify two registration methods: registerIllustration (recommended) vs unsafeRegisterIllustration
- Add JSX template requirement note for registerIllustration method
- Organize unsafeRegisterIllustration into clear Step 1 (Prepare SVG Assets) and Step 2 (Register)
- Add comprehensive parameter documentation for both methods
- Include examples for overriding title and subtitle texts via component properties
- Update playground page with improved card layout and styling
@kgogov kgogov force-pushed the using-custom-illus-docs branch from 9de80e3 to 3b5468b Compare October 22, 2025 18:59
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview October 22, 2025 19:05 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants