You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -6,16 +6,18 @@ MultiversX Front-End Library for JavaScript and TypeScript (written in TypeScrip
6
6
7
7
`sdk-dapp-ui` is a library that holds components to display user information from the MultiversX blockchain.
8
8
9
-
Since the library is built using [Stencil](https://stenciljs.com/), it can be used in any front-end framework, such as React, Angular, or Vue, but also in back-end frameworks like Next.js.
9
+
Since the library is built using [Stencil](https://stenciljs.com/), it can be used in any front-end framework, such as [React](https://github.com/multiversx/mx-template-dapp), Angular, or [Solid.js](https://github.com/multiversx/mx-solidjs-template-dapp), but also in back-end frameworks like [Next.js](https://github.com/multiversx/mx-template-dapp-nextjs).
10
10
11
11
## GitHub project
12
+
12
13
The GitHub repository can be found here: [https://github.com/multiversx/mx-sdk-dapp-ui](https://github.com/multiversx/mx-sdk-dapp-ui)
13
14
14
15
## Live demo: template-dapp
15
-
See [Template dApp](https://template-dapp.multiversx.com/) for live demo or checkout usage in the [Github repo](https://github.com/multiversx/mx-template-dapp)
16
16
17
+
See [Template dApp](https://template-dapp.multiversx.com/) for live demo or checkout usage in the [Github repo](https://github.com/multiversx/mx-template-dapp)
`sdk-dapp-ui` library is primarily designed to work with [@multiversx/sdk-dapp](https://www.npmjs.com/package/@multiversx/sdk-dapp), since components are designed to display data and emit user events, but do not hold any business logic.
43
45
44
-
The library is divided into three main categories:
45
-
There are three types of components in the library:
46
-
1. The ones that only display data (visual)
47
-
2. The ones that display data provided by a controller (controlled)
48
-
3. The ones that are designed for user interaction (functional).
49
-
50
-
Below we will detail these categories:
51
-
52
-
### 1. Visual components
46
+
The basic usage of the components would be importing the component and its corresponding interface and creating a wrapper for it in your application.
53
47
54
-
The basic usage of the component would be importing the component and its corresponding interface and creating a wrapper for it in your application.
48
+
It outputs both web components (working out of the box) and React components (you need to create a wrapper for them).
55
49
56
-
React example where the component does not need any processed data:
The library is divided into three main categories of components:
68
63
69
-
Controlled components are designed to display data that is processed by a controller. The controller is responsible for processing the data and providing it to the component.
64
+
1. The ones that only display data (visual)
65
+
2. The ones that display data provided by a controller (controlled)
66
+
3. The ones that are designed for user interaction (functional)
Visual components are the most basic building blocks that handle pure presentation. They are controlled through props and don't contain any business logic. These components focus on consistent styling and user interface elements.
77
71
78
-
Vanilla example where the component makes use of a controller from `sdk-dapp`:
Controlled components are designed to display data that is processed by a controller. They receive formatted data through props and focus on consistent data presentation. These components are typically used in data-heavy sections of the application.
112
116
113
-
Functional components in the `sdk-dapp-ui` library are designed to create interactive UIs and handle user events effectively. Typically, these components are embedded in login or signing transactions flows. They typically leverage the functionality provided by the `@multiversx/sdk-dapp` library to manage state and actions.
117
+
Components:
114
118
115
-
The way functional components are controlled are trough a [pub-sub pattern](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern) called EventBus. Each webcomponent has a method of exposing its EventBus, thus allowing sdk-dapp to get a reference to it and use it for communication.
119
+
-**Format Amount** (`mvx-format-amount`): Numerical amount formatting with validation
120
+
-**Transactions Table** (`mvx-transactions-table`): Structured display of transaction data
If you need to have a custom implementation of a functional component, you have to follow some simple steps:
146
+
### 3. Functional Components
147
+
148
+
Functional components handle specific application functionality and business logic. They integrate with the application's event system and manage user interactions. These components are typically used in complex workflows like authentication and transaction signing.
131
149
132
-
- design a UI component that has a method called `getEventBus`, implementing the `IEventBus` interface found in `src/utils/EventBus.ts`
133
-
- make sure to implement the same interfaces as the original component. For example, if overriding the `ledger-connect-modal`, you can find the interfaces in `src/components/ledger-connect-modal/ledger-connect-modal.types.ts`
You can check out the way these components are used in `@multiversx/sdk-dapp`[here](https://github.com/multiversx/mx-sdk-dapp/blob/main/src/managers/UnlockPanelManager/UnlockPanelManager.ts).
134
160
135
161
## Debugging your dApp
136
162
@@ -159,3 +185,14 @@ To run the unit tests, run:
159
185
npm test
160
186
```
161
187
188
+
To run a specific test file in Stencil, run:
189
+
190
+
```bash
191
+
npx stencil test src/components/visual/transaction-list-item/tests/transaction-list-item.spec.tsx --spec
192
+
```
193
+
194
+
To run an individual test from a specific test file in Stencil, run:
195
+
196
+
```bash
197
+
npx stencil test src/components/visual/transaction-list-item/tests/transaction-list-item.spec.tsx --spec -t 'renders with asset icon'
0 commit comments