Skip to content
This repository was archived by the owner on Aug 1, 2022. It is now read-only.

Commit ab06f60

Browse files
author
Craig Wilkinson
committed
Use z-index of parent instead of hard-coding
1 parent 253b68e commit ab06f60

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

src/index.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,7 @@ const canvasStyle = {
1919
position: "absolute"
2020
};
2121

22-
const canvasTypes = [
23-
{
24-
name: "interface",
25-
zIndex: 15
26-
},
27-
{
28-
name: "drawing",
29-
zIndex: 11
30-
},
31-
{
32-
name: "temp",
33-
zIndex: 12
34-
},
35-
{
36-
name: "grid",
37-
zIndex: 10
38-
}
39-
];
22+
const canvasTypes = ["grid", "drawing", "temp", "interface"];
4023

4124
const dimensionsPropTypes = PropTypes.oneOfType([
4225
PropTypes.number,
@@ -572,7 +555,7 @@ export default class extends PureComponent {
572555
}
573556
}}
574557
>
575-
{canvasTypes.map(({ name, zIndex }) => {
558+
{canvasTypes.map((name) => {
576559
const isInterface = name === "interface";
577560
return (
578561
<canvas
@@ -583,7 +566,7 @@ export default class extends PureComponent {
583566
this.ctx[name] = canvas.getContext("2d");
584567
}
585568
}}
586-
style={{ ...canvasStyle, zIndex }}
569+
style={canvasStyle}
587570
onMouseDown={isInterface ? this.handleDrawStart : undefined}
588571
onMouseMove={isInterface ? this.handleDrawMove : undefined}
589572
onMouseUp={isInterface ? this.handleDrawEnd : undefined}

tests/index.test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import expect from "expect";
2-
import Enzyme, { shallow } from "enzyme";
3-
import Adapter from "enzyme-adapter-react-16";
42
import React from "react";
53
import { render, unmountComponentAtNode } from "react-dom";
64

75
import DrawCanvas from "src/";
86

97
describe("DrawCanvas", () => {
10-
before(() => {
11-
Enzyme.configure({ adapter: new Adapter() });
12-
});
13-
148
let node;
159

1610
beforeEach(() => {

0 commit comments

Comments
 (0)