# Before and after

> Two blocks stacked in a frame for a refactor review.

A shadcn/ui block from the [@reui](https://reui.io) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/reui/c-code-block-16).

- Page, with a live preview: https://shadcn.exchange/r/reui/c-code-block-16
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/reui/c-code-block-16-light-57081beb01278af8.png
- Registry item: https://reui.io/r/new-york-v4/c-code-block-16.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://reui.io/r/new-york-v4/c-code-block-16.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@reui/code-block`, `@reui/frame`

## Files

### `c-code-block-16.tsx`

```tsx
import {
  CodeBlock,
  CodeBlockCopyButton,
  CodeBlockHeader,
  CodeBlockTitle,
} from "@/components/reui/code-block/code-block"
import { Frame, FramePanel } from "@/components/reui/frame"

const before = `function total(items) {
  let sum = 0
  for (let i = 0; i < items.length; i++) {
    sum = sum + items[i].price
  }
  return sum
}`

const after = `const total = (items) =>
  items.reduce((sum, item) => sum + item.price, 0)`

/**
 * A non-dense frame keeps the two panels apart, so the before and after read
 * as separate surfaces rather than one split pane.
 *
 * `p-0!` needs the important marker: FramePanel sets `px-(--frame-panel-px)`,
 * and Tailwind emits the axis utility after the `p-*` shorthand, so a plain
 * `p-0` loses. Without it the ghost blocks sit inset twice, once for the panel
 * and again for the block's own padding.
 */
export function Pattern() {
  return (
    <Frame className="w-full max-w-2xl">
      <FramePanel className="p-0!">
        <CodeBlock
          code={before}
          language="typescript"
          variant="ghost"
          showLineNumbers
        >
          <CodeBlockHeader>
            <CodeBlockTitle>Before</CodeBlockTitle>
            <CodeBlockCopyButton className="ml-auto" />
          </CodeBlockHeader>
        </CodeBlock>
      </FramePanel>
      <FramePanel className="p-0!">
        <CodeBlock
          code={after}
          language="typescript"
          variant="ghost"
          showLineNumbers
        >
          <CodeBlockHeader>
            <CodeBlockTitle>After</CodeBlockTitle>
            <CodeBlockCopyButton className="ml-auto" />
          </CodeBlockHeader>
        </CodeBlock>
      </FramePanel>
    </Frame>
  )
}
```
