Credit usage
What is left of an allowance: the remaining amount in large, a meter that turns to warning then danger, the use per day and the day it runs out.
- Domaine
- Affichage de données
- Niveau de support
- Taille
- Non mesurée
- Qui l'utilise
- Aucun produit en production ne l'importe encore
import { CreditUsage } from "@krizaka/charts/credits";Web et mobile — le même composant pour React et React Native. Bêta : son API peut encore changer à une version mineure.
Pourquoi il est là. Sovkora's credits left (PS-C ready-made charts).
Quand l’utiliser
- Sovkora's billing: the credits left this month and when they run out at the current pace.
- A storage plan (a platform's console): gigabytes used of the plan, with a unit format.
- Any quota that renews: API calls, minutes of video.
Quand ne pas l’utiliser
- Money raised towards a goal.À la place : Goal progress
- A value in a range with no notion of running out (a load, a score).À la place : Gauge
Installation
Installer
npm install @krizaka/chartsImporter
import { CreditUsage } from "@krizaka/charts/credits";Exemples
Monthly credits
An Sovkora plan: credits left, the daily use, the run-out date.
Storage plan
A platform's console: gigabytes of the plan, past the warning level.
Props
What is left of an allowance: the remaining amount, a meter in tones, the use per day and the run-out date.
| Prop | Type | Défaut | Description |
|---|---|---|---|
limitrequis | number | — | The allowance. |
titlerequis | string | — | What the allowance is (“Credits this month”): the heading and the meter's name. |
usedrequis | number | — | How much is used. |
brand | BrandId | — | The brand whose palette the charts use. Without it, a chart follows a .brand-<id> ancestor, else Krizaka. Set it
when the app loads a brand stylesheet on :root (@krizaka/tokens/brands/sovkora.css). |
className | string | — | A class on the figure (layout). |
daily | readonly (number | null)[] | — | The use of each recent day, oldest first: the sparkline and the projection. |
days | readonly unknown[] | — | The days of daily (ISO dates), for the sparkline's summary. |
description | ReactNode | — | A line under the title: the plan, the period. |
format | ValueFormat | integer | How the amounts are written. Default "integer"; a { style: "unit", unit: "gigabyte" } for storage. |
hideTitle | boolean | — | Visually hide the title (it stays the accessible name). |
labels | Partial<CreditLabels> | — | The words, passed translated; English by default. |
levels | readonly [number, number] | [0.8, 0.95] | The share where the meter turns to warning, then danger. Default [0.8, 0.95]. |
loading | boolean | — | The data is on its way. |
locale | Locale | — | The locale of every figure and date ("fr-FR"). Default "en-US". |
now | Date | — | Today, for the run-out projection: the host gives the time (from the server, the same date on both sides); without it no run-out date is shown. |
renewsAt | string | Date | — | When the allowance renews (an ISO date or a Date). |
style | CSSProperties | — | Inline style on the figure (layout only). |
Accessibilité
- The meter is a
meternamed by the title, its value said in words (“3,120 used (62 %)”). - The warning and danger tones come with words: the projection says when it runs out.
Bonnes pratiques
- Pass the use of the recent days: the projection and the sparkline need it.
- Pass
nowfrom the server when the page is server-rendered: both sides write the same date. - Lead with what is left, not what is used: it is what people decide on.
Composants liés
Générée depuis le code de @krizaka/ui 5.3.4 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub