@antv/dumi-theme-antv 0.5.0 → 0.5.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 CHANGED
@@ -34,7 +34,7 @@ TODO
34
34
  ## Development
35
35
 
36
36
  ```bash
37
- $ tnpm install
37
+ $ npm install
38
38
  ```
39
39
 
40
40
  After the dependencies are installed, a symlink from `example/.dumi/theme` to `../../src` will be created automatically, the symlink makes dumi load our theme package as a local theme, so we can start the example directly, HMR is also available:
@@ -43,6 +43,9 @@ After the dependencies are installed, a symlink from `example/.dumi/theme` to `.
43
43
  # switch to example directory
44
44
  $ cd example
45
45
 
46
+ # downloads the dependencies
47
+ npm install
48
+
46
49
  # start dev server to preview
47
50
  npm run dev
48
51
  ```
@@ -57,7 +57,7 @@ var getExampleDemos = (exampleDir) => {
57
57
  return demos;
58
58
  };
59
59
  var getTopicExamples = (topicPath, showAPIDoc) => {
60
- const examplePaths = glob.sync(`${topicPath}/*`).filter((item) => {
60
+ const examplePaths = glob.sync(`${topicPath.replace(/\\/g, "/")}/*`).filter((item) => {
61
61
  return !item.endsWith(".js");
62
62
  });
63
63
  return examplePaths.map((item) => {
@@ -21,7 +21,7 @@ import { format } from 'prettier';
21
21
  import parserBabel from 'prettier/parser-babel';
22
22
  import React, { useCallback, useEffect, useRef, useState } from 'react';
23
23
  import { bind, clear } from 'size-sensor';
24
- import { Loading } from "dumi/theme/slots/Loading";
24
+ import Loading from "dumi/theme/slots/Loading";
25
25
  import { EDITOR_TABS, Toolbar } from "./Toolbar";
26
26
  import styles from "./index.module.less";
27
27
  import { compile, execute, replaceInsertCss } from "./utils";
@@ -47,7 +47,9 @@ export var Detail = function Detail(_ref) {
47
47
  setRemoteNews = _useState2[1];
48
48
  var lang = useLocale().id;
49
49
  useEffect(function () {
50
- fetch('https://site-data-pre.alipay.com/antv/banner-messages.json').then(function (res) {
50
+ fetch('https://assets.antv.antgroup.com/antv/banner-messages.json' // 生产环境
51
+ // 'https://site-data-pre.alipay.com/antv/banner-messages.json', // 预发测试
52
+ ).then(function (res) {
51
53
  return res.json();
52
54
  }).then(function (data) {
53
55
  setRemoteNews(data);
@@ -171,6 +171,17 @@ export var Footer = function Footer(props) {
171
171
  }),
172
172
  url: 'https://kitchen.alipay.com',
173
173
  openExternal: true
174
+ }, {
175
+ icon: /*#__PURE__*/React.createElement("img", {
176
+ src: "https://mdn.alipayobjects.com/huamei_j9rjmc/afts/img/A*3ittT5OEo2gAAAAAAAAAAAAADvGmAQ/original",
177
+ width: 16,
178
+ height: 16,
179
+ alt: "Galacean"
180
+ }),
181
+ title: "Galacean",
182
+ description: "互动图形解决方案",
183
+ url: 'https://galacean.antgroup.com/',
184
+ openExternal: true
174
185
  }, {
175
186
  icon: /*#__PURE__*/React.createElement("img", {
176
187
  src: "https://gw.alipayobjects.com/zos/rmsportal/nBVXkrFdWHxbZlmMbsaH.svg",
@@ -36,6 +36,15 @@
36
36
  opacity: 1;
37
37
  }
38
38
 
39
+ &.bannerVisible {
40
+ max-height: calc(100vh - 102px);
41
+ top: 102px;
42
+ }
43
+
44
+ &.bannerVisible+.mask {
45
+ top: 102px;
46
+ }
47
+
39
48
  h3 {
40
49
  font-size: 14px;
41
50
  line-height: 22px;
@@ -1,5 +1,10 @@
1
1
  import React from 'react';
2
2
  declare const Categories: ["basic", "extension", "ecology"];
3
+ export interface ProductCategory {
4
+ type: (typeof CATEGORY_TYPE)[number];
5
+ name: string;
6
+ products: ProductType[];
7
+ }
3
8
  export interface ProductItem {
4
9
  title: string;
5
10
  icon?: React.ReactNode;
@@ -15,10 +20,7 @@ export interface ProductItem {
15
20
  }
16
21
  export type ValuesOf<T extends any[]> = T[number];
17
22
  declare const CATEGORY_TYPE: ["basic", "extension", "mobile", "ecology"];
18
- export declare const CATEGORIES: Array<{
19
- type: typeof CATEGORY_TYPE[number];
20
- name: string;
21
- }>;
23
+ export declare const CATEGORIES: Array<ProductCategory>;
22
24
  export type ProductType = {
23
25
  links: {
24
26
  /** 产品首页 */
@@ -17,16 +17,20 @@ var ANTV_DOMAIN = 'antv.vision';
17
17
  var CATEGORY_TYPE = tuple('basic', 'extension', 'mobile', 'ecology');
18
18
  export var CATEGORIES = [{
19
19
  type: 'basic',
20
- name: '标准版基础产品'
20
+ name: '标准版基础产品',
21
+ products: []
21
22
  }, {
22
23
  type: 'extension',
23
- name: '标准版扩展产品'
24
+ name: '标准版扩展产品',
25
+ products: []
24
26
  }, {
25
27
  type: 'mobile',
26
- name: '移动定制(F版)产品'
28
+ name: '移动定制(F版)产品',
29
+ products: []
27
30
  }, {
28
31
  type: 'ecology',
29
- name: '周边生态'
32
+ name: '周边生态',
33
+ products: []
30
34
  }];
31
35
  export function getNewProducts(_ref) {
32
36
  var language = _ref.language,
@@ -4,6 +4,7 @@ interface ProductsProps {
4
4
  rootDomain: string;
5
5
  language?: 'zh' | 'en';
6
6
  className?: string;
7
+ bannerVisible?: boolean;
7
8
  }
8
9
  export declare const Products: React.FC<ProductsProps>;
9
10
  export {};
@@ -18,14 +18,15 @@ import styles from "./Product.module.less";
18
18
  export var Products = function Products(_ref) {
19
19
  var show = _ref.show,
20
20
  language = _ref.language,
21
- className = _ref.className;
21
+ className = _ref.className,
22
+ bannerVisible = _ref.bannerVisible;
22
23
  var locale = useLocale();
23
24
  var _useChinaMirrorHost = useChinaMirrorHost(),
24
25
  _useChinaMirrorHost2 = _slicedToArray(_useChinaMirrorHost, 1),
25
26
  isChinaMirrorHost = _useChinaMirrorHost2[0];
26
- var _React$useState = React.useState([]),
27
+ var _React$useState = React.useState(CATEGORIES),
27
28
  _React$useState2 = _slicedToArray(_React$useState, 2),
28
- products = _React$useState2[0],
29
+ productsCategoty = _React$useState2[0],
29
30
  setProducts = _React$useState2[1];
30
31
  var lang = locale.id === 'zh' ? 'zh' : 'en';
31
32
  React.useEffect(function () {
@@ -33,23 +34,33 @@ export var Products = function Products(_ref) {
33
34
  language: lang,
34
35
  isChinaMirrorHost: isChinaMirrorHost
35
36
  }).then(function (data) {
36
- setProducts(data);
37
+ var newProducts = CATEGORIES.map(function (_ref2) {
38
+ var name = _ref2.name,
39
+ type = _ref2.type;
40
+ return {
41
+ name: name,
42
+ type: type,
43
+ products: data.filter(function (item) {
44
+ return item.category === type;
45
+ })
46
+ };
47
+ });
48
+ setProducts(newProducts);
37
49
  });
38
50
  }, [lang, isChinaMirrorHost]);
39
51
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
40
- className: cx(styles.products, className, _defineProperty({}, styles.show, !!show))
52
+ className: cx(styles.products, className, _defineProperty(_defineProperty({}, styles.show, !!show), styles.bannerVisible, !!bannerVisible))
41
53
  }, /*#__PURE__*/React.createElement("div", {
42
54
  className: styles.container
43
- }, CATEGORIES.map(function (_ref2, idx) {
44
- var name = _ref2.name,
45
- type = _ref2.type;
46
- return /*#__PURE__*/React.createElement(React.Fragment, {
55
+ }, productsCategoty.map(function (_ref3, idx) {
56
+ var name = _ref3.name,
57
+ type = _ref3.type,
58
+ products = _ref3.products;
59
+ return products.length ? /*#__PURE__*/React.createElement(React.Fragment, {
47
60
  key: idx
48
61
  }, /*#__PURE__*/React.createElement("h3", null, /*#__PURE__*/React.createElement(FormattedMessage, {
49
62
  id: name
50
- })), /*#__PURE__*/React.createElement("ul", null, products.filter(function (item) {
51
- return item.category === type;
52
- }).map(function (product) {
63
+ })), /*#__PURE__*/React.createElement("ul", null, products.map(function (product) {
53
64
  var _product$links;
54
65
  return /*#__PURE__*/React.createElement(Product, {
55
66
  key: product.title,
@@ -61,7 +72,7 @@ export var Products = function Products(_ref) {
61
72
  links: product.links,
62
73
  language: language || locale.id
63
74
  });
64
- })));
75
+ }))) : null;
65
76
  }))), /*#__PURE__*/React.createElement("div", {
66
77
  className: styles.mask
67
78
  }));
@@ -71,13 +71,6 @@ var HeaderComponent = function HeaderComponent(_ref) {
71
71
  _useState2 = _slicedToArray(_useState, 2),
72
72
  bannerVisible = _useState2[0],
73
73
  setBannerVisible = _useState2[1];
74
- useEffect(function () {
75
- setBannerVisible(localStorage.getItem(ANNOUNCEMENT_LOCALSTORAGE_ID) !== 'true');
76
- }, [announcement]);
77
- function onBannerClose() {
78
- localStorage.setItem(ANNOUNCEMENT_LOCALSTORAGE_ID, 'true');
79
- setBannerVisible(false);
80
- }
81
74
  var showChinaMirror = !!internalSite;
82
75
  var chinaMirrorUrl = get(internalSite, 'url');
83
76
  var _useState3 = useState(false),
@@ -100,6 +93,19 @@ var HeaderComponent = function HeaderComponent(_ref) {
100
93
  _useState6 = _slicedToArray(_useState5, 2),
101
94
  lang = _useState6[0],
102
95
  setLang = _useState6[1];
96
+ var announcementTitle = useMemo(function () {
97
+ return get(announcement, ['title', lang]);
98
+ }, [announcement, lang]);
99
+ var announcementLinkTitle = useMemo(function () {
100
+ return get(announcement, ['link', 'text', lang]);
101
+ }, [announcement, lang]);
102
+ useEffect(function () {
103
+ setBannerVisible(!!announcementTitle && localStorage.getItem(ANNOUNCEMENT_LOCALSTORAGE_ID) !== 'true');
104
+ }, [announcementTitle]);
105
+ function onBannerClose() {
106
+ localStorage.setItem(ANNOUNCEMENT_LOCALSTORAGE_ID, 'true');
107
+ setBannerVisible(false);
108
+ }
103
109
  var _useState7 = useState(false),
104
110
  _useState8 = _slicedToArray(_useState7, 2),
105
111
  productMenuVisible = _useState8[0],
@@ -296,6 +302,7 @@ var HeaderComponent = function HeaderComponent(_ref) {
296
302
  className: cx(styles.arrow, _defineProperty({}, styles.open, productMenuVisible))
297
303
  })), /*#__PURE__*/React.createElement(Products, {
298
304
  className: styles.productsMenu,
305
+ bannerVisible: bannerVisible,
299
306
  show: productMenuVisible,
300
307
  rootDomain: rootDomain,
301
308
  language: defaultLanguage
@@ -394,12 +401,6 @@ var HeaderComponent = function HeaderComponent(_ref) {
394
401
  target: "_blank",
395
402
  rel: "noreferrer"
396
403
  }, /*#__PURE__*/React.createElement(GithubOutlined, null))));
397
- var announcementTitle = useMemo(function () {
398
- return get(announcement, ['title', lang]);
399
- }, [announcement, lang]);
400
- var announcementLinkTitle = useMemo(function () {
401
- return get(announcement, ['link', 'text', lang]);
402
- }, [announcement, lang]);
403
404
  return /*#__PURE__*/React.createElement("header", {
404
405
  className: cx(styles.header, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.transparent, !!transparent && !productMenuVisible), styles.isHomePage, !!isHomePage && !isAntVHome), styles.lightTheme, !!isAntVHome && !productMenuVisible && isWide), styles.isAntVHome, !!isAntVHome), styles.fixed, popupMenuVisible))
405
406
  }, bannerVisible && announcementTitle && /*#__PURE__*/React.createElement(Alert, {
@@ -2,6 +2,5 @@ import React from 'react';
2
2
  /**
3
3
  * Loading
4
4
  */
5
- declare const Loading: React.FC;
6
- declare const PageLoading: React.FC;
7
- export { Loading, PageLoading };
5
+ declare const Loading: () => React.JSX.Element;
6
+ export default Loading;
@@ -67,11 +67,4 @@ var Loading = function Loading() {
67
67
  className: "loading-text"
68
68
  }, /*#__PURE__*/React.createElement("p", null, "Loading...")))));
69
69
  };
70
- var PageLoading = function PageLoading() {
71
- return /*#__PURE__*/React.createElement("div", {
72
- style: {
73
- height: '100vh'
74
- }
75
- }, /*#__PURE__*/React.createElement(Loading, null));
76
- };
77
- export { Loading, PageLoading };
70
+ export default Loading;
@@ -254,7 +254,7 @@
254
254
  font-size: 12px;
255
255
  background: #fff;
256
256
  max-height: 100vh;
257
- overflow: hidden;
257
+ overflow: auto;
258
258
 
259
259
  position: sticky;
260
260
  top: 0;
@@ -693,4 +693,4 @@
693
693
  transition: all .3s;
694
694
  background-color: #fff;
695
695
  font-family: Avenir, -apple-system, BlinkMacSystemFont, Segoe UI, PingFang SC, Hiragino Sans GB, Microsoft YaHei, Helvetica Neue, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
696
- }
696
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "keywords": [
6
6
  "dumi",
@@ -105,6 +105,7 @@
105
105
  "@types/classnames": "^2.3.1",
106
106
  "@types/fs-extra": "^9.0.13",
107
107
  "@types/glob": "^8.0.0",
108
+ "@types/hast": "^2.3.5",
108
109
  "@types/lodash-es": "^4.17.6",
109
110
  "@types/node": "^18.11.3",
110
111
  "@types/react": "^18.0.21",