Skip to content

Commit be3d822

Browse files
committed
feat(fullscreen): remove img and use icons
fix #587
1 parent 0a8b379 commit be3d822

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,9 +1,10 @@
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';
56
import useLocale from '../locale/useLocale';
6-
import MyIcon from './icon';
7+
import './index.scss';
78

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

2829
export interface IFullscreenProps
2930
extends React.DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> {
30-
themeDark?: boolean;
3131
target?: string;
3232
iconStyle?: CSSProperties;
3333
fullIcon?: ReactNode;
@@ -36,7 +36,6 @@ export interface IFullscreenProps
3636
}
3737

3838
export default function Fullscreen({
39-
themeDark,
4039
target,
4140
fullIcon,
4241
exitFullIcon,
@@ -178,24 +177,34 @@ export default function Fullscreen({
178177
};
179178

180179
return (
181-
<KeyCombiner
182-
onTrigger={handlePressFullScreen}
183-
keyMap={{
184-
70: true,
185-
91: true,
186-
16: true,
187-
}}
188-
>
189-
{customIcon ? (
190-
<span {...other} onClick={handleFullScreen}>
191-
{customIcon}
192-
</span>
193-
) : (
194-
<Button onClick={handleFullScreen}>
195-
<MyIcon style={iconStyle} type={isFullScreen} themeDark={themeDark} />
196-
{isFullScreen ? locale.exitFull : locale.full}
197-
</Button>
198-
)}
199-
</KeyCombiner>
180+
<div className="dtc-fullscreen">
181+
<KeyCombiner
182+
onTrigger={handlePressFullScreen}
183+
keyMap={{
184+
70: true,
185+
91: true,
186+
16: true,
187+
}}
188+
>
189+
{customIcon ? (
190+
<span {...other} onClick={handleFullScreen}>
191+
{customIcon}
192+
</span>
193+
) : (
194+
<Button
195+
onClick={handleFullScreen}
196+
icon={
197+
isFullScreen ? (
198+
<FullscreenExitOutlined style={iconStyle} />
199+
) : (
200+
<FullscreenOutlined style={iconStyle} />
201+
)
202+
}
203+
>
204+
{isFullScreen ? locale.exitFull : locale.full}
205+
</Button>
206+
)}
207+
</KeyCombiner>
208+
</div>
200209
);
201210
}

src/fullscreen/style.scss

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

0 commit comments

Comments
 (0)