@arcblock/ux 2.12.0 → 2.12.2

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 (59) hide show
  1. package/lib/Address/responsive-did-address.d.ts +0 -1
  2. package/lib/Address/responsive-did-address.js +42 -14
  3. package/lib/Header/demo/images/boards.svg +3 -0
  4. package/lib/Header/demo/images/chatbot.svg +3 -0
  5. package/lib/Header/demo/images/gallery.svg +3 -0
  6. package/lib/NavMenu/images/OCAP.svg +16 -0
  7. package/lib/NavMenu/images/abt-network.svg +18 -0
  8. package/lib/NavMenu/images/ai-kit.svg +46 -0
  9. package/lib/NavMenu/images/aigne.svg +8 -0
  10. package/lib/NavMenu/images/aistro.svg +14 -0
  11. package/lib/NavMenu/images/blocklet-framework.svg +25 -0
  12. package/lib/NavMenu/images/blocklet-launcher.svg +9 -0
  13. package/lib/NavMenu/images/blocklet-server.svg +19 -0
  14. package/lib/NavMenu/images/blocklet-store.svg +11 -0
  15. package/lib/NavMenu/images/creator-studio.svg +42 -0
  16. package/lib/NavMenu/images/did-connect.svg +26 -0
  17. package/lib/NavMenu/images/did-name-service.svg +3 -0
  18. package/lib/NavMenu/images/did-wallet.svg +33 -0
  19. package/lib/NavMenu/images/did.svg +3 -0
  20. package/lib/NavMenu/images/nft-studio.svg +19 -0
  21. package/lib/NavMenu/images/vc.svg +7 -0
  22. package/lib/NavMenu/images/web3-kit.svg +56 -0
  23. package/lib/NavMenu/index.d.ts +1 -0
  24. package/lib/NavMenu/index.js +2 -1
  25. package/lib/NavMenu/nav-menu-context.d.ts +17 -0
  26. package/lib/NavMenu/nav-menu-context.js +19 -0
  27. package/lib/NavMenu/nav-menu.d.ts +10 -5
  28. package/lib/NavMenu/nav-menu.js +76 -36
  29. package/lib/NavMenu/products.d.ts +5 -0
  30. package/lib/NavMenu/products.js +1639 -0
  31. package/lib/NavMenu/style.d.ts +8 -3
  32. package/lib/NavMenu/style.js +215 -175
  33. package/lib/NavMenu/sub-item-group.d.ts +5 -0
  34. package/lib/NavMenu/sub-item-group.js +44 -0
  35. package/package.json +5 -5
  36. package/src/Address/responsive-did-address.tsx +40 -12
  37. package/src/NavMenu/images/OCAP.svg +16 -0
  38. package/src/NavMenu/images/abt-network.svg +18 -0
  39. package/src/NavMenu/images/ai-kit.svg +46 -0
  40. package/src/NavMenu/images/aigne.svg +8 -0
  41. package/src/NavMenu/images/aistro.svg +14 -0
  42. package/src/NavMenu/images/blocklet-framework.svg +25 -0
  43. package/src/NavMenu/images/blocklet-launcher.svg +9 -0
  44. package/src/NavMenu/images/blocklet-server.svg +19 -0
  45. package/src/NavMenu/images/blocklet-store.svg +11 -0
  46. package/src/NavMenu/images/creator-studio.svg +42 -0
  47. package/src/NavMenu/images/did-connect.svg +26 -0
  48. package/src/NavMenu/images/did-name-service.svg +3 -0
  49. package/src/NavMenu/images/did-wallet.svg +33 -0
  50. package/src/NavMenu/images/did.svg +3 -0
  51. package/src/NavMenu/images/nft-studio.svg +19 -0
  52. package/src/NavMenu/images/vc.svg +7 -0
  53. package/src/NavMenu/images/web3-kit.svg +56 -0
  54. package/src/NavMenu/index.ts +1 -0
  55. package/src/NavMenu/nav-menu-context.tsx +30 -0
  56. package/src/NavMenu/nav-menu.tsx +98 -61
  57. package/src/NavMenu/products.tsx +378 -0
  58. package/src/NavMenu/style.ts +220 -183
  59. package/src/NavMenu/sub-item-group.tsx +36 -0
@@ -0,0 +1,378 @@
1
+ import { useLayoutEffect, useRef } from 'react';
2
+ import { Link } from 'react-router-dom';
3
+ import { useCreation, useMemoizedFn } from 'ahooks';
4
+ import { Box, BoxProps, Grid } from '@mui/material';
5
+ import { useWindowSize } from 'react-use';
6
+ import SubItemGroup from './sub-item-group';
7
+ import { Item } from './nav-menu';
8
+ import { styled } from '../Theme';
9
+ import { useNavMenuContext } from './nav-menu-context';
10
+ import { translate } from '../Locale/util';
11
+ import { useLocaleContext } from '../Locale/context';
12
+
13
+ import AIKitSvg from './images/ai-kit.svg?react';
14
+ import NftStudioSvg from './images/nft-studio.svg?react';
15
+ import CreatorStudioSvg from './images/creator-studio.svg?react';
16
+ import AigneSvg from './images/aigne.svg?react';
17
+ import AistroSvg from './images/aistro.svg?react';
18
+ import BlockletLauncherSvg from './images/blocklet-launcher.svg?react';
19
+ import BlockletStoreSvg from './images/blocklet-store.svg?react';
20
+ import Web3KitSvg from './images/web3-kit.svg?react';
21
+ import BlockletFrameworkSvg from './images/blocklet-framework.svg?react';
22
+ import AbtNetworkSvg from './images/abt-network.svg?react';
23
+ import BlockletServerSvg from './images/blocklet-server.svg?react';
24
+ import OCAPSvg from './images/OCAP.svg?react';
25
+ import DidSvg from './images/did.svg?react';
26
+ import DidWalletSvg from './images/did-wallet.svg?react';
27
+ import DidNameServiceSvg from './images/did-name-service.svg?react';
28
+ import VCSvg from './images/vc.svg?react';
29
+ import DidConnectSvg from './images/did-connect.svg?react';
30
+
31
+ const translations = {
32
+ en: {
33
+ groups: {
34
+ applications: 'Applications',
35
+ components: 'Components',
36
+ computeStorage: 'Compute/Storage',
37
+ identity: 'Identity',
38
+ },
39
+ products: {
40
+ nftStudio: {
41
+ description: 'Toolkit for NFT creation',
42
+ },
43
+ creatorStudio: {
44
+ description: "Content creators' Swiss knife",
45
+ },
46
+ aigne: {
47
+ description: 'Chat with AIGNE',
48
+ },
49
+ aistro: {
50
+ description: 'Al Language Model Astrologer',
51
+ },
52
+ blockletLauncher: {
53
+ description: 'Launch your blocklet here',
54
+ },
55
+ alKit: {
56
+ description: 'Empowers Al for application',
57
+ },
58
+ blockletStore: {
59
+ description: 'App Store for all Blocklets',
60
+ },
61
+ web3Kit: {
62
+ description: 'Provides series components',
63
+ },
64
+ blockletFramework: {
65
+ description: 'Launch your blocklet here',
66
+ },
67
+ didSpaces: {
68
+ description: 'Decentralized storage space',
69
+ },
70
+ abtNetwork: {
71
+ description: "ArcBlock's blockchain system",
72
+ },
73
+ blockletServer: {
74
+ description: 'Runtime Container Service',
75
+ },
76
+ osar: {
77
+ description: 'Supports multpy blockchains',
78
+ },
79
+ did: {
80
+ description: 'Decentralized Identity',
81
+ },
82
+ didWallet: {
83
+ description: 'Intelligent digital wallet',
84
+ },
85
+ didNameService: {
86
+ description: 'Purchase/host domain',
87
+ },
88
+ vc: {
89
+ description: 'Verifiable Credentials',
90
+ },
91
+ didConnect: {
92
+ description: 'Login with DID',
93
+ },
94
+ },
95
+ },
96
+ zh: {
97
+ groups: {
98
+ applications: '应用',
99
+ components: '组件',
100
+ computeStorage: '计算/存储',
101
+ identity: '身份',
102
+ },
103
+ products: {
104
+ nftStudio: {
105
+ description: 'NFT 创作工具包',
106
+ },
107
+ creatorStudio: {
108
+ description: '内容创作者的瑞士军刀',
109
+ },
110
+ aigne: {
111
+ description: '与 AIGNE 聊天',
112
+ },
113
+ aistro: {
114
+ description: 'Al 语言模型占星师',
115
+ },
116
+ blockletLauncher: {
117
+ description: '在这里启动你的 blocklet',
118
+ },
119
+ alKit: {
120
+ description: '为应用赋能 Al',
121
+ },
122
+ blockletStore: {
123
+ description: '所有 Blocklets 的应用商店',
124
+ },
125
+ web3Kit: {
126
+ description: '提供系列组件',
127
+ },
128
+ blockletFramework: {
129
+ description: '在这里启动你的 blocklet',
130
+ },
131
+ didSpaces: {
132
+ description: '去中心化存储空间',
133
+ },
134
+ abtNetwork: {
135
+ description: 'ArcBlock 的区块链系统',
136
+ },
137
+ blockletServer: {
138
+ description: '运行时容器服务',
139
+ },
140
+ osar: {
141
+ description: '支持多链',
142
+ },
143
+ did: {
144
+ description: '去中心化身份',
145
+ },
146
+ didWallet: {
147
+ description: '智能数字钱包',
148
+ },
149
+ didNameService: {
150
+ description: '购买/托管域名',
151
+ },
152
+ vc: {
153
+ description: '可验证凭证',
154
+ },
155
+ didConnect: {
156
+ description: '使用 DID 登录',
157
+ },
158
+ },
159
+ },
160
+ };
161
+
162
+ const Wrapper = styled(Box)`
163
+ width: 80vw;
164
+ max-width: 900px;
165
+ padding: 8px;
166
+ background: #f7f9fc;
167
+ border-radius: 8px;
168
+
169
+ &.is-inline {
170
+ width: 100%;
171
+ max-width: 100%;
172
+ border-radius: 0;
173
+ .nav-menu-sub-item-group {
174
+ padding: 8px 16px;
175
+ border-radius: 0;
176
+ }
177
+ }
178
+
179
+ .nav-menu-sub-item-group + .nav-menu-sub-item-group {
180
+ margin-top: 8px;
181
+ }
182
+ .MuiGrid-container + .MuiGrid-container {
183
+ margin-top: 0px;
184
+ }
185
+ `;
186
+
187
+ export interface ProductsProps extends BoxProps {
188
+ isOpen?: boolean;
189
+ }
190
+
191
+ export default function Products({ className, isOpen, ...rest }: ProductsProps) {
192
+ const { mode } = useNavMenuContext();
193
+ const wrapperRef = useRef<HTMLDivElement>(null);
194
+ const { width, height } = useWindowSize();
195
+ const { locale = 'en' } = useLocaleContext() || {};
196
+ const t = useMemoizedFn((key, data = {}) => translate(translations, key, locale, 'en', data));
197
+ const groups = useCreation(() => {
198
+ return [
199
+ {
200
+ type: 'Group',
201
+ label: t('groups.applications'),
202
+ children: [
203
+ [
204
+ {
205
+ label: <Link to={`https://www.nftstudio.rocks/${locale}`}>NFT Studio</Link>,
206
+ description: t('products.nftStudio.description'),
207
+ icon: <NftStudioSvg />,
208
+ },
209
+ {
210
+ label: (
211
+ <Link to={`https://www.arcblock.io/content/collections/${locale}/creator-studio`}>Creator Studio</Link>
212
+ ),
213
+ description: t('products.creatorStudio.description'),
214
+ icon: <CreatorStudioSvg />,
215
+ },
216
+ ],
217
+ [
218
+ {
219
+ label: <Link to={`https://www.aigne.io/${locale}`}>AIGNE</Link>,
220
+ description: t('products.aigne.description'),
221
+ icon: <AigneSvg />,
222
+ },
223
+ {
224
+ label: <Link to={`https://www.aistro.io/${locale}`}>Aistro</Link>,
225
+ description: t('products.aistro.description'),
226
+ icon: <AistroSvg />,
227
+ },
228
+ ],
229
+ ],
230
+ },
231
+ {
232
+ type: 'Group',
233
+ label: t('groups.components'),
234
+ children: [
235
+ [
236
+ {
237
+ label: <Link to={`https://launcher.arcblock.io/${locale}`}>Blocklet Launcher</Link>,
238
+ description: t('products.blockletLauncher.description'),
239
+ icon: <BlockletLauncherSvg />,
240
+ },
241
+ {
242
+ label: <Link to={`https://www.arcblock.io/content/collections/${locale}/ai-kit`}>Al Kit</Link>,
243
+ description: t('products.alKit.description'),
244
+ icon: <AIKitSvg />,
245
+ },
246
+ ],
247
+ [
248
+ {
249
+ label: <Link to={`https://store.blocklet.dev/${locale}`}>Blocklet Store</Link>,
250
+ description: t('products.blockletStore.description'),
251
+ icon: <BlockletStoreSvg />,
252
+ },
253
+ {
254
+ label: <Link to={`https://www.web3kit.rocks/${locale}`}>Web3 Kit</Link>,
255
+ description: t('products.web3Kit.description'),
256
+ icon: <Web3KitSvg />,
257
+ },
258
+ ],
259
+ ],
260
+ },
261
+ {
262
+ type: 'Group',
263
+ label: t('groups.computeStorage'),
264
+ children: [
265
+ [
266
+ {
267
+ label: (
268
+ <Link to={`https://www.arcblock.io/content/collections/${locale}/blocklet`}>Blocklet Framework</Link>
269
+ ),
270
+ description: t('products.blockletFramework.description'),
271
+ icon: <BlockletFrameworkSvg />,
272
+ },
273
+ {
274
+ label: <Link to={`https://www.didspaces.com/${locale}`}>DID Spaces</Link>,
275
+ description: t('products.didSpaces.description'),
276
+ icon: <DidSvg />,
277
+ },
278
+ {
279
+ label: <Link to={`https://main.abtnetwork.io/${locale}`}>ABT Network</Link>,
280
+ description: t('products.abtNetwork.description'),
281
+ icon: <AbtNetworkSvg />,
282
+ },
283
+ ],
284
+ [
285
+ {
286
+ label: (
287
+ <Link to={`https://www.arcblock.io/content/collections/${locale}/blocklet-server`}>
288
+ Blocklet Server
289
+ </Link>
290
+ ),
291
+ description: t('products.blockletServer.description'),
292
+ icon: <BlockletServerSvg />,
293
+ },
294
+ {
295
+ label: <Link to={`https://www.arcblock.io/content/collections/${locale}/blockchain`}>ОСАР</Link>,
296
+ description: t('products.osar.description'),
297
+ icon: <OCAPSvg />,
298
+ },
299
+ ],
300
+ ],
301
+ },
302
+ {
303
+ type: 'Group',
304
+ label: t('groups.identity'),
305
+ children: [
306
+ [
307
+ {
308
+ label: <Link to={`https://www.arcblock.io/content/collections/${locale}/did`}>DID</Link>,
309
+ description: t('products.did.description'),
310
+ icon: <DidSvg />,
311
+ },
312
+ {
313
+ label: <Link to={`https://www.didwallet.io/${locale}`}>DID Wallet</Link>,
314
+ description: t('products.didWallet.description'),
315
+ icon: <DidWalletSvg />,
316
+ },
317
+ {
318
+ label: <Link to={`https://www.didnames.io/${locale}`}>DID Name Service</Link>,
319
+ description: t('products.didNameService.description'),
320
+ icon: <DidNameServiceSvg />,
321
+ },
322
+ ],
323
+ [
324
+ {
325
+ label: <Link to={`https://www.arcblock.io/content/collections/${locale}/verifiable-credential`}>VC</Link>,
326
+ description: t('products.vc.description'),
327
+ icon: <VCSvg />,
328
+ },
329
+ {
330
+ label: <Link to={`https://www.didconnect.io/${locale}`}>DID Connect</Link>,
331
+ description: t('products.didConnect.description'),
332
+ icon: <DidConnectSvg />,
333
+ },
334
+ ],
335
+ ],
336
+ },
337
+ ];
338
+ }, [t, locale]);
339
+
340
+ // 防止弹框超出 window
341
+ useLayoutEffect(() => {
342
+ const wrapper = wrapperRef.current;
343
+ if (!wrapper) return;
344
+ if (!isOpen) {
345
+ wrapper.style.transform = '';
346
+ return;
347
+ }
348
+
349
+ const rect = wrapper.getBoundingClientRect();
350
+ const windowWidth = window.innerWidth;
351
+ if (rect.right > windowWidth) {
352
+ const offset = rect.right - windowWidth;
353
+ wrapper.style.transform = `translateX(-${offset + 16}px)`;
354
+ } else if (rect.left < 0) {
355
+ wrapper.style.transform = `translateX(${Math.abs(rect.left) + 16}px)`;
356
+ } else {
357
+ wrapper.style.transform = '';
358
+ }
359
+ }, [width, height, isOpen]);
360
+
361
+ return (
362
+ <Wrapper ref={wrapperRef} className={`is-${mode} ${className}`} {...rest}>
363
+ {groups.map((group) => (
364
+ <SubItemGroup key={group.label} label={group.label}>
365
+ {group.children.map((rows, i) => (
366
+ <Grid container key={i} columnSpacing={1} rowSpacing={1}>
367
+ {rows.map((item, j) => (
368
+ <Grid item xs={12} md={6} lg={4} key={j}>
369
+ <Item variant="panel" style={{ padding: '8px' }} {...item} />
370
+ </Grid>
371
+ ))}
372
+ </Grid>
373
+ ))}
374
+ </SubItemGroup>
375
+ ))}
376
+ </Wrapper>
377
+ );
378
+ }