Skip to content

Commit f16493c

Browse files
committed
feat: open marker style as props
1 parent 6632019 commit f16493c

File tree

10 files changed

+235
-232
lines changed

10 files changed

+235
-232
lines changed

README.md

Lines changed: 43 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# React Picture Annotation
22

3-
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/kunduin/react-picture-annotation/blob/master/LICENSE) [![Travis (.com)](https://img.shields.io/travis/com/kunduin/react-picture-annotation.svg)](https://travis-ci.com/Kunduin/react-picture-annotation) [![npm](https://img.shields.io/npm/v/react-picture-annotation.svg)](https://www.npmjs.com/package/react-picture-annotation) [![Greenkeeper badge](https://badges.greenkeeper.io/Kunduin/react-picture-annotation.svg)](https://greenkeeper.io/)
3+
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/kunduin/react-picture-annotation/blob/master/LICENSE) [![Travis (.com)](https://img.shields.io/travis/com/kunduin/react-picture-annotation.svg)](https://travis-ci.com/Kunduin/react-picture-annotation) [![npm](https://img.shields.io/npm/v/react-picture-annotation.svg)](https://www.npmjs.com/package/react-picture-annotation)
44

55
A simple annotation component.
66

@@ -55,119 +55,50 @@ const rootElement = document.getElementById('root');
5555
ReactDOM.render(<App />, rootElement);
5656
```
5757

58-
## Props
59-
60-
### annotationData `not required`
61-
62-
**TYPE**
63-
64-
```ts
65-
Array<IAnnotation>
66-
```
67-
68-
see [IAnnotation](#iannotation)
69-
70-
**COMMENT**
71-
72-
Control the marked areas on the page.
73-
74-
### selectedId `not required`
75-
76-
**TYPE**
77-
78-
```ts
79-
string | null;
80-
```
81-
82-
**COMMENT**
83-
84-
Control the selected shape.
85-
86-
### onChange `required`
87-
88-
**TYPE**
89-
90-
```ts
91-
(annotationData: IAnnotation[]) => void
92-
```
93-
94-
**COMMENT**
95-
96-
Called every time the shape changes.
97-
98-
### onSelected `required`
99-
100-
**TYPE**
101-
102-
```ts
103-
(id: string | null) => void
104-
```
105-
106-
**COMMENT**
107-
108-
Called each time the selection is changed.
109-
110-
### width `required`
111-
112-
**TYPE**
113-
114-
```ts
115-
number;
116-
```
117-
118-
**COMMENT**
119-
120-
Width of the canvas.
121-
122-
### height `required`
123-
124-
**TYPE**
125-
126-
```ts
127-
number;
128-
```
129-
130-
**COMMENT**
131-
132-
Height of the canvas.
133-
134-
### image `required`
135-
136-
**TYPE**
137-
138-
```ts
139-
string;
140-
```
141-
142-
**COMMENT**
143-
144-
Image to be annotated.
145-
146-
### inputElement `not required`
147-
148-
**TYPE**
149-
150-
```ts
151-
(value: string, onChange: (value: string) => void, onDelete: () => void) =>
152-
React.ReactElement;
153-
```
154-
155-
**COMMENT**
156-
157-
Customizable input control.
158-
159-
**EXAMPLE**
160-
161-
```jsx
162-
<ReactPictureAnnotation
163-
{...props}
164-
inputElement={inputProps => <MyInput {...inputProps} />}
165-
/>
58+
## ReactPictureAnnotation Props
59+
60+
| Name | Type | Comment | required |
61+
| --------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------ | -------- |
62+
| onChange | `(annotationData: IAnnotation[]) => void` | Called every time the shape changes. ||
63+
| onSelected | `(id: string or null) => void` | Called each time the selection is changed. ||
64+
| width | `number` | Width of the canvas. ||
65+
| height | `number` | Height of the canvas. ||
66+
| image | `string` | Image to be annotated. ||
67+
| inputElement | `(value: string,onChange: (value: string) => void,onDelete: () => void) => React.ReactElement;` | Customizable input control. | X |
68+
| annotationData | `Array<IAnnotation>` | Control the marked areas on the page. | X |
69+
| annotationStyle | `IShapeStyle` | Control the mark style | X |
70+
| selectedId | `string or null` | Selected markId | X |
71+
| scrollSpeed | `number` | Speed of wheel zoom, default 0.0005 | X |
72+
| marginWithInput | `number` | Margin between input and mark, default 1 | X |
73+
74+
## IShapeStyle
75+
76+
ReactPictureAnnotation can be easily modified the style through a prop named `annotationStyle`
77+
78+
```typescript
79+
export const defaultShapeStyle: IShapeStyle = {
80+
/** text area **/
81+
padding: 5, // text padding
82+
fontSize: 12, // text font size
83+
fontColor: "#212529", // text font color
84+
fontBackground: "#f8f9fa", // text background color
85+
fontFamily:
86+
"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial, sans-serif",
87+
88+
/** stroke style **/
89+
lineWidth: 2, // stroke width
90+
shapeBackground: "hsla(210, 16%, 93%, 0.2)", // background color in the middle of the marker
91+
shapeStrokeStyle: "#f8f9fa", // shape stroke color
92+
shadowBlur: 10, // stroke shadow blur
93+
shapeShadowStyle: "hsla(210, 9%, 31%, 0.35)", // shape shadow color
94+
95+
/** transformer style **/
96+
transformerBackground: "#5c7cfa",
97+
transformerSize: 10
98+
};
16699
```
167100

168-
## Types
169-
170-
### IAnnotation
101+
## IAnnotation
171102

172103
```js
173104
{

src/DefaultInputSection.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@ import DeleteButton from "./DeleteButton";
33

44
export interface IDefaultInputSection {
55
value: string;
6+
placeholder?: string;
67
onChange: (value: string) => void;
78
onDelete: () => void;
89
}
910

10-
export default ({ value, onChange, onDelete }: IDefaultInputSection) => {
11+
export default ({
12+
value,
13+
onChange,
14+
onDelete,
15+
placeholder = "INPUT TAG HERE",
16+
}: IDefaultInputSection) => {
1117
return (
1218
<div className="rp-default-input-section">
1319
<input
1420
className="rp-default-input-section_input"
15-
placeholder="INPUT TAG HERE"
21+
placeholder={placeholder}
1622
value={value}
17-
onChange={e => onChange(e.target.value)}
23+
onChange={(e) => onChange(e.target.value)}
1824
/>
1925
<a className="rp-default-input-section_delete" onClick={() => onDelete()}>
2026
<DeleteButton />

0 commit comments

Comments
 (0)