@antv/dumi-theme-antv 0.1.0 → 0.2.2
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/README.md +47 -1
- package/es/antv/404/index.d.ts +2 -0
- package/es/antv/404/index.js +1 -0
- package/es/antv/Banner/Notification.d.ts +10 -0
- package/es/antv/Banner/index.d.ts +25 -0
- package/es/antv/Banner/index.js +25 -36
- package/es/antv/Cases/Cases.d.ts +18 -0
- package/es/antv/Cases/Cases.js +1 -3
- package/es/antv/Features/FeatureCard.d.ts +8 -0
- package/es/antv/Features/index.d.ts +15 -0
- package/es/antv/Features/index.js +1 -1
- package/es/antv/Footer/index.d.ts +12 -0
- package/es/antv/Footer/index.js +22 -17
- package/es/antv/Header/Logo.d.ts +4 -0
- package/es/antv/Products/Product.d.ts +14 -0
- package/es/antv/Products/Product.js +4 -4
- package/es/antv/Products/getNewProducts.d.ts +24 -0
- package/es/antv/Products/getNewProducts.js +3 -9
- package/es/antv/Products/getProducts.d.ts +51 -0
- package/es/antv/Products/getProducts.js +3 -9
- package/es/antv/Products/index.d.ts +9 -0
- package/es/antv/Products/index.js +2 -2
- package/es/antv/hooks.d.ts +14 -0
- package/es/antv/utils.d.ts +5 -0
- package/es/builtins/API.d.ts +3 -0
- package/es/builtins/Alert.d.ts +3 -0
- package/es/builtins/Alert.js +1 -3
- package/es/builtins/Badge.d.ts +3 -0
- package/es/builtins/Badge.js +1 -3
- package/es/builtins/Example.d.ts +5 -0
- package/es/builtins/Previewer.d.ts +39 -0
- package/es/builtins/Previewer.js +7 -7
- package/es/builtins/SourceCode.d.ts +10 -0
- package/es/builtins/SourceCode.js +5 -7
- package/es/builtins/Table.d.ts +4 -0
- package/es/builtins/Tree.d.ts +4 -0
- package/es/builtins/Tree.js +3 -9
- package/es/components/Dark.d.ts +9 -0
- package/es/components/LocaleSelect.d.ts +6 -0
- package/es/components/Navbar.d.ts +10 -0
- package/es/components/Navbar.js +3 -3
- package/es/components/SearchBar.d.ts +4 -0
- package/es/components/SearchBar.js +3 -5
- package/es/components/SideMenu.d.ts +10 -0
- package/es/components/SideMenu.js +5 -5
- package/es/components/SlugList.d.ts +7 -0
- package/es/components/SlugList.js +16 -11
- package/es/declaration.d.ts +1 -0
- package/es/layout.d.ts +5 -0
- package/es/layout.js +7 -7
- package/package.json +8 -3
- package/src/antv/Banner/index.tsx +51 -33
- package/src/declaration.d.ts +1 -0
- package/src/layout.tsx +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IPreviewerComponentProps } from 'dumi/theme';
|
|
3
|
+
import './Previewer.less';
|
|
4
|
+
export interface IPreviewerProps extends IPreviewerComponentProps {
|
|
5
|
+
/**
|
|
6
|
+
* enable transform to change CSS containing block for demo
|
|
7
|
+
*/
|
|
8
|
+
transform?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* modify background for demo area
|
|
11
|
+
*/
|
|
12
|
+
background?: string;
|
|
13
|
+
/**
|
|
14
|
+
* collapse padding of demo area
|
|
15
|
+
*/
|
|
16
|
+
compact?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* configurations for action button
|
|
19
|
+
*/
|
|
20
|
+
hideActions?: ('CSB' | 'EXTERNAL' | 'RIDDLE')[];
|
|
21
|
+
/**
|
|
22
|
+
* show source code by default
|
|
23
|
+
*/
|
|
24
|
+
defaultShowCode?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* use iframe mode for this demo
|
|
27
|
+
*/
|
|
28
|
+
iframe?: true | number;
|
|
29
|
+
/**
|
|
30
|
+
* replace builtin demo url
|
|
31
|
+
*/
|
|
32
|
+
demoUrl?: string;
|
|
33
|
+
/**
|
|
34
|
+
* control action bar render
|
|
35
|
+
*/
|
|
36
|
+
actionBarRender?: (actionBarNode: React.ReactNode) => React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
declare const Previewer: React.FC<IPreviewerProps>;
|
|
39
|
+
export default Previewer;
|
package/es/builtins/Previewer.js
CHANGED
|
@@ -24,10 +24,10 @@ import './Previewer.less';
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
function getSourceType(file, source) {
|
|
27
|
-
var
|
|
27
|
+
var _a; // use file extension as source type first
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
var type = (
|
|
29
|
+
|
|
30
|
+
var type = (_a = file.match(/\.(\w+)$/)) === null || _a === void 0 ? void 0 : _a[1];
|
|
31
31
|
|
|
32
32
|
if (!type) {
|
|
33
33
|
type = source.tsx ? 'tsx' : 'jsx';
|
|
@@ -37,7 +37,7 @@ function getSourceType(file, source) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
var Previewer = function Previewer(oProps) {
|
|
40
|
-
var
|
|
40
|
+
var _a, _b, _c;
|
|
41
41
|
|
|
42
42
|
var demoRef = useRef();
|
|
43
43
|
|
|
@@ -49,8 +49,8 @@ var Previewer = function Previewer(oProps) {
|
|
|
49
49
|
var demoUrl = props.demoUrl || builtinDemoUrl;
|
|
50
50
|
var isActive = (history === null || history === void 0 ? void 0 : history.location.hash) === "#".concat(props.identifier);
|
|
51
51
|
var isSingleFile = Object.keys(props.sources).length === 1;
|
|
52
|
-
var openCSB = useCodeSandbox(((
|
|
53
|
-
var openRiddle = useRiddle(((
|
|
52
|
+
var openCSB = useCodeSandbox(((_a = props.hideActions) === null || _a === void 0 ? void 0 : _a.includes('CSB')) ? null : props);
|
|
53
|
+
var openRiddle = useRiddle(((_b = props.hideActions) === null || _b === void 0 ? void 0 : _b.includes('RIDDLE')) ? null : props);
|
|
54
54
|
|
|
55
55
|
var _useMotions = useMotions(props.motions || [], demoRef.current),
|
|
56
56
|
_useMotions2 = _slicedToArray(_useMotions, 2),
|
|
@@ -168,7 +168,7 @@ var Previewer = function Previewer(oProps) {
|
|
|
168
168
|
onClick: function onClick() {
|
|
169
169
|
return setIframeKey(Math.random());
|
|
170
170
|
}
|
|
171
|
-
}), !((
|
|
171
|
+
}), !((_c = props.hideActions) === null || _c === void 0 ? void 0 : _c.includes('EXTERNAL')) && /*#__PURE__*/React.createElement(Link, {
|
|
172
172
|
target: "_blank",
|
|
173
173
|
to: demoUrl
|
|
174
174
|
}, /*#__PURE__*/React.createElement("button", {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Language } from 'prism-react-renderer';
|
|
2
|
+
import 'prismjs/themes/prism.css';
|
|
3
|
+
import './SourceCode.less';
|
|
4
|
+
export interface ICodeBlockProps {
|
|
5
|
+
code: string;
|
|
6
|
+
lang: Language;
|
|
7
|
+
showCopy?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: ({ code, lang, showCopy }: ICodeBlockProps) => JSX.Element;
|
|
10
|
+
export default _default;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
2
|
|
|
5
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -38,7 +36,7 @@ export default (function (_ref) {
|
|
|
38
36
|
|
|
39
37
|
return /*#__PURE__*/React.createElement("div", {
|
|
40
38
|
className: "__dumi-default-code-block"
|
|
41
|
-
}, /*#__PURE__*/React.createElement(Highlight,
|
|
39
|
+
}, /*#__PURE__*/React.createElement(Highlight, Object.assign({}, defaultProps, {
|
|
42
40
|
code: code,
|
|
43
41
|
language: SIMILAR_DSL[lang] || lang,
|
|
44
42
|
theme: undefined
|
|
@@ -58,14 +56,14 @@ export default (function (_ref) {
|
|
|
58
56
|
return copyCode(code);
|
|
59
57
|
}
|
|
60
58
|
}), tokens.map(function (line, i) {
|
|
61
|
-
return /*#__PURE__*/React.createElement("div", getLineProps({
|
|
59
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({}, getLineProps({
|
|
62
60
|
line: line,
|
|
63
61
|
key: i
|
|
64
|
-
}), line.map(function (token, key) {
|
|
65
|
-
return /*#__PURE__*/React.createElement("span", getTokenProps({
|
|
62
|
+
})), line.map(function (token, key) {
|
|
63
|
+
return /*#__PURE__*/React.createElement("span", Object.assign({}, getTokenProps({
|
|
66
64
|
token: token,
|
|
67
65
|
key: key
|
|
68
|
-
}));
|
|
66
|
+
})));
|
|
69
67
|
}));
|
|
70
68
|
}));
|
|
71
69
|
}));
|
package/es/builtins/Tree.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
2
|
|
|
9
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -76,13 +70,13 @@ function getTreeFromList(nodes) {
|
|
|
76
70
|
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
77
71
|
var data = [];
|
|
78
72
|
[].concat(nodes).forEach(function (node, i) {
|
|
79
|
-
var
|
|
73
|
+
var _a;
|
|
80
74
|
|
|
81
75
|
var key = "".concat(prefix ? "".concat(prefix, "-") : '').concat(i);
|
|
82
76
|
|
|
83
77
|
switch (node.type) {
|
|
84
78
|
case 'ul':
|
|
85
|
-
var parent = ((
|
|
79
|
+
var parent = ((_a = data[data.length - 1]) === null || _a === void 0 ? void 0 : _a.children) || data;
|
|
86
80
|
var ulLeafs = getTreeFromList(node.props.children || [], key);
|
|
87
81
|
parent.push.apply(parent, _toConsumableArray(ulLeafs));
|
|
88
82
|
break;
|
|
@@ -204,7 +198,7 @@ export default (function (props) {
|
|
|
204
198
|
itemHeight: 20,
|
|
205
199
|
showLine: true,
|
|
206
200
|
selectable: false,
|
|
207
|
-
motion:
|
|
201
|
+
motion: Object.assign(Object.assign({}, collapseMotion), {
|
|
208
202
|
motionAppear: false
|
|
209
203
|
}),
|
|
210
204
|
onClick: onClick,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC, MouseEvent } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './Navbar.less';
|
|
4
|
+
interface INavbarProps {
|
|
5
|
+
location: any;
|
|
6
|
+
navPrefix?: React.ReactNode;
|
|
7
|
+
onMobileMenuClick: (ev: MouseEvent<HTMLButtonElement>) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const Navbar: FC<INavbarProps>;
|
|
10
|
+
export default Navbar;
|
package/es/components/Navbar.js
CHANGED
|
@@ -116,9 +116,9 @@ var Navbar = function Navbar(_ref) {
|
|
|
116
116
|
verticalAlign: 'top'
|
|
117
117
|
}
|
|
118
118
|
}, title))), /*#__PURE__*/React.createElement("nav", null, navPrefix, navItems.map(function (nav) {
|
|
119
|
-
var
|
|
119
|
+
var _a;
|
|
120
120
|
|
|
121
|
-
var child = Boolean((
|
|
121
|
+
var child = Boolean((_a = nav.children) === null || _a === void 0 ? void 0 : _a.length) && /*#__PURE__*/React.createElement("ul", null, nav.children.map(function (item) {
|
|
122
122
|
return /*#__PURE__*/React.createElement("li", {
|
|
123
123
|
key: item.path
|
|
124
124
|
}, /*#__PURE__*/React.createElement(NavLink, {
|
|
@@ -131,7 +131,7 @@ var Navbar = function Navbar(_ref) {
|
|
|
131
131
|
to: nav.path,
|
|
132
132
|
key: nav.path
|
|
133
133
|
}, nav.title) : nav.title, child);
|
|
134
|
-
}), /*#__PURE__*/React.createElement("span", productItemProps, "\u6240\u6709\u4EA7\u54C1", /*#__PURE__*/React.createElement("img", {
|
|
134
|
+
}), /*#__PURE__*/React.createElement("span", Object.assign({}, productItemProps), "\u6240\u6709\u4EA7\u54C1", /*#__PURE__*/React.createElement("img", {
|
|
135
135
|
src: "https://gw.alipayobjects.com/zos/antfincdn/FLrTNDvlna/antv.png",
|
|
136
136
|
alt: "antv logo arrow",
|
|
137
137
|
className: "arrow ".concat(productMenuVisible && 'open')
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
2
|
|
|
5
3
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -55,7 +53,7 @@ export default (function () {
|
|
|
55
53
|
}, [result]);
|
|
56
54
|
return /*#__PURE__*/React.createElement("div", {
|
|
57
55
|
className: "__dumi-default-search"
|
|
58
|
-
}, /*#__PURE__*/React.createElement("input",
|
|
56
|
+
}, /*#__PURE__*/React.createElement("input", Object.assign({
|
|
59
57
|
className: "__dumi-default-search-input",
|
|
60
58
|
type: "search",
|
|
61
59
|
ref: input
|
|
@@ -65,7 +63,7 @@ export default (function () {
|
|
|
65
63
|
return setKeywords(ev.target.value);
|
|
66
64
|
}
|
|
67
65
|
} : {})), /*#__PURE__*/React.createElement("ul", null, items.length > 0 && items.map(function (meta) {
|
|
68
|
-
var
|
|
66
|
+
var _a;
|
|
69
67
|
|
|
70
68
|
return /*#__PURE__*/React.createElement("li", {
|
|
71
69
|
key: meta.path,
|
|
@@ -74,7 +72,7 @@ export default (function () {
|
|
|
74
72
|
}
|
|
75
73
|
}, /*#__PURE__*/React.createElement(AnchorLink, {
|
|
76
74
|
to: meta.path
|
|
77
|
-
}, ((
|
|
75
|
+
}, ((_a = meta.parent) === null || _a === void 0 ? void 0 : _a.title) && /*#__PURE__*/React.createElement("span", null, meta.parent.title), highlight(keywords, meta.title)));
|
|
78
76
|
}), items.length === 0 && keywords && /*#__PURE__*/React.createElement("li", {
|
|
79
77
|
style: {
|
|
80
78
|
textAlign: 'center'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './SideMenu.less';
|
|
4
|
+
interface INavbarProps {
|
|
5
|
+
mobileMenuCollapsed: boolean;
|
|
6
|
+
location: any;
|
|
7
|
+
darkPrefix?: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare const SideMenu: FC<INavbarProps>;
|
|
10
|
+
export default SideMenu;
|
|
@@ -45,9 +45,9 @@ var SideMenu = function SideMenu(_ref) {
|
|
|
45
45
|
}, !!navItems.length && /*#__PURE__*/React.createElement("ul", {
|
|
46
46
|
className: "__dumi-default-menu-nav-list"
|
|
47
47
|
}, navItems.map(function (nav) {
|
|
48
|
-
var
|
|
48
|
+
var _a;
|
|
49
49
|
|
|
50
|
-
var child = Boolean((
|
|
50
|
+
var child = Boolean((_a = nav.children) === null || _a === void 0 ? void 0 : _a.length) && /*#__PURE__*/React.createElement("ul", null, nav.children.map(function (item) {
|
|
51
51
|
return /*#__PURE__*/React.createElement("li", {
|
|
52
52
|
key: item.path || item.title
|
|
53
53
|
}, /*#__PURE__*/React.createElement(NavLink, {
|
|
@@ -64,10 +64,10 @@ var SideMenu = function SideMenu(_ref) {
|
|
|
64
64
|
}), darkPrefix), /*#__PURE__*/React.createElement("ul", {
|
|
65
65
|
className: "__dumi-default-menu-list"
|
|
66
66
|
}, !isHiddenMenus && menu.map(function (item) {
|
|
67
|
-
var
|
|
67
|
+
var _a; // always use meta from routes to reduce menu data size
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
var hasSlugs = Boolean((
|
|
69
|
+
|
|
70
|
+
var hasSlugs = Boolean((_a = meta.slugs) === null || _a === void 0 ? void 0 : _a.length);
|
|
71
71
|
var hasChildren = item.children && Boolean(item.children.length);
|
|
72
72
|
var show1LevelSlugs = meta.toc === 'menu' && !hasChildren && hasSlugs && item.path === location.pathname.replace(/([^^])\/$/, '$1');
|
|
73
73
|
var menuPaths = hasChildren ? item.children.map(function (i) {
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
for (var p in s) {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
}
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
8
13
|
|
|
9
14
|
import React from 'react';
|
|
10
15
|
import { AnchorLink } from 'dumi/theme';
|
|
11
16
|
import './SlugList.less';
|
|
12
17
|
|
|
13
|
-
var SlugsList = function SlugsList(
|
|
14
|
-
var slugs =
|
|
15
|
-
props =
|
|
18
|
+
var SlugsList = function SlugsList(_a) {
|
|
19
|
+
var slugs = _a.slugs,
|
|
20
|
+
props = __rest(_a, ["slugs"]);
|
|
16
21
|
|
|
17
|
-
return /*#__PURE__*/React.createElement("ul",
|
|
22
|
+
return /*#__PURE__*/React.createElement("ul", Object.assign({
|
|
18
23
|
role: "slug-list"
|
|
19
|
-
}, props), slugs.filter(function (
|
|
20
|
-
var depth =
|
|
24
|
+
}, props), slugs.filter(function (_ref) {
|
|
25
|
+
var depth = _ref.depth;
|
|
21
26
|
return depth > 1 && depth < 4;
|
|
22
27
|
}).map(function (slug) {
|
|
23
28
|
return /*#__PURE__*/React.createElement("li", {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.module.less";
|
package/es/layout.d.ts
ADDED
package/es/layout.js
CHANGED
|
@@ -118,8 +118,8 @@ var BannerPanel = function BannerPanel(banner) {
|
|
|
118
118
|
});
|
|
119
119
|
return /*#__PURE__*/React.createElement(Banner, {
|
|
120
120
|
coverImage: coverImage,
|
|
121
|
-
title: title
|
|
122
|
-
|
|
121
|
+
title: title,
|
|
122
|
+
// @ts-ignore
|
|
123
123
|
description: description,
|
|
124
124
|
notifications: notifications,
|
|
125
125
|
buttons: actions,
|
|
@@ -147,10 +147,11 @@ var Features = function Features(features) {
|
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
var Layout = function Layout(_ref) {
|
|
150
|
-
var _meta$slugs, _match;
|
|
151
|
-
|
|
152
150
|
var children = _ref.children,
|
|
153
151
|
location = _ref.location;
|
|
152
|
+
|
|
153
|
+
var _a, _b;
|
|
154
|
+
|
|
154
155
|
var Context = useContext(context);
|
|
155
156
|
var _Context$config = Context.config,
|
|
156
157
|
mode = _Context$config.mode,
|
|
@@ -161,7 +162,6 @@ var Layout = function Layout(_ref) {
|
|
|
161
162
|
meta = _processRedirect.meta,
|
|
162
163
|
isDirect = _processRedirect.isDirect;
|
|
163
164
|
|
|
164
|
-
console.log('Context', Context, 'calculate meta', meta);
|
|
165
165
|
var repoUrl = repository.url,
|
|
166
166
|
branch = repository.branch,
|
|
167
167
|
platform = repository.platform;
|
|
@@ -178,7 +178,7 @@ var Layout = function Layout(_ref) {
|
|
|
178
178
|
var showFeatures = isSiteMode && meta.features;
|
|
179
179
|
var showIdeas = isSiteMode && meta.ideas;
|
|
180
180
|
var showSideMenu = meta.sidemenu !== false && !showHero && !showBanner && !showFeatures && !meta.gapless;
|
|
181
|
-
var showSlugs = !showHero && !showBanner && !showFeatures && Boolean((
|
|
181
|
+
var showSlugs = !showHero && !showBanner && !showFeatures && Boolean((_a = meta.slugs) === null || _a === void 0 ? void 0 : _a.length) && (meta.toc === 'content' || meta.toc === undefined) && !meta.gapless;
|
|
182
182
|
var isCN = /^zh|cn$/i.test(locale); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
183
|
|
|
184
184
|
var updatedTime = new Date(meta.updatedTime).toLocaleString([], {
|
|
@@ -187,7 +187,7 @@ var Layout = function Layout(_ref) {
|
|
|
187
187
|
var repoPlatform = {
|
|
188
188
|
github: 'GitHub',
|
|
189
189
|
gitlab: 'GitLab'
|
|
190
|
-
}[((
|
|
190
|
+
}[((_b = (repoUrl || '').match(/(github|gitlab)/)) === null || _b === void 0 ? void 0 : _b[1]) || 'nothing'] || platform; // 等dumi最新版发布后解决路由匹配问题
|
|
191
191
|
|
|
192
192
|
if (isEmpty(meta) && !isDirect) {
|
|
193
193
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/dumi-theme-antv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "The official antv site theme of dumi",
|
|
5
5
|
"files": [
|
|
6
6
|
"es",
|
|
7
7
|
"src"
|
|
8
8
|
],
|
|
9
9
|
"sideEffects": [
|
|
10
|
-
"*.less"
|
|
10
|
+
"*.less",
|
|
11
|
+
"*.module.less",
|
|
12
|
+
"*.css"
|
|
11
13
|
],
|
|
12
14
|
"scripts": {
|
|
13
15
|
"start": "father build --watch",
|
|
@@ -23,6 +25,7 @@
|
|
|
23
25
|
"i18next": "^21.6.14",
|
|
24
26
|
"lodash": "^4.17.21",
|
|
25
27
|
"lodash.throttle": "^4.1.1",
|
|
28
|
+
"omit.js": "^2.0.2",
|
|
26
29
|
"parse-github-url": "^1.0.2",
|
|
27
30
|
"prism-react-renderer": "^1.1.1",
|
|
28
31
|
"prismjs": "^1.21.0",
|
|
@@ -33,7 +36,9 @@
|
|
|
33
36
|
"react": "^17.0.1",
|
|
34
37
|
"react-github-button": "^0.1.11",
|
|
35
38
|
"react-i18next": "^11.16.2",
|
|
36
|
-
"react-
|
|
39
|
+
"react-slick": "^0.28.1",
|
|
40
|
+
"react-use": "^17.3.2",
|
|
41
|
+
"slick-carousel": "^1.8.1"
|
|
37
42
|
},
|
|
38
43
|
"repository": {
|
|
39
44
|
"type": "git",
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import GitHubButton from
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
import styles from './Banner.module.less';
|
|
11
|
-
import Notification, { NotificationProps } from './Notification';
|
|
12
|
-
|
|
13
|
-
type BannerButtonShape = 'round' | 'square';
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import { context } from "dumi/theme";
|
|
3
|
+
import gh from "parse-github-url";
|
|
4
|
+
import React, { useContext } from "react";
|
|
5
|
+
import GitHubButton from "react-github-button";
|
|
6
|
+
//@ts-ignore
|
|
7
|
+
import styles from "./Banner.module.less";
|
|
8
|
+
import Notification, { NotificationProps } from "./Notification";
|
|
9
|
+
type BannerButtonShape = "round" | "square";
|
|
14
10
|
|
|
15
11
|
interface BannerButton {
|
|
16
12
|
text: string;
|
|
@@ -34,7 +30,8 @@ interface BannerProps {
|
|
|
34
30
|
onPlayVideo?: () => void;
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
const backLeftBottom =
|
|
33
|
+
const backLeftBottom =
|
|
34
|
+
"https://gw.alipayobjects.com/zos/basement_prod/441d5eaf-e623-47cd-b9b9-2a581d9ce1e3.svg";
|
|
38
35
|
|
|
39
36
|
const Banner: React.FC<BannerProps> = ({
|
|
40
37
|
coverImage,
|
|
@@ -54,32 +51,34 @@ const Banner: React.FC<BannerProps> = ({
|
|
|
54
51
|
|
|
55
52
|
const notificationsNode = notifications
|
|
56
53
|
.slice(0, 2)
|
|
57
|
-
.map((notification, i) =>
|
|
54
|
+
.map((notification, i) => (
|
|
55
|
+
<Notification index={i} key={i} {...notification} />
|
|
56
|
+
));
|
|
58
57
|
|
|
59
58
|
const renderButtons = buttons.map((button: BannerButton, i) => {
|
|
60
|
-
const ButtonLink =
|
|
59
|
+
const ButtonLink = "a";
|
|
61
60
|
const buttonProps = {} as any;
|
|
62
|
-
if (button.link.startsWith(
|
|
63
|
-
buttonProps.target =
|
|
64
|
-
buttonProps.rel =
|
|
61
|
+
if (button.link.startsWith("http")) {
|
|
62
|
+
buttonProps.target = "_blank";
|
|
63
|
+
buttonProps.rel = "noopener noreferrer";
|
|
65
64
|
}
|
|
66
|
-
if (ButtonLink ===
|
|
65
|
+
if (ButtonLink === "a") {
|
|
67
66
|
buttonProps.href = button.link;
|
|
68
67
|
} else {
|
|
69
68
|
buttonProps.to = button.link;
|
|
70
69
|
}
|
|
71
|
-
const { shape =
|
|
70
|
+
const { shape = "round" } = button;
|
|
72
71
|
return (
|
|
73
72
|
<ButtonLink
|
|
74
73
|
{...buttonProps}
|
|
75
74
|
className={classNames(
|
|
76
75
|
styles.buttonLink,
|
|
77
|
-
styles[button.type ||
|
|
78
|
-
button.type ===
|
|
76
|
+
styles[button.type || ""],
|
|
77
|
+
button.type === "primary" ? "primary-button" : "common-button"
|
|
79
78
|
)}
|
|
80
79
|
key={i}
|
|
81
80
|
style={{
|
|
82
|
-
borderRadius: shape ===
|
|
81
|
+
borderRadius: shape === "round" ? "1000px" : "4px",
|
|
83
82
|
...button.style,
|
|
84
83
|
}}
|
|
85
84
|
>
|
|
@@ -94,8 +93,13 @@ const Banner: React.FC<BannerProps> = ({
|
|
|
94
93
|
if (githubObj && githubObj.owner && githubObj.name) {
|
|
95
94
|
renderButtons.push(
|
|
96
95
|
<div key="github" className={styles.githubWrapper}>
|
|
97
|
-
<GitHubButton
|
|
98
|
-
|
|
96
|
+
<GitHubButton
|
|
97
|
+
type="stargazers"
|
|
98
|
+
size="large"
|
|
99
|
+
namespace={githubObj.owner}
|
|
100
|
+
repo={githubObj.name}
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
99
103
|
);
|
|
100
104
|
}
|
|
101
105
|
}
|
|
@@ -104,15 +108,29 @@ const Banner: React.FC<BannerProps> = ({
|
|
|
104
108
|
<section className={classNames(styles.wrapper, className)} style={style}>
|
|
105
109
|
<div className={styles.content}>
|
|
106
110
|
<div className={styles.text}>
|
|
107
|
-
<div className={classNames(styles.title,
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
<div className={classNames(styles.title, "banner-title")}>
|
|
112
|
+
{title}
|
|
113
|
+
</div>
|
|
114
|
+
<div className={classNames(styles.description, "banner-description")}>
|
|
115
|
+
{description}
|
|
116
|
+
</div>
|
|
117
|
+
<div className={classNames(styles.buttons, "banner-buttons")}>
|
|
118
|
+
{renderButtons}
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
<div className={classNames(styles.notifications, "notifications")}>
|
|
122
|
+
{notificationsNode}
|
|
110
123
|
</div>
|
|
111
|
-
<div className={classNames(styles.
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
<div className={classNames(styles.teaser, "teaser")}>
|
|
125
|
+
<div className={classNames(styles.teaserimg, "teaser-img")}>
|
|
126
|
+
{coverImage}
|
|
127
|
+
</div>
|
|
114
128
|
</div>
|
|
115
|
-
<img
|
|
129
|
+
<img
|
|
130
|
+
className={styles.backLeftBottom}
|
|
131
|
+
src={backLeftBottom}
|
|
132
|
+
alt="back"
|
|
133
|
+
/>
|
|
116
134
|
</div>
|
|
117
135
|
</section>
|
|
118
136
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module "*.module.less";
|
package/src/layout.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import SearchBar from './components/SearchBar';
|
|
|
15
15
|
import SideMenu from './components/SideMenu';
|
|
16
16
|
import SlugList from './components/SlugList';
|
|
17
17
|
import './style/layout.less';
|
|
18
|
+
|
|
18
19
|
i18n
|
|
19
20
|
.use(initReactI18next) // passes i18n down to react-i18next
|
|
20
21
|
.init({
|
|
@@ -120,7 +121,6 @@ const Layout: React.FC<IRouteComponentProps> = ({ children, location }) => {
|
|
|
120
121
|
} = Context;
|
|
121
122
|
|
|
122
123
|
const { meta, isDirect } = processRedirect(Context, location);
|
|
123
|
-
console.log('Context', Context, 'calculate meta', meta);
|
|
124
124
|
const { url: repoUrl, branch, platform } = repository;
|
|
125
125
|
const [menuCollapsed, setMenuCollapsed] = useState<boolean>(true);
|
|
126
126
|
const isSiteMode = mode === 'site';
|