@arcblock/ux 2.2.3 → 2.4.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 (119) hide show
  1. package/lib/ActivityIndicator/index.js +7 -9
  2. package/lib/Alert/index.js +6 -5
  3. package/lib/AnimationWaiter/index.js +6 -5
  4. package/lib/Badge/index.js +6 -5
  5. package/lib/Blocklet/blocklet.js +6 -5
  6. package/lib/Blocklet/utils.js +6 -5
  7. package/lib/BlockletNFT/index.js +6 -5
  8. package/lib/Center/index.js +6 -5
  9. package/lib/ClickToCopy/index.js +6 -5
  10. package/lib/CodeBlock/index.js +6 -5
  11. package/lib/ContactForm/index.js +6 -5
  12. package/lib/CookieConsent/index.js +6 -5
  13. package/lib/CountDown/index.js +6 -5
  14. package/lib/Datatable/CustomToolbar.js +7 -9
  15. package/lib/Datatable/DatatableContext.js +2 -2
  16. package/lib/Datatable/TableSearch.js +6 -5
  17. package/lib/Datatable/index.js +12 -15
  18. package/lib/Dialog/dialog.js +8 -10
  19. package/lib/Earth/index.js +7 -9
  20. package/lib/Empty/index.js +6 -5
  21. package/lib/ErrorBoundary/fallback.js +6 -5
  22. package/lib/Footer/index.js +6 -6
  23. package/lib/Header/auto-hidden.js +6 -5
  24. package/lib/Header/header.js +6 -5
  25. package/lib/Header/responsive-header.js +7 -9
  26. package/lib/Icon/image.js +6 -5
  27. package/lib/Icon/index.js +6 -5
  28. package/lib/InfoRow/index.js +6 -5
  29. package/lib/Layout/dashboard/index.js +56 -32
  30. package/lib/Layout/dashboard/sidebar.js +75 -37
  31. package/lib/Layout/dashboard/with-external-link.js +56 -0
  32. package/lib/Layout/dashboard-legacy/header.js +6 -5
  33. package/lib/Layout/dashboard-legacy/index.js +6 -5
  34. package/lib/Layout/dashboard-legacy/sidebar.js +10 -17
  35. package/lib/Layout/index.js +7 -9
  36. package/lib/Locale/selector.js +6 -5
  37. package/lib/Logo/index.js +6 -5
  38. package/lib/Metric/index.js +6 -6
  39. package/lib/NFTDisplay/aspect-ratio-container.js +6 -5
  40. package/lib/NFTDisplay/broken.js +6 -5
  41. package/lib/NFTDisplay/index.js +6 -5
  42. package/lib/NFTDisplay/loading.js +6 -5
  43. package/lib/NFTDisplay/svg-embedder/inline-svg.js +9 -11
  44. package/lib/NavMenu/style.js +8 -13
  45. package/lib/PricingTable/PricingPlan.js +6 -5
  46. package/lib/PricingTable/index.js +6 -5
  47. package/lib/Result/result.js +6 -5
  48. package/lib/Screenshot/index.js +6 -5
  49. package/lib/SplitButton/index.js +7 -9
  50. package/lib/Tag/index.js +6 -5
  51. package/lib/TextCollapse/index.js +6 -5
  52. package/lib/Theme/theme-provider.js +2 -3
  53. package/lib/Video/index.js +6 -5
  54. package/lib/Wallet/Action.js +6 -5
  55. package/lib/Wallet/Download.js +6 -5
  56. package/lib/Wallet/Open.js +6 -5
  57. package/lib/WechatPrompt/index.js +6 -5
  58. package/lib/withTheme/index.js +9 -5
  59. package/lib/withTracker/index.js +19 -34
  60. package/package.json +6 -8
  61. package/src/ActivityIndicator/index.js +1 -1
  62. package/src/Alert/index.js +1 -1
  63. package/src/AnimationWaiter/index.js +1 -1
  64. package/src/Badge/index.js +1 -1
  65. package/src/Blocklet/blocklet.js +1 -1
  66. package/src/Blocklet/utils.js +1 -1
  67. package/src/BlockletNFT/index.js +1 -1
  68. package/src/Center/index.js +1 -1
  69. package/src/ClickToCopy/index.js +1 -1
  70. package/src/CodeBlock/index.js +1 -1
  71. package/src/ContactForm/index.js +1 -1
  72. package/src/CookieConsent/index.js +1 -1
  73. package/src/CountDown/index.js +1 -1
  74. package/src/Datatable/CustomToolbar.js +1 -1
  75. package/src/Datatable/DatatableContext.js +2 -2
  76. package/src/Datatable/TableSearch.js +1 -1
  77. package/src/Datatable/index.js +5 -4
  78. package/src/Dialog/dialog.js +1 -1
  79. package/src/Earth/index.js +1 -1
  80. package/src/Empty/index.js +1 -1
  81. package/src/ErrorBoundary/fallback.js +1 -1
  82. package/src/Footer/index.js +1 -1
  83. package/src/Header/auto-hidden.js +1 -1
  84. package/src/Header/header.js +1 -1
  85. package/src/Header/responsive-header.js +1 -1
  86. package/src/Icon/image.js +1 -1
  87. package/src/Icon/index.js +1 -1
  88. package/src/InfoRow/index.js +1 -1
  89. package/src/Layout/dashboard/index.js +56 -27
  90. package/src/Layout/dashboard/sidebar.js +100 -18
  91. package/src/Layout/dashboard/with-external-link.js +20 -0
  92. package/src/Layout/dashboard-legacy/header.js +1 -1
  93. package/src/Layout/dashboard-legacy/index.js +1 -1
  94. package/src/Layout/dashboard-legacy/sidebar.js +4 -6
  95. package/src/Layout/index.js +1 -1
  96. package/src/Locale/selector.js +1 -1
  97. package/src/Logo/index.js +1 -1
  98. package/src/Metric/index.js +1 -1
  99. package/src/NFTDisplay/aspect-ratio-container.js +1 -1
  100. package/src/NFTDisplay/broken.js +1 -1
  101. package/src/NFTDisplay/index.js +1 -1
  102. package/src/NFTDisplay/loading.js +1 -1
  103. package/src/NFTDisplay/svg-embedder/inline-svg.js +2 -2
  104. package/src/NavMenu/style.js +1 -1
  105. package/src/PricingTable/PricingPlan.js +1 -1
  106. package/src/PricingTable/index.js +1 -1
  107. package/src/Result/result.js +1 -1
  108. package/src/Screenshot/index.js +1 -1
  109. package/src/SplitButton/index.js +1 -1
  110. package/src/Tag/index.js +1 -1
  111. package/src/TextCollapse/index.js +1 -1
  112. package/src/Theme/theme-provider.js +3 -4
  113. package/src/Video/index.js +1 -1
  114. package/src/Wallet/Action.js +1 -1
  115. package/src/Wallet/Download.js +1 -1
  116. package/src/Wallet/Open.js +1 -1
  117. package/src/WechatPrompt/index.js +1 -1
  118. package/src/withTheme/index.js +6 -4
  119. package/src/withTracker/index.js +20 -33
@@ -1,17 +1,19 @@
1
1
  import { useEffect, useMemo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withRouter, Link, useLocation, matchPath } from 'react-router-dom';
3
+ import { useLocation, matchPath } from 'react-router-dom';
4
4
  import Helmet from 'react-helmet';
5
- import styled from 'styled-components';
5
+ import styled from '@emotion/styled';
6
6
  import { useTheme } from '@mui/material/styles';
7
7
  import Container from '@mui/material/Container';
8
8
  import Hidden from '@mui/material/Hidden';
9
9
  import Box from '@mui/material/Box';
10
+ import clsx from 'clsx';
10
11
  import DashboardLegacy from '../dashboard-legacy';
11
12
  import { ResponsiveHeader } from '../../Header';
12
13
  import NavMenu from '../../NavMenu';
13
14
  import Footer from '../../Footer';
14
15
  import Sidebar from './sidebar';
16
+ import { Link } from './with-external-link';
15
17
 
16
18
  // 监听 location 变化并关闭 header 中的 menu (确保 drawer - disablePortal:false, keepMounted:true)
17
19
  // 直接监听 menu 中 link 点击来触发 closeMenu 会有问题 (Suspense & lazy)
@@ -25,21 +27,33 @@ function NavMenuWrapper({ closeMenu, ...rest }) {
25
27
  return <NavMenu {...rest} />;
26
28
  }
27
29
 
28
- function Dashboard({ children, title, headerProps, links, fullWidth, ...rest }) {
30
+ function formatLinks(links, location) {
31
+ return links.map((link) => {
32
+ if (Array.isArray(link)) {
33
+ return formatLinks(link, location);
34
+ }
35
+ return {
36
+ ...link,
37
+ label: (
38
+ <Link external={link.external} to={link.url}>
39
+ {link.title}
40
+ </Link>
41
+ ),
42
+ active: !!matchPath({ path: link.url, end: false }, location.pathname),
43
+ };
44
+ });
45
+ }
46
+
47
+ function Dashboard({ children, title, headerProps, links, fullWidth, dense, ...rest }) {
29
48
  const theme = useTheme();
30
49
  const location = useLocation();
31
- const navItems = useMemo(
32
- () =>
33
- links.map((link) => ({
34
- ...link,
35
- label: <Link to={link.url}>{link.title}</Link>,
36
- active: !!matchPath(location.pathname, { path: link.url, exact: false }),
37
- })),
38
- [location, links]
39
- );
50
+ const navItems = useMemo(() => formatLinks(links, location), [location, links]);
51
+ const flattendNavItems = navItems.flat();
52
+ const _dense = dense === 'auto' ? flattendNavItems.length >= 8 : dense;
53
+ const classes = clsx('dashboard', { 'dashboard-dense': _dense }, rest.className);
40
54
 
41
55
  return (
42
- <Wrapper {...rest} className={`dashboard ${rest.className}`}>
56
+ <Wrapper {...rest} className={classes}>
43
57
  <Helmet title={title} key={title} />
44
58
 
45
59
  <StyledUxHeader {...headerProps} $theme={theme}>
@@ -48,7 +62,7 @@ function Dashboard({ children, title, headerProps, links, fullWidth, ...rest })
48
62
  return (
49
63
  <NavMenuWrapper
50
64
  mode="inline"
51
- items={navItems}
65
+ items={flattendNavItems}
52
66
  closeMenu={closeMenu}
53
67
  bgColor="transparent"
54
68
  activeTextColor={theme.palette.primary.main}
@@ -62,7 +76,7 @@ function Dashboard({ children, title, headerProps, links, fullWidth, ...rest })
62
76
  <Box display="flex" className="dashboard-body">
63
77
  <Hidden mdDown>
64
78
  <Box className="dashboard-sidebar">
65
- <Sidebar links={links} />
79
+ <Sidebar links={links} dense={_dense} />
66
80
  </Box>
67
81
  </Hidden>
68
82
  <Box className="dashboard-main">
@@ -79,15 +93,21 @@ function Dashboard({ children, title, headerProps, links, fullWidth, ...rest })
79
93
  Dashboard.propTypes = {
80
94
  children: PropTypes.any.isRequired,
81
95
  title: PropTypes.string,
96
+ // 支持分组, links item 如果是数组, 则视为一个 group
82
97
  links: PropTypes.array.isRequired,
83
98
  headerProps: PropTypes.object,
84
99
  fullWidth: PropTypes.bool,
100
+ sidebarWidth: PropTypes.number,
101
+ // sidenav 稠密一些的布局, 纵向空间占用较少, 默认为 auto, 当 links 个数 > 8 时自动启用
102
+ dense: PropTypes.oneOf([true, false, 'auto']),
85
103
  };
86
104
 
87
105
  Dashboard.defaultProps = {
88
106
  title: 'Home',
89
107
  headerProps: {},
90
108
  fullWidth: false,
109
+ sidebarWidth: 120,
110
+ dense: 'auto',
91
111
  };
92
112
 
93
113
  const Wrapper = styled.div`
@@ -103,7 +123,7 @@ const Wrapper = styled.div`
103
123
  .dashboard-sidebar {
104
124
  box-sizing: border-box;
105
125
  flex: 0 0 auto;
106
- width: 104px;
126
+ width: ${(props) => props.sidebarWidth}px;
107
127
  &:hover {
108
128
  overflow-y: auto;
109
129
  }
@@ -117,24 +137,35 @@ const Wrapper = styled.div`
117
137
  .dashboard-content {
118
138
  flex: 1;
119
139
  }
120
- `;
121
-
122
- const StyledUxHeader = styled(ResponsiveHeader)`
123
- .header-container {
124
- max-width: 100%;
140
+ &.dashboard-dense {
141
+ .dashboard-sidebar {
142
+ width: auto;
143
+ }
125
144
  }
126
- ${(props) => props.$theme.breakpoints.up('md')} {
145
+ ${(props) => props.theme.breakpoints.up('md')} {
127
146
  .header-logo {
128
147
  display: flex;
129
148
  justify-content: center;
130
- /* logo 与 sidebar 中的 icon 垂直对齐, 104 - 24 * 2 = 56 */
131
- width: 56px;
149
+ /* logo 与 sidebar 中的 icon 垂直对齐, sidebarWidth - 24 * 2 */
150
+ width: ${(props) => props.sidebarWidth - 24 * 2}px;
151
+ }
152
+ &.dashboard-dense {
153
+ .header-logo {
154
+ /* dense = true 时 logo 与 sidenav icons 不需要对齐 */
155
+ width: auto;
156
+ }
132
157
  }
133
158
  }
134
159
  `;
135
160
 
161
+ const StyledUxHeader = styled(ResponsiveHeader)`
162
+ .header-container {
163
+ max-width: 100%;
164
+ }
165
+ `;
166
+
136
167
  // 兼容旧版 dashboard
137
- function DashboardWrapper({ legacy, ...rest }) {
168
+ export default function DashboardWrapper({ legacy, ...rest }) {
138
169
  if (legacy) {
139
170
  return <DashboardLegacy {...rest} />;
140
171
  }
@@ -150,5 +181,3 @@ DashboardWrapper.defaultProps = {
150
181
  ...Dashboard.defaultProps,
151
182
  legacy: true,
152
183
  };
153
-
154
- export default withRouter(DashboardWrapper);
@@ -1,27 +1,52 @@
1
+ /* eslint-disable react/no-array-index-key */
1
2
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
3
+ import styled from '@emotion/styled';
3
4
 
4
- import { NavLink } from 'react-router-dom';
5
5
  import Typography from '@mui/material/Typography';
6
6
  import { teal } from '@mui/material/colors';
7
+ import clsx from 'clsx';
8
+ import { NavLink } from './with-external-link';
7
9
 
8
- function Sidebar({ links, addons, ...rest }) {
10
+ // 渲染 links, group links 添加分隔线, 返回展平后的、包含分隔线元素的 links 数组
11
+ function renderLinks(links) {
12
+ const result = [];
13
+ links.forEach((item, index) => {
14
+ const prev = links[index - 1];
15
+ // 当当前元素和前一个元素仅有一个为 group (array) 时, 在当前元素前面位置添加一个分隔线元素
16
+ if (index > 0 && ((Array.isArray(prev) && !Array.isArray(item)) || (Array.isArray(item) && !Array.isArray(prev)))) {
17
+ result.push(<li className="layout-sidebar-divider" key={`divider-after-${index}`} />);
18
+ }
19
+ result.push(renderLinksItem(item));
20
+ });
21
+ return result.flat();
22
+ }
23
+
24
+ function renderLinksItem(item) {
25
+ if (Array.isArray(item)) {
26
+ return item.map(renderLinksItem);
27
+ }
28
+ const { url, icon, title, showBadge, external } = item;
29
+ return (
30
+ <li key={url}>
31
+ <NavLink
32
+ to={url}
33
+ external={external}
34
+ className={({ isActive }) =>
35
+ isActive ? 'layout-sidebar-link layout-sidebar-link--active' : 'layout-sidebar-link'
36
+ }>
37
+ <span className={`layout-sidebar-icon ${showBadge ? 'layout-sidebar-badge' : ''}`}>{icon}</span>
38
+ <Typography component="span" className="layout-sidebar-link-text">
39
+ {title}
40
+ </Typography>
41
+ </NavLink>
42
+ </li>
43
+ );
44
+ }
45
+
46
+ function Sidebar({ links, addons, dense, ...rest }) {
9
47
  return (
10
- <Root {...rest}>
11
- <ul>
12
- {links.map(({ url, icon, title, showBadge }) => {
13
- return (
14
- <li key={url}>
15
- <NavLink to={url} className="layout-sidebar-link" activeClassName="layout-sidebar-link--active">
16
- <span className={`layout-sidebar-icon ${showBadge ? 'layout-sidebar-badge' : ''}`}>{icon}</span>
17
- <Typography component="span" className="layout-sidebar-link-text">
18
- {title}
19
- </Typography>
20
- </NavLink>
21
- </li>
22
- );
23
- })}
24
- </ul>
48
+ <Root {...rest} className={clsx({ 'layout-sidebar-dense': dense })}>
49
+ <ul>{renderLinks(links)}</ul>
25
50
  <div style={{ flex: 1 }} />
26
51
  {addons}
27
52
  </Root>
@@ -31,10 +56,12 @@ function Sidebar({ links, addons, ...rest }) {
31
56
  Sidebar.propTypes = {
32
57
  links: PropTypes.array.isRequired,
33
58
  addons: PropTypes.any,
59
+ dense: PropTypes.bool,
34
60
  };
35
61
 
36
62
  Sidebar.defaultProps = {
37
63
  addons: null,
64
+ dense: false,
38
65
  };
39
66
 
40
67
  const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255, 230, 0))';
@@ -94,6 +121,61 @@ const Root = styled.div`
94
121
  text-transform: capitalize;
95
122
  letter-spacing: normal;
96
123
  }
124
+ .layout-sidebar-divider {
125
+ display: flex;
126
+ justify-content: center;
127
+ align-items: center;
128
+ &::after {
129
+ content: '';
130
+ display: inline-block;
131
+ width: 80px;
132
+ max-width: 100%;
133
+ border-bottom: 1px solid #ddd;
134
+ }
135
+ }
136
+ &.layout-sidebar-dense {
137
+ box-sizing: border-box;
138
+ height: 100%;
139
+ padding-top: 28px;
140
+ border-right: 1px solid #ddd;
141
+ .layout-sidebar-link {
142
+ flex-direction: row;
143
+ align-items: center;
144
+ padding: 10px 36px 10px 24px;
145
+ }
146
+ .layout-sidebar-icon {
147
+ display: inline-block;
148
+ width: 20px;
149
+ height: 20px;
150
+ margin-right: 12px;
151
+ > img,
152
+ > svg {
153
+ width: 20px;
154
+ height: 20px;
155
+ }
156
+ }
157
+ .layout-sidebar-badge {
158
+ &:after {
159
+ width: 6px;
160
+ height: 6px;
161
+ border-radius: 6px;
162
+ right: -2px;
163
+ top: 0;
164
+ }
165
+ }
166
+ .layout-sidebar-link-text {
167
+ margin-top: 0;
168
+ font-size: 14px;
169
+ }
170
+ .layout-sidebar-divider {
171
+ &::after {
172
+ content: '';
173
+ display: inline-block;
174
+ width: 100%;
175
+ margin: 12px 0;
176
+ }
177
+ }
178
+ }
97
179
  `;
98
180
 
99
181
  export default Sidebar;
@@ -0,0 +1,20 @@
1
+ import { Link as RouterLink, NavLink as RouterNavLink } from 'react-router-dom';
2
+
3
+ // 包裹 router Link/NavLink 组件, 支持 external link (external 为 true 时通过 click 事件跳转)
4
+ export function withExternalLink(RouterLinkComponent) {
5
+ // eslint-disable-next-line react/prop-types
6
+ return function WithExternalLink({ to, external, ...rest }) {
7
+ const handleClick = (e) => {
8
+ e.preventDefault();
9
+ window.location.href = to;
10
+ };
11
+ if (external) {
12
+ return <RouterLinkComponent onClick={handleClick} to={to} {...rest} />;
13
+ }
14
+ return <RouterLinkComponent to={to} {...rest} />;
15
+ };
16
+ }
17
+
18
+ export const Link = withExternalLink(RouterLink);
19
+
20
+ export const NavLink = withExternalLink(RouterNavLink);
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
  import Button from '@mui/material/IconButton';
4
4
  import AppBar from '@mui/material/AppBar';
5
5
  import Toolbar from '@mui/material/Toolbar';
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Helmet from 'react-helmet';
4
- import styled from 'styled-components';
4
+ import styled from '@emotion/styled';
5
5
  import Container from '@mui/material/Container';
6
6
  import Box from '@mui/material/Box';
7
7
  import Drawer from '@mui/material/Drawer';
@@ -1,8 +1,8 @@
1
1
  import { memo } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
3
+ import styled from '@emotion/styled';
4
4
 
5
- import { withRouter, Link } from 'react-router-dom';
5
+ import { Link, useLocation } from 'react-router-dom';
6
6
  import { useTheme } from '@mui/material/styles';
7
7
  import Button from '@mui/material/Button';
8
8
  import Typography from '@mui/material/Typography';
@@ -11,8 +11,9 @@ import { teal } from '@mui/material/colors';
11
11
  import ImageIcon from '../../Icon/image';
12
12
  import Logo from '../../Logo';
13
13
 
14
- function Sidebar({ location, images, links, prefix, addons, logo, ...rest }) {
14
+ export default function Sidebar({ images, links, prefix, addons, logo, ...rest }) {
15
15
  const theme = useTheme();
16
+ const location = useLocation();
16
17
  const isSelected = (url, name) => {
17
18
  const pattern = new RegExp(`/${name}`);
18
19
  return pattern.test(location.pathname);
@@ -47,7 +48,6 @@ function Sidebar({ location, images, links, prefix, addons, logo, ...rest }) {
47
48
  }
48
49
 
49
50
  Sidebar.propTypes = {
50
- location: PropTypes.object.isRequired,
51
51
  images: PropTypes.object.isRequired,
52
52
  links: PropTypes.array.isRequired,
53
53
  prefix: PropTypes.string,
@@ -116,5 +116,3 @@ const MenuItem = styled(Button)`
116
116
  }
117
117
  }
118
118
  `;
119
-
120
- export default withRouter(Sidebar);
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
3
+ import styled from '@emotion/styled';
4
4
  import Helmet from 'react-helmet';
5
5
  import Link from '@mui/material/Link';
6
6
 
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react/jsx-no-bind */
2
2
  import { useState, useContext, useRef, useMemo } from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import styled from 'styled-components';
4
+ import styled from '@emotion/styled';
5
5
 
6
6
  import { useTheme } from '@mui/material/styles';
7
7
  import Button from '@mui/material/Button';
package/src/Logo/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
 
4
4
  import { ReactComponent as LightLogo } from './images/logo-light-top.svg';
5
5
  import { ReactComponent as LightText } from './images/logo-light-text.svg';
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react/no-danger */
2
2
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
3
+ import styled from '@emotion/styled';
4
4
 
5
5
  import ImageIcon from '../Icon/image';
6
6
 
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
 
4
4
  function AspectRatioContainer({ aspect, children, ...rest }) {
5
5
  return (
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components';
1
+ import styled from '@emotion/styled';
2
2
  import BrokenImage from '@mui/icons-material/BrokenImage';
3
3
 
4
4
  export default function Broken() {
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable react-hooks/rules-of-hooks */
2
2
  import { useRef, useEffect, useState } from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import styled from 'styled-components';
4
+ import styled from '@emotion/styled';
5
5
  import clsx from 'clsx';
6
6
  import { Buffer } from 'buffer';
7
7
  import get from 'lodash/get';
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components';
1
+ import styled from '@emotion/styled';
2
2
 
3
3
  export default function Loading() {
4
4
  return <Root className="nft-display__loading">loading...</Root>;
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
3
- import root from 'react-shadow/styled-components';
2
+ import styled from '@emotion/styled';
3
+ import root from 'react-shadow/emotion';
4
4
 
5
5
  /**
6
6
  * inline svg 的方式嵌入 svg, 使用 shadow DOM 避免样式污染
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components';
1
+ import styled from '@emotion/styled';
2
2
 
3
3
  const NavMenuBase = styled.nav`
4
4
  background-color: ${(props) => props.$bgColor};
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
 
4
4
  import Card from '@mui/material/Card';
5
5
  import Button from '@mui/material/Button';
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
  import Grid from '@mui/material/Grid';
4
4
 
5
5
  import PricingPlan from './PricingPlan';
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
  import Box from '@mui/material/Box';
4
4
 
5
5
  function Result({ icon, title, description, extra, ...rest }) {
@@ -1,6 +1,6 @@
1
1
  import { createElement, Children, cloneElement } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
3
+ import styled from '@emotion/styled';
4
4
 
5
5
  import { mergeProps } from '../Util';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { useState, useRef, isValidElement } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
3
+ import styled from '@emotion/styled';
4
4
  import ExpandMore from '@mui/icons-material/ExpandMore';
5
5
  import Popper from '@mui/material/Popper';
6
6
  import Paper from '@mui/material/Paper';
package/src/Tag/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { forwardRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import styled from 'styled-components';
3
+ import styled from '@emotion/styled';
4
4
 
5
5
  import Typography from '@mui/material/Typography';
6
6
  import { useTheme } from '@mui/material/styles';
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
 
3
3
  import Typography from '@mui/material/Typography';
4
- import styled from 'styled-components';
4
+ import styled from '@emotion/styled';
5
5
 
6
6
  export default function TextCollapse({
7
7
  children,
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import { ThemeProvider as StyledThemeProvider } from 'styled-components';
2
+ import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
3
3
  import { ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
4
4
  import StyledEngineProvider from '@mui/material/StyledEngineProvider';
5
5
  import CssBaseline from '@mui/material/CssBaseline';
@@ -9,17 +9,16 @@ const defaultTheme = create();
9
9
 
10
10
  /**
11
11
  * 默认的 theme provider, 可以为 webapp/blocklet 快捷的配置好 mui theme provider
12
- * 注: 目前 UX 依赖 styled-components, 所以该组件也内置了一个 StyledThemeProvider
13
12
  */
14
13
  export default function ThemeProvider({ children, theme }) {
15
14
  return (
16
15
  // injectFirst 会影响 makeStyles 自定义样式和 mui styles 覆盖问题
17
16
  <StyledEngineProvider injectFirst>
18
17
  <MuiThemeProvider theme={theme}>
19
- <StyledThemeProvider theme={theme}>
18
+ <EmotionThemeProvider theme={theme}>
20
19
  <CssBaseline />
21
20
  {children}
22
- </StyledThemeProvider>
21
+ </EmotionThemeProvider>
23
22
  </MuiThemeProvider>
24
23
  </StyledEngineProvider>
25
24
  );
@@ -1,7 +1,7 @@
1
1
  import { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Player from 'react-player';
4
- import styled from 'styled-components';
4
+ import styled from '@emotion/styled';
5
5
 
6
6
  import CircularProgress from '@mui/material/CircularProgress';
7
7
 
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
 
4
4
  import Typography from '@mui/material/Typography';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
 
4
4
  import Typography from '@mui/material/Typography';
5
5
  import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- import styled from 'styled-components';
2
+ import styled from '@emotion/styled';
3
3
  import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
4
4
  import Fab from '@mui/material/Fab';
5
5
 
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components';
1
+ import styled from '@emotion/styled';
2
2
 
3
3
  import Typography from '@mui/material/Typography';
4
4
  import Dialog from '@mui/material/Dialog';
@@ -1,15 +1,17 @@
1
1
  import * as React from 'react';
2
- import { ThemeProvider, createGlobalStyle } from 'styled-components';
2
+ import { Global, ThemeProvider, css } from '@emotion/react';
3
3
  import { ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
4
4
  import CssBaseline from '@mui/material/CssBaseline';
5
5
 
6
6
  import { create } from '../Theme';
7
7
 
8
- const GlobalStyle = createGlobalStyle`
8
+ const globalStyles = css`
9
9
  font-family: ${(props) => props.theme.typography.fontFamily};
10
10
  color: ${(props) => props.theme.typography.color.main};
11
11
 
12
- a, a:hover, a:active {
12
+ a,
13
+ a:hover,
14
+ a:active {
13
15
  text-decoration: none;
14
16
  color: ${(props) => props.theme.palette.primary.dark};
15
17
  }
@@ -57,7 +59,7 @@ function withTheme(Component, { mode = 'light', pageWidth = 'md', palette, typog
57
59
  return (
58
60
  <MuiThemeProvider theme={this.theme}>
59
61
  <CssBaseline />
60
- <GlobalStyle theme={this.theme} />
62
+ <Global styles={globalStyles} />
61
63
  <ThemeProvider theme={this.theme}>
62
64
  <Component {...this.props} />
63
65
  </ThemeProvider>