@blocklet/ui-react 3.4.15 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/lib/common/org-switch/use-org.d.ts +4 -4
  2. package/package.json +9 -6
  3. package/.aigne/doc-smith/.local/afs-storage.sqlite3 +0 -0
  4. package/.aigne/doc-smith/config.yaml +0 -78
  5. package/.aigne/doc-smith/history.yaml +0 -14
  6. package/.aigne/doc-smith/media-description.yaml +0 -11
  7. package/.aigne/doc-smith/output/structure-plan.json +0 -255
  8. package/.aigne/doc-smith/translation-cache.yaml +0 -11
  9. package/.aigne/doc-smith/upload-cache.yaml +0 -528
  10. package/build.config.ts +0 -24
  11. package/docs/_sidebar.md +0 -19
  12. package/docs/assets/diagram/component-installer-diagram-0.ja.jpg +0 -0
  13. package/docs/assets/diagram/component-installer-diagram-0.jpg +0 -0
  14. package/docs/assets/diagram/component-installer-diagram-0.zh-TW.jpg +0 -0
  15. package/docs/assets/diagram/component-installer-diagram-0.zh.jpg +0 -0
  16. package/docs/assets/diagram/component-management-diagram-0.ja.jpg +0 -0
  17. package/docs/assets/diagram/component-management-diagram-0.jpg +0 -0
  18. package/docs/assets/diagram/component-management-diagram-0.zh-TW.jpg +0 -0
  19. package/docs/assets/diagram/component-management-diagram-0.zh.jpg +0 -0
  20. package/docs/assets/diagram/core-concepts-diagram-0.ja.jpg +0 -0
  21. package/docs/assets/diagram/core-concepts-diagram-0.jpg +0 -0
  22. package/docs/assets/diagram/core-concepts-diagram-0.zh-TW.jpg +0 -0
  23. package/docs/assets/diagram/core-concepts-diagram-0.zh.jpg +0 -0
  24. package/docs/assets/diagram/dashboard-diagram-0.ja.jpg +0 -0
  25. package/docs/assets/diagram/dashboard-diagram-0.jpg +0 -0
  26. package/docs/assets/diagram/dashboard-diagram-0.zh-TW.jpg +0 -0
  27. package/docs/assets/diagram/dashboard-diagram-0.zh.jpg +0 -0
  28. package/docs/assets/diagram/header-diagram-0.ja.jpg +0 -0
  29. package/docs/assets/diagram/header-diagram-0.jpg +0 -0
  30. package/docs/assets/diagram/header-diagram-0.zh-TW.jpg +0 -0
  31. package/docs/assets/diagram/header-diagram-0.zh.jpg +0 -0
  32. package/docs/assets/diagram/layout-diagram-0.ja.jpg +0 -0
  33. package/docs/assets/diagram/layout-diagram-0.jpg +0 -0
  34. package/docs/assets/diagram/layout-diagram-0.zh-TW.jpg +0 -0
  35. package/docs/assets/diagram/layout-diagram-0.zh.jpg +0 -0
  36. package/docs/assets/diagram/notifications-diagram-0.ja.jpg +0 -0
  37. package/docs/assets/diagram/notifications-diagram-0.jpg +0 -0
  38. package/docs/assets/diagram/notifications-diagram-0.zh-TW.jpg +0 -0
  39. package/docs/assets/diagram/notifications-diagram-0.zh.jpg +0 -0
  40. package/docs/assets/diagram/overview-diagram-0.ja.jpg +0 -0
  41. package/docs/assets/diagram/overview-diagram-0.jpg +0 -0
  42. package/docs/assets/diagram/overview-diagram-0.zh-TW.jpg +0 -0
  43. package/docs/assets/diagram/overview-diagram-0.zh.jpg +0 -0
  44. package/docs/assets/diagram/user-center-diagram-0.ja.jpg +0 -0
  45. package/docs/assets/diagram/user-center-diagram-0.jpg +0 -0
  46. package/docs/assets/diagram/user-center-diagram-0.zh-TW.jpg +0 -0
  47. package/docs/assets/diagram/user-center-diagram-0.zh.jpg +0 -0
  48. package/docs/assets/diagram/user-management-diagram-0.ja.jpg +0 -0
  49. package/docs/assets/diagram/user-management-diagram-0.jpg +0 -0
  50. package/docs/assets/diagram/user-management-diagram-0.zh-TW.jpg +0 -0
  51. package/docs/assets/diagram/user-management-diagram-0.zh.jpg +0 -0
  52. package/docs/assets/diagram/user-sessions-diagram-0.ja.jpg +0 -0
  53. package/docs/assets/diagram/user-sessions-diagram-0.jpg +0 -0
  54. package/docs/assets/diagram/user-sessions-diagram-0.zh-TW.jpg +0 -0
  55. package/docs/assets/diagram/user-sessions-diagram-0.zh.jpg +0 -0
  56. package/docs/components-component-management-blocklet-studio.ja.md +0 -194
  57. package/docs/components-component-management-blocklet-studio.md +0 -194
  58. package/docs/components-component-management-blocklet-studio.zh-TW.md +0 -194
  59. package/docs/components-component-management-blocklet-studio.zh.md +0 -194
  60. package/docs/components-component-management-component-installer.ja.md +0 -182
  61. package/docs/components-component-management-component-installer.md +0 -182
  62. package/docs/components-component-management-component-installer.zh-TW.md +0 -182
  63. package/docs/components-component-management-component-installer.zh.md +0 -182
  64. package/docs/components-component-management.ja.md +0 -30
  65. package/docs/components-component-management.md +0 -30
  66. package/docs/components-component-management.zh-TW.md +0 -30
  67. package/docs/components-component-management.zh.md +0 -30
  68. package/docs/components-layout-dashboard.ja.md +0 -185
  69. package/docs/components-layout-dashboard.md +0 -187
  70. package/docs/components-layout-dashboard.zh-TW.md +0 -185
  71. package/docs/components-layout-dashboard.zh.md +0 -185
  72. package/docs/components-layout-footer.ja.md +0 -165
  73. package/docs/components-layout-footer.md +0 -165
  74. package/docs/components-layout-footer.zh-TW.md +0 -165
  75. package/docs/components-layout-footer.zh.md +0 -165
  76. package/docs/components-layout-header.ja.md +0 -183
  77. package/docs/components-layout-header.md +0 -183
  78. package/docs/components-layout-header.zh-TW.md +0 -183
  79. package/docs/components-layout-header.zh.md +0 -183
  80. package/docs/components-layout.ja.md +0 -31
  81. package/docs/components-layout.md +0 -31
  82. package/docs/components-layout.zh-TW.md +0 -31
  83. package/docs/components-layout.zh.md +0 -31
  84. package/docs/components-notifications.ja.md +0 -125
  85. package/docs/components-notifications.md +0 -125
  86. package/docs/components-notifications.zh-TW.md +0 -125
  87. package/docs/components-notifications.zh.md +0 -125
  88. package/docs/components-user-management-user-center.ja.md +0 -148
  89. package/docs/components-user-management-user-center.md +0 -147
  90. package/docs/components-user-management-user-center.zh-TW.md +0 -148
  91. package/docs/components-user-management-user-center.zh.md +0 -148
  92. package/docs/components-user-management-user-sessions.ja.md +0 -121
  93. package/docs/components-user-management-user-sessions.md +0 -123
  94. package/docs/components-user-management-user-sessions.zh-TW.md +0 -121
  95. package/docs/components-user-management-user-sessions.zh.md +0 -121
  96. package/docs/components-user-management.ja.md +0 -49
  97. package/docs/components-user-management.md +0 -51
  98. package/docs/components-user-management.zh-TW.md +0 -49
  99. package/docs/components-user-management.zh.md +0 -49
  100. package/docs/components-utilities-icon.ja.md +0 -106
  101. package/docs/components-utilities-icon.md +0 -106
  102. package/docs/components-utilities-icon.zh-TW.md +0 -106
  103. package/docs/components-utilities-icon.zh.md +0 -106
  104. package/docs/components-utilities.ja.md +0 -136
  105. package/docs/components-utilities.md +0 -136
  106. package/docs/components-utilities.zh-TW.md +0 -136
  107. package/docs/components-utilities.zh.md +0 -136
  108. package/docs/components.ja.md +0 -27
  109. package/docs/components.md +0 -27
  110. package/docs/components.zh-TW.md +0 -27
  111. package/docs/components.zh.md +0 -27
  112. package/docs/core-concepts.ja.md +0 -134
  113. package/docs/core-concepts.md +0 -135
  114. package/docs/core-concepts.zh-TW.md +0 -134
  115. package/docs/core-concepts.zh.md +0 -134
  116. package/docs/getting-started.ja.md +0 -132
  117. package/docs/getting-started.md +0 -132
  118. package/docs/getting-started.zh-TW.md +0 -132
  119. package/docs/getting-started.zh.md +0 -132
  120. package/docs/hooks-api.ja.md +0 -214
  121. package/docs/hooks-api.md +0 -214
  122. package/docs/hooks-api.zh-TW.md +0 -214
  123. package/docs/hooks-api.zh.md +0 -214
  124. package/docs/how-to-guides.ja.md +0 -413
  125. package/docs/how-to-guides.md +0 -413
  126. package/docs/how-to-guides.zh-TW.md +0 -413
  127. package/docs/how-to-guides.zh.md +0 -413
  128. package/docs/overview.ja.md +0 -51
  129. package/docs/overview.md +0 -51
  130. package/docs/overview.zh-TW.md +0 -51
  131. package/docs/overview.zh.md +0 -51
  132. package/glossary.md +0 -12
  133. package/src/@types/index.ts +0 -230
  134. package/src/@types/shims.d.ts +0 -18
  135. package/src/BlockletStudio/README.md +0 -116
  136. package/src/BlockletStudio/index.tsx +0 -145
  137. package/src/ComponentInstaller/ComponentInstaller.stories.jsx +0 -16
  138. package/src/ComponentInstaller/index.jsx +0 -207
  139. package/src/ComponentInstaller/installer-item.jsx +0 -129
  140. package/src/ComponentInstaller/locales.js +0 -22
  141. package/src/ComponentInstaller/use-component-installed.js +0 -88
  142. package/src/ComponentManager/components/add-component.tsx +0 -136
  143. package/src/ComponentManager/components/check-component.tsx +0 -3
  144. package/src/ComponentManager/components/publish-component.tsx +0 -90
  145. package/src/ComponentManager/components/resource-dialog.tsx +0 -91
  146. package/src/ComponentManager/index.tsx +0 -3
  147. package/src/ComponentManager/libs/locales.ts +0 -15
  148. package/src/Dashboard/Dashboard.stories.jsx +0 -20
  149. package/src/Dashboard/app-shell/app-badge.stories.tsx +0 -64
  150. package/src/Dashboard/app-shell/app-badge.tsx +0 -94
  151. package/src/Dashboard/app-shell/app-header.tsx +0 -104
  152. package/src/Dashboard/app-shell/app-info-context.tsx +0 -182
  153. package/src/Dashboard/app-shell/badges/app-badge-default.tsx +0 -130
  154. package/src/Dashboard/app-shell/badges/app-badge-did.tsx +0 -28
  155. package/src/Dashboard/app-shell/badges/app-badge-state.tsx +0 -40
  156. package/src/Dashboard/app-shell/badges/app-badge-switch.tsx +0 -72
  157. package/src/Dashboard/app-shell/badges/app-badge-version.tsx +0 -60
  158. package/src/Dashboard/app-shell/index.ts +0 -5
  159. package/src/Dashboard/index.jsx +0 -184
  160. package/src/Footer/Footer.stories.jsx +0 -33
  161. package/src/Footer/brand.jsx +0 -81
  162. package/src/Footer/copyright.jsx +0 -22
  163. package/src/Footer/index.jsx +0 -111
  164. package/src/Footer/internal-footer.jsx +0 -139
  165. package/src/Footer/layout/plain.jsx +0 -55
  166. package/src/Footer/layout/row.jsx +0 -43
  167. package/src/Footer/layout/standard.jsx +0 -114
  168. package/src/Footer/links.jsx +0 -321
  169. package/src/Footer/social-media.jsx +0 -55
  170. package/src/Header/Header.stories.jsx +0 -30
  171. package/src/Header/index.tsx +0 -259
  172. package/src/Icon/Icon.stories.jsx +0 -12
  173. package/src/Icon/index.tsx +0 -87
  174. package/src/Notifications/Snackbar.tsx +0 -261
  175. package/src/Notifications/hooks/use-title.tsx +0 -254
  176. package/src/Notifications/hooks/use-width.tsx +0 -16
  177. package/src/Notifications/utils.ts +0 -246
  178. package/src/UserCenter/assets/banner.png +0 -0
  179. package/src/UserCenter/components/config-inviter.tsx +0 -48
  180. package/src/UserCenter/components/config-profile.tsx +0 -99
  181. package/src/UserCenter/components/danger-zone.tsx +0 -82
  182. package/src/UserCenter/components/editable-field.tsx +0 -273
  183. package/src/UserCenter/components/fallback.tsx +0 -57
  184. package/src/UserCenter/components/nft-preview.tsx +0 -84
  185. package/src/UserCenter/components/nft.tsx +0 -279
  186. package/src/UserCenter/components/notification.tsx +0 -319
  187. package/src/UserCenter/components/passport.tsx +0 -107
  188. package/src/UserCenter/components/privacy.tsx +0 -120
  189. package/src/UserCenter/components/settings.tsx +0 -170
  190. package/src/UserCenter/components/status-dialog/date-picker.tsx +0 -77
  191. package/src/UserCenter/components/status-dialog/index.tsx +0 -293
  192. package/src/UserCenter/components/status-selector/duration-menu.tsx +0 -90
  193. package/src/UserCenter/components/status-selector/index.tsx +0 -58
  194. package/src/UserCenter/components/status-selector/menu-item.tsx +0 -56
  195. package/src/UserCenter/components/storage/action.tsx +0 -49
  196. package/src/UserCenter/components/storage/connected.tsx +0 -61
  197. package/src/UserCenter/components/storage/delete.tsx +0 -72
  198. package/src/UserCenter/components/storage/disconnect.tsx +0 -40
  199. package/src/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -1
  200. package/src/UserCenter/components/storage/icons/long-arrow.svg +0 -5
  201. package/src/UserCenter/components/storage/icons/space-connected.svg +0 -3
  202. package/src/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
  203. package/src/UserCenter/components/storage/index.tsx +0 -41
  204. package/src/UserCenter/components/storage/preview-nft.tsx +0 -72
  205. package/src/UserCenter/components/third-party-login/index.tsx +0 -199
  206. package/src/UserCenter/components/third-party-login/third-party-item.tsx +0 -296
  207. package/src/UserCenter/components/user-center.tsx +0 -787
  208. package/src/UserCenter/components/user-info/address.tsx +0 -143
  209. package/src/UserCenter/components/user-info/index.tsx +0 -4
  210. package/src/UserCenter/components/user-info/link-preview-input.tsx +0 -274
  211. package/src/UserCenter/components/user-info/metadata.tsx +0 -658
  212. package/src/UserCenter/components/user-info/social-actions/chat.tsx +0 -43
  213. package/src/UserCenter/components/user-info/social-actions/follow.tsx +0 -23
  214. package/src/UserCenter/components/user-info/social-actions/index.tsx +0 -17
  215. package/src/UserCenter/components/user-info/switch-role.tsx +0 -42
  216. package/src/UserCenter/components/user-info/timezone-select.tsx +0 -119
  217. package/src/UserCenter/components/user-info/user-basic-info.tsx +0 -292
  218. package/src/UserCenter/components/user-info/user-info-item.tsx +0 -54
  219. package/src/UserCenter/components/user-info/user-info.tsx +0 -91
  220. package/src/UserCenter/components/user-info/user-status.tsx +0 -234
  221. package/src/UserCenter/components/user-info/utils.ts +0 -320
  222. package/src/UserCenter/components/webhook-item.tsx +0 -248
  223. package/src/UserCenter/index.tsx +0 -1
  224. package/src/UserCenter/libs/locales.ts +0 -378
  225. package/src/UserCenter/libs/utils.ts +0 -30
  226. package/src/UserSessions/components/user-session-info.tsx +0 -78
  227. package/src/UserSessions/components/user-sessions.tsx +0 -545
  228. package/src/UserSessions/index.tsx +0 -1
  229. package/src/UserSessions/libs/locales.ts +0 -60
  230. package/src/UserSessions/libs/utils.ts +0 -82
  231. package/src/blocklets.js +0 -195
  232. package/src/common/domain-warning.jsx +0 -178
  233. package/src/common/header-addons.jsx +0 -119
  234. package/src/common/link-blocker.jsx +0 -20
  235. package/src/common/notification-addon.jsx +0 -135
  236. package/src/common/org-switch/avatar-uploader.jsx +0 -271
  237. package/src/common/org-switch/create.jsx +0 -267
  238. package/src/common/org-switch/index.jsx +0 -407
  239. package/src/common/org-switch/locales.js +0 -52
  240. package/src/common/org-switch/use-org.jsx +0 -79
  241. package/src/common/overridable-theme-provider.jsx +0 -17
  242. package/src/common/wallet-hidden-topbar.js +0 -14
  243. package/src/common/wizard-modal.jsx +0 -200
  244. package/src/common/ws.js +0 -68
  245. package/src/contexts/config-user-space.tsx +0 -88
  246. package/src/contexts/user-followers.tsx +0 -54
  247. package/src/hooks/use-follow.tsx +0 -75
  248. package/src/hooks/use-mobile.tsx +0 -6
  249. package/src/index.ts +0 -16
  250. package/src/libs/constant.ts +0 -1
  251. package/src/libs/spaces.tsx +0 -18
  252. package/src/libs/with-hide-when-embed.tsx +0 -24
  253. package/src/types.js +0 -45
  254. package/src/utils.js +0 -161
  255. package/vite.config.mjs +0 -34
@@ -1,135 +0,0 @@
1
- # Core Concepts
2
-
3
- This document explains the fundamental principles of the Blocklet UI React library. The core design philosophy is a **metadata-driven approach**, where UI components such as the `Header`, `Footer`, and `Dashboard` are automatically configured and rendered based on the blocklet's metadata. This strategy ensures consistency, reduces boilerplate code, and enables dynamic UIs that adapt to user roles and language preferences.
4
-
5
- The central idea is that a single configuration file, typically `blocklet.yml`, serves as the single source of truth for the application's overall structure and appearance. The library reads this metadata, processes it, and uses it to construct the appropriate UI elements.
6
-
7
- ## The Metadata-Driven Principle
8
-
9
- The library's operation can be visualized as a simple data flow: the blocklet metadata is provided as input to the library, which then processes it through a pipeline to produce fully rendered UI components. This eliminates the need for developers to manually build and configure common layout elements for each application.
10
-
11
- The following diagram illustrates this data flow:
12
- <!-- DIAGRAM_IMAGE_START:flowchart:16:9:1765962229 -->
13
- ![Core Concepts](assets/diagram/core-concepts-diagram-0.jpg)
14
- <!-- DIAGRAM_IMAGE_END -->
15
-
16
- This automated process relies on a well-defined metadata structure, which is detailed in the following section.
17
-
18
- ## Anatomy of Blocklet Metadata
19
-
20
- The library expects a specific object structure, referred to as `BlockletMetaProps`, which contains all the necessary information for rendering the UI. Below is a detailed breakdown of this structure.
21
-
22
- <x-field-group>
23
- <x-field data-name="appName" data-type="string" data-required="false" data-desc="The name of the application, typically displayed in the Header."></x-field>
24
- <x-field data-name="appLogo" data-type="React.ReactNode" data-required="false" data-desc="A React node for the application's logo, also displayed in the Header."></x-field>
25
- <x-field data-name="enableConnect" data-type="boolean" data-required="false" data-desc="Determines whether to display a DID Connect button."></x-field>
26
- <x-field data-name="enableLocale" data-type="boolean" data-required="false" data-desc="Determines whether to display the language selection component."></x-field>
27
- <x-field data-name="theme" data-type="object" data-required="false">
28
- <x-field-desc markdown>Defines the color scheme for the application layout.</x-field-desc>
29
- <x-field data-name="background" data-type="string" data-required="false" data-desc="Sets the background color for layout components like the Header and Footer."></x-field>
30
- </x-field>
31
- <x-field data-name="navigation" data-type="array" data-required="false">
32
- <x-field-desc markdown>An array of navigation item objects that define the links and menus throughout the application.</x-field-desc>
33
- <x-field data-name="title" data-type="string | object" data-required="true" data-desc="The display text for the navigation item. Can be an object for i18n."></x-field>
34
- <x-field data-name="link" data-type="string | object" data-required="false" data-desc="The URL for the navigation item. Can be an object for i18n."></x-field>
35
- <x-field data-name="icon" data-type="string" data-required="false" data-desc="An Iconify-compatible string for an icon to display next to the title."></x-field>
36
- <x-field data-name="section" data-type="string | array" data-required="false" data-desc="Specifies where the item should appear, e.g., 'header', 'footer', 'dashboard'."></x-field>
37
- <x-field data-name="role" data-type="string | array" data-required="false" data-desc="Defines which user roles can see this item, e.g., 'admin', 'guest'."></x-field>
38
- <x-field data-name="items" data-type="array" data-required="false" data-desc="An array of nested navigation items to create dropdown menus or sub-menus."></x-field>
39
- </x-field>
40
- </x-field-group>
41
-
42
- ### Navigation Configuration Example
43
-
44
- The `navigation` array is the most critical part of the metadata. It provides a structured way to define all links, menus, and their placement.
45
-
46
- ```yaml Navigation Configuration in blocklet.yml icon=mdi:code-braces
47
- # blocklet.yml
48
- navigation:
49
- - title: Features
50
- link: /features
51
- - title:
52
- en: About Us
53
- zh: 关于我们
54
- link:
55
- en: /about
56
- zh: /about-us
57
- section: footer
58
- - title: Admin Dashboard
59
- link: /admin
60
- section: dashboard
61
- role: admin
62
- - title: Social
63
- section: social
64
- items:
65
- - title: Twitter
66
- link: https://twitter.com/arcblock
67
- icon: mdi:twitter
68
- - title: GitHub
69
- link: https://github.com/arcblock
70
- icon: mdi:github
71
- ```
72
-
73
- This example illustrates several key features:
74
- - A simple header link ("Features").
75
- - A multi-language footer link ("About Us").
76
- - An admin-only link for the dashboard.
77
- - A group of social media links intended for the footer.
78
-
79
- ## The Data Processing Pipeline
80
-
81
- Before rendering, the library processes the raw metadata through a series of steps to prepare it for the UI components.
82
-
83
- ### 1. Parsing and Sectioning
84
-
85
- The first step is to parse the `navigation` array and group items based on their `section` property. A single navigation item can be assigned to multiple sections by using an array for the `section` value.
86
-
87
- The `parseNavigation` utility categorizes each item into predefined sections:
88
- - `header`: For the main application header.
89
- - `footer`: For primary links in the footer.
90
- - `social`: For social media icons, typically in the footer.
91
- - `bottom`: For legal or secondary links at the very bottom of the footer.
92
- - `dashboard`: For the sidebar navigation in a dashboard layout.
93
- - `sessionManager`: For menus within the user session component.
94
- - `userCenter`: For tabs or links within the user profile area.
95
-
96
- If an item has no `section` property, it defaults to `header`.
97
-
98
- ### 2. Internationalization (i18n)
99
-
100
- The library provides built-in support for multiple languages. If a `title` or `link` property in a navigation item is an object with language keys (e.g., `en`, `zh`), the `getLocalizedNavigation` function automatically selects the correct string based on the user's current locale.
101
-
102
- ```javascript i18n Object Example icon=logos:javascript
103
- // A navigation item with multi-language support
104
- {
105
- title: {
106
- en: 'Home',
107
- zh: '首页'
108
- },
109
- link: {
110
- en: '/home',
111
- zh: '/zh/home'
112
- }
113
- }
114
- ```
115
-
116
- ### 3. Role-Based Filtering
117
-
118
- To create a dynamic user experience, navigation items can be restricted to specific user roles. The `filterNavByRole` function filters the navigation list by comparing the `role` property of each item against the `user.role` from the current session.
119
-
120
- - If an item has no `role` property, it is visible to everyone.
121
- - If an item has a `role` property (e.g., `['admin', 'editor']`), it is only visible to users whose role is in that array.
122
- - The `guest` role is a special value that applies to unauthenticated users.
123
-
124
- This mechanism allows you to define a comprehensive navigation structure in your metadata and have the UI automatically adapt based on the logged-in user's permissions.
125
-
126
- ## Summary
127
-
128
- The core concept of the Blocklet UI React library is to leverage a centralized metadata object to drive the configuration and rendering of common UI components. This metadata-driven approach offers several advantages:
129
-
130
- - **Single Source of Truth**: Application structure, branding, and navigation are defined in one place.
131
- - **Consistency**: Ensures a consistent look and feel across different parts of the application.
132
- - **Reduced Boilerplate**: Eliminates the need to manually code common layout elements like headers and footers.
133
- - **Dynamic UI**: Natively supports internationalization and role-based access control, allowing the UI to adapt dynamically to the user and their permissions.
134
-
135
- With a clear understanding of these principles, you can effectively utilize the library's components. For more information on specific components and their usage, please refer to the [Components](./components.md) section.
@@ -1,134 +0,0 @@
1
- # 核心概念
2
-
3
- 本文件說明 Blocklet UI React 函式庫的基本原則。其核心設計理念是**元數據驅動方法**,其中 UI 元件(如 `Header`、`Footer` 和 `Dashboard`)會根據 blocklet 的元數據自動設定和渲染。此策略確保了一致性,減少了樣板程式碼,並實現了能根據使用者角色和語言偏好進行調整的動態 UI。
4
-
5
- 其中心思想是,單一設定檔(通常是 `blocklet.yml`)作為應用程式整體結構和外觀的唯一事實來源。函式庫會讀取此元數據,對其進行處理,並用它來建構適當的 UI 元素。
6
-
7
- ## 元數據驅動原則
8
-
9
- 該函式庫的運作可以視覺化為一個簡單的資料流:blocklet 元數據作為輸入提供給函式庫,函式庫接著透過一個管線對其進行處理,以產生完全渲染的 UI 元件。這免去了開發人員為每個應用程式手動建構和設定通用佈局元素的需要。
10
-
11
- <!-- DIAGRAM_IMAGE_START:flowchart:16:9:1765962229 -->
12
- ![Core Concepts](assets/diagram/core-concepts-diagram-0.zh-TW.jpg)
13
- <!-- DIAGRAM_IMAGE_END -->
14
-
15
- 這個自動化過程依賴於一個定義良好的元數據結構,下一節將對此進行詳細說明。
16
-
17
- ## Blocklet 元數據剖析
18
-
19
- 該函式庫期望一個特定的物件結構,稱為 `BlockletMetaProps`,其中包含渲染 UI 所需的所有資訊。以下是此結構的詳細分解。
20
-
21
- <x-field-group>
22
- <x-field data-name="appName" data-type="string" data-required="false" data-desc="應用程式的名稱,通常顯示在 Header 中。"></x-field>
23
- <x-field data-name="appLogo" data-type="React.ReactNode" data-required="false" data-desc="應用程式標誌的 React 節點,也顯示在 Header 中。"></x-field>
24
- <x-field data-name="enableConnect" data-type="boolean" data-required="false" data-desc="決定是否顯示 DID Connect 按鈕。"></x-field>
25
- <x-field data-name="enableLocale" data-type="boolean" data-required="false" data-desc="決定是否顯示語言選擇元件。"></x-field>
26
- <x-field data-name="theme" data-type="object" data-required="false">
27
- <x-field-desc markdown>定義應用程式佈局的配色方案。</x-field-desc>
28
- <x-field data-name="background" data-type="string" data-required="false" data-desc="設定 Header 和 Footer 等佈局元件的背景顏色。"></x-field>
29
- </x-field>
30
- <x-field data-name="navigation" data-type="array" data-required="false">
31
- <x-field-desc markdown>一個導覽項目物件的陣列,定義了整個應用程式中的連結和選單。</x-field-desc>
32
- <x-field data-name="title" data-type="string | object" data-required="true" data-desc="導覽項目的顯示文字。可以是物件以支援 i18n。"></x-field>
33
- <x-field data-name="link" data-type="string | object" data-required="false" data-desc="導覽項目的 URL。可以是物件以支援 i18n。"></x-field>
34
- <x-field data-name="icon" data-type="string" data-required="false" data-desc="一個與 Iconify 相容的字串,用於在標題旁顯示圖示。"></x-field>
35
- <x-field data-name="section" data-type="string | array" data-required="false" data-desc="指定項目應出現的位置,例如 'header'、'footer'、'dashboard'。"></x-field>
36
- <x-field data-name="role" data-type="string | array" data-required="false" data-desc="定義哪些使用者角色可以看到此項目,例如 'admin'、'guest'。"></x-field>
37
- <x-field data-name="items" data-type="array" data-required="false" data-desc="一個巢狀導覽項目的陣列,用於建立下拉選單或子選單。"></x-field>
38
- </x-field>
39
- </x-field-group>
40
-
41
- ### 導覽設定範例
42
-
43
- `navigation` 陣列是元數據中最關鍵的部分。它提供了一種結構化的方式來定義所有連結、選單及其位置。
44
-
45
- ```yaml blocklet.yml 中的導覽設定 icon=mdi:code-braces
46
- # blocklet.yml
47
- navigation:
48
- - title: Features
49
- link: /features
50
- - title:
51
- en: About Us
52
- zh: 关于我们
53
- link:
54
- en: /about
55
- zh: /about-us
56
- section: footer
57
- - title: Admin Dashboard
58
- link: /admin
59
- section: dashboard
60
- role: admin
61
- - title: Social
62
- section: social
63
- items:
64
- - title: Twitter
65
- link: https://twitter.com/arcblock
66
- icon: mdi:twitter
67
- - title: GitHub
68
- link: https://github.com/arcblock
69
- icon: mdi:github
70
- ```
71
-
72
- 此範例說明了幾個關鍵功能:
73
- - 一個簡單的 header 連結(「Features」)。
74
- - 一個多語言的 footer 連結(「About Us」)。
75
- - 一個僅限管理員的 dashboard 連結。
76
- - 一組用於 footer 的社群媒體連結。
77
-
78
- ## 資料處理管線
79
-
80
- 在渲染之前,函式庫會透過一系列步驟處理原始元數據,為 UI 元件做好準備。
81
-
82
- ### 1. 解析與分區
83
-
84
- 第一步是解析 `navigation` 陣列,並根據其 `section` 屬性將項目分組。透過為 `section` 值使用陣列,可以將單個導覽項目分配到多個區塊。
85
-
86
- `parseNavigation` 工具程式會將每個項目分類到預定義的區塊中:
87
- - `header`:用於主應用程式的 header。
88
- - `footer`:用於 footer 中的主要連結。
89
- - `social`:用於社群媒體圖示,通常在 footer 中。
90
- - `bottom`:用於 footer 最底部的法律或次要連結。
91
- - `dashboard`:用於 dashboard 佈局中的側邊欄導覽。
92
- - `sessionManager`:用於使用者會話元件中的選單。
93
- - `userCenter`:用於使用者個人資料區域中的標籤或連結。
94
-
95
- 如果項目沒有 `section` 屬性,則預設為 `header`。
96
-
97
- ### 2. 國際化 (i18n)
98
-
99
- 該函式庫內建支援多種語言。如果導覽項目中的 `title` 或 `link` 屬性是帶有語言鍵(例如 `en`、`zh`)的物件,`getLocalizedNavigation` 函式會根據使用者當前的語系自動選擇正確的字串。
100
-
101
- ```javascript i18n 物件範例 icon=logos:javascript
102
- // 一個支援多語言的導覽項目
103
- {
104
- title: {
105
- en: 'Home',
106
- zh: '首页'
107
- },
108
- link: {
109
- en: '/home',
110
- zh: '/zh/home'
111
- }
112
- }
113
- ```
114
-
115
- ### 3. 基於角色的篩選
116
-
117
- 為了創造動態的使用者體驗,可以將導覽項目限制給特定的使用者角色。`filterNavByRole` 函式會透過比較每個項目的 `role` 屬性與當前會話中的 `user.role` 來篩選導覽列表。
118
-
119
- - 如果項目沒有 `role` 屬性,則對所有人可見。
120
- - 如果項目有 `role` 屬性(例如 `['admin', 'editor']`),則僅對角色在該陣列中的使用者可見。
121
- - `guest` 角色是一個特殊值,適用於未經驗證的使用者。
122
-
123
- 此機制讓您可以在元數據中定義一個全面的導覽結構,並讓 UI 根據登入使用者的權限自動調整。
124
-
125
- ## 總結
126
-
127
- Blocklet UI React 函式庫的核心概念是利用一個集中的元數據物件來驅動通用 UI 元件的設定與渲染。這種元數據驅動的方法提供了幾個優點:
128
-
129
- - **單一事實來源**:應用程式的結構、品牌和導覽都在一個地方定義。
130
- - **一致性**:確保應用程式不同部分之間具有一致的外觀和風格。
131
- - **減少樣板程式碼**:無需手動編寫像 header 和 footer 這樣的通用佈局元素。
132
- - **動態 UI**:原生支援國際化和基於角色的存取控制,讓 UI 能夠根據使用者及其權限動態調整。
133
-
134
- 清楚了解這些原則後,您就能有效地利用該函式庫的元件。有關特定元件及其用法的更多資訊,請參閱 [元件](./components.md) 部分。
@@ -1,134 +0,0 @@
1
- # 核心概念
2
-
3
- 本文档解释了 Blocklet UI React 库的基本原则。其核心设计理念是**元数据驱动方法**,即 `Header`、`Footer` 和 `Dashboard` 等 UI 组件会根据 blocklet 的元数据自动配置和渲染。这种策略确保了一致性,减少了样板代码,并实现了能适应用户角色和语言偏好的动态 UI。
4
-
5
- 其中心思想是,单个配置文件(通常是 `blocklet.yml`)作为应用程序整体结构和外观的单一事实来源。该库读取、处理此元数据,并用其构建相应的 UI 元素。
6
-
7
- ## 元数据驱动原则
8
-
9
- 该库的运作可以看作一个简单的数据流:blocklet 元数据作为输入提供给库,库通过一个管道处理它,最终生成完全渲染的 UI 组件。这免去了开发者为每个应用程序手动构建和配置通用布局元素的需求。
10
-
11
- <!-- DIAGRAM_IMAGE_START:flowchart:16:9:1765962229 -->
12
- ![Core Concepts](assets/diagram/core-concepts-diagram-0.zh.jpg)
13
- <!-- DIAGRAM_IMAGE_END -->
14
-
15
- 这个自动化过程依赖于一个明确定义的元数据结构,下一节将详细介绍。
16
-
17
- ## Blocklet 元数据剖析
18
-
19
- 该库期望一个特定的对象结构,称为 `BlockletMetaProps`,其中包含渲染 UI 所需的所有信息。以下是该结构的详细分解。
20
-
21
- <x-field-group>
22
- <x-field data-name="appName" data-type="string" data-required="false" data-desc="应用程序的名称,通常显示在 Header 中。"></x-field>
23
- <x-field data-name="appLogo" data-type="React.ReactNode" data-required="false" data-desc="用于应用程序徽标的 React 节点,也显示在 Header 中。"></x-field>
24
- <x-field data-name="enableConnect" data-type="boolean" data-required="false" data-desc="决定是否显示 DID Connect 按钮。"></x-field>
25
- <x-field data-name="enableLocale" data-type="boolean" data-required="false" data-desc="决定是否显示语言选择组件。"></x-field>
26
- <x-field data-name="theme" data-type="object" data-required="false">
27
- <x-field-desc markdown>定义应用程序布局的配色方案。</x-field-desc>
28
- <x-field data-name="background" data-type="string" data-required="false" data-desc="为 Header 和 Footer 等布局组件设置背景颜色。"></x-field>
29
- </x-field>
30
- <x-field data-name="navigation" data-type="array" data-required="false">
31
- <x-field-desc markdown>一个由导航项对象组成的数组,用于定义整个应用程序中的链接和菜单。</x-field-desc>
32
- <x-field data-name="title" data-type="string | object" data-required="true" data-desc="导航项的显示文本。可以是用于 i18n 的对象。"></x-field>
33
- <x-field data-name="link" data-type="string | object" data-required="false" data-desc="导航项的 URL。可以是用于 i18n 的对象。"></x-field>
34
- <x-field data-name="icon" data-type="string" data-required="false" data-desc="一个与 Iconify 兼容的字符串,用于在标题旁边显示图标。"></x-field>
35
- <x-field data-name="section" data-type="string | array" data-required="false" data-desc="指定该项应出现的位置,例如 'header'、'footer'、'dashboard'。"></x-field>
36
- <x-field data-name="role" data-type="string | array" data-required="false" data-desc="定义哪些用户角色可以看到此项,例如 'admin'、'guest'。"></x-field>
37
- <x-field data-name="items" data-type="array" data-required="false" data-desc="一个嵌套导航项的数组,用于创建下拉菜单或子菜单。"></x-field>
38
- </x-field>
39
- </x-field-group>
40
-
41
- ### 导航配置示例
42
-
43
- `navigation` 数组是元数据中最关键的部分。它提供了一种结构化的方式来定义所有链接、菜单及其位置。
44
-
45
- ```yaml blocklet.yml 中的导航配置 icon=mdi:code-braces
46
- # blocklet.yml
47
- navigation:
48
- - title: Features
49
- link: /features
50
- - title:
51
- en: About Us
52
- zh: 关于我们
53
- link:
54
- en: /about
55
- zh: /about-us
56
- section: footer
57
- - title: Admin Dashboard
58
- link: /admin
59
- section: dashboard
60
- role: admin
61
- - title: Social
62
- section: social
63
- items:
64
- - title: Twitter
65
- link: https://twitter.com/arcblock
66
- icon: mdi:twitter
67
- - title: GitHub
68
- link: https://github.com/arcblock
69
- icon: mdi:github
70
- ```
71
-
72
- 此示例说明了几个关键功能:
73
- - 一个简单的页眉链接(“Features”)。
74
- - 一个多语言页脚链接(“About Us”)。
75
- - 一个仅限管理员的仪表盘链接。
76
- - 一组用于页脚的社交媒体链接。
77
-
78
- ## 数据处理管道
79
-
80
- 在渲染之前,该库会通过一系列步骤处理原始元数据,为 UI 组件做准备。
81
-
82
- ### 1. 解析与分段
83
-
84
- 第一步是解析 `navigation` 数组,并根据其 `section` 属性对项目进行分组。通过为 `section` 值使用数组,可以将单个导航项分配到多个区域。
85
-
86
- `parseNavigation` 工具将每个项目分类到预定义的区域中:
87
- - `header`:用于主应用程序页眉。
88
- - `footer`:用于页脚中的主要链接。
89
- - `social`:用于社交媒体图标,通常在页脚中。
90
- - `bottom`:用于页脚最底部的法律或次要链接。
91
- - `dashboard`:用于仪表盘布局中的侧边栏导航。
92
- - `sessionManager`:用于用户会话组件内的菜单。
93
- - `userCenter`:用于用户个人资料区域内的选项卡或链接。
94
-
95
- 如果一个项目没有 `section` 属性,它默认被归为 `header`。
96
-
97
- ### 2. 国际化 (i18n)
98
-
99
- 该库内置了对多种语言的支持。如果导航项中的 `title` 或 `link` 属性是一个带有语言键(例如 `en`、`zh`)的对象,`getLocalizedNavigation` 函数会根据用户当前的区域设置自动选择正确的字符串。
100
-
101
- ```javascript i18n 对象示例 icon=logos:javascript
102
- // 一个支持多语言的导航项
103
- {
104
- title: {
105
- en: 'Home',
106
- zh: '首页'
107
- },
108
- link: {
109
- en: '/home',
110
- zh: '/zh/home'
111
- }
112
- }
113
- ```
114
-
115
- ### 3. 基于角色的过滤
116
-
117
- 为了创建动态的用户体验,导航项可以限制于特定的用户角色。`filterNavByRole` 函数通过将每个项目的 `role` 属性与当前会话中的 `user.role` 进行比较来过滤导航列表。
118
-
119
- - 如果一个项目没有 `role` 属性,它对所有人可见。
120
- - 如果一个项目有 `role` 属性(例如 `['admin', 'editor']`),它仅对角色在该数组中的用户可见。
121
- - `guest` 角色是一个特殊值,适用于未经身份验证的用户。
122
-
123
- 这种机制允许您在元数据中定义一个全面的导航结构,并让 UI 根据登录用户的权限自动适应。
124
-
125
- ## 总结
126
-
127
- Blocklet UI React 库的核心概念是利用一个集中的元数据对象来驱动通用 UI 组件的配置和渲染。这种元数据驱动方法具有以下几个优点:
128
-
129
- - **单一事实来源**:应用程序的结构、品牌和导航都在一个地方定义。
130
- - **一致性**:确保应用程序不同部分具有一致的外观和感觉。
131
- - **减少样板代码**:无需手动编码像页眉和页脚这样的通用布局元素。
132
- - **动态 UI**:原生支持国际化和基于角色的访问控制,允许 UI 根据用户及其权限动态调整。
133
-
134
- 清楚地理解了这些原则后,您就可以有效地利用该库的组件。有关特定组件及其用法的更多信息,请参阅 [组件](./components.md) 部分。
@@ -1,132 +0,0 @@
1
- # はじめに
2
-
3
- このガイドでは、`@blocklet/ui-react` ライブラリをインストールし、最初のコンポーネントをレンダリングするための手順をステップバイステップで説明します。目標は、最小限の時間でアプリケーション内に機能する `Header` と `Footer` を実装することです。
4
-
5
- ## 前提条件
6
-
7
- 先に進む前に、開発環境に以下がインストールされていることを確認してください:
8
- * 動作する React プロジェクト。
9
- * Node.js とパッケージマネージャー(npm または yarn)。
10
-
11
- ## インストール
12
-
13
- まず、お使いのパッケージマネージャーを使用して、`@blocklet/ui-react` パッケージをプロジェクトに追加します。
14
-
15
- npm を使用する場合:
16
- ```bash npm
17
- npm install @blocklet/ui-react
18
- ```
19
-
20
- yarn を使用する場合:
21
- ```bash yarn
22
- yarn add @blocklet/ui-react
23
- ```
24
-
25
- ## 基本的な使用法: Header と Footer
26
-
27
- `Header` と `Footer` コンポーネントはシンプルに設計されており、初期設定なしでレンダリングできます。これらのコンポーネントは、blocklet のメタデータから自動的にデータを取得します。
28
-
29
- 1. `Header` と `Footer` コンポーネントをメインのアプリケーションファイル(例:`App.js`)にインポートします。
30
- 2. それぞれをアプリケーションのレイアウトの最上部と最下部に配置します。
31
-
32
- ```jsx App.js icon=logos:react
33
- import React from 'react';
34
- import Header from '@blocklet/ui-react/lib/Header';
35
- import Footer from '@blocklet/ui-react/lib/Footer';
36
-
37
- function App() {
38
- return (
39
- <div>
40
- <Header />
41
- <main style={{ padding: '20px', minHeight: 'calc(100vh - 128px)' }}>
42
- {/* アプリケーションのコンテンツはここに記述します */}
43
- <h1>Welcome to My Blocklet</h1>
44
- </main>
45
- <Footer />
46
- </div>
47
- );
48
- }
49
-
50
- export default App;
51
- ```
52
-
53
- コンポーネントは、アプリケーション名、ロゴ、ナビゲーションリンクなどの設定詳細を、Blocklet Server 環境によって注入される `window.blocklet` メタデータオブジェクトから自動的に取得します。
54
-
55
- さらに、`Header` コンポーネントは、状況に応じて追加のコントロールをインテリジェントにレンダリングします:
56
- * `SessionContext` が利用可能な場合、**ユーザーセッションマネージャー**が表示されます。
57
- * `LocaleContext` が利用可能な場合、**言語セレクター**が表示されます。
58
-
59
- ## 手動設定
60
-
61
- 開発、テスト、またはデフォルトのメタデータを上書きする必要がある場合、`blockletMeta` プロパティを使用して設定オブジェクトをコンポーネントに直接渡すことができます。
62
-
63
- ```jsx App.js icon=logos:react
64
- import React from 'react';
65
- import Header from '@blocklet/ui-react/lib/Header';
66
-
67
- const customBlockletMeta = {
68
- appName: 'My Custom App',
69
- appLogo: 'https://path.to/your/logo.png',
70
- navigation: [
71
- {
72
- title: 'Home',
73
- link: '/',
74
- },
75
- {
76
- title: 'Documentation',
77
- link: '/docs',
78
- },
79
- ],
80
- };
81
-
82
- function App() {
83
- return (
84
- <div>
85
- <Header blockletMeta={customBlockletMeta} />
86
- {/* ... rest of your app */}
87
- </div>
88
- );
89
- }
90
- ```
91
-
92
- このアプローチにより、グローバルな `window.blocklet` オブジェクトによって提供されるデータを上書きし、コンポーネントの外観と動作を正確に制御できます。
93
-
94
- ## Header のカスタマイズ
95
-
96
- `Header` コンポーネントには右側に `addons` エリアがあり、アクションボタンやカスタムリンクなど、独自のコンポーネントを含めるようにカスタマイズできます。
97
-
98
- `addons` プロパティは、デフォルトのアドオンコンポーネントを引数として受け取る関数を受け入れます。これにより、既存のコンポーネントの前に追加したり、後ろに追加したり、完全に置き換えたりすることができます。
99
-
100
- ```jsx CustomHeader.js icon=logos:react
101
- import React from 'react';
102
- import Header from '@blocklet/ui-react/lib/Header';
103
- import Button from '@mui/material/Button'; // Material-UI を使用した例
104
-
105
- function CustomHeader() {
106
- return (
107
- <Header
108
- addons={existingAddons => {
109
- return [
110
- <Button
111
- key="custom-action"
112
- variant="contained"
113
- color="primary"
114
- size="small"
115
- style={{ marginRight: 8 }}>
116
- Custom Action
117
- </Button>,
118
- ...existingAddons, // 重要: デフォルトのセッション/ロケールアドオンを保持します
119
- ];
120
- }}
121
- />
122
- );
123
- }
124
- ```
125
-
126
- この例では、カスタムボタンが既存のアドオンの前に追加されています。`...existingAddons` を含めることで、デフォルトのセッションおよびロケールコントロールが表示されたままになるようにします。
127
-
128
- ## まとめ
129
-
130
- これで、`@blocklet/ui-react` ライブラリのインストール、デフォルトの `Header` および `Footer` コンポーネントのレンダリング、そしてカスタム設定やアドオンの提供方法を学びました。
131
-
132
- これらの基本を理解したことで、ライブラリで利用可能なすべてのコンポーネントを探索する準備が整いました。レイアウト、ユーザー管理、ユーティリティコンポーネントに関する詳細なドキュメントについては、[コンポーネント](./components.md) セクションに進んでください。
@@ -1,132 +0,0 @@
1
- # Getting Started
2
-
3
- This guide provides a step-by-step walkthrough to install the `@blocklet/ui-react` library and render your first components. The objective is to have a functional `Header` and `Footer` within your application in a minimal amount of time.
4
-
5
- ## Prerequisites
6
-
7
- Before proceeding, ensure you have the following installed in your development environment:
8
- * A functional React project.
9
- * Node.js and a package manager (npm or yarn).
10
-
11
- ## Installation
12
-
13
- To begin, add the `@blocklet/ui-react` package to your project using your preferred package manager.
14
-
15
- With npm:
16
- ```bash npm
17
- npm install @blocklet/ui-react
18
- ```
19
-
20
- With yarn:
21
- ```bash yarn
22
- yarn add @blocklet/ui-react
23
- ```
24
-
25
- ## Basic Usage: Header and Footer
26
-
27
- The `Header` and `Footer` components are designed for simplicity and can be rendered without any initial configuration. They automatically source their data from the blocklet's metadata.
28
-
29
- 1. Import the `Header` and `Footer` components into your main application file (e.g., `App.js`).
30
- 2. Place them at the top and bottom of your application's layout, respectively.
31
-
32
- ```jsx App.js icon=logos:react
33
- import React from 'react';
34
- import Header from '@blocklet/ui-react/lib/Header';
35
- import Footer from '@blocklet/ui-react/lib/Footer';
36
-
37
- function App() {
38
- return (
39
- <div>
40
- <Header />
41
- <main style={{ padding: '20px', minHeight: 'calc(100vh - 128px)' }}>
42
- {/* Your application content goes here */}
43
- <h1>Welcome to My Blocklet</h1>
44
- </main>
45
- <Footer />
46
- </div>
47
- );
48
- }
49
-
50
- export default App;
51
- ```
52
-
53
- The components automatically retrieve configuration details—such as the application name, logo, and navigation links—from the `window.blocklet` metadata object, which is injected by the Blocklet Server environment.
54
-
55
- Furthermore, the `Header` component will intelligently render additional controls:
56
- * A **user session manager** is displayed if a `SessionContext` is available.
57
- * A **language selector** is displayed if a `LocaleContext` is available.
58
-
59
- ## Manual Configuration
60
-
61
- For development, testing, or cases where you need to override the default metadata, you can pass a configuration object directly to the components using the `blockletMeta` prop.
62
-
63
- ```jsx App.js icon=logos:react
64
- import React from 'react';
65
- import Header from '@blocklet/ui-react/lib/Header';
66
-
67
- const customBlockletMeta = {
68
- appName: 'My Custom App',
69
- appLogo: 'https://path.to/your/logo.png',
70
- navigation: [
71
- {
72
- title: 'Home',
73
- link: '/',
74
- },
75
- {
76
- title: 'Documentation',
77
- link: '/docs',
78
- },
79
- ],
80
- };
81
-
82
- function App() {
83
- return (
84
- <div>
85
- <Header blockletMeta={customBlockletMeta} />
86
- {/* ... rest of your app */}
87
- </div>
88
- );
89
- }
90
- ```
91
-
92
- This approach gives you precise control over the component's appearance and behavior by overriding any data provided by the global `window.blocklet` object.
93
-
94
- ## Customizing the Header
95
-
96
- The `Header` component includes an `addons` area on the right side, which you can customize to include your own components, such as action buttons or custom links.
97
-
98
- The `addons` prop accepts a function that receives the default addon components as an argument. This allows you to prepend, append, or completely replace them.
99
-
100
- ```jsx CustomHeader.js icon=logos:react
101
- import React from 'react';
102
- import Header from '@blocklet/ui-react/lib/Header';
103
- import Button from '@mui/material/Button'; // Example using Material-UI
104
-
105
- function CustomHeader() {
106
- return (
107
- <Header
108
- addons={existingAddons => {
109
- return [
110
- <Button
111
- key="custom-action"
112
- variant="contained"
113
- color="primary"
114
- size="small"
115
- style={{ marginRight: 8 }}>
116
- Custom Action
117
- </Button>,
118
- ...existingAddons, // Important: preserves default session/locale addons
119
- ];
120
- }}
121
- />
122
- );
123
- }
124
- ```
125
-
126
- In this example, a custom button is prepended to the existing addons. By including `...existingAddons`, you ensure that the default session and locale controls remain visible.
127
-
128
- ## Summary
129
-
130
- You have successfully installed the `@blocklet/ui-react` library, rendered default `Header` and `Footer` components, and learned how to provide custom configurations and addons.
131
-
132
- With these fundamentals in place, you are now prepared to explore the full range of components available in the library. For detailed documentation on layout, user management, and utility components, please proceed to the [Components](./components.md) section.