Skip to content

Commit 748f7ea

Browse files
committed
Added more examples
1 parent 587f716 commit 748f7ea

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

docs/resources/ui/components/callbacks.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
title: Action Parameters (Callbacks)
33
sidebar_position: 4
4+
tags: [Components, Actions]
5+
keywords: [Components, Actions, Action Parameter, Callbacks]
6+
description: Learn how to add action parameters or callbacks to custom components.
47
---
58

69
# Action Parameters (Callbacks)
@@ -33,13 +36,13 @@ This makes the *image upload component* component reusable, as it doesn't need t
3336

3437
## Adding Callbacks
3538

36-
Let’s continue with our previous example (image upload component) and see how to add callbacks on it:
39+
Let’s continue with our previous example (*image upload component*) and see how to add callbacks on it:
3740

3841
### Creating a Callback Parameter
3942

4043
In order to create a component that will execute a callback, you must create a component with a parameter of **Type** **Action**. You can create an action parameter called `uploadAction`, which represents the action that will be executed after the image is uploaded.
4144

42-
When you create an action parameter, you can also specify parameters that will be passed into the action. For this example, the action that will be executed will likely need to know the uploaded image URL to process it further, such as resizing and compressing the image, updating it in the database, and refreshing the profile picture. So, you can specify an action parameter called `uploadedURL`.
45+
When you create an action parameter, you can also specify parameters that will be passed into the action. For this example, the action that will be executed will likely need to know the uploaded image URL to process it further. So, you can specify an action parameter called uploadedURL.
4346

4447
Now, the page or component that uses this button can utilize this parameter in its own action flow. An example of this is shown below.
4548

@@ -141,34 +144,30 @@ You can access the value passed to the callback by navigating to the **Set Varia
141144
</div>
142145
<p></p>
143146

144-
:::tip
145147

146-
Now that we have an image upload component with action parameters, it can be reused across different pages or contexts, as it relies on the parent to define the post-upload logic. For example, the same component can be used to upload an image while posting reviews for a product, eliminating the need to create a separate component for this functionality.
148+
Now that we have an *image upload component* with action parameters set up, it can be reused across different pages or contexts, as it relies on the parent to define the post-upload logic. For example, the same component can be used to upload an image while posting reviews for a product, eliminating the need to create a separate component for this functionality.
147149

148150
![component-action-parameters.avif](imgs/component-action-parameters.avif)
149151

150-
:::
151152

152153
## More Examples
153154

154-
Let's see some more examples of adding action parameters (callbacks) to component to solidify understanding and use it in real-world scenarios.
155+
Let's see some more examples of adding action parameters (callbacks) to deepen the understanding and use it in real-world scenarios.
155156

156-
### Example 1: Dynamic Dialog Components
157+
### Example 1: Dynamic Dialog Component
157158

158159
Let’s take another example of a reusable dialog component that uses callbacks to handle context-specific actions like confirming a deletion, logging out, or saving data. In one context, "Yes" deletes an item. In another, it logs out a user.
159160

160-
Here the dialog component can execute different actions based on the context in which it's used. The specific logic for each action is defined by the parent component or page using the dialog. The dialog itself does not need to know the specifics of what should happen—it simply executes the callback passed to it.
161-
162-
[image]
161+
The specific logic for each action is defined by the parent component or page using the dialog. The dialog itself does not need to know of what should happen—it simply executes the callback passed to it when users click on the "Yes" button.
163162

164-
[how to]
163+
![dialog-component-action-parameters.avif](imgs/dialog-component-action-parameters.avif)
165164

166-
### Example 2: Custom Navigation Bar
165+
### Example 2: Custom Navigation Bar in Super App
167166

168-
[info]
167+
Using Action Parameters to build a Custom Navigation Bar in a Super App is an excellent way to create a dynamic, reusable, and modular navigation solution. A **Super App** typically hosts multiple mini-apps or features, each requiring specific navigation logic. Action Parameters allows you to define navigation behavior dynamically, depending on the active context, making it perfect for this scenario.
169168

170-
[image]
169+
Here, the navigation bar doesn’t require hardcoded routes. Instead, the navigation logic can be customized for each mini-app, allowing the navigation bar to remain focused solely on its UI role.
171170

172-
[how to]
171+
For example, in an **ecommerce mini-app**, the home button navigates to the product listing page, while the main (middle) button opens the shopping cart. In contrast, in a **cab booking mini-app**, the home button navigates to the dashboard, and the main (middle) button opens the quick booking page.
173172

174-
## Best practices
173+
![navigation-bar-action-parameters.avif](imgs/navigation-bar-action-parameters.avif)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)