@blocklet/ui-react 3.1.47 → 3.1.49

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 (98) hide show
  1. package/.aigne/doc-smith/config.yaml +76 -0
  2. package/.aigne/doc-smith/history.yaml +9 -0
  3. package/.aigne/doc-smith/output/structure-plan.json +249 -0
  4. package/.aigne/doc-smith/upload-cache.yaml +528 -0
  5. package/docs/_sidebar.md +19 -0
  6. package/docs/components-component-management-blocklet-studio.ja.md +194 -0
  7. package/docs/components-component-management-blocklet-studio.md +194 -0
  8. package/docs/components-component-management-blocklet-studio.zh-TW.md +194 -0
  9. package/docs/components-component-management-blocklet-studio.zh.md +194 -0
  10. package/docs/components-component-management-component-installer.ja.md +256 -0
  11. package/docs/components-component-management-component-installer.md +256 -0
  12. package/docs/components-component-management-component-installer.zh-TW.md +256 -0
  13. package/docs/components-component-management-component-installer.zh.md +256 -0
  14. package/docs/components-component-management.ja.md +59 -0
  15. package/docs/components-component-management.md +59 -0
  16. package/docs/components-component-management.zh-TW.md +59 -0
  17. package/docs/components-component-management.zh.md +59 -0
  18. package/docs/components-layout-dashboard.ja.md +231 -0
  19. package/docs/components-layout-dashboard.md +231 -0
  20. package/docs/components-layout-dashboard.zh-TW.md +231 -0
  21. package/docs/components-layout-dashboard.zh.md +231 -0
  22. package/docs/components-layout-footer.ja.md +165 -0
  23. package/docs/components-layout-footer.md +165 -0
  24. package/docs/components-layout-footer.zh-TW.md +165 -0
  25. package/docs/components-layout-footer.zh.md +165 -0
  26. package/docs/components-layout-header.ja.md +233 -0
  27. package/docs/components-layout-header.md +233 -0
  28. package/docs/components-layout-header.zh-TW.md +233 -0
  29. package/docs/components-layout-header.zh.md +233 -0
  30. package/docs/components-layout.ja.md +50 -0
  31. package/docs/components-layout.md +50 -0
  32. package/docs/components-layout.zh-TW.md +50 -0
  33. package/docs/components-layout.zh.md +50 -0
  34. package/docs/components-notifications.ja.md +173 -0
  35. package/docs/components-notifications.md +173 -0
  36. package/docs/components-notifications.zh-TW.md +174 -0
  37. package/docs/components-notifications.zh.md +173 -0
  38. package/docs/components-user-management-user-center.ja.md +183 -0
  39. package/docs/components-user-management-user-center.md +183 -0
  40. package/docs/components-user-management-user-center.zh-TW.md +183 -0
  41. package/docs/components-user-management-user-center.zh.md +183 -0
  42. package/docs/components-user-management-user-sessions.ja.md +164 -0
  43. package/docs/components-user-management-user-sessions.md +164 -0
  44. package/docs/components-user-management-user-sessions.zh-TW.md +164 -0
  45. package/docs/components-user-management-user-sessions.zh.md +164 -0
  46. package/docs/components-user-management.ja.md +76 -0
  47. package/docs/components-user-management.md +76 -0
  48. package/docs/components-user-management.zh-TW.md +76 -0
  49. package/docs/components-user-management.zh.md +76 -0
  50. package/docs/components-utilities-icon.ja.md +106 -0
  51. package/docs/components-utilities-icon.md +106 -0
  52. package/docs/components-utilities-icon.zh-TW.md +106 -0
  53. package/docs/components-utilities-icon.zh.md +106 -0
  54. package/docs/components-utilities.ja.md +136 -0
  55. package/docs/components-utilities.md +136 -0
  56. package/docs/components-utilities.zh-TW.md +136 -0
  57. package/docs/components-utilities.zh.md +136 -0
  58. package/docs/components.ja.md +27 -0
  59. package/docs/components.md +27 -0
  60. package/docs/components.zh-TW.md +27 -0
  61. package/docs/components.zh.md +27 -0
  62. package/docs/core-concepts.ja.md +164 -0
  63. package/docs/core-concepts.md +164 -0
  64. package/docs/core-concepts.zh-TW.md +164 -0
  65. package/docs/core-concepts.zh.md +164 -0
  66. package/docs/getting-started.ja.md +132 -0
  67. package/docs/getting-started.md +132 -0
  68. package/docs/getting-started.zh-TW.md +132 -0
  69. package/docs/getting-started.zh.md +132 -0
  70. package/docs/hooks-api.ja.md +214 -0
  71. package/docs/hooks-api.md +214 -0
  72. package/docs/hooks-api.zh-TW.md +214 -0
  73. package/docs/hooks-api.zh.md +214 -0
  74. package/docs/how-to-guides.ja.md +413 -0
  75. package/docs/how-to-guides.md +413 -0
  76. package/docs/how-to-guides.zh-TW.md +413 -0
  77. package/docs/how-to-guides.zh.md +413 -0
  78. package/docs/overview.ja.md +91 -0
  79. package/docs/overview.md +91 -0
  80. package/docs/overview.zh-TW.md +91 -0
  81. package/docs/overview.zh.md +91 -0
  82. package/glossary.md +12 -0
  83. package/lib/Dashboard/index.js +46 -42
  84. package/lib/Footer/index.js +51 -36
  85. package/lib/Header/index.js +48 -44
  86. package/lib/UserCenter/components/settings.js +1 -0
  87. package/lib/UserCenter/components/user-center.js +133 -133
  88. package/lib/blocklets.d.ts +13 -2
  89. package/lib/blocklets.js +40 -40
  90. package/lib/common/header-addons.js +37 -33
  91. package/package.json +7 -7
  92. package/src/Dashboard/index.jsx +8 -3
  93. package/src/Footer/index.jsx +22 -4
  94. package/src/Header/index.tsx +7 -2
  95. package/src/UserCenter/components/settings.tsx +1 -0
  96. package/src/UserCenter/components/user-center.tsx +6 -6
  97. package/src/blocklets.js +18 -9
  98. package/src/common/header-addons.jsx +7 -2
@@ -0,0 +1,165 @@
1
+ # Footer
2
+
3
+ The `Footer` component provides a standardized, responsive footer for your application. It automatically populates its content—including branding, navigation links, social media icons, and copyright information—by reading your blocklet's metadata. This data-driven approach ensures consistency and simplifies configuration.
4
+
5
+ The component is designed to be responsive, adapting its layout for different screen sizes. It also includes built-in logic to hide itself when the application is running in an embedded mode, ensuring a clean user interface in integrations.
6
+
7
+ ## Basic Usage
8
+
9
+ To add a footer to your application, simply import and render the `Footer` component. It requires no props for basic use, as it automatically sources data from the global `window.blocklet` object.
10
+
11
+ ```jsx Usage Example icon=logos:react
12
+ import React from 'react';
13
+ import { Footer } from '@blocklet/ui-react';
14
+
15
+ export default function App() {
16
+ return (
17
+ <div style={{ minHeight: '100vh', display: 'flex', flexDirection: 'column' }}>
18
+ <main style={{ flex: 1 }}>
19
+ {/* Your application content goes here */}
20
+ </main>
21
+ <Footer />
22
+ </div>
23
+ );
24
+ }
25
+ ```
26
+
27
+ ## Props
28
+
29
+ The `Footer` component can be customized through the following props.
30
+
31
+ <x-field-group>
32
+ <x-field data-name="meta" data-type="object" data-required="false">
33
+ <x-field-desc markdown>
34
+ An object containing blocklet metadata. Use this prop to override the default `window.blocklet` configuration or to provide data in environments where the global object is not available. The structure should match the blocklet metadata format.
35
+ </x-field-desc>
36
+ </x-field>
37
+ <x-field data-name="theme" data-type="object" data-required="false">
38
+ <x-field-desc markdown>
39
+ A theme object to customize the footer's appearance. This object is deeply merged with the application's default theme, allowing you to override specific styles like colors, fonts, and spacing.
40
+ </x-field-desc>
41
+ </x-field>
42
+ </x-field-group>
43
+
44
+ ## Metadata Configuration
45
+
46
+ The content of the `Footer` is primarily configured through the blocklet's metadata file (`blocklet.yml`). The component reads specific fields from this file to render its different sections.
47
+
48
+ Below is an example of a `blocklet.yml` configuration that populates all sections of the footer.
49
+
50
+ ```yaml blocklet.yml
51
+ name: my-app
52
+ title: My App
53
+ description: A detailed description of my application that appears in the footer.
54
+ copyright: 'My Company Inc.'
55
+
56
+ # Navigation links are structured into groups
57
+ navigation:
58
+ # Main footer navigation, supports two levels for grouping
59
+ footer:
60
+ - title: 'Products'
61
+ items:
62
+ - title: 'Product A'
63
+ link: '/products/a'
64
+ - title: 'Product B'
65
+ link: '/products/b'
66
+ - title: 'Resources'
67
+ items:
68
+ - title: 'Documentation'
69
+ link: '/docs'
70
+ - title: 'Blog'
71
+ link: '/blog'
72
+
73
+ # Social media links
74
+ social:
75
+ - title: 'twitter' # Icon is inferred from the title (e.g., 'twitter', 'github')
76
+ link: 'https://twitter.com/your-handle'
77
+ - title: 'github'
78
+ icon: 'mdi:github' # You can also specify an Iconify icon name
79
+ link: 'https://github.com/your-org'
80
+
81
+ # Bottom links, typically for legal and privacy information
82
+ bottom:
83
+ - title: 'Privacy Policy'
84
+ link: '/privacy'
85
+ - title: 'Terms of Service'
86
+ link: '/terms'
87
+ ```
88
+
89
+ ### Data Structure
90
+
91
+ The `navigation` object in your metadata defines the links displayed in the footer. It is organized into three distinct sections: `footer`, `social`, and `bottom`.
92
+
93
+ <x-field-group>
94
+ <x-field data-name="navigation" data-type="object">
95
+ <x-field-desc markdown>
96
+ Contains all navigation structures for the application.
97
+ </x-field-desc>
98
+ <x-field data-name="footer" data-type="array">
99
+ <x-field-desc markdown>
100
+ An array of link groups for the main footer navigation area. Supports a two-level hierarchy.
101
+ </x-field-desc>
102
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="The title of the navigation group (e.g., 'Products')."></x-field>
103
+ <x-field data-name="[].link" data-type="string" data-required="false" data-desc="An optional link for the group title itself."></x-field>
104
+ <x-field data-name="[].items" data-type="array" data-required="false" data-desc="An array of child navigation links.">
105
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="The display text for the link."></x-field>
106
+ <x-field data-name="[].link" data-type="string" data-required="true" data-desc="The URL for the navigation link."></x-field>
107
+ </x-field>
108
+ </x-field>
109
+ <x-field data-name="social" data-type="array">
110
+ <x-field-desc markdown>
111
+ An array of links to social media profiles.
112
+ </x-field-desc>
113
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="The name of the social media platform, used to infer the icon (e.g., 'twitter')."></x-field>
114
+ <x-field data-name="[].icon" data-type="string" data-required="false" data-desc="Explicitly specify an icon using an Iconify string (e.g., `mdi:github`). Overrides the inferred icon."></x-field>
115
+ <x-field data-name="[].link" data-type="string" data-required="true" data-desc="The URL to the social media profile."></x-field>
116
+ </x-field>
117
+ <x-field data-name="bottom" data-type="array">
118
+ <x-field-desc markdown>
119
+ An array of links displayed at the very bottom of the footer, typically for legal notices.
120
+ </x-field-desc>
121
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="The display text for the link (e.g., 'Privacy Policy')."></x-field>
122
+ <x-field data-name="[].link" data-type="string" data-required="true" data-desc="The URL for the link."></x-field>
123
+ </x-field>
124
+ </x-field>
125
+ </x-field-group>
126
+
127
+ ## Layouts
128
+
129
+ The `Footer` component intelligently selects the most appropriate layout based on the provided data. This ensures a clean and functional presentation across different use cases.
130
+
131
+ - **Standard Layout**: This layout is automatically activated when `footer` navigation links or `social` media links are defined in your metadata. It features a multi-section design that elegantly organizes the brand information, social icons, and navigation columns. On mobile devices, the navigation groups become collapsible accordions for a better user experience.
132
+
133
+ - **Plain Layout**: If no `footer` or `social` links are provided, the component falls back to a simplified, single-row layout. This is ideal for applications that only require a copyright notice and a few essential links, such as "Terms of Service" or "Privacy Policy".
134
+
135
+ ## Theming
136
+
137
+ You can customize the footer's appearance by passing a `theme` object. This object is deeply merged with the existing theme, allowing for targeted overrides.
138
+
139
+ ```jsx Custom Theme Example icon=logos:react
140
+ import { Footer } from '@blocklet/ui-react';
141
+
142
+ const customTheme = {
143
+ palette: {
144
+ background: {
145
+ default: '#2c3e50', // A darker background for the footer
146
+ },
147
+ text: {
148
+ primary: '#ecf0f1',
149
+ secondary: '#bdc3c7',
150
+ },
151
+ divider: '#34495e',
152
+ },
153
+ };
154
+
155
+ // ... in your component's render method
156
+ <Footer theme={customTheme} bordered />;
157
+ ```
158
+
159
+ ## Behavior in Embedded Mode
160
+
161
+ The `Footer` component is wrapped in a higher-order component (`withHideWhenEmbed`) that automatically hides it when the application is rendered in an embedded context. This behavior is controlled by a session storage key, `EMBED_MODE_KEY`. If this key is set to `1`, the footer will not be rendered. This is useful for preventing redundant footers when your blocklet is displayed inside another application.
162
+
163
+ ---
164
+
165
+ For information on the header component, which is also configured via blocklet metadata, please see the [Header documentation](./components-layout-header.md).
@@ -0,0 +1,165 @@
1
+ # Footer
2
+
3
+ `Footer` 元件為您的應用程式提供一個標準化、回應式的頁尾。它會透過讀取您的 blocklet 的元資料,自動填入其內容——包括品牌、導覽連結、社群媒體圖示和版權資訊。這種資料驅動的方法確保了一致性並簡化了設定。
4
+
5
+ 該元件被設計為回應式,能適應不同螢幕尺寸的版面配置。它還包含內建邏輯,可在應用程式以嵌入模式執行時自動隱藏,確保在整合中擁有乾淨的使用者介面。
6
+
7
+ ## 基本用法
8
+
9
+ 若要為您的應用程式新增頁尾,只需匯入並渲染 `Footer` 元件即可。基本使用時無需任何 props,因為它會自動從全域 `window.blocklet` 物件中取得資料。
10
+
11
+ ```jsx 使用範例 icon=logos:react
12
+ import React from 'react';
13
+ import { Footer } from '@blocklet/ui-react';
14
+
15
+ export default function App() {
16
+ return (
17
+ <div style={{ minHeight: '100vh', display: 'flex', flexDirection: 'column' }}>
18
+ <main style={{ flex: 1 }}>
19
+ {/* 您的應用程式內容放在這裡 */}
20
+ </main>
21
+ <Footer />
22
+ </div>
23
+ );
24
+ }
25
+ ```
26
+
27
+ ## Props
28
+
29
+ `Footer` 元件可透過以下 props 進行客製化。
30
+
31
+ <x-field-group>
32
+ <x-field data-name="meta" data-type="object" data-required="false">
33
+ <x-field-desc markdown>
34
+ 包含 blocklet 元資料的物件。使用此 prop 可覆寫預設的 `window.blocklet` 設定,或在全域物件不可用的環境中提供資料。其結構應與 blocklet 元資料格式相符。
35
+ </x-field-desc>
36
+ </x-field>
37
+ <x-field data-name="theme" data-type="object" data-required="false">
38
+ <x-field-desc markdown>
39
+ 用於客製化頁尾外觀的主題物件。此物件會與應用程式的預設主題進行深度合併,讓您可以覆寫特定的樣式,如顏色、字體和間距。
40
+ </x-field-desc>
41
+ </x-field>
42
+ </x-field-group>
43
+
44
+ ## 元資料設定
45
+
46
+ `Footer` 的內容主要透過 blocklet 的元資料檔案 (`blocklet.yml`) 進行設定。該元件會從此檔案中讀取特定欄位來渲染其不同區塊。
47
+
48
+ 以下是一個 `blocklet.yml` 設定範例,它會填入頁尾的所有區塊。
49
+
50
+ ```yaml blocklet.yml
51
+ name: my-app
52
+ title: My App
53
+ description: A detailed description of my application that appears in the footer.
54
+ copyright: 'My Company Inc.'
55
+
56
+ # 導覽連結被組織成群組
57
+ navigation:
58
+ # 主要頁尾導覽,支援兩層分組
59
+ footer:
60
+ - title: 'Products'
61
+ items:
62
+ - title: 'Product A'
63
+ link: '/products/a'
64
+ - title: 'Product B'
65
+ link: '/products/b'
66
+ - title: 'Resources'
67
+ items:
68
+ - title: 'Documentation'
69
+ link: '/docs'
70
+ - title: 'Blog'
71
+ link: '/blog'
72
+
73
+ # 社群媒體連結
74
+ social:
75
+ - title: 'twitter' # 圖示是從標題推斷出來的(例如 'twitter', 'github')
76
+ link: 'https://twitter.com/your-handle'
77
+ - title: 'github'
78
+ icon: 'mdi:github' # 您也可以指定一個 Iconify 圖示名稱
79
+ link: 'https://github.com/your-org'
80
+
81
+ # 底部連結,通常用於法律和隱私資訊
82
+ bottom:
83
+ - title: 'Privacy Policy'
84
+ link: '/privacy'
85
+ - title: 'Terms of Service'
86
+ link: '/terms'
87
+ ```
88
+
89
+ ### 資料結構
90
+
91
+ 您元資料中的 `navigation` 物件定義了顯示在頁尾中的連結。它被組織成三個不同的區塊:`footer`、`social` 和 `bottom`。
92
+
93
+ <x-field-group>
94
+ <x-field data-name="navigation" data-type="object">
95
+ <x-field-desc markdown>
96
+ 包含應用程式的所有導覽結構。
97
+ </x-field-desc>
98
+ <x-field data-name="footer" data-type="array">
99
+ <x-field-desc markdown>
100
+ 主要頁尾導覽區域的連結群組陣列。支援兩層的層級結構。
101
+ </x-field-desc>
102
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="導覽群組的標題(例如,「Products」)。"></x-field>
103
+ <x-field data-name="[].link" data-type="string" data-required="false" data-desc="群組標題本身的可選連結。"></x-field>
104
+ <x-field data-name="[].items" data-type="array" data-required="false" data-desc="子導覽連結的陣列。">
105
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="連結的顯示文字。"></x-field>
106
+ <x-field data-name="[].link" data-type="string" data-required="true" data-desc="導覽連結的 URL。"></x-field>
107
+ </x-field>
108
+ </x-field>
109
+ <x-field data-name="social" data-type="array">
110
+ <x-field-desc markdown>
111
+ 指向社群媒體個人資料的連結陣列。
112
+ </x-field-desc>
113
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="社群媒體平台的名稱,用於推斷圖示(例如,「twitter」)。"></x-field>
114
+ <x-field data-name="[].icon" data-type="string" data-required="false" data-desc="使用 Iconify 字串明確指定一個圖示(例如,`mdi:github`)。這會覆寫推斷出的圖示。"></x-field>
115
+ <x-field data-name="[].link" data-type="string" data-required="true" data-desc="指向社群媒體個人資料的 URL。"></x-field>
116
+ </x-field>
117
+ <x-field data-name="bottom" data-type="array">
118
+ <x-field-desc markdown>
119
+ 顯示在頁尾最底部的連結陣列,通常用於法律聲明。
120
+ </x-field-desc>
121
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="連結的顯示文字(例如,「Privacy Policy」)。"></x-field>
122
+ <x-field data-name="[].link" data-type="string" data-required="true" data-desc="連結的 URL。"></x-field>
123
+ </x-field>
124
+ </x-field>
125
+ </x-field-group>
126
+
127
+ ## 版面配置
128
+
129
+ `Footer` 元件會根據提供的資料智慧地選擇最合適的版面配置。這確保了在不同使用情境下都能有乾淨且功能齊全的呈現。
130
+
131
+ - **標準版面配置**:當您的元資料中定義了 `footer` 導覽連結或 `social` 社群媒體連結時,此版面配置會自動啟用。它採用多區塊設計,優雅地組織品牌資訊、社群圖示和導覽欄。在行動裝置上,導覽群組會變成可折疊的手風琴式選單,以提供更好的使用者體驗。
132
+
133
+ - **簡潔版面配置**:如果沒有提供 `footer` 或 `social` 連結,元件會退回使用簡化的單行版面配置。這對於只需要版權聲明和一些基本連結(如「服務條款」或「隱私權政策」)的應用程式來說非常理想。
134
+
135
+ ## 主題化
136
+
137
+ 您可以透過傳遞一個 `theme` 物件來客製化頁尾的外觀。此物件會與現有主題進行深度合併,從而實現針對性的覆寫。
138
+
139
+ ```jsx 客製化主題範例 icon=logos:react
140
+ import { Footer } from '@blocklet/ui-react';
141
+
142
+ const customTheme = {
143
+ palette: {
144
+ background: {
145
+ default: '#2c3e50', // 頁尾使用較暗的背景
146
+ },
147
+ text: {
148
+ primary: '#ecf0f1',
149
+ secondary: '#bdc3c7',
150
+ },
151
+ divider: '#34495e',
152
+ },
153
+ };
154
+
155
+ // ... 在您元件的 render 方法中
156
+ <Footer theme={customTheme} bordered />;
157
+ ```
158
+
159
+ ## 嵌入模式下的行為
160
+
161
+ `Footer` 元件被一個高階元件 (`withHideWhenEmbed`) 包裹,當應用程式在嵌入式情境中渲染時,它會自動隱藏頁尾。此行為由一個 session storage 金鑰 `EMBED_MODE_KEY` 控制。如果此金鑰被設定為 `1`,頁尾將不會被渲染。這對於防止您的 blocklet 顯示在另一個應用程式內部時出現多餘的頁尾很有用。
162
+
163
+ ---
164
+
165
+ 關於 header 元件的資訊(該元件也透過 blocklet 元資料進行設定),請參閱 [Header 文件](./components-layout-header.md)。
@@ -0,0 +1,165 @@
1
+ # Footer
2
+
3
+ `Footer` 组件为你的应用提供了一个标准化的、响应式的页脚。它通过读取 blocklet 的元数据来自动填充其内容——包括品牌信息、导航链接、社交媒体图标和版权信息。这种数据驱动的方法确保了一致性并简化了配置。
4
+
5
+ 该组件采用响应式设计,能够适应不同屏幕尺寸的布局。它还内置了逻辑,在应用以嵌入模式运行时自动隐藏,从而确保集成时用户界面的整洁。
6
+
7
+ ## 基本用法
8
+
9
+ 要为你的应用添加页脚,只需导入并渲染 `Footer` 组件即可。在基本使用中,它不需要任何 props,因为它会自动从全局 `window.blocklet` 对象中获取数据。
10
+
11
+ ```jsx Usage Example icon=logos:react
12
+ import React from 'react';
13
+ import { Footer } from '@blocklet/ui-react';
14
+
15
+ export default function App() {
16
+ return (
17
+ <div style={{ minHeight: '100vh', display: 'flex', flexDirection: 'column' }}>
18
+ <main style={{ flex: 1 }}>
19
+ {/* 你的应用内容放在这里 */}
20
+ </main>
21
+ <Footer />
22
+ </div>
23
+ );
24
+ }
25
+ ```
26
+
27
+ ## Props
28
+
29
+ `Footer` 组件可以通过以下 props 进行自定义。
30
+
31
+ <x-field-group>
32
+ <x-field data-name="meta" data-type="object" data-required="false">
33
+ <x-field-desc markdown>
34
+ 一个包含 blocklet 元数据的对象。使用此 prop 可覆盖默认的 `window.blocklet` 配置,或在全局对象不可用的环境中提供数据。其结构应与 blocklet 元数据格式匹配。
35
+ </x-field-desc>
36
+ </x-field>
37
+ <x-field data-name="theme" data-type="object" data-required="false">
38
+ <x-field-desc markdown>
39
+ 一个用于自定义页脚外观的主题对象。该对象会与应用的默认主题进行深度合并,允许你覆盖颜色、字体和间距等特定样式。
40
+ </x-field-desc>
41
+ </x-field>
42
+ </x-field-group>
43
+
44
+ ## 元数据配置
45
+
46
+ `Footer` 的内容主要通过 blocklet 的元数据文件(`blocklet.yml`)进行配置。该组件会读取此文件中的特定字段来渲染其不同部分。
47
+
48
+ 以下是一个 `blocklet.yml` 配置示例,该配置填充了页脚的所有部分。
49
+
50
+ ```yaml blocklet.yml
51
+ name: my-app
52
+ title: My App
53
+ description: A detailed description of my application that appears in the footer.
54
+ copyright: 'My Company Inc.'
55
+
56
+ # 导航链接按组进行结构化
57
+ navigation:
58
+ # 主页脚导航,支持两级分组
59
+ footer:
60
+ - title: 'Products'
61
+ items:
62
+ - title: 'Product A'
63
+ link: '/products/a'
64
+ - title: 'Product B'
65
+ link: '/products/b'
66
+ - title: 'Resources'
67
+ items:
68
+ - title: 'Documentation'
69
+ link: '/docs'
70
+ - title: 'Blog'
71
+ link: '/blog'
72
+
73
+ # 社交媒体链接
74
+ social:
75
+ - title: 'twitter' # 图标是根据标题推断的(例如 'twitter', 'github')
76
+ link: 'https://twitter.com/your-handle'
77
+ - title: 'github'
78
+ icon: 'mdi:github' # 你也可以指定一个 Iconify 图标名称
79
+ link: 'https://github.com/your-org'
80
+
81
+ # 底部链接,通常用于法律和隐私信息
82
+ bottom:
83
+ - title: 'Privacy Policy'
84
+ link: '/privacy'
85
+ - title: 'Terms of Service'
86
+ link: '/terms'
87
+ ```
88
+
89
+ ### 数据结构
90
+
91
+ 元数据中的 `navigation` 对象定义了页脚中显示的链接。它被组织成三个不同的部分:`footer`、`social` 和 `bottom`。
92
+
93
+ <x-field-group>
94
+ <x-field data-name="navigation" data-type="object">
95
+ <x-field-desc markdown>
96
+ 包含应用的所有导航结构。
97
+ </x-field-desc>
98
+ <x-field data-name="footer" data-type="array">
99
+ <x-field-desc markdown>
100
+ 用于主页脚导航区域的链接组数组。支持两级层次结构。
101
+ </x-field-desc>
102
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="导航组的标题(例如,'Products')。"></x-field>
103
+ <x-field data-name="[].link" data-type="string" data-required="false" data-desc="分组标题本身的可选链接。"></x-field>
104
+ <x-field data-name="[].items" data-type="array" data-required="false" data-desc="子导航链接的数组。">
105
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="链接的显示文本。"></x-field>
106
+ <x-field data-name="[].link" data-type="string" data-required="true" data-desc="导航链接的 URL。"></x-field>
107
+ </x-field>
108
+ </x-field>
109
+ <x-field data-name="social" data-type="array">
110
+ <x-field-desc markdown>
111
+ 指向社交媒体配置文件的链接数组。
112
+ </x-field-desc>
113
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="社交媒体平台的名称,用于推断图标(例如,'twitter')。"></x-field>
114
+ <x-field data-name="[].icon" data-type="string" data-required="false" data-desc="使用 Iconify 字符串(例如,`mdi:github`)明确指定一个图标。这将覆盖推断出的图标。"></x-field>
115
+ <x-field data-name="[].link" data-type="string" data-required="true" data-desc="社交媒体配置文件的 URL。"></x-field>
116
+ </x-field>
117
+ <x-field data-name="bottom" data-type="array">
118
+ <x-field-desc markdown>
119
+ 显示在页脚最底部的链接数组,通常用于法律声明。
120
+ </x-field-desc>
121
+ <x-field data-name="[].title" data-type="string" data-required="true" data-desc="链接的显示文本(例如,'Privacy Policy')。"></x-field>
122
+ <x-field data-name="[].link" data-type="string" data-required="true" data-desc="链接的 URL。"></x-field>
123
+ </x-field>
124
+ </x-field>
125
+ </x-field-group>
126
+
127
+ ## 布局
128
+
129
+ `Footer` 组件会根据提供的数据智能选择最合适的布局。这确保了在不同用例中都能实现清晰且功能正常的呈现。
130
+
131
+ - **标准布局**:当元数据中定义了 `footer` 导航链接或 `social` 社交媒体链接时,此布局会自动激活。它采用多区域设计,优雅地组织了品牌信息、社交图标和导航栏。在移动设备上,导航组会变为可折叠的手风琴式菜单,以提供更好的用户体验。
132
+
133
+ - **简洁布局**:如果没有提供 `footer` 或 `social` 链接,组件将回退到简化的单行布局。这对于只需要版权声明和一些基本链接(如“服务条款”或“隐私政策”)的应用来说非常理想。
134
+
135
+ ## 主题化
136
+
137
+ 你可以通过传递一个 `theme` 对象来自定义页脚的外观。该对象会与现有主题进行深度合并,从而实现有针对性的覆盖。
138
+
139
+ ```jsx Custom Theme Example icon=logos:react
140
+ import { Footer } from '@blocklet/ui-react';
141
+
142
+ const customTheme = {
143
+ palette: {
144
+ background: {
145
+ default: '#2c3e50', // 页脚使用较暗的背景色
146
+ },
147
+ text: {
148
+ primary: '#ecf0f1',
149
+ secondary: '#bdc3c7',
150
+ },
151
+ divider: '#34495e',
152
+ },
153
+ };
154
+
155
+ // ... 在你组件的 render 方法中
156
+ <Footer theme={customTheme} bordered />;
157
+ ```
158
+
159
+ ## 嵌入模式下的行为
160
+
161
+ `Footer` 组件被一个高阶组件(`withHideWhenEmbed`)包裹,当应用在嵌入式上下文中渲染时,该组件会自动隐藏 `Footer`。此行为由一个会话存储键 `EMBED_MODE_KEY` 控制。如果此键设置为 `1`,页脚将不会被渲染。这在你的 blocklet 显示在另一个应用内部时,有助于防止出现多余的页脚。
162
+
163
+ ---
164
+
165
+ 有关 `Header` 组件的信息(该组件也通过 blocklet 元数据进行配置),请参阅 [Header 文档](./components-layout-header.md)。