OOlgax DXP
Contributing

Default components

Add a component to the shared @olgax.com/components library - a 15 minute walkthrough that builds a Spacer block with registerComponent and CSS tokens.

This page is for contributors adding to the shared library that every site can install. To build blocks for one site, see Custom components.

Rules for library components

  1. A typed props interface and a registerComponent("Name", { fields, defaultProps, render }) call. See Hero.tsx.
  2. A co-located .css file that uses --olgax-* custom properties (see tokens.css) and no hard-coded colors or spacing, so it stays themeable.
  3. Imported from src/index.ts for its registration side effect.
  4. No client-only hooks (useState and similar) in render. Components must work in the Puck editor (client) and in <Render> (which can run on the server).

Walkthrough: a Spacer block

Create the component

packages/components/src/blocks/Spacer.tsx:

import { registerComponent } from "@olgax.com/sdk";

export type SpacerProps = {
  height: number;
};

const Spacer = ({ height }: SpacerProps) => <div style={{ height }} />;

registerComponent<SpacerProps>("Spacer", {
  fields: {
    height: { type: "number" },
  },
  defaultProps: {
    height: 32,
  },
  render: (props) => <Spacer {...props} />,
});

Register it in the package index

Add one line to packages/components/src/index.ts, next to the other blocks:

import "./blocks/Spacer";

Run it locally

pnpm --filter demo dev

Open http://localhost:3000/home/edit. Spacer is in the block list. Next transpiles @olgax.com/components straight from source, so there is no build step. Drag it onto the canvas and check the height field.

Document it

Add a short section to packages/components/README.md showing the props as a Data.content item, following the existing entries.

Check types

pnpm --filter demo build

Puck's config types are stricter than editor diagnostics, so a full build is the reliable check.

Add a changeset for your change. See Releasing.

Need a review or a second opinion?

Share your branch in the Olgax Discord and ask for feedback.

Questions, ideas or something not working?

Ask in our official Discord, open an issue on GitHub, or edit this page.

On this page