@weaverse/react 2.5.1 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/package.json +11 -5
- package/readme.md +83 -0
package/LICENSE
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"name": "@weaverse/react",
|
|
3
|
+
"author": "Weaverse Team",
|
|
4
|
+
"description": "React bindings for Weaverse",
|
|
5
|
+
"version": "2.6.1",
|
|
3
6
|
"license": "MIT",
|
|
4
7
|
"main": "dist/index.js",
|
|
5
8
|
"typings": "dist/index.d.ts",
|
|
6
9
|
"module": "dist/index.mjs",
|
|
10
|
+
"repository": {
|
|
11
|
+
"url": "git+https://github.com/Weaverse/weaverse.git",
|
|
12
|
+
"directory": "packages/react"
|
|
13
|
+
},
|
|
7
14
|
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
15
|
+
"access": "public",
|
|
16
|
+
"@weaverse:registry": "https://registry.npmjs.org"
|
|
9
17
|
},
|
|
10
18
|
"files": [
|
|
11
19
|
"dist/*"
|
|
@@ -29,9 +37,7 @@
|
|
|
29
37
|
"semi": false,
|
|
30
38
|
"singleQuote": true
|
|
31
39
|
},
|
|
32
|
-
"name": "@weaverse/react",
|
|
33
|
-
"author": "Weaverse Team",
|
|
34
40
|
"dependencies": {
|
|
35
|
-
"@weaverse/core": "2.
|
|
41
|
+
"@weaverse/core": "2.6.1"
|
|
36
42
|
}
|
|
37
43
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# @weaverse/react
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`@weaverse/react` is a specialized package in the Weaverse ecosystem, designed specifically for React applications. It
|
|
6
|
+
provides React components and mechanisms to render content from Weaverse CMS data. This package builds upon the core
|
|
7
|
+
functionalities of `@weaverse/core`, enabling easy integration of Weaverse content into React projects.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- React components compatible with Weaverse CMS data.
|
|
12
|
+
- Initialization of Weaverse Core instances tailored for React.
|
|
13
|
+
- `WeaverseRoot` component for rendering within the Weaverse context.
|
|
14
|
+
- Mechanism to register React components for use with Weaverse CMS.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @weaverse/react
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Initialization and Component Registration
|
|
23
|
+
|
|
24
|
+
First, initialize a Weaverse Core instance with the necessary parameters:
|
|
25
|
+
|
|
26
|
+
```jsx
|
|
27
|
+
import { Weaverse } from '@weaverse/core';
|
|
28
|
+
|
|
29
|
+
let weaverse = new Weaverse({
|
|
30
|
+
projectId: 'your_project_id',
|
|
31
|
+
data: 'WeaverseProjectDataType' // fetched from Weaverse CMS
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Next, register your React components with the Weaverse instance:
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
weaverse.registerElement({
|
|
39
|
+
type: 'Button',
|
|
40
|
+
Component: ButtonComponent,
|
|
41
|
+
schema: {
|
|
42
|
+
title: 'Button',
|
|
43
|
+
type: 'Button',
|
|
44
|
+
inspector: {
|
|
45
|
+
// define settings inputs for customizing the Component here
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
After initializing and registering elements, use the `WeaverseRoot` component to render your React components within the
|
|
54
|
+
Weaverse context:
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
import React from 'react';
|
|
58
|
+
import { WeaverseRoot } from '@weaverse/react';
|
|
59
|
+
|
|
60
|
+
function App() {
|
|
61
|
+
// ... your other React component logic
|
|
62
|
+
|
|
63
|
+
return <WeaverseRoot context={weaverse} />;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default App;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Best Practices
|
|
70
|
+
|
|
71
|
+
- Initialize the Weaverse instance at your application's root level.
|
|
72
|
+
- Register all necessary React components with the Weaverse instance before rendering.
|
|
73
|
+
- Use the `WeaverseRoot` component to integrate the Weaverse CMS data into your React application effectively.
|
|
74
|
+
|
|
75
|
+
## Contributing
|
|
76
|
+
|
|
77
|
+
We welcome contributions to the `@weaverse/react` package. For more information on contributing, please refer to our
|
|
78
|
+
guidelines.
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
This project is created by The Weaverse Team ([https://weaverse.io](https://weaverse.io)) and is licensed under the MIT
|
|
83
|
+
License.
|