Skip to content

Commit e9eb098

Browse files
authored
Merge pull request #2 from react-native-oh-library/codegen
update index.js
2 parents 2eb3033 + f2d586a commit e9eb098

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

README.md

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,6 @@ web: svg
1616

1717
`yarn add react-native-clippathview`
1818

19-
## Harmony
20-
21-
```js
22-
import { View, Text, ScrollView } from 'react-native'
23-
import React from 'react'
24-
import ClipPath from '@react-native-oh-tpl/clip-path'
25-
26-
export default function index() {
27-
const viewBox = [0, 0, 400, 400]
28-
const path = 'M 200 0 L 280 100 L 400 160 L 330 270 L 320 400 L 200 350 L 80 400 L 80 270 L 0 160 L 120 100 Z'
29-
30-
return (
31-
<ScrollView style={{ width: '100%', height: '100%' }}>
32-
<ClipPath viewBox={viewBox} d={path} style={{ width: 200, height: 100, backgroundColor: '#ff0' }}>
33-
<Text style={{ lineHeight: 5, fontSize: 6 }}>children</Text>
34-
<Text style={{ lineHeight: 5, fontSize: 6 }}>children</Text>
35-
<Text style={{ lineHeight: 5, fontSize: 6 }}>children</Text>
36-
</ClipPath>
37-
</ScrollView>
38-
)
39-
}
40-
```
41-
4219
## IOS
4320

4421
**Add Swift**
@@ -72,6 +49,28 @@ import {ClipPathView , ClipPathViewH } from 'react-native-clippathview'
7249
</ClipPathView>
7350

7451
```
52+
## Harmony
53+
54+
```js
55+
import { View, Text, ScrollView } from 'react-native'
56+
import React from 'react'
57+
import { ClipPathView } from 'react-native-clippathview'
58+
59+
export default function index() {
60+
const viewBox = [0, 0, 400, 400]
61+
const path = 'M 200 0 L 280 100 L 400 160 L 330 270 L 320 400 L 200 350 L 80 400 L 80 270 L 0 160 L 120 100 Z'
62+
63+
return (
64+
<ScrollView style={{ width: '100%', height: '100%' }}>
65+
<ClipPath d={path} style={{ backgroundColor: '#ff0' }}>
66+
<Text style={{ lineHeight: 5, fontSize: 6 }}>children</Text>
67+
<Text style={{ lineHeight: 5, fontSize: 6 }}>children</Text>
68+
<Text style={{ lineHeight: 5, fontSize: 6 }}>children</Text>
69+
</ClipPath>
70+
</ScrollView>
71+
)
72+
}
73+
```
7574

7675
## Props
7776

index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33
// import ClipPathH from 'react-native-clippathview/src/ClipPathH'
44
// export const ClipPathViewH = ClipPathH
55
// export const ClipPathView = ClipPath
6-
import ClipPath from './src/ClipPathNativeComponent'
6+
7+
import React from 'react';
8+
import ClipPathNativeComponent from './src/ClipPathNativeComponent';
9+
10+
const ClipPath = React.forwardRef((props, ref) => {
11+
const { style, ...otherProps } = props;
12+
const { backgroundColor, ...otherStyle } = style;
13+
let newProps = { ...otherProps, style: otherStyle };
14+
if (backgroundColor) {
15+
newProps.fill = backgroundColor;
16+
}
17+
return (
18+
<ClipPathNativeComponent ref={ref} {...newProps}></ClipPathNativeComponent>
19+
)
20+
})
721
export {
822
ClipPath as ClipPathView
923
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@react-native-oh-tpl/clip-path",
33
"title": "React Native ClipPath",
4-
"version": "1.1.8-0.1.2",
4+
"version": "1.1.8-0.1.3",
55
"description": "ClipPath Android Web IOS Harmony",
66
"main": "index.js",
77
"files": [

0 commit comments

Comments
 (0)