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
Copy file name to clipboardExpand all lines: apps/docs/docs/main-components/blocks/customizing.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,28 @@ sidebar_position: 300
4
4
5
5
# Customizing
6
6
7
-
While each block can have some basic configuration (like choosing a UI variant via props, or providing different text labels), that might not be enough for you. For cases where you'd like to perform more deep customizations, like adding new elements,
7
+
While each block can have some basic configuration (like choosing a UI variant via props, or providing different text labels), that might not be enough for you. For cases where you'd like to perform more deep customizations, like adding new elements or modifying the layout, there is also the possibility to completely take over the ownership of the block - you can easily move its entire source code to your own project.
8
8
9
9
## Ejecting a block
10
+
11
+
To _eject_ a block from the version that is published to NPM, you can run a dedicated script:
12
+
13
+
```shell
14
+
npm run eject-block
15
+
```
16
+
17
+
which will then prompt you for to the blocks you want to take over. Once the process is done, the code of these blocks will be copied to your project into the `packages/blocks` folder, and automatically install their dependencies.
18
+
19
+
Once you restart the app, it will now use the ejected version of these blocks, instead of ones installed earlier via NPM.
20
+
10
21
## Modifying a block
22
+
23
+
Since you now control the entire source code of the block, customizing it is easy. You can make any changes you want directly in that block, just like you'd do that when you create a new block from scratch yourself.
24
+
25
+
These changes may include all parts of the block - the API Harmonization, the Frontend, and SDK areas.
26
+
11
27
## Upgrades & versioning
28
+
29
+
This comes with a slight drawback, however - after you eject a block, you can no longer easily upgrade it to a newer version that might be published to the NPM registry. These new versions may include bugfixes or new features that you also might want.
30
+
31
+
You can still achieve that, by simply running the eject script once more - it will **overwrite your own changes** to the block. However, assuming you are using any kind of code versioning, you can then pick and choose the changes you want to keep.
Copy file name to clipboardExpand all lines: apps/docs/docs/main-components/blocks/index.md
+59-1Lines changed: 59 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,67 @@ sidebar_position: 000
4
4
5
5
# Blocks
6
6
7
-
> TODO: what is a block
7
+
Blocks are designed to provide a modular and efficient approach to building feature-rich applications with minimal effort. Essentially, a block is a reusable, self-contained unit of functionality that combines harmonizing and frontend components into a single package.
8
+
9
+
At their core, blocks are standalone modules that contain everything required to add a specific feature or functionality to your app. Each block is independently packaged as an NPM module and includes three primary parts:
10
+
11
+
1.**API Harmonization Module:** Handles data aggregation, normalization, and exposes an API for that block.
12
+
2.**Frontend Components:** React-based implementations that render the block's UI, including server and client components.
13
+
3.**SDK Methods:** Simplified access to the block's API, designed for use internally within the block or externally by developers.
14
+
15
+
Each block is a self-contained unit consolidating the logic for both data fetching and rendering, allowing independent development, maintenance, and upgrades.
16
+
17
+
## Purpose of blocks
18
+
19
+
The primary purpose of blocks is to enhance **developer productivity** and **consistency** across applications by creating reusable building blocks for key functionalities. Here’s how blocks fulfill this purpose:
20
+
21
+
-**Modularity:** Each block is a fully isolated unit, allowing developers to quickly add or remove functionality without impacting other components of the application.
22
+
-**Reusability:** Blocks are designed to work independently, making it easy to reuse them across multiple projects.
23
+
-**Ease of Customization:** Blocks can be easily customized to fit the needs of a specific project while keeping the base package upgradable.
24
+
-**Scalability:** By decoupling concerns and encapsulating logic, blocks simplify scaling and adding features to applications.
25
+
26
+
## How can blocks help you
27
+
28
+
Blocks bring several advantages for developers, simplifying and accelerating the app development process:
29
+
30
+
1.**Streamlined Development**
31
+
32
+
Blocks encapsulate both frontend and backend code for a feature. You can simply install and integrate pre-built blocks to their app, avoiding the need to write these functionalities from scratch.
33
+
34
+
2.**Ease of Integration**
35
+
36
+
Blocks can be installed with a single command as NPM packages and then easily imported into both the API Harmonization server and Frontend app.
37
+
38
+
3.**Customization Support**
39
+
40
+
You can customize blocks to match your app's requirements while retaining the ability to receive updates from the base package.
41
+
42
+
4.**Consistency Across Projects**
43
+
44
+
Using block-based architecture encourages consistent code patterns and practices across teams and projects.
45
+
46
+
5.**Focus on Business Logic**
47
+
48
+
With most of the repetitive work taken care of by blocks, you can focus more on solving business-related problems instead of spending time implementing boilerplate functionality.
49
+
50
+
6.**Encourages Collaboration**
51
+
52
+
Blocks allow you to work on individual pieces of functionality without interfering with or breaking other parts of the application.
53
+
54
+
## How blocks fit into your app
55
+
56
+
Each block provides both API handling and UI and rendering logic functionalities. Once installed:
57
+
58
+
-**API Harmonization** ensures the block's necessary APIs are exposed and available in the API Harmonization server.
59
+
-**Frontend** renders the block in the application's interface, fetching any required data and managing its internal logic.
60
+
61
+
For example:
62
+
63
+
- If you add an "FAQ" block, its frontend renderer displays a list of FAQs in your app, while its backend handles fetching the content.
64
+
- You can easily extend this block to fit their design or content needs while utilizing the same robust base implementation.
8
65
9
66
## What’s inside?
67
+
10
68
-**[Structure](./structure.md)** – Learn how the blocks are structured in the monorepo.
11
69
-**[Usage](./usage.md)** – Understand how to work with blocks and how to add a new one.
12
70
-**[Customizing](./customizing.md)** – Find out how you can customize an existing block in your own project and how the upgrades work.
0 commit comments