@arcblock/ux 2.13.12 → 2.13.14

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 (144) hide show
  1. package/lib/ActivityIndicator/index.js +9 -5
  2. package/lib/Address/did-address.js +14 -7
  3. package/lib/Address/responsive-did-address.js +3 -1
  4. package/lib/BlockletV2/blocklet.js +1 -1
  5. package/lib/CloseButton/index.js +1 -2
  6. package/lib/Colors/index.d.ts +1 -3
  7. package/lib/Colors/index.js +2 -4
  8. package/lib/Colors/themes/default.d.ts +3 -66
  9. package/lib/Colors/themes/default.js +4 -74
  10. package/lib/Colors/themes/did-connect.d.ts +11 -6
  11. package/lib/Colors/themes/did-connect.js +17 -12
  12. package/lib/Colors/themes/temp.d.ts +3 -0
  13. package/lib/Colors/themes/temp.js +3 -0
  14. package/lib/Config/config-provider.d.ts +4 -5
  15. package/lib/Config/config-provider.js +7 -26
  16. package/lib/Config/theme-mode-toggle.js +0 -1
  17. package/lib/DID/index.js +3 -4
  18. package/lib/DIDConnect/app-icon.d.ts +8 -0
  19. package/lib/DIDConnect/app-icon.js +31 -0
  20. package/lib/DIDConnect/app-info-item.d.ts +7 -0
  21. package/lib/DIDConnect/app-info-item.js +73 -0
  22. package/lib/DIDConnect/did-connect-footer.d.ts +4 -0
  23. package/lib/DIDConnect/did-connect-footer.js +54 -0
  24. package/lib/DIDConnect/did-connect-logo.d.ts +1 -0
  25. package/lib/DIDConnect/did-connect-logo.js +11 -0
  26. package/lib/DIDConnect/index.d.ts +7 -0
  27. package/lib/DIDConnect/index.js +7 -0
  28. package/lib/DIDConnect/powered-by.d.ts +3 -0
  29. package/lib/DIDConnect/powered-by.js +46 -0
  30. package/lib/DIDConnect/with-container.d.ts +11 -0
  31. package/lib/DIDConnect/with-container.js +273 -0
  32. package/lib/DIDConnect/with-ux-theme.d.ts +1 -0
  33. package/lib/DIDConnect/with-ux-theme.js +23 -0
  34. package/lib/Datatable/CustomToolbar.js +3 -0
  35. package/lib/Datatable/index.js +105 -71
  36. package/lib/Dialog/confirm.d.ts +6 -1
  37. package/lib/Dialog/confirm.js +7 -3
  38. package/lib/Dialog/use-confirm.js +6 -0
  39. package/lib/Footer/index.js +2 -5
  40. package/lib/Header/header.js +3 -1
  41. package/lib/Header/responsive-header.js +3 -1
  42. package/lib/Layout/dashboard/index.js +14 -2
  43. package/lib/Layout/dashboard/sidebar.js +1 -2
  44. package/lib/LoadingMask/index.js +4 -3
  45. package/lib/Locale/selector.js +3 -3
  46. package/lib/Locale/util.d.ts +3 -3
  47. package/lib/Locale/util.js +6 -1
  48. package/lib/LoginButton/index.d.ts +12 -0
  49. package/lib/LoginButton/index.js +74 -0
  50. package/lib/NavMenu/nav-menu.js +14 -9
  51. package/lib/NavMenu/products.js +3 -1
  52. package/lib/NavMenu/style.js +7 -3
  53. package/lib/NavMenu/sub-item-group.js +1 -1
  54. package/lib/PhoneInput/country-select.js +2 -3
  55. package/lib/SessionBlocklet/index.js +3 -3
  56. package/lib/SessionUser/components/did-space.js +14 -28
  57. package/lib/SessionUser/components/logged-in.js +2 -2
  58. package/lib/SessionUser/components/quick-login-item.js +13 -11
  59. package/lib/SessionUser/components/session-user-item.js +5 -6
  60. package/lib/SessionUser/components/session-user-switch.js +15 -13
  61. package/lib/SessionUser/components/un-login.js +51 -38
  62. package/lib/SessionUser/components/user-info.js +9 -8
  63. package/lib/SessionUser/images/did-spaces.svg +7 -13
  64. package/lib/SharedBridge/index.d.ts +16 -0
  65. package/lib/SharedBridge/index.js +109 -0
  66. package/lib/SharedBridge/need-storage-access-api-dialog.d.ts +7 -0
  67. package/lib/SharedBridge/need-storage-access-api-dialog.js +212 -0
  68. package/lib/Success/index.js +8 -4
  69. package/lib/Switch/index.js +3 -3
  70. package/lib/Tabs/index.js +8 -9
  71. package/lib/Theme/index.d.ts +2 -2
  72. package/lib/Theme/index.js +1 -1
  73. package/lib/Theme/theme-provider.d.ts +5 -1
  74. package/lib/Theme/theme-provider.js +60 -5
  75. package/lib/Theme/theme.d.ts +6 -3
  76. package/lib/Theme/theme.js +55 -19
  77. package/lib/UserCard/Container/card.js +1 -1
  78. package/lib/UserCard/Container/dialog.js +1 -1
  79. package/lib/Util/iframe.d.ts +5 -0
  80. package/lib/Util/iframe.js +24 -0
  81. package/lib/Util/index.d.ts +18 -1
  82. package/lib/Util/index.js +90 -5
  83. package/lib/type.d.ts +5 -1
  84. package/package.json +8 -6
  85. package/src/ActivityIndicator/index.jsx +4 -4
  86. package/src/Address/did-address.tsx +5 -5
  87. package/src/Address/responsive-did-address.tsx +11 -1
  88. package/src/BlockletV2/blocklet.tsx +1 -1
  89. package/src/CloseButton/index.tsx +1 -2
  90. package/src/Colors/index.ts +2 -7
  91. package/src/Colors/themes/default.ts +4 -50
  92. package/src/Colors/themes/did-connect.ts +13 -6
  93. package/src/Colors/themes/temp.ts +3 -0
  94. package/src/Config/config-provider.tsx +17 -30
  95. package/src/Config/theme-mode-toggle.tsx +1 -1
  96. package/src/DID/index.tsx +3 -4
  97. package/src/DIDConnect/app-icon.tsx +36 -0
  98. package/src/DIDConnect/app-info-item.tsx +82 -0
  99. package/src/DIDConnect/did-connect-footer.tsx +51 -0
  100. package/src/DIDConnect/did-connect-logo.tsx +8 -0
  101. package/src/DIDConnect/index.ts +7 -0
  102. package/src/DIDConnect/powered-by.tsx +48 -0
  103. package/src/DIDConnect/with-container.tsx +307 -0
  104. package/src/DIDConnect/with-ux-theme.tsx +22 -0
  105. package/src/Datatable/CustomToolbar.jsx +1 -0
  106. package/src/Datatable/index.jsx +107 -70
  107. package/src/Dialog/confirm.jsx +31 -23
  108. package/src/Dialog/use-confirm.jsx +6 -0
  109. package/src/Footer/index.tsx +2 -2
  110. package/src/Header/header.tsx +1 -1
  111. package/src/Header/responsive-header.tsx +2 -0
  112. package/src/Layout/dashboard/index.tsx +8 -4
  113. package/src/Layout/dashboard/sidebar.tsx +1 -2
  114. package/src/LoadingMask/index.tsx +3 -4
  115. package/src/Locale/selector.tsx +3 -4
  116. package/src/Locale/util.ts +7 -2
  117. package/src/LoginButton/index.tsx +73 -0
  118. package/src/NavMenu/nav-menu.tsx +15 -10
  119. package/src/NavMenu/products.tsx +1 -1
  120. package/src/NavMenu/style.ts +5 -2
  121. package/src/NavMenu/sub-item-group.tsx +1 -1
  122. package/src/PhoneInput/country-select.tsx +2 -3
  123. package/src/SessionBlocklet/index.tsx +3 -3
  124. package/src/SessionUser/components/did-space.tsx +14 -10
  125. package/src/SessionUser/components/logged-in.tsx +2 -2
  126. package/src/SessionUser/components/quick-login-item.tsx +11 -12
  127. package/src/SessionUser/components/session-user-item.tsx +3 -6
  128. package/src/SessionUser/components/session-user-switch.tsx +13 -12
  129. package/src/SessionUser/components/un-login.tsx +41 -33
  130. package/src/SessionUser/components/user-info.tsx +7 -8
  131. package/src/SessionUser/images/did-spaces.svg +7 -13
  132. package/src/SharedBridge/index.tsx +123 -0
  133. package/src/SharedBridge/need-storage-access-api-dialog.tsx +171 -0
  134. package/src/Success/index.tsx +6 -4
  135. package/src/Switch/index.jsx +3 -3
  136. package/src/Tabs/index.tsx +8 -9
  137. package/src/Theme/index.ts +2 -2
  138. package/src/Theme/theme-provider.tsx +73 -2
  139. package/src/Theme/theme.ts +73 -22
  140. package/src/UserCard/Container/card.tsx +1 -1
  141. package/src/UserCard/Container/dialog.tsx +1 -1
  142. package/src/Util/iframe.ts +19 -0
  143. package/src/Util/index.ts +102 -4
  144. package/src/type.d.ts +5 -1
@@ -1,54 +1,8 @@
1
+ import { BLOCKLET_THEME_LIGHT, type Theme } from '@blocklet/theme';
2
+
1
3
  /**
2
- * 默认 colors, ABT 系列
3
- *
4
- * - colors object 结构是在 mui theme#palette object 基础上调整后的结构
5
- * - 色值在 mui default theme 基础上将 figma 中常用的 colors 进行覆盖
6
- * - 扩展一些常用色值 (如 DID 系列)
7
- * - figma: https://www.figma.com/file/1qHyMF137EXOQpSFVByszG/UX-Library?node-id=295%3A1518
4
+ * @deprecated 请使用 MUI theme 对象替代
8
5
  */
9
- const colors = {
10
- common: {
11
- black: '#000',
12
- white: '#fff',
13
- },
14
- primary: { main: '#3773F2', contrastText: '#fff' }, // override
15
- secondary: { main: '#16CED1', contrastText: '#fff' }, // override
16
- error: { main: '#F16E6E', contrastText: '#fff' }, // override
17
- warning: { main: '#DE9E37', contrastText: '#fff' }, // override
18
- info: { main: '#0775F8', contrastText: '#fff' }, // override
19
- success: { main: '#34BE74', contrastText: '#fff' }, // override
20
- grey: {
21
- 50: '#fafafa',
22
- 100: '#f5f5f5',
23
- 200: '#eeeeee',
24
- 300: '#e0e0e0',
25
- 400: '#bdbdbd',
26
- 500: '#9e9e9e',
27
- 600: '#757575',
28
- 700: '#616161',
29
- 800: '#424242',
30
- 900: '#212121',
31
- A100: '#d5d5d5',
32
- A200: '#aaaaaa',
33
- A400: '#303030',
34
- A700: '#616161',
35
- },
36
- text: {
37
- primary: 'rgba(0, 0, 0, 0.87)',
38
- secondary: 'rgba(0, 0, 0, 0.54)',
39
- disabled: 'rgba(0, 0, 0, 0.38)',
40
- hint: 'rgba(0, 0, 0, 0.38)',
41
- },
42
- divider: 'rgba(0, 0, 0, 0.12)',
43
- background: {
44
- default: '#fff',
45
- },
46
- // 扩展色值, 适用于 did 相关的组件, 如果某些产品整体风格是 did 系列, 可以扩展出一个 did 系列的 theme
47
- did: {
48
- primary: '#4598FA',
49
- secondary: '#49C3AD',
50
- },
51
- // TODO: 等设计规范稳定后, 考虑扩展 trade 相关的常用颜色 (send/receive/exchange/transfer)
52
- };
6
+ const colors = BLOCKLET_THEME_LIGHT.palette as Theme['palette'];
53
7
 
54
8
  export default colors;
@@ -1,3 +1,8 @@
1
+ import type { Theme } from '@mui/material';
2
+
3
+ /**
4
+ * @deprecated 请使用 MUI theme 对象替代
5
+ */
1
6
  const colors = {
2
7
  background: {
3
8
  overlay: 'rgba(15, 23, 42, 0.5)',
@@ -10,7 +15,7 @@ const colors = {
10
15
  text: {
11
16
  primary: '#18181B',
12
17
  secondary: '#71717B',
13
- disable: '#D4D4D8',
18
+ disabled: '#D4D4D8',
14
19
  hint: '#D4D4D8',
15
20
  },
16
21
  state: {
@@ -23,37 +28,39 @@ const colors = {
23
28
  main: '#2B7FFF',
24
29
  light: '#51A2FF',
25
30
  dark: '#155DFC',
31
+ contrastText: '#fff',
26
32
  },
27
33
  secondary: {
28
34
  main: '#615FFF',
29
35
  light: '#7C86FF',
30
36
  dark: '#4F39F6',
37
+ contrastText: '#fff',
31
38
  },
32
39
  error: {
33
40
  main: '#FB2C36',
34
41
  light: '#FF6467',
35
42
  dark: '#E7000B',
43
+ contrastText: '#fff',
36
44
  },
37
45
  warning: {
38
46
  main: '#FF6900',
39
47
  light: '#FF8904',
40
48
  dark: '#F54900',
49
+ contrastText: '#fff',
41
50
  },
42
51
  info: {
43
52
  main: '#2B7FFF',
44
53
  light: '#51A2FF',
45
54
  dark: '#155DFC',
55
+ contrastText: '#fff',
46
56
  },
47
57
  success: {
48
58
  main: '#00C950',
49
59
  light: '#05DF72',
50
60
  dark: '#00A63E',
61
+ contrastText: '#fff',
51
62
  },
52
- divider: {
53
- main: 'rgba(18, 22, 24, 0.06)',
54
- light: '#F4F4F5',
55
- dark: '#D4D4D5',
56
- },
63
+ divider: 'rgba(18, 22, 24, 0.06)',
57
64
  };
58
65
 
59
66
  export default colors;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @deprecated 请使用 MUI theme 对象替代
3
+ */
1
4
  const colors = {
2
5
  textMuted: 'rgba(18, 22, 24, 0.36)',
3
6
  textSubtitle: 'rgba(18, 22, 24, 0.6)',
@@ -1,34 +1,33 @@
1
1
  import { createContext, useContext, ReactNode, useMemo, useState, useCallback, useEffect } from 'react';
2
- import { type PaletteMode } from '@mui/material';
3
- import type { ThemeOptions } from '@mui/material/styles';
4
- import useMediaQuery from '@mui/material/useMediaQuery';
2
+ import { ThemeOptions, type PaletteMode } from '@mui/material';
3
+ import { BLOCKLET_THEME_PREFER_KEY } from '@blocklet/theme';
5
4
  import set from 'lodash/set';
6
5
  import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
7
6
  import { LocaleProvider, LocaleProviderProps, useLocaleContext } from '../Locale/context';
8
7
  import ThemeProvider, { ThemeProviderProps } from '../Theme/theme-provider';
9
- import { createTheme, useTheme } from '../Theme';
8
+ import {
9
+ createTheme,
10
+ getDefaultThemePrefer,
11
+ lazyThemeConfig,
12
+ useTheme,
13
+ type UserThemeOptions,
14
+ type ThemeConfig,
15
+ } from '../Theme';
10
16
 
11
17
  export interface ConfigContextType {
12
18
  mode: PaletteMode;
13
- themeOptions: ThemeOptions;
19
+ themeOptions: UserThemeOptions;
14
20
  toggleMode: () => void;
15
21
  }
16
22
 
17
23
  const ConfigContext = createContext<ConfigContextType>({} as ConfigContextType);
18
- const preferThemeModeKey = 'blocklet_theme_prefer';
19
-
20
- export function isThemeRecord(
21
- theme: ThemeOptions | Record<PaletteMode, ThemeOptions>
22
- ): theme is Record<PaletteMode, ThemeOptions> {
23
- return 'light' in theme || 'dark' in theme;
24
- }
25
24
 
26
25
  export interface ConfigProviderProps
27
26
  extends Omit<LocaleProviderProps, 'translations'>,
28
27
  Omit<ThemeProviderProps, 'theme'> {
29
28
  children: ReactNode;
30
29
  prefer?: PaletteMode;
31
- theme?: ThemeOptions | Record<PaletteMode, ThemeOptions>;
30
+ theme?: UserThemeOptions | ((config: ThemeConfig) => UserThemeOptions);
32
31
  disableBlockletTheme?: boolean;
33
32
  translations?: Record<string, any>;
34
33
  }
@@ -50,33 +49,21 @@ export function ConfigProvider({
50
49
  languages,
51
50
  onLoadingTranslation,
52
51
  }: ConfigProviderProps) {
53
- const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
54
52
  const [mode, setMode] = useState<PaletteMode>(() => {
55
53
  if (prefer) {
56
54
  return prefer;
57
55
  }
58
56
 
59
- // 未启用暗色主题
60
- if (['1', 'true'].includes(window.blocklet?.USE_DARK_THEME) === false) {
61
- return 'light';
62
- }
63
-
64
- // 本地缓存
65
- const localPrefer = localStorage.getItem(preferThemeModeKey) as PaletteMode;
66
- if (localPrefer && (localPrefer === 'light' || localPrefer === 'dark')) {
67
- return localPrefer;
68
- }
69
-
70
- // 系统偏好
71
- return prefersDarkMode ? 'dark' : 'light';
57
+ return getDefaultThemePrefer();
72
58
  });
73
59
 
74
60
  const _themeOptions = useMemo(() => {
75
61
  let result: ThemeOptions = {};
62
+ const getThemeConfig = lazyThemeConfig(mode);
76
63
 
77
64
  if (themeOptions) {
78
- if (isThemeRecord(themeOptions)) {
79
- result = themeOptions[mode] ? { ...themeOptions[mode] } : {};
65
+ if (typeof themeOptions === 'function') {
66
+ result = themeOptions(getThemeConfig());
80
67
  } else {
81
68
  result = { ...themeOptions };
82
69
  }
@@ -95,7 +82,7 @@ export function ConfigProvider({
95
82
  const toggleMode = useCallback(() => {
96
83
  const newMode = mode === 'light' ? 'dark' : 'light';
97
84
  setMode(newMode);
98
- localStorage.setItem(preferThemeModeKey, newMode);
85
+ localStorage.setItem(BLOCKLET_THEME_PREFER_KEY, newMode);
99
86
  }, [mode, setMode]);
100
87
 
101
88
  const config = useMemo(
@@ -15,7 +15,7 @@ export default function ThemeModeToggle() {
15
15
  }
16
16
 
17
17
  return (
18
- <IconButton onClick={toggleMode} color="inherit">
18
+ <IconButton onClick={toggleMode}>
19
19
  {mode === 'light' ? <LightModeOutlinedIcon /> : <Brightness2OutlinedIcon />}
20
20
  </IconButton>
21
21
  );
package/src/DID/index.tsx CHANGED
@@ -9,7 +9,6 @@ import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
9
9
 
10
10
  import Address, { IDidAddressWrapper } from '../Address';
11
11
  import Avatar from '../Avatar';
12
- import { temp as colors } from '../Colors';
13
12
  import { DID_PREFIX } from '../Util/constant';
14
13
 
15
14
  import { HTMLDidAddressElement } from '../Address/did-address';
@@ -222,7 +221,7 @@ export const DID = forwardRef<HTMLDIDElement, DIDProps>((props, ref) => {
222
221
  flexShrink: 0,
223
222
  cursor: 'pointer',
224
223
  ml: 0.5,
225
- color: 'grey.500',
224
+ color: 'text.secondary',
226
225
  }}
227
226
  />
228
227
  ) : null}
@@ -290,7 +289,7 @@ export function DIDDialog({
290
289
  target="_blank"
291
290
  rel="noreferrer"
292
291
  sx={{
293
- color: colors.foregroundsFgInteractive,
292
+ color: 'secondary.main',
294
293
  textDecoration: 'none',
295
294
  '&:hover': {
296
295
  textDecoration: 'underline',
@@ -371,7 +370,7 @@ export function DIDDialog({
371
370
  <Typography
372
371
  variant="body2"
373
372
  sx={{
374
- color: colors.textSubtitle,
373
+ color: 'text.secondary',
375
374
  fontSize: '12px',
376
375
  mt: 1,
377
376
  }}>
@@ -0,0 +1,36 @@
1
+ import { useState } from 'react';
2
+ import { joinURL } from 'ufo';
3
+ import { SxProps } from '@mui/material';
4
+
5
+ import Img from '../Img';
6
+ import { isUrl } from '../Util';
7
+ import DidAvatar from '../Avatar';
8
+
9
+ type AppIconProps = {
10
+ appInfo: any;
11
+ size?: number;
12
+ sx?: SxProps;
13
+ };
14
+
15
+ export default function AppIcon({ appInfo, size = 32, ...rest }: AppIconProps) {
16
+ const [error, setError] = useState(false);
17
+ if (error || !(appInfo.appUrl || appInfo.appLogo)) {
18
+ return <DidAvatar did={appInfo.appPid} size={size} />;
19
+ }
20
+
21
+ let logoUrl = appInfo.appLogo || '';
22
+ if (!isUrl(logoUrl)) {
23
+ logoUrl = joinURL(appInfo.appUrl || '', logoUrl);
24
+ }
25
+
26
+ return (
27
+ <Img
28
+ src={logoUrl}
29
+ alt={appInfo.appName || 'Blocklet Icon'}
30
+ width={size}
31
+ height={size}
32
+ {...rest}
33
+ onError={() => setError(true)}
34
+ />
35
+ );
36
+ }
@@ -0,0 +1,82 @@
1
+ import { Box, IconButton, SxProps, Tooltip, useMediaQuery } from '@mui/material';
2
+ import CheckIcon from '@iconify-icons/material-symbols/check';
3
+ import { Icon } from '@iconify/react';
4
+
5
+ import DID from '../DID';
6
+ import { mergeSx } from '../Util/style';
7
+ import AppIcon from './app-icon';
8
+
9
+ export default function AppInfoItem({
10
+ appInfo,
11
+ active = false,
12
+ appLogo = null,
13
+ sx,
14
+ }: {
15
+ appInfo: any;
16
+ active?: boolean;
17
+ appLogo?: React.ReactNode;
18
+ sx?: SxProps;
19
+ }) {
20
+ const isTinyView = useMediaQuery('(max-width:400px)');
21
+
22
+ return (
23
+ <Box
24
+ sx={mergeSx(
25
+ {
26
+ display: 'flex',
27
+ alignItems: 'center',
28
+ fontWeight: 600,
29
+ color: 'text.primary',
30
+
31
+ '& .app-info-content': {
32
+ paddingLeft: '8px',
33
+ overflow: 'hidden',
34
+ },
35
+
36
+ '& .app-info-name': {
37
+ maxWidth: '100%',
38
+ lineHeight: 'normal',
39
+ whiteSpace: 'nowrap',
40
+ overflow: 'hidden',
41
+ textOverflow: 'ellipsis',
42
+ fontSize: '12px',
43
+ color: 'text.primary',
44
+ },
45
+ },
46
+ sx
47
+ )}>
48
+ {appLogo || (
49
+ <Box
50
+ sx={{
51
+ borderRadius: 1,
52
+ overflow: 'hidden',
53
+ fontSize: 0,
54
+ }}>
55
+ <AppIcon appInfo={appInfo} />
56
+ </Box>
57
+ )}
58
+
59
+ <Box className="app-info-content">
60
+ <Tooltip title={appInfo.appName} placement="top">
61
+ <Box className="app-info-name">{appInfo.appName}</Box>
62
+ </Tooltip>
63
+ {appInfo.appPid && (
64
+ <DID
65
+ className="app-info-did"
66
+ did={appInfo.appPid}
67
+ sx={{ fontSize: '10px !important' }}
68
+ copyable={false}
69
+ startChars={isTinyView ? 6 : 8}
70
+ endChars={isTinyView ? 6 : 8}
71
+ size={12}
72
+ />
73
+ )}
74
+ </Box>
75
+ {active ? (
76
+ <IconButton size="small" color="success">
77
+ <Icon icon={CheckIcon} color="success" />
78
+ </IconButton>
79
+ ) : null}
80
+ </Box>
81
+ );
82
+ }
@@ -0,0 +1,51 @@
1
+ import { Box, useMediaQuery } from '@mui/material';
2
+
3
+ import PoweredBy from './powered-by';
4
+ import AppInfoItem from './app-info-item';
5
+ import AppIcon from './app-icon';
6
+ import { getDIDColor, hexToRgba } from '../Util';
7
+
8
+ export default function DIDConnectFooter({
9
+ currentAppInfo = globalThis.blocklet,
10
+ currentAppColor = globalThis.blocklet?.appPid ? getDIDColor(globalThis.blocklet?.appPid) : '#fff',
11
+ }: {
12
+ currentAppInfo?: any;
13
+ currentAppColor?: string;
14
+ }) {
15
+ const isSmallView = useMediaQuery('(max-width:640px)');
16
+
17
+ return (
18
+ <Box
19
+ sx={{
20
+ display: 'flex',
21
+ justifyContent: 'space-between',
22
+ alignItems: 'center',
23
+ gap: 1,
24
+ fontSize: 12,
25
+ backgroundColor: hexToRgba(currentAppColor, 0.08),
26
+ // 需要保持跟 .did-connect__root 的规则一样
27
+ mx: isSmallView ? -2 : -3,
28
+ px: isSmallView ? 2 : 3,
29
+ py: 1.5,
30
+ // HACK: 极限条件下,footer 会溢出,使用隐藏的滚动条来处理这种情况(屏幕宽度小于 360 时会出现)
31
+ overflow: 'auto',
32
+ '&::-webkit-scrollbar': {
33
+ display: 'none', // 隐藏滚动条 (Webkit 浏览器)
34
+ },
35
+ '-ms-overflow-style': 'none', // 隐藏滚动条 (IE 浏览器)
36
+ 'scrollbar-width': 'none', // 隐藏滚动条 (Firefox)
37
+ }}
38
+ className="did-connect__footer">
39
+ <AppInfoItem
40
+ appInfo={currentAppInfo}
41
+ appLogo={<AppIcon appInfo={currentAppInfo} size={24} sx={{ flexShrink: 0 }} />}
42
+ sx={{
43
+ flex: 1,
44
+ overflow: 'hidden',
45
+ }}
46
+ />
47
+
48
+ <PoweredBy sx={{ maxWidth: '100%', justifyContent: 'end' }} />
49
+ </Box>
50
+ );
51
+ }
@@ -0,0 +1,8 @@
1
+ import DidBrandConnect from '@arcblock/icons/lib/DidBrandConnect';
2
+ import { useTheme } from '@mui/material';
3
+
4
+ export default function DidConnectLogo() {
5
+ const theme = useTheme();
6
+
7
+ return <DidBrandConnect style={{ filter: theme.palette.mode === 'dark' ? 'invert(1)' : 'none' }} />;
8
+ }
@@ -0,0 +1,7 @@
1
+ export { default as DIDConnectFooter } from './did-connect-footer';
2
+ export { default as AppInfoItem } from './app-info-item';
3
+ export { default as AppIcon } from './app-icon';
4
+ export { default as PoweredBy } from './powered-by';
5
+ export { default as withContainer } from './with-container';
6
+ export { default as withUxTheme } from './with-ux-theme';
7
+ export { default as DIDConnectLogo } from './did-connect-logo';
@@ -0,0 +1,48 @@
1
+ import { Box, useTheme } from '@mui/material';
2
+ import { Icon } from '@iconify/react';
3
+ import shieldCheckIcon from '@iconify-icons/mdi/shield-check';
4
+
5
+ import DidConnectLogo from './did-connect-logo';
6
+ import { mergeSx } from '../Util/style';
7
+
8
+ export default function PoweredBy({ ...rest }) {
9
+ const { palette } = useTheme();
10
+
11
+ return (
12
+ <Box
13
+ {...rest}
14
+ sx={mergeSx(
15
+ {
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ color: 'text.secondary',
20
+ gap: 0.5,
21
+ fontSize: 12,
22
+ fontFamily: 'Lexend',
23
+ whiteSpace: 'nowrap',
24
+ },
25
+ rest?.sx
26
+ )}>
27
+ <Icon icon={shieldCheckIcon} color={palette.success.main} />
28
+ Secured by
29
+ <Box
30
+ component="a"
31
+ href="https://www.didconnect.io/"
32
+ target="_blank"
33
+ rel="noopener"
34
+ sx={{
35
+ color: 'initial',
36
+ display: 'flex',
37
+ alignItems: 'center',
38
+ gap: 0.5,
39
+ textDecoration: 'none',
40
+ '&:hover': {
41
+ textDecoration: 'underline',
42
+ },
43
+ }}>
44
+ <DidConnectLogo />
45
+ </Box>
46
+ </Box>
47
+ );
48
+ }