@blocklet/launcher-layout 2.3.20 → 2.3.21
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/compact-layout.js +55 -34
- package/lib/content.js +67 -20
- package/lib/context/step.js +19 -28
- package/lib/header.js +224 -91
- package/lib/index.js +198 -101
- package/lib/info-list.js +45 -0
- package/lib/launch-result-message.js +116 -55
- package/lib/locale.js +1 -8
- package/lib/markdown-body.js +45 -21
- package/lib/nav.js +300 -51
- package/lib/page-header.js +51 -38
- package/lib/theme-provider.js +24 -32
- package/lib/wizard/server-eula.js +60 -41
- package/lib/wizard/wizard-desc.js +129 -114
- package/package.json +7 -21
- package/es/assets/blocklet-default-logo.png +0 -0
- package/es/compact-layout.js +0 -114
- package/es/content.js +0 -72
- package/es/context/step.js +0 -137
- package/es/header.js +0 -337
- package/es/index.js +0 -307
- package/es/launch-result-message.js +0 -144
- package/es/locale.js +0 -13
- package/es/markdown-body.js +0 -52
- package/es/nav.js +0 -405
- package/es/page-header.js +0 -66
- package/es/theme-provider.js +0 -41
- package/es/wizard/server-eula.js +0 -96
- package/es/wizard/wizard-desc.js +0 -332
package/lib/header.js
CHANGED
|
@@ -1,38 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
22
|
-
function AppHeader(_ref) {
|
|
23
|
-
let {
|
|
24
|
-
blockletMeta,
|
|
25
|
-
subTitle,
|
|
26
|
-
logoUrl,
|
|
27
|
-
locale,
|
|
28
|
-
navLogo,
|
|
29
|
-
loading
|
|
30
|
-
} = _ref;
|
|
31
|
-
const isMobile = (0, _useMediaQuery.default)(theme => theme.breakpoints.down('md'));
|
|
1
|
+
import Img from '@arcblock/ux/lib/Img';
|
|
2
|
+
import { getBlockletDisplayName } from '@blocklet/launcher-util/es/util';
|
|
3
|
+
import styled from '@emotion/styled';
|
|
4
|
+
import { Skeleton, useMediaQuery } from '@mui/material';
|
|
5
|
+
import isEmpty from 'is-empty';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { useEffect, useRef, useState } from 'react';
|
|
8
|
+
import joinUrl from 'url-join';
|
|
9
|
+
import defaultBlockletLogo from './assets/blocklet-default-logo.png';
|
|
10
|
+
import { getLaunchingText } from './locale';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
function AppHeader({
|
|
13
|
+
blockletMeta,
|
|
14
|
+
subTitle,
|
|
15
|
+
logoUrl,
|
|
16
|
+
locale,
|
|
17
|
+
navLogo,
|
|
18
|
+
loading
|
|
19
|
+
}) {
|
|
20
|
+
const isMobile = useMediaQuery(theme => theme.breakpoints.down('md'));
|
|
32
21
|
const blockletSize = isMobile ? 18 : 48;
|
|
33
|
-
const appNameRef =
|
|
34
|
-
const [appNameSize, setAppNameSize] =
|
|
35
|
-
|
|
22
|
+
const appNameRef = useRef(null);
|
|
23
|
+
const [appNameSize, setAppNameSize] = useState('');
|
|
24
|
+
useEffect(() => {
|
|
36
25
|
if (appNameRef.current && appNameRef.current.offsetHeight > 34) {
|
|
37
26
|
if (appNameSize === '') {
|
|
38
27
|
setAppNameSize('middle');
|
|
@@ -41,34 +30,34 @@ function AppHeader(_ref) {
|
|
|
41
30
|
}
|
|
42
31
|
}
|
|
43
32
|
}, [appNameSize]);
|
|
44
|
-
return /*#__PURE__*/(
|
|
33
|
+
return /*#__PURE__*/_jsxs(Container, {
|
|
45
34
|
className: appNameSize === 'small' ? 'center-mode' : '',
|
|
46
|
-
children: [isMobile ? /*#__PURE__*/(
|
|
35
|
+
children: [isMobile ? /*#__PURE__*/_jsx("div", {
|
|
47
36
|
className: "app-icon",
|
|
48
37
|
children: navLogo
|
|
49
|
-
}) : /*#__PURE__*/(
|
|
38
|
+
}) : /*#__PURE__*/_jsxs("div", {
|
|
50
39
|
className: "app-icon",
|
|
51
|
-
children: [loading && /*#__PURE__*/(
|
|
40
|
+
children: [loading && /*#__PURE__*/_jsx(AppIconSkeleton, {
|
|
52
41
|
blockletSize: blockletSize,
|
|
53
42
|
isMobile: isMobile
|
|
54
|
-
}), !loading && /*#__PURE__*/(
|
|
43
|
+
}), !loading && /*#__PURE__*/_jsx(AppIcon, {
|
|
55
44
|
blockletSize: blockletSize,
|
|
56
45
|
logoUrl: logoUrl
|
|
57
46
|
})]
|
|
58
|
-
}), /*#__PURE__*/(
|
|
47
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
59
48
|
className: "header-title",
|
|
60
|
-
children: [isMobile && subTitle && /*#__PURE__*/(
|
|
49
|
+
children: [isMobile && subTitle && /*#__PURE__*/_jsx("div", {
|
|
61
50
|
className: "header-title-sub",
|
|
62
51
|
children: subTitle
|
|
63
|
-
}), /*#__PURE__*/(
|
|
52
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
64
53
|
className: "app-name-content",
|
|
65
|
-
children: [!isMobile && /*#__PURE__*/(
|
|
54
|
+
children: [!isMobile && /*#__PURE__*/_jsx("div", {
|
|
66
55
|
className: "launching-context",
|
|
67
|
-
children: subTitle ||
|
|
68
|
-
}), /*#__PURE__*/(
|
|
69
|
-
className:
|
|
56
|
+
children: subTitle || getLaunchingText(locale)
|
|
57
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
58
|
+
className: `header-title-name ${appNameSize === 'middle' || appNameSize === 'small' ? 'middle-size' : ''}`,
|
|
70
59
|
ref: appNameRef,
|
|
71
|
-
children: /*#__PURE__*/(
|
|
60
|
+
children: /*#__PURE__*/_jsx(AppTitle, {
|
|
72
61
|
logoUrl: logoUrl,
|
|
73
62
|
isMobile: isMobile,
|
|
74
63
|
blockletMeta: blockletMeta,
|
|
@@ -81,12 +70,12 @@ function AppHeader(_ref) {
|
|
|
81
70
|
});
|
|
82
71
|
}
|
|
83
72
|
AppHeader.propTypes = {
|
|
84
|
-
blockletMeta:
|
|
85
|
-
subTitle:
|
|
86
|
-
logoUrl:
|
|
87
|
-
locale:
|
|
88
|
-
navLogo:
|
|
89
|
-
loading:
|
|
73
|
+
blockletMeta: PropTypes.object,
|
|
74
|
+
subTitle: PropTypes.any,
|
|
75
|
+
logoUrl: PropTypes.string,
|
|
76
|
+
locale: PropTypes.string,
|
|
77
|
+
navLogo: PropTypes.any,
|
|
78
|
+
loading: PropTypes.bool
|
|
90
79
|
};
|
|
91
80
|
AppHeader.defaultProps = {
|
|
92
81
|
subTitle: '',
|
|
@@ -98,13 +87,12 @@ AppHeader.defaultProps = {
|
|
|
98
87
|
};
|
|
99
88
|
|
|
100
89
|
// eslint-disable-next-line react/prop-types
|
|
101
|
-
function AppIconSkeleton(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
} = _ref2;
|
|
90
|
+
function AppIconSkeleton({
|
|
91
|
+
blockletSize,
|
|
92
|
+
isMobile
|
|
93
|
+
}) {
|
|
106
94
|
if (isMobile) {
|
|
107
|
-
return /*#__PURE__*/(
|
|
95
|
+
return /*#__PURE__*/_jsx(Skeleton, {
|
|
108
96
|
variant: "rectangular",
|
|
109
97
|
width: 100,
|
|
110
98
|
height: 16,
|
|
@@ -114,7 +102,7 @@ function AppIconSkeleton(_ref2) {
|
|
|
114
102
|
}
|
|
115
103
|
});
|
|
116
104
|
}
|
|
117
|
-
return /*#__PURE__*/(
|
|
105
|
+
return /*#__PURE__*/_jsx(Skeleton, {
|
|
118
106
|
variant: "rectangular",
|
|
119
107
|
width: blockletSize,
|
|
120
108
|
height: blockletSize
|
|
@@ -122,36 +110,34 @@ function AppIconSkeleton(_ref2) {
|
|
|
122
110
|
}
|
|
123
111
|
|
|
124
112
|
// eslint-disable-next-line react/prop-types
|
|
125
|
-
function AppIcon(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Img.default, {
|
|
113
|
+
function AppIcon({
|
|
114
|
+
logoUrl,
|
|
115
|
+
blockletSize
|
|
116
|
+
}) {
|
|
117
|
+
return /*#__PURE__*/_jsx(Img, {
|
|
131
118
|
// force update
|
|
132
119
|
width: blockletSize,
|
|
133
120
|
height: blockletSize,
|
|
134
121
|
src: logoUrl,
|
|
135
122
|
alt: "blocklet icon",
|
|
136
|
-
fallback:
|
|
123
|
+
fallback: defaultBlockletLogo,
|
|
137
124
|
style: {
|
|
138
125
|
verticalAlign: 'text-bottom'
|
|
139
126
|
}
|
|
140
|
-
},
|
|
127
|
+
}, `layout-app-icon-${logoUrl}`);
|
|
141
128
|
}
|
|
142
129
|
|
|
143
130
|
// eslint-disable-next-line react/prop-types
|
|
144
|
-
function AppTitle(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const name = (0, _util.getBlockletDisplayName)(blockletMeta);
|
|
131
|
+
function AppTitle({
|
|
132
|
+
isMobile,
|
|
133
|
+
logoUrl,
|
|
134
|
+
blockletMeta,
|
|
135
|
+
blockletSize,
|
|
136
|
+
loading
|
|
137
|
+
}) {
|
|
138
|
+
const name = getBlockletDisplayName(blockletMeta);
|
|
153
139
|
if (loading) {
|
|
154
|
-
return /*#__PURE__*/(
|
|
140
|
+
return /*#__PURE__*/_jsx(Skeleton, {
|
|
155
141
|
variant: "rectangular",
|
|
156
142
|
width: 100,
|
|
157
143
|
height: 16,
|
|
@@ -161,8 +147,8 @@ function AppTitle(_ref4) {
|
|
|
161
147
|
}
|
|
162
148
|
});
|
|
163
149
|
}
|
|
164
|
-
if ((
|
|
165
|
-
return /*#__PURE__*/(
|
|
150
|
+
if (isEmpty(blockletMeta)) {
|
|
151
|
+
return /*#__PURE__*/_jsx(Skeleton, {
|
|
166
152
|
variant: "rectangular",
|
|
167
153
|
animation: false,
|
|
168
154
|
width: 100,
|
|
@@ -174,30 +160,177 @@ function AppTitle(_ref4) {
|
|
|
174
160
|
});
|
|
175
161
|
}
|
|
176
162
|
if (isMobile) {
|
|
177
|
-
return /*#__PURE__*/(
|
|
178
|
-
children: [/*#__PURE__*/(
|
|
163
|
+
return /*#__PURE__*/_jsxs(MobileTitleStyle, {
|
|
164
|
+
children: [/*#__PURE__*/_jsx(AppIcon, {
|
|
179
165
|
blockletSize: blockletSize,
|
|
180
166
|
logoUrl: logoUrl
|
|
181
|
-
}), /*#__PURE__*/(
|
|
167
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
182
168
|
className: "ellipsis-title",
|
|
183
|
-
children:
|
|
169
|
+
children: getBlockletDisplayName(blockletMeta)
|
|
184
170
|
})]
|
|
185
171
|
});
|
|
186
172
|
}
|
|
187
|
-
return /*#__PURE__*/(
|
|
173
|
+
return /*#__PURE__*/_jsx(AppLink, {
|
|
188
174
|
target: "_blank",
|
|
189
|
-
href: (
|
|
175
|
+
href: joinUrl(blockletMeta?.registryUrl || '', `/blocklets/${blockletMeta?.did}`),
|
|
190
176
|
title: name,
|
|
191
177
|
children: name
|
|
192
178
|
});
|
|
193
179
|
}
|
|
194
|
-
const MobileTitleStyle =
|
|
180
|
+
const MobileTitleStyle = styled.div`
|
|
181
|
+
.ellipsis-title {
|
|
182
|
+
flex: 1;
|
|
183
|
+
position: absolute;
|
|
184
|
+
left: 0;
|
|
185
|
+
top: 0;
|
|
186
|
+
width: 100%;
|
|
187
|
+
height: 100%;
|
|
188
|
+
white-space: nowrap;
|
|
189
|
+
overflow: hidden;
|
|
190
|
+
text-overflow: ellipsis;
|
|
191
|
+
|
|
192
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
193
|
+
left: 26px;
|
|
194
|
+
width: calc(100% - 26px);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
195
198
|
AppTitle.propTypes = {
|
|
196
|
-
blockletMeta:
|
|
199
|
+
blockletMeta: PropTypes.object
|
|
197
200
|
};
|
|
198
201
|
AppTitle.defaultProps = {
|
|
199
202
|
blockletMeta: {}
|
|
200
203
|
};
|
|
201
|
-
|
|
202
|
-
const AppLink =
|
|
203
|
-
|
|
204
|
+
export default AppHeader;
|
|
205
|
+
const AppLink = styled.a`
|
|
206
|
+
color: ${props => props.theme.palette.common.black};
|
|
207
|
+
text-decoration: none;
|
|
208
|
+
overflow: hidden;
|
|
209
|
+
text-overflow: ellipsis;
|
|
210
|
+
display: -webkit-box;
|
|
211
|
+
-webkit-line-clamp: 2;
|
|
212
|
+
-webkit-box-orient: vertical;
|
|
213
|
+
font-family: Lato, Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
|
|
214
|
+
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
215
|
+
text-decoration: none;
|
|
216
|
+
font-weight: 700;
|
|
217
|
+
-webkit-font-smoothing: antialiased;
|
|
218
|
+
|
|
219
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
220
|
+
display: block;
|
|
221
|
+
max-width: calc(100vw - 150px);
|
|
222
|
+
white-space: nowrap;
|
|
223
|
+
overflow: hidden;
|
|
224
|
+
text-overflow: ellipsis;
|
|
225
|
+
}
|
|
226
|
+
`;
|
|
227
|
+
const Container = styled.div`
|
|
228
|
+
display: flex;
|
|
229
|
+
justify-content: flex-start;
|
|
230
|
+
align-items: flex-start;
|
|
231
|
+
width: 100%;
|
|
232
|
+
${props => props.theme.breakpoints.up('md')} {
|
|
233
|
+
min-height: 70px;
|
|
234
|
+
}
|
|
235
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
236
|
+
align-items: center;
|
|
237
|
+
}
|
|
238
|
+
.app-name-content {
|
|
239
|
+
width: 100%;
|
|
240
|
+
display: flex;
|
|
241
|
+
align-items: center;
|
|
242
|
+
justify-content: center;
|
|
243
|
+
${props => props.theme.breakpoints.up('md')} {
|
|
244
|
+
align-items: flex-start;
|
|
245
|
+
flex-direction: column;
|
|
246
|
+
}
|
|
247
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
248
|
+
justify-content: flex-start;
|
|
249
|
+
height: 22px;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
.launching-context {
|
|
253
|
+
flex-shrink: 0;
|
|
254
|
+
font-size: 14px;
|
|
255
|
+
font-weight: 600;
|
|
256
|
+
color: ${props => props.theme.palette.grey[500]};
|
|
257
|
+
${props => props.theme.breakpoints.up('md')} {
|
|
258
|
+
margin-bottom: 4px;
|
|
259
|
+
}
|
|
260
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
261
|
+
font-size: 14px;
|
|
262
|
+
line-height: 15px;
|
|
263
|
+
&:after {
|
|
264
|
+
display: inline-block;
|
|
265
|
+
margin: 0 4px;
|
|
266
|
+
content: ':';
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
&.center-mode {
|
|
272
|
+
align-items: flex-start;
|
|
273
|
+
.launching-context {
|
|
274
|
+
${props => props.theme.breakpoints.up('sm')} {
|
|
275
|
+
margin-bottom: 0;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.app-icon {
|
|
281
|
+
flex-shrink: 0;
|
|
282
|
+
> * {
|
|
283
|
+
display: block;
|
|
284
|
+
vertical-align: middle;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.header-title {
|
|
289
|
+
flex: 1;
|
|
290
|
+
display: flex;
|
|
291
|
+
flex-direction: column;
|
|
292
|
+
justify-content: space-around;
|
|
293
|
+
align-items: flex-start;
|
|
294
|
+
margin-left: 24px;
|
|
295
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
296
|
+
margin-left: 16px;
|
|
297
|
+
}
|
|
298
|
+
.header-title-name {
|
|
299
|
+
position: relative;
|
|
300
|
+
display: flex;
|
|
301
|
+
justify-content: center;
|
|
302
|
+
align-items: center;
|
|
303
|
+
flex: 1;
|
|
304
|
+
height: 100%;
|
|
305
|
+
color: ${props => props.theme.palette.common.black};
|
|
306
|
+
font-weight: 700;
|
|
307
|
+
${props => props.theme.breakpoints.up('sm')} {
|
|
308
|
+
font-size: 18px;
|
|
309
|
+
|
|
310
|
+
&.middle-size {
|
|
311
|
+
font-size: 16px;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
315
|
+
display: block;
|
|
316
|
+
max-width: calc(100vw - 100px);
|
|
317
|
+
font-size: 16px;
|
|
318
|
+
white-space: nowrap;
|
|
319
|
+
overflow: hidden;
|
|
320
|
+
text-overflow: ellipsis;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.header-title-sub {
|
|
325
|
+
color: ${props => props.theme.palette.grey[700]};
|
|
326
|
+
font-size: 12px;
|
|
327
|
+
line-height: 16px;
|
|
328
|
+
|
|
329
|
+
${props => props.theme.breakpoints.down('md')} {
|
|
330
|
+
white-space: nowrap;
|
|
331
|
+
overflow: hidden;
|
|
332
|
+
text-overflow: ellipsis;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
`;
|