@blocklet/ui-react 1.17.13 → 1.17.16
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.
- package/lib/Footer/index.js +1 -1
- package/lib/Header/index.js +28 -15
- package/package.json +5 -4
- package/src/Footer/index.js +4 -0
- package/src/Header/index.js +19 -7
package/lib/Footer/index.js
CHANGED
|
@@ -80,7 +80,7 @@ Footer.defaultProps = {
|
|
|
80
80
|
const Root = _styledComponents.default.div.withConfig({
|
|
81
81
|
displayName: "Footer__Root",
|
|
82
82
|
componentId: "sc-1iwl1nd-0"
|
|
83
|
-
})(["padding:32px 40px;border-top:1px solid #eee;color:#9397a1;", " .footer_line{display:flex;justify-content:space-between;}.footer_line + .footer_line{margin-top:32px;}.footer_brand{display:flex;align-items:center;color:#777;img{height:36px;}span{margin-left:8px;font-size:20px;}}.footer_nav{> *{background:transparent;}}", "{.footer_line{flex-direction:column;}.footer_line + .footer_line{margin-top:0;}.footer_brand{img{height:24px;}span{font-size:16px;}}}"], _ref2 => {
|
|
83
|
+
})(["padding:32px 40px;border-top:1px solid #eee;color:#9397a1;", " .footer_line{display:flex;justify-content:space-between;}.footer_line + .footer_line{margin-top:32px;}.footer_brand{display:flex;align-items:center;color:#777;img{height:36px;}span{margin-left:8px;font-size:20px;}}.footer_nav{.navmenu{padding-left:0;padding-right:0;}> *{background:transparent;}}", "{.footer_line{flex-direction:column;}.footer_line + .footer_line{margin-top:0;}.footer_brand{img{height:24px;}span{font-size:16px;}}}"], _ref2 => {
|
|
84
84
|
let {
|
|
85
85
|
$bgcolor
|
|
86
86
|
} = _ref2;
|
package/lib/Header/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
13
|
|
|
14
|
-
var _Header =
|
|
14
|
+
var _Header = require("@arcblock/ux/lib/Header");
|
|
15
15
|
|
|
16
16
|
var _NavMenu = _interopRequireDefault(require("@arcblock/ux/lib/NavMenu"));
|
|
17
17
|
|
|
@@ -23,6 +23,8 @@ var _selector = _interopRequireDefault(require("@arcblock/ux/lib/Locale/selector
|
|
|
23
23
|
|
|
24
24
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
25
25
|
|
|
26
|
+
require("@iconify/iconify");
|
|
27
|
+
|
|
26
28
|
const _excluded = ["blockletMeta", "addons"];
|
|
27
29
|
|
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -42,9 +44,15 @@ const isLinkActive = link => {
|
|
|
42
44
|
|
|
43
45
|
const parseNavigation = navigation => {
|
|
44
46
|
const parseItem = item => {
|
|
47
|
+
const icon = item.icon ? /*#__PURE__*/_react.default.createElement("span", {
|
|
48
|
+
className: "iconify",
|
|
49
|
+
"data-icon": item.icon
|
|
50
|
+
}) : null;
|
|
51
|
+
|
|
45
52
|
if (item.items) {
|
|
46
53
|
return {
|
|
47
54
|
label: item.title,
|
|
55
|
+
icon,
|
|
48
56
|
children: item.items.map(parseItem)
|
|
49
57
|
};
|
|
50
58
|
}
|
|
@@ -64,7 +72,8 @@ const parseNavigation = navigation => {
|
|
|
64
72
|
label: /*#__PURE__*/_react.default.createElement("a", Object.assign({
|
|
65
73
|
href: item.link
|
|
66
74
|
}, props), item.title),
|
|
67
|
-
active: isLinkActive(item.link)
|
|
75
|
+
active: isLinkActive(item.link),
|
|
76
|
+
icon
|
|
68
77
|
};
|
|
69
78
|
};
|
|
70
79
|
|
|
@@ -146,18 +155,22 @@ function Header(_ref) {
|
|
|
146
155
|
alt: "logo"
|
|
147
156
|
})),
|
|
148
157
|
brand: appName,
|
|
149
|
-
mobile: {
|
|
150
|
-
enableMenu: false,
|
|
151
|
-
hideLogo: false
|
|
152
|
-
},
|
|
153
158
|
addons: renderAddons()
|
|
154
159
|
}, rest, {
|
|
155
160
|
$bgcolor: blockletTheme === null || blockletTheme === void 0 ? void 0 : blockletTheme.background
|
|
156
|
-
}),
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
}), !(navItems !== null && navItems !== void 0 && navItems.length) ? null : _ref2 => {
|
|
162
|
+
let {
|
|
163
|
+
isMobile,
|
|
164
|
+
closeMenu
|
|
165
|
+
} = _ref2;
|
|
166
|
+
return /*#__PURE__*/_react.default.createElement(_NavMenu.default, {
|
|
167
|
+
mode: isMobile ? 'inline' : 'horizontal',
|
|
168
|
+
items: navItems,
|
|
169
|
+
onSelected: closeMenu,
|
|
170
|
+
className: "header-nav",
|
|
171
|
+
bgColor: "transparent"
|
|
172
|
+
});
|
|
173
|
+
});
|
|
161
174
|
}
|
|
162
175
|
|
|
163
176
|
Header.propTypes = {
|
|
@@ -171,12 +184,12 @@ Header.defaultProps = {
|
|
|
171
184
|
blockletMeta: null,
|
|
172
185
|
addons: null
|
|
173
186
|
};
|
|
174
|
-
const StyledUxHeader = (0, _styledComponents.default)(_Header.
|
|
187
|
+
const StyledUxHeader = (0, _styledComponents.default)(_Header.ResponsiveHeader).withConfig({
|
|
175
188
|
displayName: "Header__StyledUxHeader",
|
|
176
189
|
componentId: "sc-kcf4st-0"
|
|
177
|
-
})(["", " .header-logo{min-width:40px;}.header-nav{.navmenu-sub .navmenu-item{min-width:80px;}}"],
|
|
190
|
+
})(["", " .header-logo{min-width:40px;}.header-nav{.navmenu-sub .navmenu-item{min-width:80px;}}"], _ref3 => {
|
|
178
191
|
let {
|
|
179
192
|
$bgcolor
|
|
180
|
-
} =
|
|
181
|
-
return
|
|
193
|
+
} = _ref3;
|
|
194
|
+
return "background-color: ".concat($bgcolor || '#fff', ";");
|
|
182
195
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.16",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -34,8 +34,9 @@
|
|
|
34
34
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@arcblock/did-connect": "^1.17.
|
|
38
|
-
"@arcblock/ux": "^1.17.
|
|
37
|
+
"@arcblock/did-connect": "^1.17.16",
|
|
38
|
+
"@arcblock/ux": "^1.17.16",
|
|
39
|
+
"@iconify/iconify": "^2.2.1",
|
|
39
40
|
"@material-ui/core": "^4.12.3",
|
|
40
41
|
"core-js": "^3.6.4",
|
|
41
42
|
"styled-components": "^5.0.0"
|
|
@@ -55,5 +56,5 @@
|
|
|
55
56
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
56
57
|
"jest": "^24.1.0"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "acab741ed856df9b4def509821a1ab6217350625"
|
|
59
60
|
}
|
package/src/Footer/index.js
CHANGED
package/src/Header/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
-
import
|
|
4
|
+
import { ResponsiveHeader } from '@arcblock/ux/lib/Header';
|
|
5
5
|
import NavMenu from '@arcblock/ux/lib/NavMenu';
|
|
6
6
|
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
7
7
|
import SessionManager from '@arcblock/did-connect/lib/SessionManager';
|
|
8
8
|
import LocaleSelector from '@arcblock/ux/lib/Locale/selector';
|
|
9
9
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
10
|
+
import '@iconify/iconify';
|
|
10
11
|
|
|
11
12
|
const isLinkActive = link => {
|
|
12
13
|
if (window.location.pathname === '/') {
|
|
@@ -18,9 +19,11 @@ const isLinkActive = link => {
|
|
|
18
19
|
// blocklet meta 中的 navigation 数据 => NavMenu 组件的 items
|
|
19
20
|
const parseNavigation = navigation => {
|
|
20
21
|
const parseItem = item => {
|
|
22
|
+
const icon = item.icon ? <span className="iconify" data-icon={item.icon} /> : null;
|
|
21
23
|
if (item.items) {
|
|
22
24
|
return {
|
|
23
25
|
label: item.title,
|
|
26
|
+
icon,
|
|
24
27
|
children: item.items.map(parseItem),
|
|
25
28
|
};
|
|
26
29
|
}
|
|
@@ -40,6 +43,7 @@ const parseNavigation = navigation => {
|
|
|
40
43
|
</a>
|
|
41
44
|
),
|
|
42
45
|
active: isLinkActive(item.link),
|
|
46
|
+
icon,
|
|
43
47
|
};
|
|
44
48
|
};
|
|
45
49
|
const items = navigation.map(parseItem);
|
|
@@ -97,13 +101,21 @@ export default function Header({ blockletMeta, addons, ...rest }) {
|
|
|
97
101
|
</a>
|
|
98
102
|
}
|
|
99
103
|
brand={appName}
|
|
100
|
-
mobile={{ enableMenu: false, hideLogo: false }}
|
|
101
104
|
addons={renderAddons()}
|
|
102
105
|
{...rest}
|
|
103
106
|
$bgcolor={blockletTheme?.background}>
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
{/* blocklet.yml 没有配置 navigation 时, 则为 children 传入 null, 此时 ResponsiveHeader 会渲染普通的不带 menu 的 Header */}
|
|
108
|
+
{!navItems?.length
|
|
109
|
+
? null
|
|
110
|
+
: ({ isMobile, closeMenu }) => (
|
|
111
|
+
<NavMenu
|
|
112
|
+
mode={isMobile ? 'inline' : 'horizontal'}
|
|
113
|
+
items={navItems}
|
|
114
|
+
onSelected={closeMenu}
|
|
115
|
+
className="header-nav"
|
|
116
|
+
bgColor="transparent"
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
107
119
|
</StyledUxHeader>
|
|
108
120
|
);
|
|
109
121
|
}
|
|
@@ -121,8 +133,8 @@ Header.defaultProps = {
|
|
|
121
133
|
addons: null,
|
|
122
134
|
};
|
|
123
135
|
|
|
124
|
-
const StyledUxHeader = styled(
|
|
125
|
-
${({ $bgcolor }) =>
|
|
136
|
+
const StyledUxHeader = styled(ResponsiveHeader)`
|
|
137
|
+
${({ $bgcolor }) => `background-color: ${$bgcolor || '#fff'};`}
|
|
126
138
|
.header-logo {
|
|
127
139
|
min-width: 40px;
|
|
128
140
|
}
|