RHDS Extension for Next Gen UI Agent
Project description
Next Gen UI Red Hat Design System Renderer
This module is part of the Next Gen UI Agent project.
This Python package provides a Server-Side renderer for Next Gen UI Agent that produces Red Hat Design System Web Components as an output. Renderer id for configuration in UI Agent is rhds.
Next Gen UI Agent utilises Stevedore Plugin framework which automates to a high degree how you can configure this plugin to work in your deployment.
Provides
- Rendering of Dynamic Componet html using RHDS.
- Supported:
one-card,image,video-player - Tech-Preview:
set-of-cards,table
- Supported:
video-playerusesVideo embedelement, which supports YouTube video url's only
Installation
pip install -U next_gen_ui_rhds_renderer
Usage
By installing next_gen_ui_rhds_renderer the agent automatically discovers the renderer.
To enable renderer simply configure your Next Gen UI Agent to use rhds as component system.
Extending the RHDS renderer to support hand build components
In this section we'll explain how to add support for rendering hand build components aka HBC to the RHDS server-side renderer.
The process is as simple as creating a new renderer package by following steps which are documented here with one simplification of the process. In step 5, rather than implementing your own StrategyFactory from scratch, we suggest just extending the RhdsStrategyFactory and overriding two functions that will add the HBC support. Below you can see an example code how your code could look like. The benefit of going this route is that all the standard strategies for dynamically chosen components and Jinja templates remain as they are.
As it's documented below in comment for HbcExampleRhdsStrategy you can also have your own Jinja templates on top of the existing ones.
Full code example can be found in our examples repository here.
from next_gen_ui_agent.data_transform.types import ComponentDataBase
from next_gen_ui_rhds_renderer.rhds_renderer import (
RhdsStrategyBase,
RhdsStrategyFactory,
)
class HbcExampleRhdsStrategyFactory(RhdsStrategyFactory):
"""Example extension of RhdsStrategyFactory demonstrating how to add custom hand build components handling."""
# Example hardcoded array of custom HBC (Human Build Components) supported components
CUSTOM_HBC_COMPONENTS = [
"hbc-example-component",
"DUMMY_COMPONENT_TYPE", # This is purely for shareable tests to work
]
def get_component_system_name(self) -> str:
"""Override to return custom renderer name."""
return "hbc-example-rhds"
def default_render_strategy_handler(self, component: ComponentDataBase):
"""Override to provide example of checking against custom HBC components."""
# Check if the component type matches any custom HBC components
if component.component in self.CUSTOM_HBC_COMPONENTS:
# Return a basic strategy for custom HBC components which assumes that the component name is the same as the template name.
return HbcExampleRhdsStrategy()
# If no custom HBC component matches, throw ValueError as in default implementation
raise ValueError(
f"This component: {component.component} is not supported by Red Hat Design System rendering plugin."
)
class HbcExampleRhdsStrategy(RhdsStrategyBase):
"""
Example strategy for HBC components that loads templates from the next_gen_ui_rhds_hbc_example_renderer module.
In case you need to load templates from a different folder you can override the __init__ method.
Usage:
class MyStrategy(HbcExampleRhdsStrategyBase):
def __init__(self):
super().__init__("my_templates")
"""
pass
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file next_gen_ui_rhds_renderer-0.3.0-py3-none-any.whl.
File metadata
- Download URL: next_gen_ui_rhds_renderer-0.3.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b67652bb10d9a0e18838a06a80652641a4c6a98d3c1b65d21ab77e841132460
|
|
| MD5 |
363ff1cf87395fee2dc561073cbad030
|
|
| BLAKE2b-256 |
83534a4c35780d8b439c89d0f0a66c349783137bb4160b9466d1eb4e3d4b0f98
|