@antv/dumi-theme-antv 0.1.0

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.
Files changed (111) hide show
  1. package/README.md +9 -0
  2. package/es/antv/404/index.js +20 -0
  3. package/es/antv/Banner/Banner.module.less +412 -0
  4. package/es/antv/Banner/Notification.js +44 -0
  5. package/es/antv/Banner/Notification.module.less +108 -0
  6. package/es/antv/Banner/index.js +115 -0
  7. package/es/antv/Cases/Cases.js +124 -0
  8. package/es/antv/Cases/Cases.module.less +203 -0
  9. package/es/antv/Features/FeatureCard.js +25 -0
  10. package/es/antv/Features/FeatureCard.module.less +51 -0
  11. package/es/antv/Features/Features.module.less +169 -0
  12. package/es/antv/Features/index.js +102 -0
  13. package/es/antv/Footer/Footer.module.less +36 -0
  14. package/es/antv/Footer/index.js +232 -0
  15. package/es/antv/Header/Logo.js +130 -0
  16. package/es/antv/Products/Product.js +61 -0
  17. package/es/antv/Products/Product.module.less +146 -0
  18. package/es/antv/Products/getNewProducts.js +41 -0
  19. package/es/antv/Products/getProducts.js +466 -0
  20. package/es/antv/Products/index.js +81 -0
  21. package/es/antv/hooks.js +81 -0
  22. package/es/antv/mixins.less +21 -0
  23. package/es/antv/utils.js +49 -0
  24. package/es/builtins/API.js +37 -0
  25. package/es/builtins/Alert.js +9 -0
  26. package/es/builtins/Alert.less +62 -0
  27. package/es/builtins/Badge.js +9 -0
  28. package/es/builtins/Badge.less +31 -0
  29. package/es/builtins/Example.js +48 -0
  30. package/es/builtins/Example.less +47 -0
  31. package/es/builtins/Previewer.js +225 -0
  32. package/es/builtins/Previewer.less +406 -0
  33. package/es/builtins/SourceCode.js +72 -0
  34. package/es/builtins/SourceCode.less +103 -0
  35. package/es/builtins/Table.js +56 -0
  36. package/es/builtins/Table.less +43 -0
  37. package/es/builtins/Tree.js +219 -0
  38. package/es/builtins/Tree.less +159 -0
  39. package/es/components/Dark.js +125 -0
  40. package/es/components/Dark.less +121 -0
  41. package/es/components/LocaleSelect.js +53 -0
  42. package/es/components/LocaleSelect.less +59 -0
  43. package/es/components/Navbar.js +155 -0
  44. package/es/components/Navbar.less +180 -0
  45. package/es/components/SearchBar.js +83 -0
  46. package/es/components/SearchBar.less +165 -0
  47. package/es/components/SideMenu.js +99 -0
  48. package/es/components/SideMenu.less +379 -0
  49. package/es/components/SlugList.js +33 -0
  50. package/es/components/SlugList.less +18 -0
  51. package/es/layout.js +276 -0
  52. package/es/style/layout.less +402 -0
  53. package/es/style/markdown.less +240 -0
  54. package/es/style/variables.less +37 -0
  55. package/package.json +58 -0
  56. package/src/antv/404/index.tsx +25 -0
  57. package/src/antv/Banner/Banner.module.less +412 -0
  58. package/src/antv/Banner/Notification.module.less +108 -0
  59. package/src/antv/Banner/Notification.tsx +45 -0
  60. package/src/antv/Banner/index.tsx +121 -0
  61. package/src/antv/Cases/Cases.module.less +203 -0
  62. package/src/antv/Cases/Cases.tsx +116 -0
  63. package/src/antv/Features/FeatureCard.module.less +51 -0
  64. package/src/antv/Features/FeatureCard.tsx +24 -0
  65. package/src/antv/Features/Features.module.less +169 -0
  66. package/src/antv/Features/index.tsx +86 -0
  67. package/src/antv/Footer/Footer.module.less +36 -0
  68. package/src/antv/Footer/index.tsx +272 -0
  69. package/src/antv/Header/Logo.tsx +85 -0
  70. package/src/antv/Products/Product.module.less +146 -0
  71. package/src/antv/Products/Product.tsx +80 -0
  72. package/src/antv/Products/getNewProducts.tsx +53 -0
  73. package/src/antv/Products/getProducts.tsx +626 -0
  74. package/src/antv/Products/index.tsx +70 -0
  75. package/src/antv/hooks.ts +87 -0
  76. package/src/antv/mixins.less +21 -0
  77. package/src/antv/utils.ts +44 -0
  78. package/src/builtins/API.tsx +57 -0
  79. package/src/builtins/Alert.less +62 -0
  80. package/src/builtins/Alert.tsx +4 -0
  81. package/src/builtins/Badge.less +31 -0
  82. package/src/builtins/Badge.tsx +4 -0
  83. package/src/builtins/Example.less +47 -0
  84. package/src/builtins/Example.tsx +34 -0
  85. package/src/builtins/Previewer.less +406 -0
  86. package/src/builtins/Previewer.tsx +264 -0
  87. package/src/builtins/SourceCode.less +103 -0
  88. package/src/builtins/SourceCode.tsx +55 -0
  89. package/src/builtins/Table.less +43 -0
  90. package/src/builtins/Table.tsx +42 -0
  91. package/src/builtins/Tree.less +159 -0
  92. package/src/builtins/Tree.tsx +130 -0
  93. package/src/components/Dark.less +121 -0
  94. package/src/components/Dark.tsx +78 -0
  95. package/src/components/LocaleSelect.less +59 -0
  96. package/src/components/LocaleSelect.tsx +53 -0
  97. package/src/components/Navbar.less +180 -0
  98. package/src/components/Navbar.tsx +152 -0
  99. package/src/components/SearchBar.less +165 -0
  100. package/src/components/SearchBar.tsx +68 -0
  101. package/src/components/SideMenu.less +379 -0
  102. package/src/components/SideMenu.tsx +148 -0
  103. package/src/components/SlugList.less +18 -0
  104. package/src/components/SlugList.tsx +20 -0
  105. package/src/layout.tsx +225 -0
  106. package/src/style/layout.less +402 -0
  107. package/src/style/markdown.less +240 -0
  108. package/src/style/variables.less +37 -0
  109. package/src/test/SearchBar.test.ts +32 -0
  110. package/src/test/Table.test.tsx +41 -0
  111. package/src/test/index.test.tsx +377 -0
@@ -0,0 +1,87 @@
1
+ import { useEffect, useState } from "react";
2
+ export interface NavigatorBannerProps {
3
+ post?: {
4
+ slug?: string;
5
+ title?: string;
6
+ };
7
+ type: "prev" | "next";
8
+ }
9
+
10
+ export const useChinaMirrorHost = (): [boolean] => {
11
+ const [isChinaMirrorHost, setIsChinaMirrorHost] = useState(false);
12
+ useEffect(() => {
13
+ if (
14
+ window.location.host.includes("gitee.io") &&
15
+ window.location.host.includes("antv")
16
+ ) {
17
+ setIsChinaMirrorHost(true);
18
+ }
19
+ }, []);
20
+ return [isChinaMirrorHost];
21
+ };
22
+
23
+ export const usePrevAndNext = (): NavigatorBannerProps["post"][] => {
24
+ const [prevAndNext, setPrevAndNext] = useState<
25
+ NavigatorBannerProps["post"][]
26
+ >([]);
27
+ useEffect(() => {
28
+ const menuNodes = document.querySelectorAll("aside .ant-menu-item a");
29
+ const currentMenuNode = document.querySelector(
30
+ "aside .ant-menu-item-selected a"
31
+ );
32
+ const currentIndex = Array.from(menuNodes).findIndex(
33
+ (node) => node === currentMenuNode
34
+ );
35
+ const prevNode =
36
+ currentIndex - 1 >= 0 ? menuNodes[currentIndex - 1] : undefined;
37
+ const nextNode =
38
+ currentIndex + 1 < menuNodes.length
39
+ ? menuNodes[currentIndex + 1]
40
+ : undefined;
41
+ const prev = prevNode
42
+ ? {
43
+ slug: prevNode.getAttribute("href") || undefined,
44
+ title: prevNode.textContent || undefined,
45
+ }
46
+ : undefined;
47
+ const next = nextNode
48
+ ? {
49
+ slug: nextNode.getAttribute("href") || undefined,
50
+ title: nextNode.textContent || undefined,
51
+ }
52
+ : undefined;
53
+ setPrevAndNext([prev, next]);
54
+ }, []);
55
+ return prevAndNext;
56
+ };
57
+
58
+ export const useLogoLink = ({
59
+ link = "",
60
+ siteUrl = "",
61
+ lang = "",
62
+ }: {
63
+ link?: string;
64
+ siteUrl?: string;
65
+ lang?: string;
66
+ }): [string] => {
67
+ let defaultLogoLink;
68
+ if (link) {
69
+ defaultLogoLink = link;
70
+ } else if (siteUrl === "https://antv.vision") {
71
+ defaultLogoLink = `/${lang}`;
72
+ } else {
73
+ defaultLogoLink = `https://antv.vision/${lang}`;
74
+ }
75
+
76
+ const [giteeLogoLink, setGiteeLogoLink] = useState("");
77
+ useEffect(() => {
78
+ if (
79
+ window.location.host.includes("gitee.io") &&
80
+ window.location.host.includes("antv")
81
+ ) {
82
+ setGiteeLogoLink(`https://antv.gitee.io/${lang}`);
83
+ }
84
+ }, []);
85
+
86
+ return [giteeLogoLink || defaultLogoLink];
87
+ };
@@ -0,0 +1,21 @@
1
+ @import "~antd/es/style/themes/default.less";
2
+ @primaryColor: #873bf4;
3
+
4
+ .container1440() {
5
+ width: 1440px;
6
+ max-width: calc(100% - 80px);
7
+ margin-left: auto;
8
+ margin-right: auto;
9
+
10
+ @media only screen and (max-width: 931.99px) {
11
+ & {
12
+ max-width: calc(100% - 60px);
13
+ }
14
+ }
15
+
16
+ @media only screen and (max-width: 767.99px) {
17
+ & {
18
+ max-width: calc(100% - 32px);
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,44 @@
1
+ type Status = 'responded' | 'error' | 'timeout';
2
+
3
+ export const ping = (callback: (status: Status) => void): NodeJS.Timeout => {
4
+ const url =
5
+ 'https://private-a' +
6
+ 'lipay' +
7
+ 'objects.alip' +
8
+ 'ay.com/alip' +
9
+ 'ay-rmsdeploy-image/rmsportal/RKuAiriJqrUhyqW.png';
10
+ const img = new Image();
11
+ let done = false;
12
+ const finish = (status: Status) => {
13
+ if (!done) {
14
+ done = true;
15
+ img.src = '';
16
+ callback(status);
17
+ }
18
+ };
19
+ img.onload = () => finish('responded');
20
+ img.onerror = () => finish('error');
21
+ img.src = url;
22
+ return setTimeout(() => finish('timeout'), 1500);
23
+ };
24
+
25
+ export const capitalize = (s: string): string => {
26
+ if (typeof s !== 'string') {
27
+ return '';
28
+ }
29
+ return s.charAt(0).toUpperCase() + s.slice(1);
30
+ };
31
+
32
+ export const getChinaMirrorHost = (host?: string): string => {
33
+ const hostString = typeof host === 'undefined' ? window.location.host : host;
34
+ // antv.vision => antv.gitee.io
35
+ if (hostString === 'antv.vision') {
36
+ return 'antv.gitee.io';
37
+ }
38
+ // g2plot.antv.vision => antv-g2plot.gitee.io
39
+ const match = hostString.match(/(.*)\.antv\.vision/);
40
+ if (match && match[1]) {
41
+ return `antv-${match[1]}.gitee.io`;
42
+ }
43
+ return hostString;
44
+ };
@@ -0,0 +1,57 @@
1
+ import React, { useContext } from 'react';
2
+ import type { IApiComponentProps} from 'dumi/theme';
3
+ import { context, useApiData, AnchorLink } from 'dumi/theme';
4
+
5
+ const LOCALE_TEXTS = {
6
+ 'zh-CN': {
7
+ name: '属性名',
8
+ description: '描述',
9
+ type: '类型',
10
+ default: '默认值',
11
+ required: '(必选)',
12
+ },
13
+ 'en-US': {
14
+ name: 'Name',
15
+ description: 'Description',
16
+ type: 'Type',
17
+ default: 'Default',
18
+ required: '(required)',
19
+ },
20
+ };
21
+
22
+ export default ({ identifier, export: expt }: IApiComponentProps) => {
23
+ const data = useApiData(identifier);
24
+ const { locale } = useContext(context);
25
+ const texts = /^zh|cn$/i.test(locale) ? LOCALE_TEXTS['zh-CN'] : LOCALE_TEXTS['en-US'];
26
+
27
+ return (
28
+ <>
29
+ {data && (
30
+ <table style={{ marginTop: 24 }}>
31
+ <thead>
32
+ <tr>
33
+ <th>{texts.name}</th>
34
+ <th>{texts.description}</th>
35
+ <th>{texts.type}</th>
36
+ <th>{texts.default}</th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ {data[expt].map(row => (
41
+ <tr key={row.identifier}>
42
+ <td>{row.identifier}</td>
43
+ <td>{row.description || '--'}</td>
44
+ <td>
45
+ <code>{row.type}</code>
46
+ </td>
47
+ <td>
48
+ <code>{row.default || (row.required && texts.required) || '--'}</code>
49
+ </td>
50
+ </tr>
51
+ ))}
52
+ </tbody>
53
+ </table>
54
+ )}
55
+ </>
56
+ );
57
+ };
@@ -0,0 +1,62 @@
1
+ @import (reference) '../style/variables.less';
2
+
3
+ .@{prefix}-alert {
4
+ @s-border-right: 3px;
5
+
6
+ position: relative;
7
+ margin: 24px 0;
8
+ padding: 10px 20px;
9
+ color: @c-text;
10
+ font-size: 14px;
11
+ line-height: 20px;
12
+ border-left: 0;
13
+ background: #ffffff;
14
+ box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.06);
15
+ border-radius: 1px;
16
+
17
+ [data-prefers-color=dark] & {
18
+ color: @c-text-dark;
19
+ background: @c-bg-dark;
20
+ box-shadow: 0 1px 2px -2px rgba(0,0,0,0.64), 0 3px 6px 0 rgba(0,0,0,0.48), 0 5px 12px 4px rgba(0,0,0,0.36);
21
+ }
22
+
23
+ &::after {
24
+ content: '';
25
+ position: absolute;
26
+ display: inline-block;
27
+ top: 0;
28
+ left: 0;
29
+ bottom: 0;
30
+ width: @s-border-right;
31
+ border-radius: 1px;
32
+ }
33
+
34
+ &:first-child {
35
+ margin-top: 0;
36
+ }
37
+
38
+ &:not([type]),
39
+ &[type='warning'] {
40
+ &::after {
41
+ background: #ffc121;
42
+ }
43
+ }
44
+
45
+ &[type='info'] {
46
+ &::after {
47
+ background: #69b9ff;
48
+ }
49
+ }
50
+
51
+ &[type='success'] {
52
+ &::after {
53
+ background: #8cd225;
54
+ }
55
+ }
56
+
57
+ &[type='error'] {
58
+ &::after {
59
+ background: #ff4646;
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import './Alert.less';
3
+
4
+ export default (props: any) => <div className="__dumi-default-alert" {...props} />;
@@ -0,0 +1,31 @@
1
+ @import (reference) '../style/variables.less';
2
+
3
+ .@{prefix}-badge {
4
+ display: inline-block;
5
+ margin-left: 6px;
6
+ padding: 1px 7px;
7
+ color: #fff;
8
+ font-size: 13px;
9
+ line-height: 20px;
10
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1);
11
+ box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.06);
12
+ border-radius: 1px;
13
+ vertical-align: top;
14
+
15
+ &:not([type]),
16
+ &[type='info'] {
17
+ background: #4569d4;
18
+ }
19
+
20
+ &[type='warning'] {
21
+ background: #ffc121;
22
+ }
23
+
24
+ &[type='success'] {
25
+ background: #8cd225;
26
+ }
27
+
28
+ &[type='error'] {
29
+ background: #ff4646;
30
+ }
31
+ }
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import './Badge.less';
3
+
4
+ export default (props: any) => <span className="__dumi-default-badge" {...props} />;
@@ -0,0 +1,47 @@
1
+ @import (reference) '../style/variables.less';
2
+
3
+ .@{prefix}-example-wrapper {
4
+ padding-top: 16px;
5
+ height: calc(100vh - @s-nav-height - 2px);
6
+
7
+ @media @mobile {
8
+ padding-top: 16px;
9
+ }
10
+
11
+ &-toolbar {
12
+ display: flex;
13
+ color: @c-heading;
14
+ font-size: 16px;
15
+ font-weight: 500;
16
+ justify-content: space-between;
17
+ margin-bottom: 16px;
18
+ border-bottom: 1px solid @c-border;
19
+
20
+ button,
21
+ a {
22
+ display: inline-block;
23
+ margin: 6px 0 6px 12px;
24
+ width: 16px;
25
+ height: 16px;
26
+ font-weight: 400;
27
+ border: 0;
28
+ outline: none;
29
+ vertical-align: middle;
30
+ cursor: pointer;
31
+
32
+ &:first-child {
33
+ background-position-x: -144px;
34
+ }
35
+
36
+ &:nth-child(2) {
37
+ background-position-x: -126px;
38
+ }
39
+ }
40
+ }
41
+
42
+ iframe {
43
+ width: 100%;
44
+ min-height: 100%;
45
+ border: 0;
46
+ }
47
+ }
@@ -0,0 +1,34 @@
1
+ import React, { useRef, useEffect, useState } from 'react';
2
+ import './Example.less';
3
+
4
+ export default (props: { route: any }) => {
5
+ const elm = useRef<HTMLIFrameElement>();
6
+ const [height, setHeight] = useState(0);
7
+
8
+ useEffect(() => {
9
+ setHeight(elm.current.contentWindow.document.documentElement.scrollHeight);
10
+ }, [elm]);
11
+
12
+ return (
13
+ props.route.meta.examplePath && (
14
+ <div className="__dumi-default-example-wrapper">
15
+ <div className="__dumi-default-example-wrapper-toolbar">
16
+ {props.route.meta.description || props.route.meta.title}
17
+ <span>
18
+ <button
19
+ className="__dumi-default-icon"
20
+ onClick={() => elm.current.contentWindow.location.reload()}
21
+ />
22
+ <a
23
+ target="_blank"
24
+ rel="noopener noreferrer"
25
+ href={props.route.meta.examplePath}
26
+ className="__dumi-default-icon"
27
+ />
28
+ </span>
29
+ </div>
30
+ <iframe src={props.route.meta.examplePath} ref={elm} style={{ height }} title="dumi" />
31
+ </div>
32
+ )
33
+ );
34
+ };