@contentful/experiences-components-react 1.0.2 → 1.0.3-beta.0
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/README.md +4 -91
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
> Experience Builder is currently in a private alpha and not available publicly. If you are interested in participating in the alpha, please reach out to your Contentful account team.
|
|
4
|
-
|
|
5
|
-
This folder contains the source code for the default/example components that can be used with Experience Builder. These components can be used as-is to kick start building your experiences, or used as an example for building your own components.
|
|
6
|
-
|
|
7
|
-
## In this guide
|
|
8
|
-
|
|
9
|
-
- [Components](#components)
|
|
10
|
-
- [Getting started](#getting-started)
|
|
11
|
-
* [Installation](#installation)
|
|
12
|
-
- [Styling](#styling)
|
|
13
|
-
* [Including default styles](#including-default-styles)
|
|
14
|
-
* [Adding custom styles](#adding-custom-styles)
|
|
15
|
-
- [withExperienceBuilder util](#withexperiencebuilder-util)
|
|
16
|
-
* [Usage](#usage)
|
|
1
|
+
# @contentful/experiences-components-react
|
|
17
2
|
|
|
3
|
+
This package provides the default structure and basic components for the [Experiences SDK](https://www.contentful.com/developers/docs/experiences/set-up-experiences-sdk/). You can use these components directly to start building your experiences, or as examples to create your own components.
|
|
18
4
|
|
|
19
5
|
## Components
|
|
20
6
|
|
|
@@ -26,79 +12,6 @@ The following components are available:
|
|
|
26
12
|
- [RichText](src/components/RichText/README.md)
|
|
27
13
|
- [Text](src/components/Text/README.md)
|
|
28
14
|
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
### Installation
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm install @contentful/experiences-components-react
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Styling
|
|
38
|
-
|
|
39
|
-
By default, the components are unstyled. This allows you to style the components to match your brand and design system. If you want a set of default styles to get started, see below.
|
|
40
|
-
|
|
41
|
-
### Adding custom styles
|
|
42
|
-
|
|
43
|
-
Each component has a css class that you can use to add your own styles. The classes are named in the style of `cf-{component-name}` (ie `cf-button`).
|
|
44
|
-
|
|
45
|
-
For example, to style the `Button` component, you can do the following:
|
|
46
|
-
|
|
47
|
-
```css
|
|
48
|
-
.cf-button {
|
|
49
|
-
/* your styles here */
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
All components also support passing in custom class names via the `className` prop. This allows you to add your own class names to the component, which you can then use to style the component.
|
|
54
|
-
|
|
55
|
-
## withExperienceBuilder util
|
|
56
|
-
|
|
57
|
-
We provide a helper function (as a [higher-order-component](https://legacy.reactjs.org/docs/higher-order-components.html)) to make it easier to register your own custom components with Experience Builder. This function helps ensure your component has all the required props and is properly registered with Experience Builder.
|
|
58
|
-
|
|
59
|
-
### Usage
|
|
60
|
-
|
|
61
|
-
```jsx
|
|
62
|
-
import { withExperienceBuilder } from '@/utils/withExperienceBuilder';
|
|
63
|
-
import { MyComponent } from './MyComponent';
|
|
64
|
-
|
|
65
|
-
export const ExperienceBuilderMyComponent = withExperienceBuilder(
|
|
66
|
-
// Your component
|
|
67
|
-
MyComponent,
|
|
68
|
-
// component registration configuration for EB
|
|
69
|
-
{
|
|
70
|
-
id: 'my-component',
|
|
71
|
-
name: 'My Component',
|
|
72
|
-
category: 'Custom',
|
|
73
|
-
variables: {
|
|
74
|
-
label: {
|
|
75
|
-
type: 'Text',
|
|
76
|
-
defaultValue: 'My Component',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Container wrapping
|
|
84
|
-
|
|
85
|
-
By default, the `withExperienceBuilder` function will not wrap your component in a container. However, it is often useful to have your component wrapped. If the components is wrapped, all the styles generated from Experience Builder will be applied to the wrapping container instead of the component itself. This will make it so the additional styles don't interfere with your component's styles.
|
|
86
|
-
|
|
87
|
-
To wrap your component, pass in the `wrapComponent` option:
|
|
88
|
-
|
|
89
|
-
```jsx
|
|
90
|
-
export const ExperienceBuilderMyComponent = withExperienceBuilder(
|
|
91
|
-
// Your component
|
|
92
|
-
MyComponent,
|
|
93
|
-
// component registration configuration for EB
|
|
94
|
-
{ /* EB config */ },
|
|
95
|
-
// wrap the component with a container (defaults to false)
|
|
96
|
-
{ wrapComponent: true }
|
|
97
|
-
);
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
You can also provide the tag name the container will use (which defaults to 'div'):
|
|
15
|
+
## Documentation
|
|
101
16
|
|
|
102
|
-
|
|
103
|
-
{ wrapComponent: true, wrapContainerTag: 'span' }
|
|
104
|
-
```
|
|
17
|
+
Please refer to our [Documentation](https://www.contentful.com/developers/docs/experiences/register-custom-components/#built-in-components) to learn more about it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-components-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3-beta.0",
|
|
4
4
|
"description": "A basic set of components to use with Studio Experiences",
|
|
5
5
|
"homepage": "https://github.com/contentful/experience-builder/tree/next/packages/components#readme",
|
|
6
6
|
"repository": {
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
"react-dom": ">=17.0.0"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@contentful/experiences-core": "
|
|
77
|
+
"@contentful/experiences-core": "1.0.3-beta.0",
|
|
78
78
|
"@contentful/rich-text-react-renderer": "^15.17.2",
|
|
79
79
|
"postcss-import": "^15.1.0",
|
|
80
80
|
"style-inject": "^0.3.0"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "fb5795ffb70c011a5802c89ecac4128f6153a2ac"
|
|
83
83
|
}
|