@measured/puck 0.8.0-canary.f4b0563 → 0.9.0-canary.222697e

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/README.md +64 -0
  2. package/dist/index.js +428 -205
  3. package/package.json +12 -1
package/README.md CHANGED
@@ -160,6 +160,63 @@ export const MyComponent: ComponentConfig = {
160
160
  };
161
161
  ```
162
162
 
163
+ ## DropZones
164
+
165
+ Puck supports creating complex layouts (like multi-column layouts) using the `<DropZone>` component.
166
+
167
+ ### Example
168
+
169
+ In this example, we use the `<DropZone>` component to render two nested DropZones within another component:
170
+
171
+ ```tsx
172
+ import { DropZone } from "@measured/puck";
173
+
174
+ export const MyComponent: ComponentConfig = {
175
+ render: () => {
176
+ return (
177
+ <div>
178
+ <DropZone zone="first-drop-zone">
179
+ <DropZone zone="second-drop-zone">
180
+ </div>
181
+ )
182
+ }
183
+ };
184
+ ```
185
+
186
+ ### Custom root entry points
187
+
188
+ You can also do this at the root of your component. This is useful if you have a fixed layout and only want to make certain parts of your page customisable:
189
+
190
+ ```tsx
191
+ import { DropZone, Config } from "@measured/puck";
192
+
193
+ export const config: Config = {
194
+ root: {
195
+ render: ({ children }) => {
196
+ return (
197
+ <div>
198
+ {/* children renders the default zone. This can be omitted if necessary. */}
199
+ {children}
200
+
201
+ <div>
202
+ <DropZone zone="other-drop-zone">
203
+ </div>
204
+ </div>
205
+ )
206
+ }
207
+ }
208
+ };
209
+ ```
210
+
211
+ ### The Rules of DropZones
212
+
213
+ The current DropZone implementation has certain rules and limitations:
214
+
215
+ 1. You can drag from the component list on the LHS into any DropZone
216
+ 2. You can drag components between DropZones, so long as those DropZones share a parent (also known as _area_)
217
+ 3. You can't drag between DropZones that don't share a parent (or _area_)
218
+ 4. Your mouse must be directly over a DropZone for a collision to be detected
219
+
163
220
  ## Reference
164
221
 
165
222
  ### `<Puck>`
@@ -183,6 +240,13 @@ The `<Render>` component renders user-facing UI using Puck data.
183
240
  - **config** (`Config`): Puck component configuration
184
241
  - **data** (`Data`): Data to render
185
242
 
243
+ ### `<DropZone>`
244
+
245
+ The `<DropZone>` component allows you to create advanced layouts, like multi-columns.
246
+
247
+ - **zone** (`string`): Identifier for the zone of your component, unique to the parent component
248
+ - **style** (`CSSProperties`): Custom inline styles
249
+
186
250
  ### `Config`
187
251
 
188
252
  The `Config` object describes which components Puck should render, how they should render and which inputs are available to them.