UX Framework - Extending Existing Components
Authors:
Ben Harrison, Esma Tuzovic
Changed on:
22 July 2024
Overview
This article provides an overview of methods for configuring components within the UX framework. Customization is possible through configuring the various types of components, such as sub-components, wrapper components, and context components. Read on to find out how to use the above approaches.Key points
- Core components are highly extensible through configuration; check if your requirements can be met by updating the manifest or component properties (props in the configuration).
`DynamicAttribute`values in core components allow for the creation of small, specialized sub-components that enhance functionality.- Wrapper components can be used to modify existing components' props or styles, enabling more complex customizations beyond basic configurations.
- Context components can override default data handling by performing additional queries, but be cautious as this can impact performance.
1. Configure
The first thing to check is whether the requirement is supported by configuration.Core components are designed for extensibility, and many different use cases can be supported by simply updating the manifest (refer to 'How to Override the default manifest' for additional details regarding manifest updates) or, in certain instances, the component's settings. Various components utilize template strings to accept numerous string values. This functionality enables you to employ a Mustache syntax for generating dynamic values, thereby facilitating the mapping and transformation of data sourced from GraphQL or other origins directly into the UI. You can identify the Mustache template by the use of double quotes surrounding it.You can retrieve some mustache template samples in UX Configuration Common Concepts, within the Template Strings paragraph.For further information on the Mustache template, you can refer to the following article: See also Escaping/unescaping of values in UX Framework.
2. Sub-components
Some components accept`DynamicAttribute` values in their column or row configuration.These create opportunities for developers to build small utility components that can co-exist with core library components. Here are a couple of usage examples:Scenario 1: Collapsible Attributes Component. Refer to the provided code sample below.Scenario 2: Using an attribute to embed the print button component into a table column. Refer to the provided code sample below.3. Wrapper Component
There are cases where we might want to use an existing component but adjust its functionality to a certain degree. For those familiar with React, this is akin to higher-order components. These modifications could include modifying component props, or applying different styles to a standard component. This is particularly useful when building or extending field components, as those are not typically configurable in the manifest, but a wrapper component can be used to load a configuration from a setting and pass that into the underlying library component.Here's a code sample for the wrapper component concept (utilized for`PageDateFilter`):