Преглед на файлове

Add properties section to Readme

iou90 преди 4 години
родител
ревизия
7e33fece20
променени са 1 файла, в които са добавени 24 реда и са изтрити 22 реда
  1. 24
    22
      README.md

+ 24
- 22
README.md Целия файл

@@ -11,7 +11,12 @@ An auto height webview for React Native, even auto width for inline html.
11 11
 
12 12
 `npm install react-native-autoheight-webview@1.0.1 --save` (0.57 <= rn < 0.59)
13 13
 
14
-Read [README_old](./README_old.md) for earlier version guide.
14
+Read [README_old](./README_old.md) for earlier version guide and please note that fixes and new features will only be included in the last version.
15
+
16
+## showcase
17
+
18
+![react-native-autoheight-webview iOS](https://media.giphy.com/media/tocJYDUGCgwac0kkyB/giphy.gif)&nbsp;
19
+![react-native-autoheight-webview Android](https://media.giphy.com/media/9JyX1wZshYIxuPklHK/giphy.gif)
15 20
 
16 21
 ## usage
17 22
 
@@ -21,11 +26,8 @@ import AutoHeightWebView from 'react-native-autoheight-webview'
21 26
 import { Dimensions } from 'react-native'
22 27
 
23 28
 <AutoHeightWebView
24
-    // default by screen width,
25
-    // if there are some text selection issues on iOS, the width should be reduced more than 15 and the marginTop should be added more than 35
26 29
     style={{ width: Dimensions.get('window').width - 15, marginTop: 35 }}
27 30
     customScript={`document.body.style.background = 'lightyellow';`}
28
-    // add custom CSS to the page's <head>
29 31
     customStyle={`
30 32
       * {
31 33
         font-family: 'Times New Roman';
@@ -34,29 +36,14 @@ import { Dimensions } from 'react-native'
34 36
         font-size: 16px;
35 37
       }
36 38
     `}
37
-    // either height or width updated will trigger onSizeUpdated
38 39
     onSizeUpdated={({size => console.log(size.height)})},
39
-    /*
40
-    using local or remote files
41
-    to add local files:
42
-    add files to android/app/src/main/assets/ (depends on baseUrl) on android
43
-    add files to web/ (depends on baseUrl) on iOS
44
-    */
45 40
     files={[{
46 41
         href: 'cssfileaddress',
47 42
         type: 'text/css',
48 43
         rel: 'stylesheet'
49 44
     }]}
50
-    // baseUrl now contained by source
51
-    // 'web/' by default on iOS
52
-    // 'file:///android_asset/' by default on Android
53
-    // or uri
54 45
     source={{ html: `<p style="font-weight: 400;font-style: normal;font-size: 21px;line-height: 1.58;letter-spacing: -.003em;">Tags are great for describing the essence of your story in a single word or phrase, but stories are rarely about a single thing. <span style="background-color: transparent !important;background-image: linear-gradient(to bottom, rgba(146, 249, 190, 1), rgba(146, 249, 190, 1));">If I pen a story about moving across the country to start a new job in a car with my husband, two cats, a dog, and a tarantula, I wouldn’t only tag the piece with “moving”. I’d also use the tags “pets”, “marriage”, “career change”, and “travel tips”.</span></p>` }}
55
-    // false by default on iOS & Android (different from react-native-webview which true by default on Android),
56
-    // when scalesPageToFit was assigned to true, it will apply page scale to size directly instead of using viewport meta script 
57 46
     scalesPageToFit={true}
58
-    // only works on iOS when scalesPageToFit was false,
59
-    // in other conditions, you can use your own custom scripts to create viewport meta to disable zooming
60 47
     zoomable={false}
61 48
     /*
62 49
     other react-native-webview props
@@ -64,12 +51,27 @@ import { Dimensions } from 'react-native'
64 51
   />
65 52
 ```
66 53
 
67
-## showcase
54
+## properties
68 55
 
69
-![react-native-autoheight-webview iOS](https://media.giphy.com/media/tocJYDUGCgwac0kkyB/giphy.gif)&nbsp;
70
-![react-native-autoheight-webview Android](https://media.giphy.com/media/9JyX1wZshYIxuPklHK/giphy.gif)
56
+| Prop                         | Default |                                                      Type                                                       | Description                                                                                                                                                                                                  |
57
+| :--------------------------- | :-----: | :-------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
58
+| style                        |    -    |                                              `ViewPropTypes.style`                                              | The width of this component will be the width of screen by default, if there are some text selection issues on iOS, the width should be reduced more than 15 and the marginTop should be added more than 35. |
59
+| customScript                 |    -    |                                               `PropTypes.string`                                                | -                                                                                                                                                                                                            |
60
+| customStyle                  |    -    |                                               `PropTypes.string`                                                | The custom css content will be added to the page's `<head>`.                                                                                                                                                 |
61
+| onSizeUpdated                |    -    |                                                `PropTypes.func`                                                 | Either updated height or width will trigger onSizeUpdated.                                                                                                                                                   |
62
+| files                        |    -    | `PropTypes.arrayOf(PropTypes.shape({ href: PropTypes.string, type: PropTypes.string, rel: PropTypes.string }))` | Using local or remote files. To add local files: Add files to android/app/src/main/assets/ (depends on baseUrl) on android; add files to web/ (depends on baseUrl) on iOS.                                   |
63
+| source                       |    -    |                                               `PropTypes.object`                                                | BaseUrl now contained by source. 'web/' by default on iOS; 'file:///android_asset/' by default on Android or uri.                                                                                            |
64
+| scalesPageToFit              |  false  |                                                `PropTypes.bool`                                                 | False by default (different from react-native-webview which true by default on Android). When scalesPageToFit was enabled, it will apply the scale of the page directly instead of using viewport meta script.    |
65
+| zoomable                     |  true   |                                                `PropTypes.bool`                                                 | Only works on iOS when disable scalesPageToFit, in other conditions, using custom scripts to create viewport meta to disable zooming.                                                                        |
66
+| showsVerticalScrollIndicator |  false  |                                                `PropTypes.bool`                                                 | False by default (different from react-native-webview).                                                                                                                                                      |
67
+| showsVerticalScrollIndicator |  false  |                                                `PropTypes.bool`                                                 | False by default (different from react-native-webview).                                                                                                                                                      |
68
+| originWhitelist              |  ['*']  |                                      `PropTypes.arrayOf(PropTypes.string)`                                      | -                                                                                                                                                                                                            |
71 69
 
72 70
 ## demo
73 71
 
72
+```
73
+npx react-native run-ios/anroid
74
+```
75
+
74 76
 You may have to use yarn to install the dependencies of the demo and remove "demo/node_modules/react-native-autoheight-webview/demo" manually, cause of installing a local package with npm will create symlink, but there is no supporting of React Native to symlink (https://github.com/facebook/watchman/issues/105) and "yarn install" ignores "files" from local dependencies (https://github.com/yarnpkg/yarn/issues/2822).
75 77
 For android, you may have to copy the "Users\UserName\.android\debug.keystore" to "demo/android/app/".