Skip to content

Commit 89be606

Browse files
authored
feat: z-index (#117)
1 parent e667921 commit 89be606

File tree

9 files changed

+48
-2
lines changed

9 files changed

+48
-2
lines changed

src/components/IFrameWidget/editor.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ class IFrameWidgetEditor extends Component<Props, IFrameWidgetProps> {
195195
value={this.state.position?.left}
196196
/>
197197
</FormGroup>
198+
<FormGroup>
199+
<TextField
200+
type="number"
201+
label="z-index"
202+
fullWidth
203+
variant="outlined"
204+
onChange={(e) => {
205+
this.setState({ ...this.state, zIndex: parseInt(e.target.value) });
206+
}}
207+
value={this.state.zIndex}
208+
/>
209+
</FormGroup>
198210
</>
199211

200212
<FormGroup>
@@ -226,6 +238,7 @@ class IFrameWidgetEditor extends Component<Props, IFrameWidgetProps> {
226238
retry_count: 3,
227239
width: 640,
228240
height: 480,
241+
zIndex: 0,
229242
};
230243
}
231244

src/components/IFrameWidget/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type IFrameWidgetProps = {
1212
width: number;
1313
height: number;
1414
position?: Position;
15+
zIndex: number;
1516
}
1617

1718
export type { Position, IFrameWidgetProps };

src/components/IFrameWidget/widget.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { VFC, useState, CSSProperties } from 'react';
22
import styled from 'styled-components';
33
import type { IFrameWidgetProps } from './types';
44

5-
const IFrameWidget: VFC<IFrameWidgetProps> = ({ url, retry_time, retry_count, width, height, position }) => {
5+
const IFrameWidget: VFC<IFrameWidgetProps> = ({ url, retry_time, retry_count, width, height, position, zIndex }) => {
66
const [count, setCount] = useState(0);
77

88
const handleLoaded = () => {
@@ -20,6 +20,7 @@ const IFrameWidget: VFC<IFrameWidgetProps> = ({ url, retry_time, retry_count, wi
2020

2121
const style: CSSProperties = {
2222
position: 'absolute',
23+
zIndex,
2324
};
2425

2526
if (position?.top !== undefined) style.top = position.top;

src/components/TextWidget/editor.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,18 @@ class TextWidgetEditor extends Component<Props, TextWidgetProps> {
314314
value={this.state.position?.left}
315315
/>
316316
</FormGroup>
317+
<FormGroup>
318+
<TextField
319+
type="number"
320+
label="z-index"
321+
fullWidth
322+
variant="outlined"
323+
onChange={(e) => {
324+
this.setState({ ...this.state, zIndex: parseInt(e.target.value) });
325+
}}
326+
value={this.state.zIndex}
327+
/>
328+
</FormGroup>
317329
<FormGroup>
318330
<FormControlLabel
319331
control={
@@ -371,6 +383,7 @@ class TextWidgetEditor extends Component<Props, TextWidgetProps> {
371383
text: "",
372384
hidden: false,
373385
autoHidden: true,
386+
zIndex: 0,
374387
}
375388
}
376389

src/components/TextWidget/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type TextWidgetProps = {
2121
position?: Position;
2222
hidden: boolean;
2323
autoHidden: boolean;
24+
zIndex: number;
2425
};
2526

2627
export type { Position, TextWidgetProps };

src/components/TextWidget/widget.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const TextWidget: VFC<TextWidgetProps> = ({
4343
position,
4444
hidden,
4545
autoHidden,
46+
zIndex,
4647
}) => {
4748
const edge = calcTextShadow(edgeWeight || 1, edgeColor || '#000000');
4849

@@ -57,6 +58,7 @@ const TextWidget: VFC<TextWidgetProps> = ({
5758
textAlign: textAlign || 'left',
5859
backgroundColor: backgroundColor || 'rgba(0,0,0,0.1)',
5960
display: hidden || autoHidden && text.length === 0 ? 'none' : 'block',
61+
zIndex,
6062
};
6163

6264
if (position?.top !== undefined) style.top = position.top;

src/components/TimeWidget/editor.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ class TimeWidgetEditor extends Component<Props, TimeWidgetProps> {
7373
value={this.state.size}
7474
/>
7575
</FormGroup>
76+
<FormGroup>
77+
<TextField
78+
type="number"
79+
label="z-index"
80+
fullWidth
81+
variant="outlined"
82+
onChange={(e) => {
83+
this.setState({ ...this.state, zIndex: parseInt(e.target.value) });
84+
}}
85+
value={this.state.zIndex}
86+
/>
87+
</FormGroup>
7688
<FormGroup>
7789
<FormControlLabel
7890
control={
@@ -116,6 +128,7 @@ class TimeWidgetEditor extends Component<Props, TimeWidgetProps> {
116128
public static defaultProps: TimeWidgetProps = {
117129
size: 24,
118130
hidden: false,
131+
zIndex: 0,
119132
};
120133
}
121134

src/components/TimeWidget/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
type TimeWidgetProps = {
22
size: number;
33
hidden: boolean;
4+
zIndex: number;
45
};
56

67
export type { TimeWidgetProps };

src/components/TimeWidget/widget.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TimeWidget extends React.Component<TimeWidgetProps, TimeWidgetState> {
1616
}
1717

1818
render() {
19-
const { size } = this.props
19+
const { size, zIndex } = this.props
2020

2121
const style: CSSProperties = {
2222
display: this.props.hidden ? 'none' : 'flex',
@@ -34,6 +34,7 @@ class TimeWidget extends React.Component<TimeWidgetProps, TimeWidgetState> {
3434
transform: `translate(${size*1.25}px, ${size*2.4}px) rotate(-20deg)`,
3535
fontSize: `${size}px`,
3636
fontWeight: 'bold',
37+
zIndex: zIndex,
3738
}
3839

3940
return (

0 commit comments

Comments
 (0)