Skip to content

Commit 6742ad7

Browse files
committed
test(story): add style test
1 parent f16493c commit 6742ad7

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

stories/index.stories.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@ import { withA11y } from "@storybook/addon-a11y";
22
import { addDecorator, storiesOf } from "@storybook/react";
33
import React, { useEffect, useState } from "react";
44

5-
import { ReactPictureAnnotation } from "../src";
5+
import {
6+
DefaultInputSection,
7+
defaultShapeStyle,
8+
ReactPictureAnnotation,
9+
} from "../src";
610
import { IAnnotation } from "../src/Annotation";
711
import { IShapeData } from "../src/Shape";
812

9-
addDecorator(storyFn => <div>{storyFn()}</div>);
13+
addDecorator((storyFn) => <div>{storyFn()}</div>);
1014

1115
storiesOf("Hello World", module)
1216
.addDecorator(withA11y)
1317
.add("with text", () => {
1418
const AnnotationComponent = () => {
1519
const [size, setSize] = useState({
1620
width: window.innerWidth - 16,
17-
height: window.innerHeight - 16
21+
height: window.innerHeight - 16,
1822
});
1923

2024
const [annotationData, setAnnotationData] = useState<
21-
Array<IAnnotation<IShapeData>>
25+
IAnnotation<IShapeData>[]
2226
>([
2327
{
2428
id: "a",
@@ -28,17 +32,17 @@ storiesOf("Hello World", module)
2832
width: 161,
2933
height: 165,
3034
x: 229,
31-
y: 92
32-
}
33-
}
35+
y: 92,
36+
},
37+
},
3438
]);
3539

3640
const [selectedId, setSelectedId] = useState<string | null>("a");
3741

3842
const onResize = () => {
3943
setSize({
4044
width: window.innerWidth - 16,
41-
height: window.innerHeight - 16
45+
height: window.innerHeight - 16,
4246
});
4347
};
4448

@@ -54,10 +58,21 @@ storiesOf("Hello World", module)
5458
width={size.width}
5559
height={size.height}
5660
annotationData={annotationData}
57-
onChange={data => setAnnotationData(data)}
61+
onChange={(data) => setAnnotationData(data)}
5862
selectedId={selectedId}
59-
onSelect={e => setSelectedId(e)}
63+
onSelect={(e) => setSelectedId(e)}
64+
annotationStyle={{
65+
...defaultShapeStyle,
66+
shapeStrokeStyle: "#2193ff",
67+
transformerBackground: "black",
68+
}}
6069
image="https://bequank.oss-cn-beijing.aliyuncs.com/landpage/large/60682895_p0_master1200.jpg"
70+
inputElement={(value, onChange, onDelete) => (
71+
<DefaultInputSection
72+
placeholder={"Hello world"}
73+
{...{ value, onChange, onDelete }}
74+
/>
75+
)}
6176
/>
6277
);
6378
};

0 commit comments

Comments
 (0)