Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: v0.18.0 #768

Merged
merged 2 commits into from
Jan 22, 2025
Merged

release: v0.18.0 #768

merged 2 commits into from
Jan 22, 2025

Conversation

chrisvxd
Copy link
Member

@chrisvxd chrisvxd commented Jan 6, 2025

Puck 0.18: The new drag-and-drop engine

Puck 0.18 launches our groundbreaking drag-and-drop engine for page building with advanced CSS layouts.

With native support for CSS grid and flexbox, Puck 0.18 enables powerful new paradigms for creating design-in-browser experiences directly within your Puck application.

Thanks to our contributors and sponsors for making this huge milestone possible.

New.DND.engine.mp4

TLDR

  • New drag-and-drop engine: Multi-dimensional drag-and-drop across any CSS layout to create a sophisticated page building experience. Read the docs.
  • Dynamic DropZone height: DropZones now shrink to the height of their children, with a configurable height when empty.
  • Toggle interactive hotkey: Make your components interactive in Preview mode with the cmd+i hotkey.
  • Parent selector: A new action allows you to quickly select the component's parent directly from the action bar.
  • No more position: fixed: We've removed this pesky style from the default layout so it's easier to embed in your app.
  • New ActionBar.Label component: Create sections in your action bar with the new <ActionBar.Label> component.

Highlights

New drag-and-drop engine

Our flagship feature is a new drag-and-drop engine for Puck with full CSS grid & flexbox support to enable advanced layouts. We call these fluid layouts, and the the change is fully backwards compatible.

Thanks to @clauderic at dnd-kit for all the support in making this possible, and the Puck community for all the feedback! 🙏

Fluid layouts

To implement a fluid layout, add your display property of choice (e.g. display: flex) to your DropZone via the style or className props and off you go—Puck will gracefully handle drag-and-drop across all dimensions.

const config = {
  components: {
    Example: {
      render: () => (
        <DropZone
          zone="my-content"
          style={{ display: "flex" }} // Use flexbox in this DropZone
        />
      ),
    },
    Card: {
      render: ({ text }) => (
        <div>{text}</div>
      ),
    },
  },
};

dragging items in a fluid layout with flexbox

See the Multi-column Layouts docs for the full documentation.

Remove wrapping elements

The new inline and dragRef APIs enable you to remove the wrapping element from Puck components entirely, which can be useful if you need to treat your component as a direct descendant of its parent (such as if you need to use CSS properties like flex-grow).

Here's an example implementing an advanced grid layout, where the children can specify their position using the grid-column and grid-row properties:

const config = {
  components: {
    Example: {
      render: () => (
        <DropZone
          zone="my-content"
          style={{ display: "grid", gridTemplateColumns: "1fr 1fr 1fr 1fr" }} // Use CSS grid in this DropZone
        />
      ),
    },
    Card: {
      inline: true, // Enable inline mode, removing the Puck wrapper
      render: ({ text, puck }) => (
        <div
          ref={puck.dragRef} // Let Puck know this element is draggable
          style={{ gridColumn: `span ${spanCol}`, gridRow: `span ${spanRow}` }} // Apply styles
        >
          {text}
        </div>
      ),
    },
  },
};

Advanced grid example

Dragging between nested DropZones

The new engine makes it possible to drag between nested DropZones, which resolves one of the longest standing limitations of Puck's drag-and-drop experience.

dragging-between-nested-components

Dynamic DropZone height

DropZones now shrink to the height of their children so that the preview is a faithful representation of the final output, with a new configurable height when empty.

<DropZone
  zone="my-content"
  minEmptyHeight={256} // The DropZone will grow to 256px when empty
/>

Dynamic DropZone resize

The <ActionBar.Label> component

The new <ActionBar.Label> component enables you to to label areas within a custom ActionBar:

<ActionBar>
  <ActionBar.Label label="Label 1" />
  <ActionBar.Group>
    <ActionBar.Label label="Label 2" />
    <ActionBar.Action></ActionBar.Action>
  </ActionBar.Group>
</ActionBar>
image

Parent selector

A new action allows you to quickly select the component's parent directly from the action bar. Tap the arrow to the left of the component label to jump to the parent.

parent-selector

Toggle interactive hotkey

Make your components interactive directly within Preview mode with the cmd+i (or ctrl+i on Windows) hotkey.

This can be programatically set via the new previewMode parameter on the app state.

No more position:fixed

We've removed this pesky style from the default layout so it's easier to embed in your app. Not much to show here, but let's pour one out for position:fixed 🥂

Full changelog

Features

  • add action to select parent component to ActionBar (7c910d5)
  • add ActionBar.Label component for adding labels to action bars (d2645fd)
  • add DropZone collisionAxis API for forcing collision direction (ba68732)
  • add meta+i hotkey and previewMode state to toggle interactivity (ec1eba5)
  • add wrapFields prop to control padding of fields in Puck.Fields (30f9a92)
  • control empty DropZone height with minEmptyHeight prop (96f8340)
  • deselect item on viewport change (e35585d)
  • forward the ref to the DropZone component (676aa1c)
  • introduce new drag-and-drop engine (6ebb3b8)
  • reduce DropZone to height of items unless empty (2b2595a)
  • remove position: fixed; from Puck layout (5deb774)
  • support inline Drawers, deprecating unnecessary props (f93b71e)

Bug Fixes

  • deselect item on delete (f27871b)
  • improve heading-analyzer reliability (ab6c018)
  • never render FieldLabel with padding or borders (a97b54f)
  • prevent propagation of custom ActionBar actions by default (14909bd)
  • prevent user pollution of ActionBar styles (e154cb7)
  • render DropZones the same in Puck and Render (d975aaf)
  • reset resolveFields lastFields param when changing component (7fead35)
  • select new item when dispatching duplicate action (e3d0025)
  • set root DropZone to 100% height (3d93f46)
  • stop actions from overflowing outside left of frame (c036b6d)
  • trigger iframe resize when closing devtools (2c0b782)

New contributors

Copy link

vercel bot commented Jan 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
puck-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 4:22pm
puck-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 21, 2025 4:22pm

@chrisvxd chrisvxd marked this pull request as ready for review January 22, 2025 11:03
@chrisvxd chrisvxd merged commit 4ff8f4f into main Jan 22, 2025
4 checks passed
@chrisvxd chrisvxd deleted the prep-release branch January 22, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant