Browse Source

fix: fix CopyBlock style warning

pull/4536/head
陈帅 7 years ago
parent
commit
21d4f7519c
  1. 13
      src/components/CopyBlock/index.tsx

13
src/components/CopyBlock/index.tsx

@ -1,7 +1,7 @@
import { Icon, Popover, Typography } from 'antd'; import { Icon, Popover, Typography } from 'antd';
import { FormattedMessage } from 'umi-plugin-react/locale'; import { FormattedMessage } from 'umi-plugin-react/locale';
import React from 'react'; import React, { useRef } from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import { isAntDesignPro } from '@/utils/utils'; import { isAntDesignPro } from '@/utils/utils';
import styles from './index.less'; import styles from './index.less';
@ -41,8 +41,13 @@ const BlockCodeView: React.SFC<{
text: blockUrl, text: blockUrl,
onCopy: () => onBlockCopy(url), onCopy: () => onBlockCopy(url),
}} }}
style={{
display: 'flex',
}}
> >
<code className={styles['copy-block-code']}>{blockUrl}</code> <pre>
<code className={styles['copy-block-code']}>{blockUrl}</code>
</pre>
</Typography.Paragraph> </Typography.Paragraph>
</div> </div>
); );
@ -58,14 +63,16 @@ export default connect(({ routing }: { routing: RoutingType }) => ({
location: routing.location, location: routing.location,
}))(({ location }: RoutingType) => { }))(({ location }: RoutingType) => {
const url = location.pathname; const url = location.pathname;
const divDom = useRef<HTMLDivElement>(null);
return ( return (
<Popover <Popover
title={<FormattedMessage id="app.preview.down.block" defaultMessage="下载此页面到本地项目" />} title={<FormattedMessage id="app.preview.down.block" defaultMessage="下载此页面到本地项目" />}
placement="topLeft" placement="topLeft"
content={<BlockCodeView url={url} />} content={<BlockCodeView url={url} />}
trigger="click" trigger="click"
getPopupContainer={dom => (divDom.current ? divDom.current : dom)}
> >
<div className={styles['copy-block']}> <div className={styles['copy-block']} ref={divDom}>
<Icon type="download" /> <Icon type="download" />
</div> </div>
</Popover> </Popover>

Loading…
Cancel
Save