@arcblock/ux 2.1.30 → 2.1.33
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 +37 -26
- package/lib/Layout/dashboard/index.js +2 -4
- package/lib/Layout/dashboard-legacy/index.js +2 -4
- package/lib/Locale/selector.js +34 -12
- package/lib/NavMenu/style.js +1 -1
- package/package.json +4 -4
- package/src/Footer/index.js +14 -11
- package/src/Layout/dashboard/index.js +1 -4
- package/src/Layout/dashboard-legacy/index.js +1 -4
- package/src/Locale/selector.js +35 -5
- package/src/NavMenu/style.js +2 -0
package/lib/Footer/index.js
CHANGED
|
@@ -11,6 +11,8 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
11
11
|
|
|
12
12
|
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
13
13
|
|
|
14
|
+
var _Container = _interopRequireDefault(require("@mui/material/Container"));
|
|
15
|
+
|
|
14
16
|
var _Util = require("../Util");
|
|
15
17
|
|
|
16
18
|
var _Logo = _interopRequireDefault(require("../Logo"));
|
|
@@ -35,32 +37,35 @@ function Footer(props) {
|
|
|
35
37
|
className: className,
|
|
36
38
|
style: style,
|
|
37
39
|
dark: dark,
|
|
38
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
className: "footer-
|
|
46
|
-
children: [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Container.default, {
|
|
41
|
+
maxWidth: false,
|
|
42
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
43
|
+
component: "div",
|
|
44
|
+
className: "footer",
|
|
45
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
46
|
+
component: "p",
|
|
47
|
+
className: "footer-item",
|
|
48
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
49
|
+
className: "footer-copy",
|
|
50
|
+
children: ["Copyright \xA9 ", copyYear, " "]
|
|
51
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
52
|
+
className: "footer-brand",
|
|
53
|
+
children: brand
|
|
54
|
+
})]
|
|
55
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
56
|
+
component: "p",
|
|
57
|
+
className: "footer-item",
|
|
58
|
+
style: {
|
|
59
|
+
justifyContent: 'flex-end',
|
|
60
|
+
flexShrink: 0
|
|
61
|
+
},
|
|
62
|
+
children: ["Powered by", /*#__PURE__*/(0, _jsxRuntime.jsx)(_Logo.default, {
|
|
63
|
+
mode: dark ? 'light' : 'dark',
|
|
64
|
+
layout: "horizontal",
|
|
65
|
+
className: "logo-container"
|
|
66
|
+
})]
|
|
62
67
|
})]
|
|
63
|
-
})
|
|
68
|
+
})
|
|
64
69
|
})
|
|
65
70
|
});
|
|
66
71
|
}
|
|
@@ -83,4 +88,10 @@ Footer.defaultProps = {
|
|
|
83
88
|
const Container = _styledComponents.default.div.withConfig({
|
|
84
89
|
displayName: "Footer__Container",
|
|
85
90
|
componentId: "sc-1qpifuv-0"
|
|
86
|
-
})(["margin-top:64px;padding:24px 0 32px;border-top:1px solid ", ";box-sizing:border-box;width:100%;@media (max-width:540px){padding:8px 0;}.footer{display:flex;align-items:center;justify-content:space-between;.footer-item{color:", ";display:flex;align-items:center;flex-wrap:wrap;font-size:0.9rem;}.footer-brand{margin-left:8px;margin-right:8px;}.logo-container{margin:
|
|
91
|
+
})(["margin-top:64px;padding:24px 0 32px;border-top:1px solid ", ";box-sizing:border-box;width:100%;@media (max-width:540px){padding:8px 0;}.footer{display:flex;align-items:center;justify-content:space-between;.footer-item{color:", ";display:flex;align-items:center;flex-wrap:wrap;font-size:0.9rem;}.footer-brand{margin-left:8px;margin-right:8px;}.logo-container{margin-left:24px;width:90px;opacity:0.5;}@media (max-width:540px){.footer-item{font-size:0.7rem;}.logo-container{margin:0 0 0 16px;width:70px;height:40px;}}@media (max-width:380px){.footer-item{font-size:0.65rem;}.logo-container{margin:0 0 0 8px;height:24px;}}}"], props => props.dark ? props.theme.palette.grey[900] : '#dee2e7', _ref => {
|
|
92
|
+
let {
|
|
93
|
+
theme,
|
|
94
|
+
dark
|
|
95
|
+
} = _ref;
|
|
96
|
+
return dark ? theme.palette.grey[500] : theme.palette.grey[900];
|
|
97
|
+
});
|
|
@@ -131,9 +131,7 @@ function Dashboard(_ref2) {
|
|
|
131
131
|
maxWidth: false
|
|
132
132
|
}), {}, {
|
|
133
133
|
children: children
|
|
134
|
-
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Footer.default, {
|
|
135
|
-
className: "dashboard-footer"
|
|
136
|
-
})]
|
|
134
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Footer.default, {})]
|
|
137
135
|
})]
|
|
138
136
|
})]
|
|
139
137
|
}));
|
|
@@ -155,7 +153,7 @@ Dashboard.defaultProps = {
|
|
|
155
153
|
const Wrapper = _styledComponents.default.div.withConfig({
|
|
156
154
|
displayName: "dashboard__Wrapper",
|
|
157
155
|
componentId: "sc-arvc7q-0"
|
|
158
|
-
})(["&.dashboard{display:flex;flex-direction:column;height:100vh;}.dashboard-body{overflow:hidden;flex:1;}.dashboard-sidebar{box-sizing:border-box;flex:0 0 auto;width:104px;&:hover{overflow-y:auto;}}.dashboard-main{display:flex;flex-direction:column;overflow:auto;flex:1;}.dashboard-content{flex:1;}
|
|
156
|
+
})(["&.dashboard{display:flex;flex-direction:column;height:100vh;}.dashboard-body{overflow:hidden;flex:1;}.dashboard-sidebar{box-sizing:border-box;flex:0 0 auto;width:104px;&:hover{overflow-y:auto;}}.dashboard-main{display:flex;flex-direction:column;overflow:auto;flex:1;}.dashboard-content{flex:1;}"]);
|
|
159
157
|
|
|
160
158
|
const StyledUxHeader = (0, _styledComponents.default)(_Header.ResponsiveHeader).withConfig({
|
|
161
159
|
displayName: "dashboard__StyledUxHeader",
|
|
@@ -46,7 +46,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
46
46
|
const Wrapper = _styledComponents.default.div.withConfig({
|
|
47
47
|
displayName: "dashboard-legacy__Wrapper",
|
|
48
48
|
componentId: "sc-z8z10v-0"
|
|
49
|
-
})(["&.dashboard{display:flex;flex-direction:column;height:100vh;}.dashboard__body{overflow:hidden;flex:1;}.dashboard__main{display:flex;flex-direction:column;overflow:auto;flex:1;}.dashboard__content{flex:1;}.
|
|
49
|
+
})(["&.dashboard{display:flex;flex-direction:column;height:100vh;}.dashboard__body{overflow:hidden;flex:1;}.dashboard__main{display:flex;flex-direction:column;overflow:auto;flex:1;}.dashboard__content{flex:1;}.drawerPaper{position:relative;white-space:nowrap;width:120px;background:", ";box-shadow:2px 16px 10px 0 rgba(0,0,0,", ");border:0;}"], props => props.theme.palette.background.default, props => props.theme.mode === 'light' ? 0.05 : 0.5);
|
|
50
50
|
|
|
51
51
|
function Dashboard(_ref) {
|
|
52
52
|
let {
|
|
@@ -126,9 +126,7 @@ function Dashboard(_ref) {
|
|
|
126
126
|
maxWidth: isFullWidth ? false : 'lg',
|
|
127
127
|
className: "dashboard__content",
|
|
128
128
|
children: children
|
|
129
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Footer.default, {
|
|
130
|
-
className: "dashboard__footer"
|
|
131
|
-
})]
|
|
129
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Footer.default, {})]
|
|
132
130
|
})]
|
|
133
131
|
})]
|
|
134
132
|
}));
|
package/lib/Locale/selector.js
CHANGED
|
@@ -41,7 +41,7 @@ var _globeLight = _interopRequireDefault(require("./images/globe-light.png"));
|
|
|
41
41
|
|
|
42
42
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
43
43
|
|
|
44
|
-
const _excluded = ["dark", "showText", "popperProps"];
|
|
44
|
+
const _excluded = ["dark", "showText", "popperProps", "popperType", "icon"];
|
|
45
45
|
|
|
46
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
47
47
|
|
|
@@ -59,7 +59,9 @@ function LocaleSelector(props) {
|
|
|
59
59
|
const {
|
|
60
60
|
dark,
|
|
61
61
|
showText,
|
|
62
|
-
popperProps
|
|
62
|
+
popperProps,
|
|
63
|
+
popperType,
|
|
64
|
+
icon: Icon
|
|
63
65
|
} = props,
|
|
64
66
|
rest = _objectWithoutProperties(props, _excluded);
|
|
65
67
|
|
|
@@ -88,23 +90,39 @@ function LocaleSelector(props) {
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
const ButtonComponent = showText ? _Button.default : _IconButton.default;
|
|
91
|
-
|
|
93
|
+
const handleEventProps = popperType === 'hover' ? {
|
|
94
|
+
onMouseEnter: () => {
|
|
95
|
+
setOpen(true);
|
|
96
|
+
},
|
|
97
|
+
onMouseLeave: onClose
|
|
98
|
+
} : {
|
|
99
|
+
onClick: () => {
|
|
100
|
+
setOpen(!open);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const renderIcon = (0, _react.useMemo)(() => {
|
|
104
|
+
if (Icon) {
|
|
105
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
109
|
+
src: dark ? _globeDark.default : _globeLight.default,
|
|
110
|
+
className: "trigger-image",
|
|
111
|
+
alt: "globe"
|
|
112
|
+
});
|
|
113
|
+
}, [Icon, dark]);
|
|
114
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, _objectSpread(_objectSpread(_objectSpread({
|
|
92
115
|
component: "div",
|
|
93
116
|
dark: dark,
|
|
94
117
|
theme: theme
|
|
95
|
-
}, rest), {}, {
|
|
118
|
+
}, rest), handleEventProps), {}, {
|
|
96
119
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(ButtonComponent, {
|
|
97
120
|
ref: anchorEl,
|
|
98
121
|
className: "trigger",
|
|
99
|
-
onClick: () => setOpen(!open),
|
|
100
122
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
101
123
|
display: "flex",
|
|
102
124
|
alignItems: "center",
|
|
103
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
104
|
-
src: dark ? _globeDark.default : _globeLight.default,
|
|
105
|
-
className: "trigger-image",
|
|
106
|
-
alt: "globe"
|
|
107
|
-
}), showText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
125
|
+
children: [renderIcon, showText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
108
126
|
component: "strong",
|
|
109
127
|
className: "trigger-text",
|
|
110
128
|
children: _context.languages.find(x => x.value === locale).text
|
|
@@ -146,14 +164,18 @@ LocaleSelector.propTypes = {
|
|
|
146
164
|
size: _propTypes.default.number,
|
|
147
165
|
showText: _propTypes.default.bool,
|
|
148
166
|
popperProps: _propTypes.default.object,
|
|
149
|
-
onChange: _propTypes.default.func
|
|
167
|
+
onChange: _propTypes.default.func,
|
|
168
|
+
popperType: _propTypes.default.oneOf(['hover', 'click']),
|
|
169
|
+
icon: _propTypes.default.any
|
|
150
170
|
};
|
|
151
171
|
LocaleSelector.defaultProps = {
|
|
152
172
|
dark: false,
|
|
153
173
|
showText: true,
|
|
154
174
|
size: 24,
|
|
155
175
|
popperProps: {},
|
|
156
|
-
onChange: () => {}
|
|
176
|
+
onChange: () => {},
|
|
177
|
+
popperType: 'click',
|
|
178
|
+
icon: null
|
|
157
179
|
};
|
|
158
180
|
var _default = LocaleSelector;
|
|
159
181
|
exports.default = _default;
|
package/lib/NavMenu/style.js
CHANGED
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
const NavMenuBase = _styledComponents.default.nav.withConfig({
|
|
13
13
|
displayName: "style__NavMenuBase",
|
|
14
14
|
componentId: "sc-2g7isz-0"
|
|
15
|
-
})(["background-color:", ";font-size:14px;ul{list-style:none;margin:0;padding:0;}.navmenu-item,.navmenu-sub{display:flex;align-items:center;}a{color:inherit;}.navmenu-item,.navmenu-sub{color:", ";}.navmenu-item--active,.navmenu-item:hover,.navmenu-sub--opened{color:", ";}.navmenu-item{position:relative;cursor:pointer;transition:color 0.2s ease-in-out;a{text-decoration:none;white-space:nowrap;}a::before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:transparent;content:'';}}.navmenu-sub{position:relative;cursor:pointer;}.navmenu-item-icon,.navmenu-sub-icon,.navmenu-sub-expand-icon{display:flex;line-height:1;}.navmenu-item-icon,.navmenu-sub-icon{margin-right:4px;}.navmenu-item-icon > *,.navmenu-sub-icon > *{font-size:1.5em;}.navmenu-sub-expand-icon{margin-left:8px;> *{width:0.8em;height:0.8em;transition:transform 0.2s ease-in-out;}}"], props => props.$bgColor, props => props.$textColor, props => props.$activeTextColor);
|
|
15
|
+
})(["background-color:", ";font-size:14px;ul{list-style:none;margin:0;padding:0;}.navmenu-item,.navmenu-sub{display:flex;align-items:center;}a{color:inherit;}.navmenu-item,.navmenu-sub{color:", ";}.navmenu-item--active,.navmenu-item:hover,.navmenu-sub--opened{color:", ";}.navmenu-item{position:relative;cursor:pointer;transition:color 0.2s ease-in-out;a{text-decoration:none;white-space:nowrap;}a::before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:transparent;content:'';}}.navmenu-sub{position:relative;cursor:pointer;}.navmenu-item-icon,.navmenu-sub-icon,.navmenu-sub-expand-icon{display:flex;line-height:1;}.navmenu-item-icon,.navmenu-sub-icon{margin-right:4px;}.navmenu-item-icon > *,.navmenu-sub-icon > *{width:auto;max-height:20px;font-size:1.5em;}.navmenu-sub-expand-icon{margin-left:8px;> *{width:0.8em;height:0.8em;transition:transform 0.2s ease-in-out;}}"], props => props.$bgColor, props => props.$textColor, props => props.$activeTextColor);
|
|
16
16
|
|
|
17
17
|
const HorizontalStyle = (0, _styledComponents.default)(NavMenuBase).withConfig({
|
|
18
18
|
displayName: "style__HorizontalStyle",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.33",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"react": ">=18.1.0",
|
|
53
53
|
"react-ga": "^2.7.0"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "616c11e20c48d33f153258bcf00eba030dabf648",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@arcblock/icons": "^2.1.
|
|
58
|
-
"@arcblock/react-hooks": "^2.1.
|
|
57
|
+
"@arcblock/icons": "^2.1.33",
|
|
58
|
+
"@arcblock/react-hooks": "^2.1.33",
|
|
59
59
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
60
|
"@emotion/react": "^11.9.0",
|
|
61
61
|
"@emotion/styled": "^11.8.1",
|
package/src/Footer/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import Typography from '@mui/material/Typography';
|
|
5
|
+
import MuiContainer from '@mui/material/Container';
|
|
5
6
|
|
|
6
7
|
import { mergeProps } from '../Util';
|
|
7
8
|
import Logo from '../Logo';
|
|
@@ -15,16 +16,18 @@ export default function Footer(props) {
|
|
|
15
16
|
|
|
16
17
|
return (
|
|
17
18
|
<Container className={className} style={style} dark={dark}>
|
|
18
|
-
<
|
|
19
|
-
<Typography component="
|
|
20
|
-
<
|
|
21
|
-
|
|
19
|
+
<MuiContainer maxWidth={false}>
|
|
20
|
+
<Typography component="div" className="footer">
|
|
21
|
+
<Typography component="p" className="footer-item">
|
|
22
|
+
<span className="footer-copy">Copyright © {copyYear} </span>
|
|
23
|
+
<span className="footer-brand">{brand}</span>
|
|
24
|
+
</Typography>
|
|
25
|
+
<Typography component="p" className="footer-item" style={{ justifyContent: 'flex-end', flexShrink: 0 }}>
|
|
26
|
+
Powered by
|
|
27
|
+
<Logo mode={dark ? 'light' : 'dark'} layout="horizontal" className="logo-container" />
|
|
28
|
+
</Typography>
|
|
22
29
|
</Typography>
|
|
23
|
-
|
|
24
|
-
Powered by
|
|
25
|
-
<Logo mode={dark ? 'light' : 'dark'} layout="horizontal" className="logo-container" />
|
|
26
|
-
</Typography>
|
|
27
|
-
</Typography>
|
|
30
|
+
</MuiContainer>
|
|
28
31
|
</Container>
|
|
29
32
|
);
|
|
30
33
|
}
|
|
@@ -62,7 +65,7 @@ const Container = styled.div`
|
|
|
62
65
|
justify-content: space-between;
|
|
63
66
|
|
|
64
67
|
.footer-item {
|
|
65
|
-
color: ${(
|
|
68
|
+
color: ${({ theme, dark }) => (dark ? theme.palette.grey[500] : theme.palette.grey[900])};
|
|
66
69
|
display: flex;
|
|
67
70
|
align-items: center;
|
|
68
71
|
flex-wrap: wrap;
|
|
@@ -75,7 +78,7 @@ const Container = styled.div`
|
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
.logo-container {
|
|
78
|
-
margin:
|
|
81
|
+
margin-left: 24px;
|
|
79
82
|
width: 90px;
|
|
80
83
|
opacity: 0.5;
|
|
81
84
|
}
|
|
@@ -69,7 +69,7 @@ function Dashboard({ children, title, headerProps, links, fullWidth, ...rest })
|
|
|
69
69
|
<Container className="dashboard-content" {...(fullWidth && { maxWidth: false })}>
|
|
70
70
|
{children}
|
|
71
71
|
</Container>
|
|
72
|
-
<Footer
|
|
72
|
+
<Footer />
|
|
73
73
|
</Box>
|
|
74
74
|
</Box>
|
|
75
75
|
</Wrapper>
|
|
@@ -117,9 +117,6 @@ const Wrapper = styled.div`
|
|
|
117
117
|
.dashboard-content {
|
|
118
118
|
flex: 1;
|
|
119
119
|
}
|
|
120
|
-
.dashboard-footer {
|
|
121
|
-
padding-left: 30px;
|
|
122
|
-
}
|
|
123
120
|
`;
|
|
124
121
|
|
|
125
122
|
const StyledUxHeader = styled(ResponsiveHeader)`
|
|
@@ -30,9 +30,6 @@ const Wrapper = styled.div`
|
|
|
30
30
|
.dashboard__content {
|
|
31
31
|
flex: 1;
|
|
32
32
|
}
|
|
33
|
-
.dashboard__footer {
|
|
34
|
-
padding-left: 30px;
|
|
35
|
-
}
|
|
36
33
|
|
|
37
34
|
.drawerPaper {
|
|
38
35
|
position: relative;
|
|
@@ -105,7 +102,7 @@ export default function Dashboard({
|
|
|
105
102
|
<Container maxWidth={isFullWidth ? false : 'lg'} className="dashboard__content">
|
|
106
103
|
{children}
|
|
107
104
|
</Container>
|
|
108
|
-
<Footer
|
|
105
|
+
<Footer />
|
|
109
106
|
</Box>
|
|
110
107
|
</Box>
|
|
111
108
|
</Wrapper>
|
package/src/Locale/selector.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/jsx-no-bind */
|
|
2
|
-
import { useState, useContext, useRef } from 'react';
|
|
2
|
+
import { useState, useContext, useRef, useMemo } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
|
|
@@ -22,7 +22,7 @@ import globeDark from './images/globe-dark.png';
|
|
|
22
22
|
import globeLight from './images/globe-light.png';
|
|
23
23
|
|
|
24
24
|
function LocaleSelector(props) {
|
|
25
|
-
const { dark, showText, popperProps, ...rest } = props;
|
|
25
|
+
const { dark, showText, popperProps, popperType, icon: Icon, ...rest } = props;
|
|
26
26
|
const { locale, changeLocale } = useContext(LocaleContext);
|
|
27
27
|
const anchorEl = useRef(null);
|
|
28
28
|
const [open, setOpen] = useState(false);
|
|
@@ -43,11 +43,34 @@ function LocaleSelector(props) {
|
|
|
43
43
|
|
|
44
44
|
const ButtonComponent = showText ? Button : IconButton;
|
|
45
45
|
|
|
46
|
+
const handleEventProps =
|
|
47
|
+
popperType === 'hover'
|
|
48
|
+
? {
|
|
49
|
+
onMouseEnter: () => {
|
|
50
|
+
setOpen(true);
|
|
51
|
+
},
|
|
52
|
+
onMouseLeave: onClose,
|
|
53
|
+
}
|
|
54
|
+
: {
|
|
55
|
+
onClick: () => {
|
|
56
|
+
setOpen(!open);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const renderIcon = useMemo(() => {
|
|
61
|
+
if (Icon) {
|
|
62
|
+
return <Icon />;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return <img src={dark ? globeDark : globeLight} className="trigger-image" alt="globe" />;
|
|
66
|
+
}, [Icon, dark]);
|
|
67
|
+
|
|
46
68
|
return (
|
|
47
|
-
<Div component="div" dark={dark} theme={theme} {...rest}>
|
|
48
|
-
<ButtonComponent ref={anchorEl} className="trigger"
|
|
69
|
+
<Div component="div" dark={dark} theme={theme} {...rest} {...handleEventProps}>
|
|
70
|
+
<ButtonComponent ref={anchorEl} className="trigger">
|
|
49
71
|
<Box display="flex" alignItems="center">
|
|
50
|
-
|
|
72
|
+
{renderIcon}
|
|
73
|
+
|
|
51
74
|
{showText ? (
|
|
52
75
|
<Typography component="strong" className="trigger-text">
|
|
53
76
|
{languages.find((x) => x.value === locale).text}
|
|
@@ -57,6 +80,7 @@ function LocaleSelector(props) {
|
|
|
57
80
|
)}
|
|
58
81
|
</Box>
|
|
59
82
|
</ButtonComponent>
|
|
83
|
+
|
|
60
84
|
<Popper open={open} anchorEl={anchorEl.current} {...popperProps} disablePortal>
|
|
61
85
|
<div className="locales">
|
|
62
86
|
<ClickAwayListener onClickAway={onClose}>
|
|
@@ -84,6 +108,8 @@ LocaleSelector.propTypes = {
|
|
|
84
108
|
showText: PropTypes.bool,
|
|
85
109
|
popperProps: PropTypes.object,
|
|
86
110
|
onChange: PropTypes.func,
|
|
111
|
+
popperType: PropTypes.oneOf(['hover', 'click']),
|
|
112
|
+
icon: PropTypes.any,
|
|
87
113
|
};
|
|
88
114
|
|
|
89
115
|
LocaleSelector.defaultProps = {
|
|
@@ -92,6 +118,8 @@ LocaleSelector.defaultProps = {
|
|
|
92
118
|
size: 24,
|
|
93
119
|
popperProps: {},
|
|
94
120
|
onChange: () => {},
|
|
121
|
+
popperType: 'click',
|
|
122
|
+
icon: null,
|
|
95
123
|
};
|
|
96
124
|
|
|
97
125
|
export default LocaleSelector;
|
|
@@ -102,10 +130,12 @@ const Div = styled.div`
|
|
|
102
130
|
flex-direction: column;
|
|
103
131
|
justify-content: center;
|
|
104
132
|
font-size: 14px;
|
|
133
|
+
|
|
105
134
|
.trigger-image {
|
|
106
135
|
width: ${(props) => props.size}px;
|
|
107
136
|
height: ${(props) => props.size}px;
|
|
108
137
|
}
|
|
138
|
+
|
|
109
139
|
.trigger-text {
|
|
110
140
|
margin-left: 5px;
|
|
111
141
|
font-size: 14px;
|