Costs Agreement

The costs agreement builder's parts: badges for how an answer resolves and where a value comes from, rule pills and kinds, the question list, the review checks, the template library row and the builder popover.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

LEAP CRMBuilt for the CRM from the core library. It knows about the CRM's own records, so it isn't a general building block.

import { CaBadge, CaRulePill, CaRuleKind, CaQuestionRow, CaQuestionsHeader, CaReceiptCheck, CaTemplateRow, CaPopover } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Known

Props

tone
children

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse each CaBadge tone for its one meaning: known, derived or ask for how an answer resolves, and contact, opportunity, firm or external for where a value comes from. Use Badge for labels outside the builder.
DoSet open on a CaRulePill while its popover is open, so the pill keeps the focus ring and screen readers hear it as expanded.
DoPass the current question's answer controls as CaQuestionRow children, like a Field with Save and Leave blank, and give open and answered rows onSelect so the lawyer can go back to one.
DoReturn focus to the pill or field that opened a CaPopover when onClose runs. The builder places the popover itself, so nothing else moves focus back.
DoUse width="xwide" (680 px) for the field popover and the default 340 px for a rule. wide is 520 px for content in between.
Don'tTint a section of the agreement to show a rule applies to it. Put the rule's CaRulePill in the page margin and its CaRuleKind in the popover, so colour stays in the pill and the icon.

Props

CaBadge

PropTypeDefaultDescription
tone| "known" | "derived" | "ask" | "tag" | "rule" | "contact" | "opportunity" | "firm" | "external""known"Where the value comes from: known, derived or asked, each with its own colour.
children *ReactNode—What it shows inside.

CaRulePill

PropTypeDefaultDescription
openbooleanfalseIts popover is open: the pill takes the focus ring.
children *ReactNode—What it shows inside.

CaRuleKind

PropTypeDefaultDescription
kind *CaRuleKind—show_when, hide_when, repeat or else: the rule's icon, colour and label.

CaStatusCircle

PropTypeDefaultDescription
state *"open" | "current" | "done"—Where the question stands; the circle fills as it moves on.

CaReceiptCheck

PropTypeDefaultDescription
status *"fine" | "look"—fine in the known green, or look in the ask amber when it needs attention.
title *ReactNode—What was checked, like "Fees match the matter type".
detailReactNode—A grey line under the title on why, or what to look at.
childrenReactNode—What it shows inside.

CaTemplateRow

PropTypeDefaultDescription
title *string—The template's name.
metastring—What it covers, like "Family law · 12 questions".

CaQuestionRow

PropTypeDefaultDescription
state *"open" | "done" | "current"—open, current (the one being answered) or done.
question *ReactNode—The question as the client will read it.
answerReactNode—The answer, shown in green once done.
metaReactNode—A note under the current question, like "Used in 3 places".
childrenReactNode—The current question's answer controls: a Field with Save and Leave blank, or Yes / No toggles.
onSelect() => void—Makes an open or answered question the current one.

CaQuestionsHeader

PropTypeDefaultDescription
answered *number—How many questions have an answer.
total *number—How many questions there are.

CaPopover

PropTypeDefaultDescription
label *string—Names the popover for screen readers.
headerReactNode—What leads the header, like a rule pill and its kind.
descriptionReactNode—A muted line under the header, like what the rule does.
childrenReactNode—The popover's fields.
footerReactNode—The action row at the foot, like Remove rule and Save.
onClose *() => void—Runs when the popover's close button is pressed.
width"default" | "wide" | "xwide""default"340 px by default, 520 wide, 680 for the field dialog.

Code

What the playground shows, ready to copy.

import { CaBadge } from "@leap-crm/design-system";

<CaBadge>Known</CaBadge>

Rules

A rule's name in the page margin opens its popover; open, it takes the focus ring. Each kind has its action hue and icon.

Show whenHide whenRepeatOtherwise

Questions

The sticky header with progress, then each question in document order: open, answered in green with its answer, or current in navy with its answer controls.

Questions4 of 9 answered
Current question: What is the supervising partner’s hourly rate?Used in 3 places

Review checks

One check on the review step: fine in the known green, or needs a look in the ask amber. Screen readers hear which.

Fine: Every question answered

9 answers written into the agreement

Needs a look: 2 sections removed by rules

Show when · Matter type is Family law

Template row

A template in the library: a page thumbnail, its title and what it covers. Hover for the subtle fill.

Popover

Every builder popover: the rule pill and kind, a Close, what the rule does, its fields, and an action row. 340, 520 or 680 px wide.

Show when

Kept when the test on the opportunity’s data holds; removed otherwise.

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { useState } from "react";

import { ActionRow, Button, CaBadge, CaPopover, CaQuestionRow, CaQuestionsHeader, CaReceiptCheck, CaRuleKind, CaRulePill, CaStatusCircle, CaTemplateRow, Field, Input, caRuleKindHints, type CaBadgeTone } from "@leap-crm/design-system";

const tones: CaBadgeTone[] = [
  "known",
  "derived",
  "ask",
  "tag",
  "rule",
  "contact",
  "opportunity",
  "firm",
  "external",
];

function RulePillDemo() {
  const [open, setOpen] = useState(false);
  return (
    <CaRulePill open={open} onClick={() => setOpen(value => !value)}>
      Hourly rates
    </CaRulePill>
  );
}

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
TabMoves through its buttons in order.
EnterSpacePresses the focused button.