Skip to Content
BBRICKSv0.7.4
KitPrimitives

MoneyFigure

Label + "?" + amount: the one way a money figure is shown. The amount is LTR and tabular.

import { MoneyFigure } from '@ergasti/bricks';

Examples

The "?" note

Press, hover or focus the "?" to see what a figure includes and excludes; Escape closes it. Wrap the page in MoneyNotesProvider with the server's dictionary.

Code
import { MoneyNote, MoneyNotesProvider, useLanguage } from '@ergasti/bricks';
import { moneyNotes } from './sample-data';

function Question() {
  const language = useLanguage();
  return (
    <MoneyNotesProvider notes={moneyNotes(language)}>
      <div style={{ display: 'flex', gap: 24, alignItems: 'center', paddingTop: 90 }}>
        <span>Sales <MoneyNote figure="sales" /></span>
        <span>Held <MoneyNote figure="wallet_held" amount="18450.00" /></span>
      </div>
    </MoneyNotesProvider>
  );
}

A dotted term and a figure

With children the trigger is the label itself; MoneyFigure pairs the term with its amount.

Code
import { Money, MoneyFigure, MoneyNote, MoneyNotesProvider, useLanguage } from '@ergasti/bricks';
import { moneyNotes } from './sample-data';

function Terms() {
  const language = useLanguage();
  return (
    <MoneyNotesProvider notes={moneyNotes(language)}>
      <div style={{ display: 'grid', gap: 10, paddingTop: 90 }}>
        <MoneyNote figure="wallet_available"><b>Available</b></MoneyNote>
        <MoneyFigure figure="wallet_balance" amount="61840.00" />
        <MoneyFigure figure="wallet_topped_up" amount="287800.00" label="Total top-ups" />
        <Money value="43390.00" />
      </div>
    </MoneyNotesProvider>
  );
}

Variants

A note that wraps a label can be drawn 'term' (dotted underline, the default), 'plain' (plain text that still opens the note) or 'icon' (plain text with the small "?" after it). BricksProvider moneyNoteStyle sets one look for a whole subtree.

Code
import { MoneyNote, MoneyNotesProvider, useLanguage } from '@ergasti/bricks';
import { moneyNotes } from './sample-data';

function Variants() {
  const language = useLanguage();
  return (
    <MoneyNotesProvider notes={moneyNotes(language)}>
      <div style={{ display: 'grid', gap: 10, paddingTop: 70 }}>
        <MoneyNote figure="wallet_available" variant="term">Available (term)</MoneyNote>
        <MoneyNote figure="wallet_available" variant="plain">Available (plain)</MoneyNote>
        <MoneyNote figure="wallet_available" variant="icon">Available (icon)</MoneyNote>
      </div>
    </MoneyNotesProvider>
  );
}

Props

Prop

Type

Accessibility

  • Roles in the markup: dialog.
  • ARIA attributes set: aria-label, aria-expanded, aria-controls, aria-hidden, aria-labelledby.
  • It moves focus in code.
  • Its tests cover: “is a real button with an aria-label naming the figure, closed by default”; “opens on Enter and on Space; Escape closes it and returns focus to the button”; “inside a drawer, renders into the drawer (so its focus trap and inert handling still hold), not the table”; “shows the dictionary label, a note button and the amount dir=ltr, tabular”; “wraps the label: the label is the trigger, named for its figure”; “opens on keyboard focus, closes on blur; Escape closes without the returned focus reopening it”.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

useBricks · useMoneyDisplay · useLanguage · MoneyNotesProvider · MoneyNote · Money · Avatar · AvatarStack · Button · ButtonLink

Source

src/kit/MoneyNote.tsx (line 261) on GitHub.

On this page