@logicflow/dumi-theme-simple
Version:
Simple website theme based on dumi2.
82 lines (81 loc) • 2.85 kB
JavaScript
import React from 'react';
import { Link, useLocale } from 'dumi';
import cx from 'classnames';
import { Badge } from 'antd';
import { createFromIconfontCN } from '@ant-design/icons';
import { ic } from "../../../../../slots/hooks";
import styles from "../../../index.module.less";
import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var IconFontIcon = createFromIconfontCN({
scriptUrl: 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/iconfont/iconfont.js' // self generate
});
/**
* DEMO 的卡片预览
*
* @param {DemoCardProps} props 相关参数,详见类型定义
* @returns {React.FC} React.FC
*/
export var DemoCard = function DemoCard(props) {
var demo = props.demo,
topicId = props.topicId,
exampleId = props.exampleId;
var locale = useLocale();
var renderCardInternal = function renderCardInternal() {
var img = demo.screenshot || 'https://cdn.jsdelivr.net/gh/Logic-Flow/static@latest/docs/screenshot-placeholder-white.png';
return /*#__PURE__*/_jsx(_Fragment, {
children: /*#__PURE__*/_jsx("div", {
className: cx('demo-card-screenshot', styles.screenshot),
style: {
backgroundImage: "url(\"".concat(img, "\")")
}
})
});
};
return demo.isExternal ? /*#__PURE__*/_jsxs("a", {
className: styles.galleryCardLink,
href: demo.previewUrl,
target: "_blank",
rel: "noreferrer",
children: [demo.isNew ? /*#__PURE__*/_jsx(Badge.Ribbon, {
text: "new",
className: styles.customRibbon,
children: renderCardInternal()
}) : renderCardInternal(), /*#__PURE__*/_jsxs("h4", {
children: [ic(demo.title), demo.githubUrl && /*#__PURE__*/_jsx("a", {
href: demo.githubUrl,
style: {
margin: '0 10px',
fontSize: '20px'
},
target: "_blank",
rel: "noreferrer",
children: /*#__PURE__*/_jsx(IconFontIcon, {
type: "icon-githublogo"
})
})]
})]
}) : /*#__PURE__*/_jsxs(Link, {
className: styles.galleryCardLink,
to: "".concat(locale.id === 'zh' ? '' : '/en', "/examples/").concat(topicId, "/").concat(exampleId, "/#").concat(demo.id),
children: [demo.isNew ? /*#__PURE__*/_jsx(Badge.Ribbon, {
text: "new",
className: styles.customRibbon,
children: renderCardInternal()
}) : renderCardInternal(), /*#__PURE__*/_jsxs("h4", {
children: [ic(demo.title), demo.githubUrl && /*#__PURE__*/_jsx("a", {
href: demo.githubUrl,
style: {
margin: '0 10px',
fontSize: '20px'
},
target: "_blank",
rel: "noreferrer",
children: /*#__PURE__*/_jsx(IconFontIcon, {
type: "icon-githublogo"
})
})]
})]
});
};