PureAdmin.Components.Comparison (PureAdmin v1.1.0)

Copy Markdown View Source

Comparison table components for Pure Admin.

Provides components for two-column and three-column data comparison patterns (version control, data changes, merge conflicts).

Examples

<.comparison_table>
  <:head>
    <th style="width: 20%;">#</th>
    <th style="width: 40%;">Base values</th>
    <th style="width: 40%;">New values</th>
  </:head>

  <.comparison_row label="Town">
    <:cell>
      <.comparison_value value="Beveren" is_copyable />
    </:cell>
    <:cell is_changed>
      <.comparison_value value="Antwerpen" is_copyable />
    </:cell>
  </.comparison_row>

  <.comparison_section colspan={3}>Address metadata</.comparison_section>
</.comparison_table>

Summary

Functions

Renders a comparison table row with a label and value cells.

Renders a section header row in a comparison table.

Renders a comparison table wrapper.

Renders a comparison value cell content with optional copy button.

JS command to copy a value to clipboard.

Functions

comparison_row(assigns)

Renders a comparison table row with a label and value cells.

The :cell slot renders each value column. Use slot attrs is_changed, is_solid, and is_conflict to highlight differences.

Examples

<.comparison_row label="Town">
  <:cell>
    <.comparison_value value="Beveren" is_copyable />
  </:cell>
  <:cell is_changed>
    <.comparison_value value="Antwerpen" is_copyable />
  </:cell>
</.comparison_row>

<%!-- Empty row (no cells or empty cells) --%>
<.comparison_row label="Region" cells={2} />

Attributes

  • label (:string) (required) - Field name shown in the label column.
  • cells (:integer) - Number of empty cells to render (when no :cell slot). Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • cell - Value cell content. Accepts attributes:
    • is_changed (:boolean) - Pink highlight for changed values.
    • is_solid (:boolean) - Solid background variant (no left border).
    • is_conflict (:boolean) - Orange highlight for merge conflicts.

comparison_section(assigns)

Renders a section header row in a comparison table.

Examples

<.comparison_section colspan={3}>Address metadata</.comparison_section>

Attributes

  • colspan (:integer) (required) - Number of columns to span.
  • Global attributes are accepted.

Slots

  • inner_block (required)

comparison_table(assigns)

Renders a comparison table wrapper.

Wraps content in <table class="pa-table pa-comparison-table"> with a thead from the :head slot and tbody from inner_block.

Examples

<.comparison_table>
  <:head>
    <th style="width: 20%;">#</th>
    <th style="width: 40%;">Base</.th>
    <th style="width: 40%;">New</.th>
  </:head>
  ...rows...
</.comparison_table>

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • head (required) - Table header row content (<th> elements).
  • inner_block (required) - Table body content (comparison_row, comparison_section).

comparison_value(assigns)

Renders a comparison value cell content with optional copy button.

Examples

<.comparison_value value="Antwerpen" is_copyable />
<.comparison_value value="be" />

Attributes

  • value (:string) (required) - The value to display.
  • is_copyable (:boolean) - Show copy-to-clipboard button. Defaults to true.
  • Global attributes are accepted.

copy_to_clipboard(value)

JS command to copy a value to clipboard.

Uses the Clipboard API via a JS dispatch event.