@tempoxyz/ds 0.3.9 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/AGENTS.md +9 -0
- package/dist/docs/components/accordion.md +489 -0
- package/dist/docs/components/address-card.md +147 -0
- package/dist/docs/components/agent-logo.md +194 -0
- package/dist/docs/components/alert-dialog.md +631 -0
- package/dist/docs/components/alert.md +448 -0
- package/dist/docs/components/amount-input.md +305 -0
- package/dist/docs/components/amount.md +794 -0
- package/dist/docs/components/app-shell.md +559 -0
- package/dist/docs/components/asset-chip.md +294 -0
- package/dist/docs/components/autocomplete.md +619 -0
- package/dist/docs/components/avatar.md +321 -0
- package/dist/docs/components/badge.md +339 -0
- package/dist/docs/components/badged-logo.md +116 -0
- package/dist/docs/components/banner.md +379 -0
- package/dist/docs/components/bar-chart.md +208 -0
- package/dist/docs/components/breadcrumbs.md +380 -0
- package/dist/docs/components/button-group.md +286 -0
- package/dist/docs/components/button.md +650 -0
- package/dist/docs/components/calendar.md +375 -0
- package/dist/docs/components/callout.md +96 -0
- package/dist/docs/components/checkbox-group.md +521 -0
- package/dist/docs/components/checkbox.md +467 -0
- package/dist/docs/components/choice-group.md +516 -0
- package/dist/docs/components/choicebox.md +641 -0
- package/dist/docs/components/code.md +100 -0
- package/dist/docs/components/combobox.md +939 -0
- package/dist/docs/components/container.md +257 -0
- package/dist/docs/components/copy-button.md +642 -0
- package/dist/docs/components/date-picker.md +514 -0
- package/dist/docs/components/dialog.md +1332 -0
- package/dist/docs/components/drawer.md +966 -0
- package/dist/docs/components/empty.md +340 -0
- package/dist/docs/components/field.md +570 -0
- package/dist/docs/components/fieldset.md +398 -0
- package/dist/docs/components/frame.md +434 -0
- package/dist/docs/components/gauge.md +299 -0
- package/dist/docs/components/get-started-visual.md +117 -0
- package/dist/docs/components/grid.md +288 -0
- package/dist/docs/components/hero-visual.md +155 -0
- package/dist/docs/components/hex.md +487 -0
- package/dist/docs/components/icon-tile.md +292 -0
- package/dist/docs/components/identicon.md +371 -0
- package/dist/docs/components/inline.md +233 -0
- package/dist/docs/components/inset.md +225 -0
- package/dist/docs/components/kbd.md +423 -0
- package/dist/docs/components/list-group.md +981 -0
- package/dist/docs/components/loading-dots.md +237 -0
- package/dist/docs/components/menu.md +934 -0
- package/dist/docs/components/native-select.md +204 -0
- package/dist/docs/components/network-logo.md +248 -0
- package/dist/docs/components/number-field.md +543 -0
- package/dist/docs/components/otp-field.md +616 -0
- package/dist/docs/components/pagination.md +516 -0
- package/dist/docs/components/popover.md +544 -0
- package/dist/docs/components/progress.md +388 -0
- package/dist/docs/components/qr.md +314 -0
- package/dist/docs/components/radio-group.md +528 -0
- package/dist/docs/components/secret-value.md +406 -0
- package/dist/docs/components/select.md +751 -0
- package/dist/docs/components/separator.md +379 -0
- package/dist/docs/components/sidebar-menu.md +922 -0
- package/dist/docs/components/skeleton.md +517 -0
- package/dist/docs/components/slider.md +539 -0
- package/dist/docs/components/snippet.md +424 -0
- package/dist/docs/components/spinner.md +216 -0
- package/dist/docs/components/split-bar.md +139 -0
- package/dist/docs/components/split-button.md +464 -0
- package/dist/docs/components/stack.md +299 -0
- package/dist/docs/components/status-chip.md +226 -0
- package/dist/docs/components/status-indicator.md +119 -0
- package/dist/docs/components/status-row.md +174 -0
- package/dist/docs/components/stepper.md +451 -0
- package/dist/docs/components/success-hero.md +157 -0
- package/dist/docs/components/surface.md +639 -0
- package/dist/docs/components/switch.md +472 -0
- package/dist/docs/components/table.md +967 -0
- package/dist/docs/components/tabs.md +627 -0
- package/dist/docs/components/tempo-logo.md +185 -0
- package/dist/docs/components/text-input.md +624 -0
- package/dist/docs/components/textarea.md +352 -0
- package/dist/docs/components/toast.md +535 -0
- package/dist/docs/components/token-logo.md +371 -0
- package/dist/docs/components/token.md +247 -0
- package/dist/docs/components/tooltip.md +490 -0
- package/dist/docs/components/verification-code.md +116 -0
- package/dist/docs/components/visual.md +249 -0
- package/dist/docs/components.md +203 -0
- package/dist/docs/foundations/accessibility.md +377 -0
- package/dist/docs/foundations/agents.md +150 -0
- package/dist/docs/foundations/color.md +522 -0
- package/dist/docs/foundations/content/tone.md +194 -0
- package/dist/docs/foundations/content/voice.md +194 -0
- package/dist/docs/foundations/content/writing-style.md +406 -0
- package/dist/docs/foundations/iconography.md +282 -0
- package/dist/docs/foundations/intent.md +360 -0
- package/dist/docs/foundations/layout.md +508 -0
- package/dist/docs/foundations/linter.md +296 -0
- package/dist/docs/foundations/motion.md +151 -0
- package/dist/docs/foundations/radius-and-padding.md +86 -0
- package/dist/docs/foundations/typography.md +266 -0
- package/dist/docs/index.md +137 -0
- package/dist/docs/introduction/faq.md +132 -0
- package/dist/docs/introduction/getting-started.md +377 -0
- package/dist/docs/patterns/blockchain-values.md +709 -0
- package/dist/docs/patterns/dashboards.md +638 -0
- package/dist/docs/patterns/destructive-actions.md +626 -0
- package/dist/docs/patterns/empty-states.md +612 -0
- package/dist/docs/patterns/errors-and-validation.md +808 -0
- package/dist/docs/patterns/feedback-and-status.md +518 -0
- package/dist/docs/patterns/forms.md +679 -0
- package/dist/docs/patterns/loading.md +630 -0
- package/dist/docs/patterns/navigation.md +397 -0
- package/dist/docs/patterns/payments.md +765 -0
- package/dist/docs/patterns/responsive-layout.md +997 -0
- package/dist/docs/patterns/tables-and-lists.md +964 -0
- package/dist/docs/products/tempo-console.md +671 -0
- package/dist/docs/products/tempo-performance.md +437 -0
- package/dist/docs/products/tempo-wallet.md +438 -0
- package/dist/web/components/OtpField.css +1 -1
- package/dist/web/components/OtpField.d.ts +1 -1
- package/dist/web/components/OtpField.d.ts.map +1 -1
- package/dist/web/components/OtpField.js +3 -4
- package/dist/web/components/OtpField.js.map +1 -1
- package/dist/web/components/OtpField.js.zyzz.json +1 -1
- package/dist/web/index.js.zyzz.json +1 -1
- package/package.json +1 -1
- package/src/web/components/OtpField.tsx +2 -24
|
@@ -0,0 +1,794 @@
|
|
|
1
|
+
# Amount
|
|
2
|
+
|
|
3
|
+
Formats a number as money or a token amount.
|
|
4
|
+
|
|
5
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Amount.tsx)
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Formats a number in `en-US` with tabular figures, as money or followed by a token symbol.
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
### Basic
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Amount } from '@tempoxyz/ds'
|
|
17
|
+
|
|
18
|
+
export function Demo() {
|
|
19
|
+
return <Amount symbol="PathUSD" value="1250.50" />
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Basic.tsx)
|
|
24
|
+
|
|
25
|
+
### Size
|
|
26
|
+
|
|
27
|
+
Set `size` to `sm` (default), `md`, `lg`, or `xl`.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
31
|
+
|
|
32
|
+
export const fill = true
|
|
33
|
+
export function Demo() {
|
|
34
|
+
return (
|
|
35
|
+
<div {...styles.stack()}>
|
|
36
|
+
{(['sm', 'md', 'lg', 'xl'] as const).map((size) => (
|
|
37
|
+
<Amount key={size} size={size} symbol="PathUSD" value={1250.5} />
|
|
38
|
+
))}
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
namespace styles {
|
|
44
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Size.tsx)
|
|
49
|
+
|
|
50
|
+
### Currency
|
|
51
|
+
|
|
52
|
+
Set `currency` to an ISO 4217 code for money, or `symbol` to follow the number with a token symbol. Pass one, not both.
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
56
|
+
|
|
57
|
+
export const fill = true
|
|
58
|
+
export function Demo() {
|
|
59
|
+
return (
|
|
60
|
+
<div {...styles.stack()}>
|
|
61
|
+
<Amount currency="USD" size="lg" value={1234.5} />
|
|
62
|
+
<Amount currency="EUR" value={1234.5} />
|
|
63
|
+
<Amount size="lg" symbol="PathUSD" value={1234.5} />
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
namespace styles {
|
|
69
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Currency.tsx)
|
|
74
|
+
|
|
75
|
+
### Align
|
|
76
|
+
|
|
77
|
+
Set `align` to `left` (default), `center`, or `right`.
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
81
|
+
|
|
82
|
+
export const fill = true
|
|
83
|
+
export function Demo() {
|
|
84
|
+
return (
|
|
85
|
+
<div {...styles.stack()}>
|
|
86
|
+
{(['left', 'center', 'right'] as const).map((align) => (
|
|
87
|
+
<Amount align={align} currency="USD" key={align} size="md" value={1234.5} />
|
|
88
|
+
))}
|
|
89
|
+
</div>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
namespace styles {
|
|
94
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Align.tsx)
|
|
99
|
+
|
|
100
|
+
### Sign
|
|
101
|
+
|
|
102
|
+
Set `sign` to `+`, `-`, or `−` to prefix the amount.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
106
|
+
|
|
107
|
+
export const fill = true
|
|
108
|
+
export function Demo() {
|
|
109
|
+
return (
|
|
110
|
+
<div {...styles.stack()}>
|
|
111
|
+
<Amount align="center" sign="+" size="md" symbol="PathUSD" value="1250.50" />
|
|
112
|
+
<Amount align="right" currency="USD" sign="−" size="md" value={1234.5} />
|
|
113
|
+
</div>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
namespace styles {
|
|
118
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Sign.tsx)
|
|
123
|
+
|
|
124
|
+
### Strikethrough
|
|
125
|
+
|
|
126
|
+
Set `strikethrough` to mark a superseded amount.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
130
|
+
|
|
131
|
+
export const fill = true
|
|
132
|
+
export function Demo() {
|
|
133
|
+
return (
|
|
134
|
+
<div {...styles.stack()}>
|
|
135
|
+
<Amount size="md" strikethrough symbol="PathUSD" value={1250.5} />
|
|
136
|
+
</div>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
namespace styles {
|
|
141
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Strikethrough.tsx)
|
|
146
|
+
|
|
147
|
+
### Precise
|
|
148
|
+
|
|
149
|
+
Set `precise` to show two significant digits for a currency value below the smallest shown unit.
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
153
|
+
|
|
154
|
+
export const fill = true
|
|
155
|
+
export function Demo() {
|
|
156
|
+
return (
|
|
157
|
+
<div {...styles.stack()}>
|
|
158
|
+
<Amount currency="USD" value={0.0004} />
|
|
159
|
+
<Amount currency="USD" precise value={0.0004} />
|
|
160
|
+
</div>
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
namespace styles {
|
|
165
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Precise.tsx)
|
|
170
|
+
|
|
171
|
+
### Max Decimals
|
|
172
|
+
|
|
173
|
+
Set `maxDecimals` to cap the fraction digits shown.
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
177
|
+
|
|
178
|
+
export const fill = true
|
|
179
|
+
export function Demo() {
|
|
180
|
+
return (
|
|
181
|
+
<div {...styles.stack()}>
|
|
182
|
+
<Amount symbol="PathUSD" value="1.23456" />
|
|
183
|
+
<Amount maxDecimals={2} symbol="PathUSD" value="1.23456" />
|
|
184
|
+
</div>
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
namespace styles {
|
|
189
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/MaxDecimals.tsx)
|
|
194
|
+
|
|
195
|
+
### Locale
|
|
196
|
+
|
|
197
|
+
Set `locale` to a BCP 47 tag, such as `de-DE`, to change grouping, decimal marks, and currency symbols. It defaults to `en-US`, so server and browser render the same text.
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
201
|
+
|
|
202
|
+
export const fill = true
|
|
203
|
+
export function Demo() {
|
|
204
|
+
return (
|
|
205
|
+
<div {...styles.stack()}>
|
|
206
|
+
<Amount currency="USD" value="1250.50" />
|
|
207
|
+
<Amount currency="USD" locale="de-DE" value="1250.50" />
|
|
208
|
+
</div>
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
namespace styles {
|
|
213
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Locale.tsx)
|
|
218
|
+
|
|
219
|
+
## Anatomy
|
|
220
|
+
|
|
221
|
+
Import the component and assemble its parts.
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import { Amount } from '@tempoxyz/ds'
|
|
225
|
+
|
|
226
|
+
<Amount />
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Guidelines
|
|
230
|
+
|
|
231
|
+
### When to Use
|
|
232
|
+
|
|
233
|
+
* Show balances, payment amounts, fees, and converted values, such as 1,250.50 USDC or $1,250.50.
|
|
234
|
+
* Show amounts in tables, rows, and review screens with consistent formatting.
|
|
235
|
+
|
|
236
|
+
### When Not to Use
|
|
237
|
+
|
|
238
|
+
* Use [AmountInput](/docs/components/amount-input) when people enter an amount.
|
|
239
|
+
* Use `Table.Cell` with `numeric` in a [Table](/docs/components/table) for counts and metrics without a unit, such as TPS or block height.
|
|
240
|
+
|
|
241
|
+
### Always Show the Unit
|
|
242
|
+
|
|
243
|
+
**Do:** Pass `symbol` for a token amount and `currency` for money.
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
/**
|
|
247
|
+
* Do example for "Always Show the Unit" on the Amount page.
|
|
248
|
+
* Pass `symbol` for a token amount and `currency` for money.
|
|
249
|
+
* @module
|
|
250
|
+
*/
|
|
251
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
252
|
+
|
|
253
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
254
|
+
export function Demo() {
|
|
255
|
+
return (
|
|
256
|
+
<div {...styles.stack()}>
|
|
257
|
+
<Amount size="md" symbol="USDC" value="1250.50" />
|
|
258
|
+
<Amount currency="USD" value="1250.50" />
|
|
259
|
+
</div>
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
namespace styles {
|
|
264
|
+
export const stack = style({ display: 'grid', gap: '4' })
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Don't:** Show an amount without its token or currency.
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
/**
|
|
272
|
+
* Don't example for "Always Show the Unit" on the Amount page.
|
|
273
|
+
* Don't show an amount without its token or currency.
|
|
274
|
+
* @module
|
|
275
|
+
*/
|
|
276
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
277
|
+
|
|
278
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
279
|
+
export function Demo() {
|
|
280
|
+
return (
|
|
281
|
+
<div {...styles.stack()}>
|
|
282
|
+
<Amount size="md" value="1250.50" />
|
|
283
|
+
<Amount value="1250.50" />
|
|
284
|
+
</div>
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
namespace styles {
|
|
289
|
+
export const stack = style({ display: 'grid', gap: '4' })
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Choose Currency or Symbol
|
|
294
|
+
|
|
295
|
+
* **Currency:** Money and converted values, such as a portfolio total.
|
|
296
|
+
* **Symbol:** Token amounts, such as what an account holds or sends.
|
|
297
|
+
|
|
298
|
+
Show a stablecoin balance in its token, such as PathUSD, even if it tracks the dollar. If you have a rate, add a converted value with `currency` as a second line.
|
|
299
|
+
|
|
300
|
+
### Pass Exact Decimal Strings
|
|
301
|
+
|
|
302
|
+
Pass `value` as a decimal string, such as a token balance converted from base units. Without `currency`, a string keeps its own fraction digits, including trailing zeros.
|
|
303
|
+
|
|
304
|
+
**Do:** Pass decimal strings, such as `"0.30"`.
|
|
305
|
+
|
|
306
|
+
```tsx
|
|
307
|
+
/**
|
|
308
|
+
* Do example for "Pass Exact Decimal Strings" on the Amount page.
|
|
309
|
+
* Pass decimal strings, such as `"0.30"`.
|
|
310
|
+
* @module
|
|
311
|
+
*/
|
|
312
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
313
|
+
|
|
314
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
315
|
+
export function Demo() {
|
|
316
|
+
return (
|
|
317
|
+
<div {...styles.list()}>
|
|
318
|
+
<div {...styles.row()}>
|
|
319
|
+
<span {...styles.label()}>Available balance</span>
|
|
320
|
+
<Amount align="right" symbol="USDC" value="1250.10" />
|
|
321
|
+
</div>
|
|
322
|
+
<div {...styles.row()}>
|
|
323
|
+
<span {...styles.label()}>Total fees</span>
|
|
324
|
+
<Amount align="right" symbol="USDC" value="0.30" />
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
namespace styles {
|
|
331
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
332
|
+
|
|
333
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
334
|
+
|
|
335
|
+
export const row = style({
|
|
336
|
+
alignItems: 'baseline',
|
|
337
|
+
display: 'flex',
|
|
338
|
+
gap: '16',
|
|
339
|
+
justifyContent: 'space-between',
|
|
340
|
+
})
|
|
341
|
+
}
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
**Don't:** Pass numbers. They drop trailing zeros and show floating-point errors.
|
|
345
|
+
|
|
346
|
+
```tsx
|
|
347
|
+
/**
|
|
348
|
+
* Don't example for "Pass Exact Decimal Strings" on the Amount page.
|
|
349
|
+
* Don't pass numbers. They drop trailing zeros and show floating-point errors.
|
|
350
|
+
* @module
|
|
351
|
+
*/
|
|
352
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
353
|
+
|
|
354
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
355
|
+
export function Demo() {
|
|
356
|
+
return (
|
|
357
|
+
<div {...styles.list()}>
|
|
358
|
+
<div {...styles.row()}>
|
|
359
|
+
<span {...styles.label()}>Available balance</span>
|
|
360
|
+
<Amount align="right" symbol="USDC" value={1250.1} />
|
|
361
|
+
</div>
|
|
362
|
+
<div {...styles.row()}>
|
|
363
|
+
<span {...styles.label()}>Total fees</span>
|
|
364
|
+
<Amount align="right" symbol="USDC" value={0.1 + 0.2} />
|
|
365
|
+
</div>
|
|
366
|
+
</div>
|
|
367
|
+
)
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
namespace styles {
|
|
371
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
372
|
+
|
|
373
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
374
|
+
|
|
375
|
+
export const row = style({
|
|
376
|
+
alignItems: 'baseline',
|
|
377
|
+
display: 'flex',
|
|
378
|
+
gap: '16',
|
|
379
|
+
justifyContent: 'space-between',
|
|
380
|
+
})
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Set Decimals by Purpose
|
|
385
|
+
|
|
386
|
+
* **With `currency`:** Shows the currency's own digits, two for USD. `maxDecimals={0}` renders `$5`.
|
|
387
|
+
* **Without `currency`:** Shows every digit of the string. Set `maxDecimals` in lists, and show the exact value in details and review screens.
|
|
388
|
+
* **Rounding:** `0.999` with `maxDecimals={2}` renders `1.00`. Show the exact balance wherever people choose how much to send.
|
|
389
|
+
|
|
390
|
+
**Do:** Use one decimal count down a column so decimal points line up.
|
|
391
|
+
|
|
392
|
+
```tsx
|
|
393
|
+
/**
|
|
394
|
+
* Do example for "Set Decimals by Purpose" on the Amount page.
|
|
395
|
+
* Use one decimal count down a column so decimal points line up.
|
|
396
|
+
* @module
|
|
397
|
+
*/
|
|
398
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
399
|
+
|
|
400
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
401
|
+
export function Demo() {
|
|
402
|
+
return (
|
|
403
|
+
<div {...styles.list()}>
|
|
404
|
+
<div {...styles.row()}>
|
|
405
|
+
<span {...styles.label()}>Main wallet</span>
|
|
406
|
+
<Amount align="right" symbol="USDC" value="1250.50" />
|
|
407
|
+
</div>
|
|
408
|
+
<div {...styles.row()}>
|
|
409
|
+
<span {...styles.label()}>Savings</span>
|
|
410
|
+
<Amount align="right" symbol="USDC" value="84.10" />
|
|
411
|
+
</div>
|
|
412
|
+
<div {...styles.row()}>
|
|
413
|
+
<span {...styles.label()}>Payroll</span>
|
|
414
|
+
<Amount align="right" symbol="USDC" value="312.00" />
|
|
415
|
+
</div>
|
|
416
|
+
</div>
|
|
417
|
+
)
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
namespace styles {
|
|
421
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
422
|
+
|
|
423
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
424
|
+
|
|
425
|
+
export const row = style({
|
|
426
|
+
alignItems: 'baseline',
|
|
427
|
+
display: 'flex',
|
|
428
|
+
gap: '16',
|
|
429
|
+
justifyContent: 'space-between',
|
|
430
|
+
})
|
|
431
|
+
}
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Don't:** Mix decimal counts in one column.
|
|
435
|
+
|
|
436
|
+
```tsx
|
|
437
|
+
/**
|
|
438
|
+
* Don't example for "Set Decimals by Purpose" on the Amount page.
|
|
439
|
+
* Don't mix decimal counts in one column.
|
|
440
|
+
* @module
|
|
441
|
+
*/
|
|
442
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
443
|
+
|
|
444
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
445
|
+
export function Demo() {
|
|
446
|
+
return (
|
|
447
|
+
<div {...styles.list()}>
|
|
448
|
+
<div {...styles.row()}>
|
|
449
|
+
<span {...styles.label()}>Main wallet</span>
|
|
450
|
+
<Amount align="right" symbol="USDC" value="1250.504812" />
|
|
451
|
+
</div>
|
|
452
|
+
<div {...styles.row()}>
|
|
453
|
+
<span {...styles.label()}>Savings</span>
|
|
454
|
+
<Amount align="right" symbol="USDC" value="84.1" />
|
|
455
|
+
</div>
|
|
456
|
+
<div {...styles.row()}>
|
|
457
|
+
<span {...styles.label()}>Payroll</span>
|
|
458
|
+
<Amount align="right" symbol="USDC" value="312.0005" />
|
|
459
|
+
</div>
|
|
460
|
+
</div>
|
|
461
|
+
)
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
namespace styles {
|
|
465
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
466
|
+
|
|
467
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
468
|
+
|
|
469
|
+
export const row = style({
|
|
470
|
+
alignItems: 'baseline',
|
|
471
|
+
display: 'flex',
|
|
472
|
+
gap: '16',
|
|
473
|
+
justifyContent: 'space-between',
|
|
474
|
+
})
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Show Values Below a Cent Precisely
|
|
479
|
+
|
|
480
|
+
A currency value below its smallest unit renders as a bound, such as `<$0.01`.
|
|
481
|
+
|
|
482
|
+
**Do:** Set `precise` on network fees to show two significant digits.
|
|
483
|
+
|
|
484
|
+
```tsx
|
|
485
|
+
/**
|
|
486
|
+
* Do example for "Show Values Below a Cent Precisely" on the Amount page.
|
|
487
|
+
* Set `precise` on network fees to show two significant digits.
|
|
488
|
+
* @module
|
|
489
|
+
*/
|
|
490
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
491
|
+
|
|
492
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
493
|
+
export function Demo() {
|
|
494
|
+
return (
|
|
495
|
+
<div {...styles.list()}>
|
|
496
|
+
<div {...styles.row()}>
|
|
497
|
+
<span {...styles.label()}>You send</span>
|
|
498
|
+
<Amount align="right" symbol="USDC" value="250.00" />
|
|
499
|
+
</div>
|
|
500
|
+
<div {...styles.row()}>
|
|
501
|
+
<span {...styles.label()}>Network fee</span>
|
|
502
|
+
<Amount align="right" currency="USD" precise value="0.0004" />
|
|
503
|
+
</div>
|
|
504
|
+
</div>
|
|
505
|
+
)
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
namespace styles {
|
|
509
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
510
|
+
|
|
511
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
512
|
+
|
|
513
|
+
export const row = style({
|
|
514
|
+
alignItems: 'baseline',
|
|
515
|
+
display: 'flex',
|
|
516
|
+
gap: '16',
|
|
517
|
+
justifyContent: 'space-between',
|
|
518
|
+
})
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
**Don't:** Show a fee people pay as a bound.
|
|
523
|
+
|
|
524
|
+
```tsx
|
|
525
|
+
/**
|
|
526
|
+
* Don't example for "Show Values Below a Cent Precisely" on the Amount page.
|
|
527
|
+
* Don't show a fee people pay as a bound.
|
|
528
|
+
* @module
|
|
529
|
+
*/
|
|
530
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
531
|
+
|
|
532
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
533
|
+
export function Demo() {
|
|
534
|
+
return (
|
|
535
|
+
<div {...styles.list()}>
|
|
536
|
+
<div {...styles.row()}>
|
|
537
|
+
<span {...styles.label()}>You send</span>
|
|
538
|
+
<Amount align="right" symbol="USDC" value="250.00" />
|
|
539
|
+
</div>
|
|
540
|
+
<div {...styles.row()}>
|
|
541
|
+
<span {...styles.label()}>Network fee</span>
|
|
542
|
+
<Amount align="right" currency="USD" value="0.0004" />
|
|
543
|
+
</div>
|
|
544
|
+
</div>
|
|
545
|
+
)
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
namespace styles {
|
|
549
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
550
|
+
|
|
551
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
552
|
+
|
|
553
|
+
export const row = style({
|
|
554
|
+
alignItems: 'baseline',
|
|
555
|
+
display: 'flex',
|
|
556
|
+
gap: '16',
|
|
557
|
+
justifyContent: 'space-between',
|
|
558
|
+
})
|
|
559
|
+
}
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
### Show Direction With a Sign
|
|
563
|
+
|
|
564
|
+
Set `sign="+"` for money in and `sign="−"` for money out. Pass `value` without its own minus, or the amount shows two signs. Prefer the minus sign `−` to the hyphen `-`.
|
|
565
|
+
|
|
566
|
+
**Do:** Mark incoming and outgoing amounts with `+` and `−`.
|
|
567
|
+
|
|
568
|
+
```tsx
|
|
569
|
+
/**
|
|
570
|
+
* Do example for "Show Direction With a Sign" on the Amount page.
|
|
571
|
+
* Mark incoming and outgoing amounts with `+` and `−`.
|
|
572
|
+
* @module
|
|
573
|
+
*/
|
|
574
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
575
|
+
|
|
576
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
577
|
+
export function Demo() {
|
|
578
|
+
return (
|
|
579
|
+
<div {...styles.list()}>
|
|
580
|
+
<div {...styles.row()}>
|
|
581
|
+
<span {...styles.label()}>Received from Jane</span>
|
|
582
|
+
<Amount align="right" sign="+" symbol="USDC" value="120.00" />
|
|
583
|
+
</div>
|
|
584
|
+
<div {...styles.row()}>
|
|
585
|
+
<span {...styles.label()}>Sent to 0x91bd…07e1</span>
|
|
586
|
+
<Amount align="right" sign="−" symbol="USDC" value="48.50" />
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
)
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
namespace styles {
|
|
593
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
594
|
+
|
|
595
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
596
|
+
|
|
597
|
+
export const row = style({
|
|
598
|
+
alignItems: 'baseline',
|
|
599
|
+
display: 'flex',
|
|
600
|
+
gap: '16',
|
|
601
|
+
justifyContent: 'space-between',
|
|
602
|
+
})
|
|
603
|
+
}
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
**Don't:** Show direction with green and red alone.
|
|
607
|
+
|
|
608
|
+
```tsx
|
|
609
|
+
/**
|
|
610
|
+
* Don't example for "Show Direction With a Sign" on the Amount page.
|
|
611
|
+
* Don't show direction with green and red alone.
|
|
612
|
+
* @module
|
|
613
|
+
*/
|
|
614
|
+
import { style } from '@tempoxyz/ds'
|
|
615
|
+
|
|
616
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
617
|
+
export function Demo() {
|
|
618
|
+
return (
|
|
619
|
+
<div {...styles.list()}>
|
|
620
|
+
<div {...styles.row()}>
|
|
621
|
+
<span {...styles.label()}>Received from Jane</span>
|
|
622
|
+
<span {...styles.credit()}>120.00 USDC</span>
|
|
623
|
+
</div>
|
|
624
|
+
<div {...styles.row()}>
|
|
625
|
+
<span {...styles.label()}>Sent to 0x91bd…07e1</span>
|
|
626
|
+
<span {...styles.debit()}>48.50 USDC</span>
|
|
627
|
+
</div>
|
|
628
|
+
</div>
|
|
629
|
+
)
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
namespace styles {
|
|
633
|
+
export const credit = style({
|
|
634
|
+
color: 'content.positive',
|
|
635
|
+
fontVariantNumeric: 'tabular-nums !custom',
|
|
636
|
+
typography: 'body.b2Strong',
|
|
637
|
+
})
|
|
638
|
+
|
|
639
|
+
export const debit = style({
|
|
640
|
+
color: 'content.negative',
|
|
641
|
+
fontVariantNumeric: 'tabular-nums !custom',
|
|
642
|
+
typography: 'body.b2Strong',
|
|
643
|
+
})
|
|
644
|
+
|
|
645
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
646
|
+
|
|
647
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
648
|
+
|
|
649
|
+
export const row = style({
|
|
650
|
+
alignItems: 'baseline',
|
|
651
|
+
display: 'flex',
|
|
652
|
+
gap: '16',
|
|
653
|
+
justifyContent: 'space-between',
|
|
654
|
+
})
|
|
655
|
+
}
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### Mark Superseded Amounts in Words
|
|
659
|
+
|
|
660
|
+
Use `strikethrough` for an amount that no longer applies, such as an expired fee quote, and show the new amount beside it.
|
|
661
|
+
|
|
662
|
+
**Do:** Say it in text, such as Was $0.02.
|
|
663
|
+
|
|
664
|
+
```tsx
|
|
665
|
+
/**
|
|
666
|
+
* Do example for "Mark Superseded Amounts in Words" on the Amount page.
|
|
667
|
+
* Say it in text, such as Was $0.02.
|
|
668
|
+
* @module
|
|
669
|
+
*/
|
|
670
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
671
|
+
|
|
672
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
673
|
+
export function Demo() {
|
|
674
|
+
return (
|
|
675
|
+
<div {...styles.row()}>
|
|
676
|
+
<span {...styles.label()}>Network fee</span>
|
|
677
|
+
<div {...styles.values()}>
|
|
678
|
+
<span {...styles.label()}>Was</span>
|
|
679
|
+
<Amount currency="USD" strikethrough value="0.02" />
|
|
680
|
+
<Amount currency="USD" value="0.01" />
|
|
681
|
+
</div>
|
|
682
|
+
</div>
|
|
683
|
+
)
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
namespace styles {
|
|
687
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
688
|
+
|
|
689
|
+
export const row = style({
|
|
690
|
+
alignItems: 'baseline',
|
|
691
|
+
display: 'flex',
|
|
692
|
+
gap: '16',
|
|
693
|
+
justifyContent: 'space-between',
|
|
694
|
+
width: '100% !custom',
|
|
695
|
+
})
|
|
696
|
+
|
|
697
|
+
export const values = style({ alignItems: 'baseline', display: 'flex', gap: '8' })
|
|
698
|
+
}
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
**Don't:** Rely on the line. Screen readers don't announce it.
|
|
702
|
+
|
|
703
|
+
```tsx
|
|
704
|
+
/**
|
|
705
|
+
* Don't example for "Mark Superseded Amounts in Words" on the Amount page.
|
|
706
|
+
* Don't rely on the line. Screen readers don't announce it.
|
|
707
|
+
* @module
|
|
708
|
+
*/
|
|
709
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
710
|
+
|
|
711
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
712
|
+
export function Demo() {
|
|
713
|
+
return (
|
|
714
|
+
<div {...styles.row()}>
|
|
715
|
+
<span {...styles.label()}>Network fee</span>
|
|
716
|
+
<div {...styles.values()}>
|
|
717
|
+
<Amount currency="USD" strikethrough value="0.02" />
|
|
718
|
+
<Amount currency="USD" value="0.01" />
|
|
719
|
+
</div>
|
|
720
|
+
</div>
|
|
721
|
+
)
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
namespace styles {
|
|
725
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
726
|
+
|
|
727
|
+
export const row = style({
|
|
728
|
+
alignItems: 'baseline',
|
|
729
|
+
display: 'flex',
|
|
730
|
+
gap: '16',
|
|
731
|
+
justifyContent: 'space-between',
|
|
732
|
+
width: '100% !custom',
|
|
733
|
+
})
|
|
734
|
+
|
|
735
|
+
export const values = style({ alignItems: 'baseline', display: 'flex', gap: '8' })
|
|
736
|
+
}
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
### Size by Importance
|
|
740
|
+
|
|
741
|
+
* **Small (sm):** The default, for lists, tables, and rows.
|
|
742
|
+
* **Medium (md):** Card values and review totals.
|
|
743
|
+
* **Large (lg):** A balance at the top of a page.
|
|
744
|
+
* **Extra Large (xl):** The single balance on a home screen.
|
|
745
|
+
|
|
746
|
+
Amount renders as a block and ignores the alignment of a table cell. Set `align="right"` in an end-aligned column.
|
|
747
|
+
|
|
748
|
+
## Content
|
|
749
|
+
|
|
750
|
+
* Label each amount by its role, such as You send, Network fee, or Available balance.
|
|
751
|
+
* Don't repeat the unit in text, such as USD after $1,250.50.
|
|
752
|
+
* Don't abbreviate amounts people act on, such as 1.2K.
|
|
753
|
+
|
|
754
|
+
## Accessibility
|
|
755
|
+
|
|
756
|
+
Renders a `<span>` with no role. Screen readers read the formatted text as written. How they read symbols, such as `$`, `−`, or the `<` in `<$0.01`, depends on the screen reader and its settings.
|
|
757
|
+
|
|
758
|
+
### Semantics
|
|
759
|
+
|
|
760
|
+
* **Root (span):** Plain text. Screen readers read the number with its sign and unit.
|
|
761
|
+
* **Locale (locale):** Formats in `en-US`. Set `locale` to the page language for other separators.
|
|
762
|
+
* **Strikethrough (strikethrough):** Visual only. Say in text that an amount is superseded.
|
|
763
|
+
|
|
764
|
+
### Your Responsibilities
|
|
765
|
+
|
|
766
|
+
* **Mark Inexact Amounts:** Say in text if an amount is a bound or estimate, such as "Less than $0.01".
|
|
767
|
+
* **Announce Live Updates (aria-live):** Amount does not announce updates. Put awaited ones, such as a quote, in a live region.
|
|
768
|
+
* **Label Direction in Words:** Keep the sign, and label direction in words, such as "Received" and "Sent".
|
|
769
|
+
|
|
770
|
+
## Related
|
|
771
|
+
|
|
772
|
+
[AmountInput](/docs/components/amount-input)
|
|
773
|
+
|
|
774
|
+
Use for entering amounts.
|
|
775
|
+
|
|
776
|
+
[TokenLogo](/docs/components/token-logo)
|
|
777
|
+
|
|
778
|
+
Use for the token icon beside an amount.
|
|
779
|
+
|
|
780
|
+
[Table](/docs/components/table)
|
|
781
|
+
|
|
782
|
+
Use for laying out amounts.
|
|
783
|
+
|
|
784
|
+
[ListGroup](/docs/components/list-group)
|
|
785
|
+
|
|
786
|
+
Use for laying out amounts.
|
|
787
|
+
|
|
788
|
+
[Payments](/docs/patterns/payments)
|
|
789
|
+
|
|
790
|
+
Covers send and review screens.
|
|
791
|
+
|
|
792
|
+
[Blockchain Values](/docs/patterns/blockchain-values)
|
|
793
|
+
|
|
794
|
+
Covers token amounts and fees.
|