|
3 | 3 | "prefix": "brick",
|
4 | 4 | "body": [
|
5 | 5 | "import React from 'react'",
|
6 |
| - "import { Text, RichText, Image, File, Repeater, types } from 'react-bricks/frontend'", |
| 6 | + "import { types, Text } from 'react-bricks/${2|frontend,rsc|}'", |
7 | 7 | "",
|
8 |
| - "interface Props {", |
9 |
| - "\t", |
| 8 | + "interface ${1:${TM_FILENAME_BASE}}Props {", |
| 9 | + "\ttitle: types.TextValue", |
10 | 10 | "}",
|
11 | 11 | "",
|
12 |
| - "const ${1:${TM_FILENAME_BASE}}: types.Brick<Props> = (props) => {", |
| 12 | + "const ${1:${TM_FILENAME_BASE}}: types.Brick<${1:${TM_FILENAME_BASE}}Props> = ({ title }) => {", |
13 | 13 | "\treturn (",
|
14 | 14 | "\t\t<div>",
|
15 | 15 | "\t\t\t<Text",
|
16 | 16 | "\t\t\t\tpropName=\"title\"",
|
17 |
| - "\t\t\t\tplaceholder=\"Title...\"", |
18 |
| - "\t\t\t\trenderBlock={({ children }) => (<span>{children}</span>)}", |
| 17 | + "\t\t\t\tvalue={title}", |
| 18 | + "\t\t\t\tplaceholder=\"Type a title...\"", |
| 19 | + "\t\t\t\trenderBlock={({ children }) => (<h1>{children}</h1>)}", |
19 | 20 | "\t\t\t/>$0",
|
20 | 21 | "\t\t</div>",
|
21 | 22 | "\t)",
|
22 | 23 | "}",
|
23 | 24 | "",
|
24 | 25 | "${1:${TM_FILENAME_BASE}}.schema = {",
|
25 |
| - "\tname: '${1:${TM_FILENAME_BASE}}',", |
| 26 | + "\t$LINE_COMMENT Unique brick name", |
| 27 | + "\tname: '${TM_FILENAME_BASE/(.*)/${1:/downcase}/}',", |
26 | 28 | "\tlabel: '${1:${TM_FILENAME_BASE}}',",
|
27 |
| - "\t$LINE_COMMENT category: '',", |
28 |
| - "\t$LINE_COMMENT tags: [],", |
29 | 29 | "",
|
30 | 30 | "\t$LINE_COMMENT Defaults when a new brick is added",
|
31 | 31 | "\tgetDefaultProps: () => ({",
|
|
47 | 47 | "{",
|
48 | 48 | "\tname: '${1:name}',",
|
49 | 49 | "\tlabel: '${2:Label}',",
|
50 |
| - "\ttype: types.SideEditPropType.${3|Text,Textarea,Number,Date,Boolean,Select,Range,Image,Custom|},", |
| 50 | + "\ttype: types.SideEditPropType.${3|Text,Textarea,Number,Date,Boolean,Select,Autocomplete,Range,Image,Relationship,Custom|},", |
51 | 51 | "}"
|
52 | 52 | ],
|
53 | 53 | "description": "Creates a React Bricks' Brick `sideEditProp`"
|
|
69 | 69 | "body": [
|
70 | 70 | "<Text",
|
71 | 71 | "\tpropName=\"${1:text}\"",
|
| 72 | + "\tvalue={${1:text}}", |
72 | 73 | "\tplaceholder=\"Type a ${1:text}...\"",
|
73 |
| - "\trenderBlock={({ children \\}) => ${2:(<span>{children\\}</span>)}}", |
| 74 | + "\trenderBlock={({ children }) => ${2:(<span>{children\\}</span>)}}", |
74 | 75 | "/>"
|
75 | 76 | ],
|
76 | 77 | "description": "Add a React Bricks <Text> component"
|
|
80 | 81 | "body": [
|
81 | 82 | "<RichText",
|
82 | 83 | "\tpropName=\"${1:text}\"",
|
| 84 | + "\tvalue={${1:text}}", |
83 | 85 | "\tplaceholder=\"Type a ${1:text}...\"",
|
84 |
| - "\trenderBlock={({ children \\}) => (${2:<span>{children\\}</span>})}", |
| 86 | + "\trenderBlock={({ children }) => (${2:<span>{children\\}</span>})}", |
85 | 87 | "\tallowedFeatures={[types.RichTextFeatures.${3:Bold}]}",
|
86 | 88 | "/>"
|
87 | 89 | ],
|
|
92 | 94 | "body": [
|
93 | 95 | "<Image",
|
94 | 96 | "\tpropName=\"${1:image}\"",
|
| 97 | + "\tsource={${1:image}}", |
95 | 98 | "\talt=\"${2:altText}\"",
|
96 | 99 | "\tmaxWidth={${3:300}}",
|
97 | 100 | "\taspectRatio={${4:1}}",
|
|
104 | 107 | "body": [
|
105 | 108 | "<File",
|
106 | 109 | "\tpropName=\"${1:file}\"",
|
| 110 | + "\tsource={${1:file}}", |
107 | 111 | "\tallowedExtensions={[${2:'.pdf'}]}",
|
108 | 112 | "\trenderBlock={({ name, url, size }) => (",
|
109 | 113 | "\t\t<a href={url}>",
|
|
116 | 120 | },
|
117 | 121 | "React Bricks Repeater": {
|
118 | 122 | "prefix": "Repeater",
|
119 |
| - "body": ["<Repeater propName=\"${1:propName}\" />"], |
| 123 | + "body": ["<Repeater propName=\"${1:items}\" items={${1:items}} />"], |
120 | 124 | "description": "Add React Bricks <Repeater> component"
|
121 | 125 | }
|
122 | 126 | }
|
0 commit comments