Skip to content

Commit 5cf9277

Browse files
committed
feat(fullscreen): remove img and use icons
fix #587
1 parent f687f07 commit 5cf9277

File tree

7 files changed

+44
-115
lines changed

7 files changed

+44
-115
lines changed

src/fullscreen/demos/local.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
import React, { useEffect, useState } from 'react';
1+
import React from 'react';
22
import { Card } from 'antd';
33
import { Fullscreen } from 'dt-react-component';
44

55
export default () => {
6-
const [targetKey, setTargetKey] = useState('');
7-
8-
useEffect(() => {
9-
setTargetKey('localContainer');
10-
}, []);
11-
126
return (
13-
<Card id={targetKey} style={{ background: '#fafafa' }}>
14-
<Fullscreen target={targetKey} />
7+
<Card id="localContainer" style={{ background: '#fafafa' }}>
8+
<Fullscreen target="localContainer" />
159
<div style={{ margin: '10px 0', textAlign: 'center' }}>Fullscreen in this</div>
1610
</Card>
1711
);

src/fullscreen/demos/theme.tsx

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/fullscreen/icon.tsx

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/fullscreen/index.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ demo:
1515
## 代码演示
1616

1717
<code src="./demos/basic.tsx" title="基本使用"></code>
18-
<code src="./demos/theme.tsx" title="主题切换"></code>
1918
<code src="./demos/local.tsx" title="局部全屏" iframe="124"></code>
2019
<code src="./demos/custom.tsx" title="自定义全屏图标" ></code>
2120

2221
## API
2322

24-
| 参数 | 说明 | 类型 | 默认值 |
25-
| ------------ | -------------------------- | ----------------- | ------- |
26-
| target | 全局操作作用于指定目标对象 | `string` | - |
27-
| themeDark | 是否使用暗黑主题模式 | `boolean` | `false` |
28-
| iconStyle | 图标元素样式 | `CSSProperties` | - |
29-
| fullIcon | 自定义全屏图标 | `React.ReactNode` | - |
30-
| exitFullIcon | 自定义退出全屏图标 | `React.ReactNode` | - |
23+
| 参数 | 说明 | 类型 | 默认值 |
24+
| ------------ | -------------------------- | ----------------- | ------ |
25+
| target | 全局操作作用于指定目标对象 | `string` | - |
26+
| iconStyle | 图标元素样式 | `CSSProperties` | - |
27+
| fullIcon | 自定义全屏图标 | `React.ReactNode` | - |
28+
| exitFullIcon | 自定义退出全屏图标 | `React.ReactNode` | - |

src/fullscreen/index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.dtc-fullscreen {
2+
width: fit-content;
3+
}

src/fullscreen/index.tsx

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { CSSProperties, HTMLAttributes, ReactNode, useEffect, useState } from 'react';
2-
import { Button } from 'antd';
2+
import { FullscreenExitOutlined, FullscreenOutlined } from '@dtinsight/react-icons';
33

4+
import Button from '../button';
45
import KeyEventListener from '../keyEventListener';
5-
import MyIcon from './icon';
6+
import './index.scss';
67

78
const { KeyCombiner } = KeyEventListener;
89
declare let document: any;
@@ -26,7 +27,6 @@ interface DocumentWithFullscreen extends Document {
2627

2728
export interface IFullscreenProps
2829
extends React.DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> {
29-
themeDark?: boolean;
3030
target?: string;
3131
iconStyle?: CSSProperties;
3232
fullIcon?: ReactNode;
@@ -35,7 +35,6 @@ export interface IFullscreenProps
3535
}
3636

3737
export default function Fullscreen({
38-
themeDark,
3938
target,
4039
fullIcon,
4140
exitFullIcon,
@@ -173,24 +172,34 @@ export default function Fullscreen({
173172
};
174173

175174
return (
176-
<KeyCombiner
177-
onTrigger={handlePressFullScreen}
178-
keyMap={{
179-
70: true,
180-
91: true,
181-
16: true,
182-
}}
183-
>
184-
{customIcon ? (
185-
<span {...other} onClick={handleFullScreen}>
186-
{customIcon}
187-
</span>
188-
) : (
189-
<Button onClick={handleFullScreen}>
190-
<MyIcon style={iconStyle} type={isFullScreen} themeDark={themeDark} />
191-
{isFullScreen ? '退出全屏' : '全屏'}
192-
</Button>
193-
)}
194-
</KeyCombiner>
175+
<div className="dtc-fullscreen">
176+
<KeyCombiner
177+
onTrigger={handlePressFullScreen}
178+
keyMap={{
179+
70: true,
180+
91: true,
181+
16: true,
182+
}}
183+
>
184+
{customIcon ? (
185+
<span {...other} onClick={handleFullScreen}>
186+
{customIcon}
187+
</span>
188+
) : (
189+
<Button
190+
onClick={handleFullScreen}
191+
icon={
192+
isFullScreen ? (
193+
<FullscreenExitOutlined style={iconStyle} />
194+
) : (
195+
<FullscreenOutlined style={iconStyle} />
196+
)
197+
}
198+
>
199+
{isFullScreen ? '退出全屏' : '全屏'}
200+
</Button>
201+
)}
202+
</KeyCombiner>
203+
</div>
195204
);
196205
}

src/fullscreen/style.scss

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)