-
Notifications
You must be signed in to change notification settings - Fork 982
/
Copy pathHeroWithChildren.builder.js
84 lines (79 loc) · 1.99 KB
/
HeroWithChildren.builder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { Builder, withChildren } from '@builder.io/react';
import { HeroWithEditableChildren } from './HeroWithChildren';
// This line is very important! :)
const HeroWithBuilderChildren = withChildren(HeroWithEditableChildren);
Builder.registerComponent(HeroWithBuilderChildren, {
name: 'Hero With Children',
inputs: [
{
name: 'image',
type: 'file',
allowedFileTypes: ['jpeg', 'jpg', 'png', 'svg', 'webp'],
required: true,
defaultValue:
'https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F349738e6805b481ab6c50bda7e24445e',
},
{
name: 'height',
type: 'number',
defaultValue: 400,
required: true,
},
{
name: 'parallaxStrength',
type: 'number',
defaultValue: 400,
},
],
// (Optionally) specify requirements that the direct children can only be certain types
childRequirements: {
message: 'You can only put Buttons, Text, or Headings in a Hero',
query: {
'component.name': { $in: ['Button', 'Text', 'Heading'] },
},
},
// It's generally best to supply some default children
// for easy and intuitive usage in the Builder.io UIs by
// non-devs
defaultChildren: [
{
'@type': '@builder.io/sdk:Element',
component: {
name: 'Heading',
options: {
text: 'You can edit the contents of this example!',
type: 'h4',
},
},
},
{
'@type': '@builder.io/sdk:Element',
component: {
name: 'Text',
options: {
text: 'You can edit this too. Or duplicate it. Or delete it!',
},
},
responsiveStyles: {
large: {
marginTop: '20px',
},
},
},
{
'@type': '@builder.io/sdk:Element',
component: {
name: 'Button',
options: {
text: 'Hello',
type: 'outlined',
},
},
responsiveStyles: {
large: {
marginTop: '20px',
},
},
},
],
});