@antv/dumi-theme-antv 0.3.0-beta.13 → 0.3.0-beta.14

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.
@@ -5,7 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
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
6
 
7
7
  import React from 'react';
8
- import { useLocale, useSiteData } from 'dumi';
8
+ import { useLocale, useSiteData, FormattedMessage } from 'dumi';
9
9
  import { SEO } from "../../slots/SEO";
10
10
  import { Header } from "../../slots/Header";
11
11
  import { Detail } from "../../slots/Detail";
@@ -13,7 +13,6 @@ import { Features } from "../../slots/Features";
13
13
  import { Cases } from "../../slots/Cases";
14
14
  import { Companies } from "../../slots/Companies";
15
15
  import { Footer } from "../../slots/Footer";
16
- import { useT } from "../../slots/hooks";
17
16
  /**
18
17
  * Index 路由下的入口
19
18
  * - 获取数据
@@ -73,7 +72,9 @@ export var Index = function Index() {
73
72
  titleSuffix: "AntV",
74
73
  lang: locale.id
75
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, {
76
- title: useT("感谢信赖"),
75
+ title: /*#__PURE__*/React.createElement(FormattedMessage, {
76
+ id: "\u611F\u8C22\u4FE1\u8D56"
77
+ }),
77
78
  companies: companies
78
79
  }), /*#__PURE__*/React.createElement(Footer, null));
79
80
  };
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Link, useLocale } from 'dumi';
3
+ import cx from 'classnames';
3
4
  import { Badge } from 'antd';
5
+ import { ic } from "../../../../../slots/hooks";
4
6
  import styles from "../../../index.module.less";
5
7
  /**
6
8
  * DEMO 的卡片预览
@@ -19,9 +21,9 @@ export var DemoCard = function DemoCard(props) {
19
21
  var renderCardInternal = function renderCardInternal() {
20
22
  var img = demo.screenshot || 'https://gw.alipayobjects.com/os/s/prod/antv/assets/image/screenshot-placeholder-b8e70.png';
21
23
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
24
+ className: cx('demo-card-screenshot', styles.screenshot),
22
25
  style: {
23
- backgroundImage: "url(\"".concat(img, "\")"),
24
- backgroundSize: 'cover'
26
+ backgroundImage: "url(\"".concat(img, "\")")
25
27
  }
26
28
  }));
27
29
  };
@@ -32,5 +34,5 @@ export var DemoCard = function DemoCard(props) {
32
34
  }, demo.isNew ? /*#__PURE__*/React.createElement(Badge.Ribbon, {
33
35
  text: "new",
34
36
  className: styles.customRibbon
35
- }, renderCardInternal()) : renderCardInternal(), /*#__PURE__*/React.createElement("h4", null, demo.title[locale.id]));
37
+ }, renderCardInternal()) : renderCardInternal(), /*#__PURE__*/React.createElement("h4", null, ic(demo.title)));
36
38
  };
@@ -369,6 +369,12 @@
369
369
  transition: all 0.3s;
370
370
  margin: 12px;
371
371
 
372
+ .screenshot {
373
+ background-size: contain;
374
+ background-repeat: no-repeat;
375
+ background-position: center;
376
+ }
377
+
372
378
  > div {
373
379
  border: 1px solid @border-color-split;
374
380
  border-radius: 6px;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export interface NotificationProps {
3
+ index?: number;
4
+ type: string;
5
+ title: string;
6
+ date: string;
7
+ link: string;
8
+ }
9
+ declare const Notification: React.FC<NotificationProps>;
10
+ export default Notification;
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { Link } from 'dumi';
3
+ import styles from "./Notification.module.less";
4
+ var numberImages = ['https://gw.alipayobjects.com/zos/antfincdn/IqREAm36K7/1.png', 'https://gw.alipayobjects.com/zos/antfincdn/3fG1Iqjfnz/2.png'];
5
+
6
+ var Notification = function Notification(_ref) {
7
+ var _ref$index = _ref.index,
8
+ index = _ref$index === void 0 ? 0 : _ref$index,
9
+ type = _ref.type,
10
+ title = _ref.title,
11
+ date = _ref.date,
12
+ _ref$link = _ref.link,
13
+ link = _ref$link === void 0 ? '' : _ref$link;
14
+ var children = /*#__PURE__*/React.createElement("div", {
15
+ className: styles.container
16
+ }, /*#__PURE__*/React.createElement("img", {
17
+ className: styles.number,
18
+ src: numberImages[index],
19
+ alt: index.toString()
20
+ }), /*#__PURE__*/React.createElement("div", {
21
+ className: styles.content
22
+ }, /*#__PURE__*/React.createElement("p", {
23
+ className: styles.description
24
+ }, type, " \u2027 ", title), /*#__PURE__*/React.createElement("p", {
25
+ className: styles.date
26
+ }, date)));
27
+
28
+ if (link.startsWith('http')) {
29
+ return /*#__PURE__*/React.createElement("a", {
30
+ href: link,
31
+ target: "_blank",
32
+ rel: "noopener noreferrer",
33
+ className: styles.notification
34
+ }, children);
35
+ }
36
+
37
+ return /*#__PURE__*/React.createElement(Link, {
38
+ to: link,
39
+ className: styles.notification
40
+ }, children);
41
+ };
42
+
43
+ export default Notification;
@@ -0,0 +1,120 @@
1
+ .notification {
2
+ width: 50%;
3
+ margin-right: 2%;
4
+
5
+ &:last-child {
6
+ margin-right: 0;
7
+ }
8
+
9
+ .container {
10
+ height: 44px;
11
+ display: flex;
12
+
13
+ .number {
14
+ height: 100%;
15
+ width: 44px;
16
+ }
17
+
18
+ .content {
19
+ padding-left: 20px;
20
+ color: rgba(49, 70, 89, 1);
21
+ text-align: left;
22
+
23
+ .description {
24
+ top: 0;
25
+ font-size: 1.14em;
26
+ margin-bottom: 0;
27
+ transition: all 0.3s;
28
+ }
29
+
30
+ .date {
31
+ color: rgba(216, 203, 249, 1);
32
+ bottom: 0;
33
+ font-size: 1em;
34
+ margin-top: 4px;
35
+ margin-bottom: 0;
36
+ }
37
+ }
38
+ }
39
+
40
+ &:hover .description {
41
+ color: rgba(89, 126, 247, 1);
42
+ }
43
+ }
44
+
45
+ @media (max-width: 900px) {
46
+ .notification {
47
+ position: absolute;
48
+ width: 100%;
49
+
50
+ &:nth-child(1) {
51
+ animation: showAndHide0 6s infinite;
52
+ }
53
+
54
+ &:nth-child(2) {
55
+ top: 44px;
56
+ animation: showAndHide1 6s infinite;
57
+ }
58
+ }
59
+ }
60
+
61
+ @media (max-width: 768px) {
62
+ .notification {
63
+ width: 100%;
64
+ }
65
+ }
66
+
67
+ @keyframes showAndHide0 {
68
+ 0% {
69
+ opacity: 1;
70
+ top: 0px;
71
+ }
72
+
73
+ 33.3% {
74
+ opacity: 1;
75
+ top: 0px;
76
+ }
77
+
78
+ 50% {
79
+ opacity: 0;
80
+ top: -30px;
81
+ }
82
+
83
+ 83.3% {
84
+ opacity: 0;
85
+ top: 30px;
86
+ }
87
+
88
+ 100% {
89
+ opacity: 1;
90
+ top: 0px;
91
+ }
92
+ }
93
+
94
+ /* Standard syntax */
95
+ @keyframes showAndHide1 {
96
+ 0% {
97
+ opacity: 0;
98
+ top: 30px;
99
+ }
100
+
101
+ 33.3% {
102
+ opacity: 0;
103
+ top: 30px;
104
+ }
105
+
106
+ 50% {
107
+ opacity: 1;
108
+ top: 0px;
109
+ }
110
+
111
+ 83.3% {
112
+ opacity: 1;
113
+ top: 0px;
114
+ }
115
+
116
+ 100% {
117
+ opacity: 0;
118
+ top: -30px;
119
+ }
120
+ }
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { NotificationProps } from './Notification';
3
+ import 'video-react/dist/video-react.css';
4
+ declare type BannerButtonShape = 'round' | 'square';
5
+ interface BannerButton {
6
+ text: string;
7
+ link: string;
8
+ style?: React.CSSProperties;
9
+ type?: string;
10
+ shape?: BannerButtonShape;
11
+ }
12
+ interface BannerProps {
13
+ coverImage?: React.ReactNode;
14
+ title: string;
15
+ description: string;
16
+ notifications?: NotificationProps[];
17
+ style?: React.CSSProperties;
18
+ className?: string;
19
+ video?: string;
20
+ showGithubStars?: boolean;
21
+ buttons?: BannerButton[];
22
+ onCloseVideo?: () => void;
23
+ onPlayVideo?: () => void;
24
+ }
25
+ declare const Banner: React.FC<BannerProps>;
26
+ export default Banner;
@@ -0,0 +1,184 @@
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
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
8
+
9
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
+
11
+ 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."); }
12
+
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+
15
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
+
17
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
18
+
19
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
+
21
+ import React, { useEffect, useState } from 'react';
22
+ import { Modal } from 'antd';
23
+ import { CaretRightOutlined } from '@ant-design/icons';
24
+ import { FormattedMessage, Link, useLocale, useSiteData } from 'dumi';
25
+ import classNames from 'classnames';
26
+ import GitHubButton from 'react-github-button';
27
+ import gh from 'parse-github-url';
28
+ import { Player } from 'video-react';
29
+ import Notification from "./Notification";
30
+ import 'video-react/dist/video-react.css';
31
+ import styles from "./index.module.less";
32
+ var backLeftBottom = 'https://gw.alipayobjects.com/zos/basement_prod/441d5eaf-e623-47cd-b9b9-2a581d9ce1e3.svg';
33
+
34
+ var Banner = function Banner(_ref) {
35
+ var coverImage = _ref.coverImage,
36
+ title = _ref.title,
37
+ description = _ref.description,
38
+ notifications = _ref.notifications,
39
+ _ref$style = _ref.style,
40
+ style = _ref$style === void 0 ? {} : _ref$style,
41
+ className = _ref.className,
42
+ video = _ref.video,
43
+ _ref$showGithubStars = _ref.showGithubStars,
44
+ showGithubStars = _ref$showGithubStars === void 0 ? true : _ref$showGithubStars,
45
+ _ref$buttons = _ref.buttons,
46
+ buttons = _ref$buttons === void 0 ? [] : _ref$buttons,
47
+ onCloseVideo = _ref.onCloseVideo,
48
+ onPlayVideo = _ref.onPlayVideo;
49
+ var locale = useLocale();
50
+ var lang = locale.id.includes('zh') ? 'zh' : 'en';
51
+ var notificationsUrl = "https://my-json-server.typicode.com/antvis/antvis-sites-data/notifications?lang=".concat(lang);
52
+
53
+ var _useState = useState([]),
54
+ _useState2 = _slicedToArray(_useState, 2),
55
+ remoteNews = _useState2[0],
56
+ setRemoteNews = _useState2[1];
57
+
58
+ var _useSiteData = useSiteData(),
59
+ themeConfig = _useSiteData.themeConfig;
60
+
61
+ var githubUrl = themeConfig.githubUrl;
62
+ useEffect(function () {
63
+ fetch(notificationsUrl).then(function (res) {
64
+ return res.json();
65
+ }).then(function (data) {
66
+ setRemoteNews(data);
67
+ });
68
+ }, [notificationsUrl]);
69
+ var notificationsNode = (notifications || remoteNews).slice(0, 2).map(function (notification, i) {
70
+ return /*#__PURE__*/React.createElement(Notification, _extends({
71
+ index: i,
72
+ key: i
73
+ }, notification));
74
+ });
75
+
76
+ var showVideo = function showVideo() {
77
+ if (onPlayVideo) {
78
+ onPlayVideo();
79
+ }
80
+
81
+ Modal.info({
82
+ title: 'This is a notification message',
83
+ className: styles.videoModal,
84
+ onCancel: onCloseVideo,
85
+ content: /*#__PURE__*/React.createElement(Player, {
86
+ className: styles.video,
87
+ autoPlay: true,
88
+ src: video
89
+ }),
90
+ width: '70%'
91
+ });
92
+ };
93
+
94
+ var renderButtons = buttons.map(function (button, i) {
95
+ var ButtonLink = button.link.startsWith('http') || button.link.startsWith('#') ? 'a' : Link;
96
+ var buttonProps = {};
97
+
98
+ if (button.link.startsWith('http')) {
99
+ buttonProps.target = '_blank';
100
+ buttonProps.rel = 'noopener noreferrer';
101
+ }
102
+
103
+ if (ButtonLink === 'a') {
104
+ buttonProps.href = button.link;
105
+ } else {
106
+ buttonProps.to = button.link;
107
+ }
108
+
109
+ var _button$shape = button.shape,
110
+ shape = _button$shape === void 0 ? 'round' : _button$shape;
111
+ return /*#__PURE__*/React.createElement(ButtonLink, _extends({}, buttonProps, {
112
+ className: classNames(styles.buttonLink, styles[button.type || ''], button.type === 'primary' ? 'primary-button' : 'common-button'),
113
+ key: i,
114
+ style: _objectSpread({
115
+ borderRadius: shape === 'round' ? '1000px' : '4px'
116
+ }, button.style)
117
+ }), /*#__PURE__*/React.createElement("span", {
118
+ className: styles.button
119
+ }, button.text));
120
+ });
121
+
122
+ if (video) {
123
+ renderButtons.push( /*#__PURE__*/React.createElement("div", {
124
+ key: "video",
125
+ onClick: showVideo,
126
+ className: styles.videoButtonWrapper
127
+ }, /*#__PURE__*/React.createElement("div", {
128
+ className: styles.videoButton
129
+ }, /*#__PURE__*/React.createElement(CaretRightOutlined, {
130
+ className: styles.videoButtonIcon
131
+ }), /*#__PURE__*/React.createElement("p", {
132
+ className: styles.videoButtonText,
133
+ style: {
134
+ fontSize: '14px',
135
+ lineHeight: '40px'
136
+ }
137
+ }, /*#__PURE__*/React.createElement(FormattedMessage, {
138
+ id: "\u77E5\u6E90\u30FB\u81F4\u8FDC"
139
+ })))));
140
+ }
141
+
142
+ if (showGithubStars) {
143
+ var githubObj = gh(githubUrl);
144
+
145
+ if (githubObj && githubObj.owner && githubObj.name) {
146
+ renderButtons.push( /*#__PURE__*/React.createElement("div", {
147
+ key: "github",
148
+ className: styles.githubWrapper
149
+ }, /*#__PURE__*/React.createElement(GitHubButton, {
150
+ type: "stargazers",
151
+ size: "large",
152
+ namespace: githubObj.owner,
153
+ repo: githubObj.name
154
+ })));
155
+ }
156
+ }
157
+
158
+ return /*#__PURE__*/React.createElement("section", {
159
+ className: classNames(styles.wrapper, className),
160
+ style: style
161
+ }, /*#__PURE__*/React.createElement("div", {
162
+ className: styles.content
163
+ }, /*#__PURE__*/React.createElement("div", {
164
+ className: styles.text
165
+ }, /*#__PURE__*/React.createElement("div", {
166
+ className: classNames(styles.title, 'banner-title')
167
+ }, title), /*#__PURE__*/React.createElement("p", {
168
+ className: classNames(styles.description, 'banner-description')
169
+ }, description), /*#__PURE__*/React.createElement("div", {
170
+ className: classNames(styles.buttons, 'banner-buttons')
171
+ }, renderButtons)), /*#__PURE__*/React.createElement("div", {
172
+ className: classNames(styles.notifications, 'notifications')
173
+ }, notificationsNode), /*#__PURE__*/React.createElement("div", {
174
+ className: classNames(styles.teaser, 'teaser')
175
+ }, /*#__PURE__*/React.createElement("div", {
176
+ className: classNames(styles.teaserimg, 'teaser-img')
177
+ }, coverImage)), /*#__PURE__*/React.createElement("img", {
178
+ className: styles.backLeftBottom,
179
+ src: backLeftBottom,
180
+ alt: "back"
181
+ })));
182
+ };
183
+
184
+ export default Banner;