@antv/dumi-theme-antv 0.3.0-beta.18 → 0.3.0-beta.19

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.
@@ -15,7 +15,7 @@ import { get } from 'lodash-es';
15
15
  import React, { useContext } from 'react';
16
16
  import { ErrorBoundary } from 'react-error-boundary';
17
17
  import { ThemeAntVContext } from "../../context";
18
- import { CodeRunner } from "../../slots/CodeRunner";
18
+ import { CodeRunner } from "dumi/theme/slots/CodeRunner";
19
19
  import styles from "./index.module.less";
20
20
 
21
21
  /**
@@ -6,13 +6,14 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
 
7
7
  import React from 'react';
8
8
  import { useLocale, useSiteData, FormattedMessage } from 'dumi';
9
- import { SEO } from "../../slots/SEO";
10
- import { Header } from "../../slots/Header";
9
+ import { SEO } from "dumi/theme/slots/SEO";
10
+ import { Header } from "dumi/theme/slots/Header";
11
11
  import { Detail } from 'dumi/theme/slots/Detail';
12
- import { Features } from "../../slots/Features";
13
- import { Cases } from "../../slots/Cases";
14
- import { Companies } from "../../slots/Companies";
15
- import { Footer } from "../../slots/Footer";
12
+ import { Features } from "dumi/theme/slots/Features";
13
+ import { Cases } from "dumi/theme/slots/Cases";
14
+ import { Companies } from "dumi/theme/slots/Companies";
15
+ import { Footer } from "dumi/theme/slots/Footer";
16
+ import { size } from 'lodash-es';
16
17
  /**
17
18
  * Index 路由下的入口
18
19
  * - 获取数据
@@ -71,10 +72,10 @@ export var Index = function Index() {
71
72
  title: "".concat(metaTitle[locale.id]),
72
73
  titleSuffix: "AntV",
73
74
  lang: locale.id
74
- }), /*#__PURE__*/React.createElement(Header, null), detail && /*#__PURE__*/React.createElement(Detail, detailProps), features && /*#__PURE__*/React.createElement(Features, featuresProps), cases && /*#__PURE__*/React.createElement(Cases, casesProps), /*#__PURE__*/React.createElement(Companies, {
75
+ }), /*#__PURE__*/React.createElement(Header, null), size(detail) ? /*#__PURE__*/React.createElement(Detail, detailProps) : null, size(features) ? /*#__PURE__*/React.createElement(Features, featuresProps) : null, size(cases) ? /*#__PURE__*/React.createElement(Cases, casesProps) : null, size(companies) ? /*#__PURE__*/React.createElement(Companies, {
75
76
  title: /*#__PURE__*/React.createElement(FormattedMessage, {
76
77
  id: isAntVSite ? "2000+ 公司正在使用" : "感谢信赖"
77
78
  }),
78
79
  companies: companies
79
- }), /*#__PURE__*/React.createElement(Footer, null));
80
+ }) : null, /*#__PURE__*/React.createElement(Footer, null));
80
81
  };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { ManualContent } from "../../slots/ManualContent";
3
- import { Header } from "../../slots/Header";
4
- import { Footer } from "../../slots/Footer";
2
+ import { ManualContent } from "dumi/theme/slots/ManualContent";
3
+ import { Header } from "dumi/theme/slots/Header";
4
+ import { Footer } from "dumi/theme/slots/Footer";
5
5
 
6
6
  /**
7
7
  * Manual 路由下的入口
package/dist/pages/404.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { SEO } from "../slots/SEO";
3
- import { Header } from "../slots/Header";
4
- import { NotFound as NotFoundPage } from "../slots/404";
5
- import { Footer } from "../slots/Footer";
2
+ import { SEO } from "dumi/theme/slots/SEO";
3
+ import { Header } from "dumi/theme/slots/Header";
4
+ import { NotFound as NotFoundPage } from "dumi/theme/slots/404";
5
+ import { Footer } from "dumi/theme/slots/Footer";
6
6
  /**
7
7
  * 404 页面
8
8
  */
@@ -15,10 +15,10 @@ import { useParams, useLocation, useNavigate } from 'react-router-dom';
15
15
  import { get } from 'lodash-es';
16
16
  import { Layout } from 'antd';
17
17
  import { useLocale, useSiteData } from 'dumi';
18
- import { SEO } from "../../slots/SEO";
19
- import { Header } from "../../slots/Header";
20
- import { ExampleSider } from "../../slots/ExampleSider";
21
- import { CodeRunner } from "../../slots/CodeRunner";
18
+ import { SEO } from "dumi/theme/slots/SEO";
19
+ import { Header } from "dumi/theme/slots/Header";
20
+ import { ExampleSider } from "dumi/theme/slots/ExampleSider";
21
+ import { CodeRunner } from "dumi/theme/slots/CodeRunner";
22
22
  import { getDemoInfo } from "../../slots/CodeRunner/utils";
23
23
  import { ThemeAntVContext } from "../../context";
24
24
  import styles from "./index.module.less";
@@ -19,6 +19,10 @@ var MenuIcon = createFromIconfontCN({
19
19
  scriptUrl: '//at.alicdn.com/t/font_470089_1lnym745udm.js' // generated by iconfont.cn
20
20
 
21
21
  });
22
+
23
+ function getCategoryId(tid, eid) {
24
+ return [tid, eid].join('-').replace(/\s/g, '');
25
+ }
22
26
  /**
23
27
  * LeftMenu
24
28
  *
@@ -27,6 +31,7 @@ var MenuIcon = createFromIconfontCN({
27
31
  * @author YuZhanglong <loveyzl1123@gmail.com>
28
32
  */
29
33
 
34
+
30
35
  export var LeftMenu = function LeftMenu(props) {
31
36
  var exampleTopics = props.exampleTopics;
32
37
 
@@ -66,7 +71,7 @@ export var LeftMenu = function LeftMenu(props) {
66
71
  return /*#__PURE__*/React.createElement(Menu.Item, {
67
72
  key: example.id
68
73
  }, /*#__PURE__*/React.createElement(Anchor.Link, {
69
- href: "#category-".concat(example.id.replace(/\s/g, '')),
74
+ href: "#".concat(getCategoryId(topic.id, example.id)),
70
75
  title: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", null, example.title[locale.id]))
71
76
  }));
72
77
  }));
@@ -15,9 +15,9 @@ import { useContext, useEffect } from 'react';
15
15
  import { useNavigate } from 'react-router-dom';
16
16
  import { BackTop, Layout as AntLayout } from 'antd';
17
17
  import { useLocale } from 'dumi';
18
- import { SEO } from "../../slots/SEO";
19
- import { Header } from "../../slots/Header";
20
- import { Footer } from "../../slots/Footer";
18
+ import { SEO } from "dumi/theme/slots/SEO";
19
+ import { Header } from "dumi/theme/slots/Header";
20
+ import { Footer } from "dumi/theme/slots/Footer";
21
21
  import NavigatorBanner from "../../slots/Header/Products/NavigatorBanner";
22
22
  import { VerticalAlignTopOutlined } from '@ant-design/icons';
23
23
  import { Article } from "./components/Article";
@@ -199,6 +199,11 @@
199
199
 
200
200
  .layout {
201
201
  margin: 24px 0 32px;
202
+ :global {
203
+ .ant-layout-content {
204
+ background-color: #ffffff;
205
+ }
206
+ }
202
207
  }
203
208
 
204
209
  .main {
@@ -206,6 +211,7 @@
206
211
  width: calc(100% - @toc-width);
207
212
  padding-left: 48px;
208
213
  padding-right: 24px;
214
+ padding-bottom: 24px;
209
215
  overflow: hidden;
210
216
 
211
217
  .meta {
@@ -521,6 +527,7 @@
521
527
  margin-top: 30px;
522
528
  padding-left: 24px;
523
529
  padding-right: 24px;
530
+ margin-bottom: 30px;
524
531
  }
525
532
  }
526
533
  }
@@ -17,7 +17,7 @@ import { debounce, noop } from 'lodash-es';
17
17
  import { bind, clear } from 'size-sensor';
18
18
  import { replaceInsertCss, execute, compile } from "./utils";
19
19
  import { Toolbar, EDITOR_TABS } from "./Toolbar";
20
- import { Loading } from "../Loading";
20
+ import { Loading } from "dumi/theme/slots/Loading";
21
21
  import styles from "./index.module.less";
22
22
  loader.config({
23
23
  'vs/nls': {
@@ -14,11 +14,11 @@ import React, { useState } from 'react';
14
14
  import { useSiteData, useLocale } from 'dumi';
15
15
  import { noop } from 'lodash-es';
16
16
  import SplitPane from 'react-split-pane';
17
- import { CodeEditor } from "../CodeEditor";
18
- import { CodePreview } from "../CodePreview";
17
+ import { CodeEditor } from "dumi/theme/slots/CodeEditor";
18
+ import { CodePreview } from "dumi/theme/slots/CodePreview";
19
19
  import { CodeHeader } from "../CodePreview/CodeHeader";
20
20
  import { getDemoInfo } from "./utils";
21
- import { NotFound } from "../404";
21
+ import { NotFound } from "dumi/theme/slots/404";
22
22
  import { ic } from "../hooks";
23
23
 
24
24
  /**
@@ -18,7 +18,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
 
19
19
  import React, { useEffect, useRef, useState } from 'react';
20
20
  import { Input, Menu, Tooltip } from 'antd';
21
- import { useLocale, FormattedMessage } from 'dumi';
21
+ import { useLocale, FormattedMessage, useIntl } from 'dumi';
22
+ import { cloneDeep } from 'lodash-es';
22
23
  import { createFromIconfontCN, SearchOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
23
24
  import classNames from 'classnames';
24
25
  import { filterTreeNode } from "../utils";
@@ -56,22 +57,19 @@ export var ExampleSider = function ExampleSider(props) {
56
57
  setSearchValue = _useState6[1];
57
58
 
58
59
  var locale = useLocale();
60
+ var intl = useIntl();
59
61
 
60
62
  var getCurrentTopics = function getCurrentTopics() {
61
- if (searchValue) {
62
- var res = filterTreeNode({
63
- id: 'FAKE_ID',
64
- childrenKey: 'exampleTopics',
65
- title: {
66
- 'zh': 'FAKE_TITLE',
67
- 'en': 'FAKE_TITLE'
68
- },
69
- exampleTopics: exampleTopics
70
- }, searchValue, locale.id);
71
- return (res === null || res === void 0 ? void 0 : res.exampleTopics) || [];
72
- }
73
-
74
- return exampleTopics;
63
+ var res = filterTreeNode({
64
+ id: 'FAKE_ID',
65
+ childrenKey: 'exampleTopics',
66
+ title: {
67
+ 'zh': 'FAKE_TITLE',
68
+ 'en': 'FAKE_TITLE'
69
+ },
70
+ exampleTopics: cloneDeep(exampleTopics)
71
+ }, searchValue, locale.id);
72
+ return (res === null || res === void 0 ? void 0 : res.exampleTopics) || [];
75
73
  }; // 初始化菜单栏展开keys
76
74
 
77
75
 
@@ -130,11 +128,11 @@ export var ExampleSider = function ExampleSider(props) {
130
128
  }, topic.title && getSearchValueTitle(topic.title[locale.id])))
131
129
  }, topic.examples.map(function (example) {
132
130
  return /*#__PURE__*/React.createElement(Menu.SubMenu, {
133
- key: "EXAMPLE-".concat(example.id),
131
+ key: "EXAMPLE-".concat(topic.id, "-").concat(example.id),
134
132
  title: example.title[locale.id]
135
133
  }, example.demos.map(function (demo) {
136
134
  return /*#__PURE__*/React.createElement(Menu.Item, {
137
- key: "DEMO-".concat(demo.id),
135
+ key: "DEMO-".concat(topic.id, "-").concat(example.id, "-").concat(demo.id),
138
136
  style: {
139
137
  height: 70,
140
138
  padding: 0,
@@ -160,8 +158,8 @@ export var ExampleSider = function ExampleSider(props) {
160
158
  className: styles.searchSider
161
159
  }, /*#__PURE__*/React.createElement(Input, {
162
160
  size: "small",
163
- placeholder: /*#__PURE__*/React.createElement(FormattedMessage, {
164
- id: "\u641C\u7D22\u2026"
161
+ placeholder: intl.formatMessage({
162
+ id: '搜索…'
165
163
  }),
166
164
  prefix: /*#__PURE__*/React.createElement(SearchOutlined, null),
167
165
  value: searchValue,
@@ -88,7 +88,7 @@ export var Features = function Features(_ref) {
88
88
  }, /*#__PURE__*/React.createElement("p", {
89
89
  key: "title",
90
90
  className: styles.title
91
- }, title), /*#__PURE__*/React.createElement("div", {
91
+ }), /*#__PURE__*/React.createElement("div", {
92
92
  key: "block",
93
93
  className: styles.cardsContainer
94
94
  }, /*#__PURE__*/React.createElement(Row, {
@@ -58,7 +58,7 @@
58
58
  position: absolute;
59
59
  width: 95.83%;
60
60
  left: 4.17%;
61
- top: 144px;
61
+ top: 88px;
62
62
  background: #fff;
63
63
  height: 65%;
64
64
  box-shadow: -5px 5px 15px rgba(0, 0, 0, 0.1);
@@ -19,19 +19,19 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
19
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
20
 
21
21
  import React, { useEffect, useState } from 'react';
22
- import { Layout, Affix, BackTop, Menu, Tooltip } from 'antd';
22
+ import { Layout, Affix, BackTop, Menu } from 'antd';
23
23
  import { useMedia } from 'react-use';
24
24
  import Drawer from 'rc-drawer';
25
25
  import { useLocale, useSiteData, useFullSidebarData, useRouteMeta } from 'dumi';
26
26
  import { useNavigate } from "react-router-dom";
27
- import { EditOutlined, MenuFoldOutlined, MenuUnfoldOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
27
+ import { MenuFoldOutlined, MenuUnfoldOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
28
28
  import readingTime from 'reading-time';
29
29
  import URI from 'uri-parse';
30
- import { SEO } from "../SEO";
30
+ import { SEO } from "dumi/theme/slots/SEO";
31
31
  import { getBaseRoute, getIndexRoute, getOpenKeys, getNavigateUrl } from "./utils";
32
32
  import { NavigatorBanner } from "./NavigatorBanner";
33
33
  import ReadingTime from "./ReadingTime";
34
- import { ContentTable } from "../ContentTable";
34
+ import { ContentTable } from "dumi/theme/slots/ContentTable";
35
35
  import { useScrollToTop } from "../hooks";
36
36
  import 'rc-drawer/assets/index.css';
37
37
  import styles from "./index.module.less";
@@ -308,18 +308,7 @@ export var ManualContent = function ManualContent(_ref) {
308
308
  className: styles.main
309
309
  }, /*#__PURE__*/React.createElement("h1", {
310
310
  className: styles.contentTitle
311
- }, linkoTitle[window.location.pathname], /*#__PURE__*/React.createElement(Tooltip, {
312
- title: '在 GitHub 上编辑'
313
- }, /*#__PURE__*/React.createElement("a", {
314
- href: getGithubSourceUrl({
315
- githubUrl: githubUrl,
316
- relativePath: relativePath,
317
- prefix: 'docs'
318
- }),
319
- target: "_blank",
320
- rel: "noopener noreferrer",
321
- className: styles.editOnGtiHubButton
322
- }, /*#__PURE__*/React.createElement(EditOutlined, null)))), /*#__PURE__*/React.createElement("div", {
311
+ }, linkoTitle[window.location.pathname]), /*#__PURE__*/React.createElement("div", {
323
312
  className: styles.readtimeContainer
324
313
  }, /*#__PURE__*/React.createElement(ReadingTime, {
325
314
  readingTime: time,
@@ -84,6 +84,14 @@
84
84
  background-color: rgba(0, 0, 0, 0.03);
85
85
  }
86
86
 
87
+ code {
88
+ padding: 0.2em 0.4em;
89
+ margin: 0;
90
+ font-size: 85%;
91
+ background-color: rgba(175, 184, 193, 0.2);
92
+ border-radius: 6px;
93
+ }
94
+
87
95
  code[class*='language-'] {
88
96
  background: none;
89
97
  }
@@ -197,6 +205,10 @@
197
205
  > p > br {
198
206
  clear: both;
199
207
  }
208
+
209
+ img {
210
+ max-width: 100%;
211
+ }
200
212
  }
201
213
 
202
214
  .layout {
package/dist/slots/_.less CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  @media only screen and (max-width: 931.99px) {
12
12
  & {
13
- max-width: calc(100% - 60px);
13
+ max-width: calc(100% - 80px);
14
14
  }
15
15
  }
16
16
 
@@ -13,3 +13,4 @@ export declare const usePrevAndNext: () => NavigatorBannerProps['post'][];
13
13
  * @param v
14
14
  */
15
15
  export declare function ic(v: string | object): any;
16
+ export declare function icWithLocale(v: string | object, locale: any): any;
@@ -94,5 +94,8 @@ export var usePrevAndNext = function usePrevAndNext() {
94
94
 
95
95
  export function ic(v) {
96
96
  var locale = useLocale();
97
- return _typeof(v) === 'object' ? get(v, [locale.id]) : v;
97
+ return icWithLocale(v, locale.id);
98
+ }
99
+ export function icWithLocale(v, locale) {
100
+ return _typeof(v) === 'object' ? get(v, [locale]) : v;
98
101
  }
@@ -18,6 +18,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
18
18
 
19
19
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
20
20
 
21
+ import { icWithLocale } from "./hooks";
21
22
  export function ping() {
22
23
  return _ping.apply(this, arguments);
23
24
  }
@@ -102,7 +103,11 @@ export var filterTreeNode = function filterTreeNode(treeNode, keyValue, locale)
102
103
  }
103
104
  }
104
105
 
105
- var isCurrentTreeNodeMatched = treeNode.title[locale].toLowerCase().includes(keyValue.toLowerCase()); // 当前节点自身匹配,那么其孩子直接匹配,可以直接返回当前节点
106
+ var title = icWithLocale(treeNode.title, locale) || '';
107
+ var matchFields = [title, treeNode.id, treeNode.filename];
108
+ var isCurrentTreeNodeMatched = matchFields.some(function (f) {
109
+ return (f ? f.toLowerCase() : '').includes(keyValue ? keyValue.toLowerCase() : '');
110
+ }); // 当前节点自身匹配,那么其孩子直接匹配,可以直接返回当前节点
106
111
 
107
112
  if (isCurrentTreeNodeMatched) {
108
113
  return treeNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.3.0-beta.18",
3
+ "version": "0.3.0-beta.19",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "types": "dist/types.d.ts",
6
6
  "scripts": {