@tempoxyz/ds 0.3.14 → 0.3.15
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 +73 -10
- package/dist/docs/{marketing/introduction/getting-started.md → marketing.md} +28 -20
- package/dist/docs/product/components/actions.md +2058 -0
- package/dist/docs/product/components/blockchain.md +3825 -0
- package/dist/docs/product/components/data-display.md +5901 -0
- package/dist/docs/product/components/feedback-and-status.md +4008 -0
- package/dist/docs/product/components/forms-and-inputs.md +10543 -0
- package/dist/docs/product/components/layout.md +3339 -0
- package/dist/docs/product/components/navigation.md +2914 -0
- package/dist/docs/product/components/overlays.md +4917 -0
- package/dist/docs/product/components.md +125 -125
- package/dist/docs/product/foundations.md +4596 -0
- package/dist/docs/product/patterns.md +10129 -0
- package/package.json +1 -1
- package/dist/docs/index.md +0 -145
- package/dist/docs/product/components/accordion.md +0 -489
- package/dist/docs/product/components/address-card.md +0 -147
- package/dist/docs/product/components/agent-logo.md +0 -194
- package/dist/docs/product/components/alert-dialog.md +0 -631
- package/dist/docs/product/components/alert.md +0 -448
- package/dist/docs/product/components/amount-input.md +0 -305
- package/dist/docs/product/components/amount.md +0 -794
- package/dist/docs/product/components/app-shell.md +0 -559
- package/dist/docs/product/components/asset-chip.md +0 -294
- package/dist/docs/product/components/autocomplete.md +0 -620
- package/dist/docs/product/components/avatar.md +0 -321
- package/dist/docs/product/components/badge.md +0 -339
- package/dist/docs/product/components/badged-logo.md +0 -116
- package/dist/docs/product/components/banner.md +0 -379
- package/dist/docs/product/components/bar-chart.md +0 -208
- package/dist/docs/product/components/breadcrumbs.md +0 -380
- package/dist/docs/product/components/button-group.md +0 -286
- package/dist/docs/product/components/button.md +0 -650
- package/dist/docs/product/components/calendar.md +0 -375
- package/dist/docs/product/components/callout.md +0 -96
- package/dist/docs/product/components/checkbox-group.md +0 -521
- package/dist/docs/product/components/checkbox.md +0 -467
- package/dist/docs/product/components/choice-group.md +0 -516
- package/dist/docs/product/components/choicebox.md +0 -641
- package/dist/docs/product/components/code.md +0 -100
- package/dist/docs/product/components/combobox.md +0 -939
- package/dist/docs/product/components/container.md +0 -257
- package/dist/docs/product/components/copy-button.md +0 -642
- package/dist/docs/product/components/date-picker.md +0 -514
- package/dist/docs/product/components/dialog.md +0 -1332
- package/dist/docs/product/components/drawer.md +0 -966
- package/dist/docs/product/components/empty.md +0 -340
- package/dist/docs/product/components/field.md +0 -570
- package/dist/docs/product/components/fieldset.md +0 -398
- package/dist/docs/product/components/frame.md +0 -434
- package/dist/docs/product/components/gauge.md +0 -299
- package/dist/docs/product/components/get-started-visual.md +0 -117
- package/dist/docs/product/components/grid.md +0 -288
- package/dist/docs/product/components/hero-visual.md +0 -155
- package/dist/docs/product/components/hex.md +0 -487
- package/dist/docs/product/components/icon-tile.md +0 -292
- package/dist/docs/product/components/identicon.md +0 -371
- package/dist/docs/product/components/inline.md +0 -233
- package/dist/docs/product/components/inset.md +0 -225
- package/dist/docs/product/components/kbd.md +0 -423
- package/dist/docs/product/components/list-group.md +0 -981
- package/dist/docs/product/components/loading-dots.md +0 -237
- package/dist/docs/product/components/menu.md +0 -934
- package/dist/docs/product/components/native-select.md +0 -204
- package/dist/docs/product/components/network-logo.md +0 -248
- package/dist/docs/product/components/number-field.md +0 -543
- package/dist/docs/product/components/otp-field.md +0 -616
- package/dist/docs/product/components/pagination.md +0 -516
- package/dist/docs/product/components/popover.md +0 -544
- package/dist/docs/product/components/progress.md +0 -388
- package/dist/docs/product/components/qr.md +0 -314
- package/dist/docs/product/components/radio-group.md +0 -528
- package/dist/docs/product/components/secret-value.md +0 -406
- package/dist/docs/product/components/select.md +0 -751
- package/dist/docs/product/components/separator.md +0 -379
- package/dist/docs/product/components/sidebar-menu.md +0 -922
- package/dist/docs/product/components/skeleton.md +0 -517
- package/dist/docs/product/components/slider.md +0 -539
- package/dist/docs/product/components/snippet.md +0 -424
- package/dist/docs/product/components/spinner.md +0 -216
- package/dist/docs/product/components/split-bar.md +0 -139
- package/dist/docs/product/components/split-button.md +0 -464
- package/dist/docs/product/components/stack.md +0 -299
- package/dist/docs/product/components/status-chip.md +0 -226
- package/dist/docs/product/components/status-indicator.md +0 -119
- package/dist/docs/product/components/status-row.md +0 -174
- package/dist/docs/product/components/stepper.md +0 -451
- package/dist/docs/product/components/success-hero.md +0 -157
- package/dist/docs/product/components/surface.md +0 -639
- package/dist/docs/product/components/switch.md +0 -472
- package/dist/docs/product/components/table.md +0 -968
- package/dist/docs/product/components/tabs.md +0 -627
- package/dist/docs/product/components/tempo-logo.md +0 -185
- package/dist/docs/product/components/text-input.md +0 -624
- package/dist/docs/product/components/textarea.md +0 -352
- package/dist/docs/product/components/toast.md +0 -535
- package/dist/docs/product/components/token-logo.md +0 -371
- package/dist/docs/product/components/token.md +0 -247
- package/dist/docs/product/components/tooltip.md +0 -490
- package/dist/docs/product/components/verification-code.md +0 -116
- package/dist/docs/product/components/visual.md +0 -249
- package/dist/docs/product/foundations/accessibility.md +0 -377
- package/dist/docs/product/foundations/agents.md +0 -159
- package/dist/docs/product/foundations/color.md +0 -522
- package/dist/docs/product/foundations/content/tone.md +0 -194
- package/dist/docs/product/foundations/content/voice.md +0 -194
- package/dist/docs/product/foundations/content/writing-style.md +0 -406
- package/dist/docs/product/foundations/iconography.md +0 -282
- package/dist/docs/product/foundations/intent.md +0 -360
- package/dist/docs/product/foundations/layout.md +0 -508
- package/dist/docs/product/foundations/linter.md +0 -523
- package/dist/docs/product/foundations/motion.md +0 -151
- package/dist/docs/product/foundations/radius-and-padding.md +0 -86
- package/dist/docs/product/foundations/typography.md +0 -331
- package/dist/docs/product/introduction/faq.md +0 -133
- package/dist/docs/product/introduction/getting-started.md +0 -377
- package/dist/docs/product/patterns/blockchain-values.md +0 -709
- package/dist/docs/product/patterns/dashboards.md +0 -638
- package/dist/docs/product/patterns/destructive-actions.md +0 -626
- package/dist/docs/product/patterns/empty-states.md +0 -612
- package/dist/docs/product/patterns/errors-and-validation.md +0 -808
- package/dist/docs/product/patterns/feedback-and-status.md +0 -518
- package/dist/docs/product/patterns/forms.md +0 -679
- package/dist/docs/product/patterns/loading.md +0 -630
- package/dist/docs/product/patterns/navigation.md +0 -397
- package/dist/docs/product/patterns/payments.md +0 -765
- package/dist/docs/product/patterns/responsive-layout.md +0 -997
- package/dist/docs/product/patterns/tables-and-lists.md +0 -1170
- package/dist/docs/product/products/tempo-console.md +0 -671
- package/dist/docs/product/products/tempo-performance.md +0 -435
- package/dist/docs/product/products/tempo-wallet.md +0 -438
|
@@ -0,0 +1,3825 @@
|
|
|
1
|
+
# Blockchain
|
|
2
|
+
|
|
3
|
+
Each component section states its guidance first, then its Examples and Use Cases. Read a section up to its Examples heading before you use the component, then read the examples it needs.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
Components for onchain values such as addresses, amounts, and tokens.
|
|
8
|
+
|
|
9
|
+
- [AddressCard](#addresscard): Shows a wallet address to receive funds, with its QR code and networks.
|
|
10
|
+
- [Amount](#amount): Formats a number as money or a token amount.
|
|
11
|
+
- [AssetChip](#assetchip): Labels a supported asset or network in a small chip, which can also pick one.
|
|
12
|
+
- [BadgedLogo](#badgedlogo): Marks a token or an app with a small badge on the corner of its logo.
|
|
13
|
+
- [Hex](#hex): Shows a hex string, such as an address, truncated to fit.
|
|
14
|
+
- [Identicon](#identicon): Shows a unique gradient avatar derived from an address.
|
|
15
|
+
- [NetworkLogo](#networklogo): Shows the logo of the network a token lives on.
|
|
16
|
+
- [Qr](#qr): Renders a value as a QR code.
|
|
17
|
+
- [SecretValue](#secretvalue): Masks a secret and adds reveal and copy buttons.
|
|
18
|
+
- [Token](#token-1): Shows which token an amount is in, and opens a picker to change it.
|
|
19
|
+
- [TokenLogo](#tokenlogo): Shows a token logo by contract address or symbol.
|
|
20
|
+
|
|
21
|
+
## AddressCard
|
|
22
|
+
|
|
23
|
+
Shows a wallet address to receive funds, with its QR code and networks.
|
|
24
|
+
|
|
25
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/AddressCard.tsx)
|
|
26
|
+
|
|
27
|
+
Figma: [Content/Address Card](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-4005)
|
|
28
|
+
|
|
29
|
+
### Overview
|
|
30
|
+
|
|
31
|
+
An address card renders a bordered receive card. A QR code of the address sits beside the shortened address, a copy button, and the networks that the address accepts.
|
|
32
|
+
|
|
33
|
+
### Anatomy
|
|
34
|
+
|
|
35
|
+
Import the component and assemble its parts.
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { AddressCard } from '@tempoxyz/ds'
|
|
39
|
+
|
|
40
|
+
<AddressCard>
|
|
41
|
+
<AddressCard.Networks>
|
|
42
|
+
<AddressCard.Network />
|
|
43
|
+
</AddressCard.Networks>
|
|
44
|
+
</AddressCard>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Guidelines
|
|
48
|
+
|
|
49
|
+
#### When to Use
|
|
50
|
+
|
|
51
|
+
* Show the address that a person sends funds to, such as on a deposit screen.
|
|
52
|
+
* Let a person scan the address from another device or copy it.
|
|
53
|
+
|
|
54
|
+
#### When Not to Use
|
|
55
|
+
|
|
56
|
+
* Use [Hex](#hex) for an address inside a row or a sentence.
|
|
57
|
+
* Use [Qr](#qr) alone for a code that encodes something other than an address.
|
|
58
|
+
|
|
59
|
+
#### List Only the Accepted Networks
|
|
60
|
+
|
|
61
|
+
**Do:** List the networks that the address accepts.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<AddressCard address="0x7a3f2c9b1e4d8a6f0c5b3e7d9a1f4c8e2b6d91c2">
|
|
65
|
+
<AddressCard.Networks>
|
|
66
|
+
<AddressCard.Network network="tempo" selected>
|
|
67
|
+
Tempo
|
|
68
|
+
</AddressCard.Network>
|
|
69
|
+
<AddressCard.Network network="base">Base</AddressCard.Network>
|
|
70
|
+
</AddressCard.Networks>
|
|
71
|
+
</AddressCard>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Don't:** Leave out the networks when the address accepts only some of them.
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
<AddressCard address="0x7a3f2c9b1e4d8a6f0c5b3e7d9a1f4c8e2b6d91c2" />
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Keep the Full Address
|
|
81
|
+
|
|
82
|
+
Pass the whole address. The card shortens the text, and the copy button and QR code use the full value.
|
|
83
|
+
|
|
84
|
+
### Content
|
|
85
|
+
|
|
86
|
+
* **Label:** Name the address from the reader's view, such as Your wallet address.
|
|
87
|
+
* **Networks:** Name each network as its brand does, such as Ethereum or Base.
|
|
88
|
+
|
|
89
|
+
### Accessibility
|
|
90
|
+
|
|
91
|
+
The card renders a `<div>` with no role. Screen readers read the full address, the named QR code, the copy button, and the network group.
|
|
92
|
+
|
|
93
|
+
* **Address (Full value):** Screen readers read every character, not the shortened text.
|
|
94
|
+
* **Copy (button):** The copy button announces Copied after a copy.
|
|
95
|
+
* **Networks (group):** The label names the group of network chips.
|
|
96
|
+
* **Pick a Network (aria-pressed):** A chip with an onClick announces its selected state.
|
|
97
|
+
|
|
98
|
+
### Related
|
|
99
|
+
|
|
100
|
+
[Hex](#hex)
|
|
101
|
+
|
|
102
|
+
Use for an address inside a row or a sentence.
|
|
103
|
+
|
|
104
|
+
[Qr](#qr)
|
|
105
|
+
|
|
106
|
+
Use for a QR code of another value.
|
|
107
|
+
|
|
108
|
+
[AssetChip](#assetchip)
|
|
109
|
+
|
|
110
|
+
Use for the chips of supported assets.
|
|
111
|
+
|
|
112
|
+
### Examples
|
|
113
|
+
|
|
114
|
+
#### Basic
|
|
115
|
+
|
|
116
|
+
Pass the full `address`. The card shows its first and last four characters.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
/** Demonstrates AddressCard in the documentation. @module */
|
|
120
|
+
import { AddressCard, style } from '@tempoxyz/ds'
|
|
121
|
+
|
|
122
|
+
export function Demo() {
|
|
123
|
+
return (
|
|
124
|
+
<div {...styles.frame()}>
|
|
125
|
+
<AddressCard address="0x7a3f2c9b1e4d8a6f0c5b3e7d9a1f4c8e2b6d91c2" />
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
namespace styles {
|
|
131
|
+
export const frame = style({ maxWidth: '28.75rem !custom', width: '100% !custom' })
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/AddressCard/Basic.tsx)
|
|
136
|
+
|
|
137
|
+
#### Networks
|
|
138
|
+
|
|
139
|
+
Add `AddressCard.Networks` with one `AddressCard.Network` per network. Set `selected` on the picked one.
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
/** Demonstrates AddressCard in the documentation. @module */
|
|
143
|
+
import { AddressCard, style } from '@tempoxyz/ds'
|
|
144
|
+
|
|
145
|
+
export function Demo() {
|
|
146
|
+
return (
|
|
147
|
+
<div {...styles.frame()}>
|
|
148
|
+
<AddressCard address="0x7a3f2c9b1e4d8a6f0c5b3e7d9a1f4c8e2b6d91c2">
|
|
149
|
+
<AddressCard.Networks>
|
|
150
|
+
<AddressCard.Network network="ethereum" selected>
|
|
151
|
+
Ethereum
|
|
152
|
+
</AddressCard.Network>
|
|
153
|
+
<AddressCard.Network network="base">Base</AddressCard.Network>
|
|
154
|
+
<AddressCard.Network network="solana">Solana</AddressCard.Network>
|
|
155
|
+
<AddressCard.Network network="tempo">Tempo</AddressCard.Network>
|
|
156
|
+
</AddressCard.Networks>
|
|
157
|
+
</AddressCard>
|
|
158
|
+
</div>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
namespace styles {
|
|
163
|
+
export const frame = style({ maxWidth: '28.75rem !custom', width: '100% !custom' })
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/AddressCard/Networks.tsx)
|
|
168
|
+
|
|
169
|
+
## Amount
|
|
170
|
+
|
|
171
|
+
Formats a number as money or a token amount.
|
|
172
|
+
|
|
173
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Amount.tsx)
|
|
174
|
+
|
|
175
|
+
### Overview
|
|
176
|
+
|
|
177
|
+
Formats a number in `en-US` with tabular figures, as money or followed by a token symbol.
|
|
178
|
+
|
|
179
|
+
### Anatomy
|
|
180
|
+
|
|
181
|
+
Import the component and assemble its parts.
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import { Amount } from '@tempoxyz/ds'
|
|
185
|
+
|
|
186
|
+
<Amount />
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Guidelines
|
|
190
|
+
|
|
191
|
+
#### When to Use
|
|
192
|
+
|
|
193
|
+
* Show balances, payment amounts, fees, and converted values, such as 1,250.50 USDC or $1,250.50.
|
|
194
|
+
* Show amounts in tables, rows, and review screens with consistent formatting.
|
|
195
|
+
|
|
196
|
+
#### When Not to Use
|
|
197
|
+
|
|
198
|
+
* Use [AmountInput](forms-and-inputs.md#amountinput) when people enter an amount.
|
|
199
|
+
* Use `Table.Cell` with `numeric` in a [Table](data-display.md#table) for counts and metrics without a unit, such as TPS or block height.
|
|
200
|
+
|
|
201
|
+
#### Always Show the Unit
|
|
202
|
+
|
|
203
|
+
**Do:** Pass `symbol` for a token amount and `currency` for money.
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
/**
|
|
207
|
+
* Do example for "Always Show the Unit" on the Amount page.
|
|
208
|
+
* Pass `symbol` for a token amount and `currency` for money.
|
|
209
|
+
* @module
|
|
210
|
+
*/
|
|
211
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
212
|
+
|
|
213
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
214
|
+
export function Demo() {
|
|
215
|
+
return (
|
|
216
|
+
<div {...styles.stack()}>
|
|
217
|
+
<Amount size="md" symbol="USDC" value="1250.50" />
|
|
218
|
+
<Amount currency="USD" value="1250.50" />
|
|
219
|
+
</div>
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
namespace styles {
|
|
224
|
+
export const stack = style({ display: 'grid', gap: '4' })
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Don't:** Show an amount without its token or currency.
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
/**
|
|
232
|
+
* Don't example for "Always Show the Unit" on the Amount page.
|
|
233
|
+
* Don't show an amount without its token or currency.
|
|
234
|
+
* @module
|
|
235
|
+
*/
|
|
236
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
237
|
+
|
|
238
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
239
|
+
export function Demo() {
|
|
240
|
+
return (
|
|
241
|
+
<div {...styles.stack()}>
|
|
242
|
+
<Amount size="md" value="1250.50" />
|
|
243
|
+
<Amount value="1250.50" />
|
|
244
|
+
</div>
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
namespace styles {
|
|
249
|
+
export const stack = style({ display: 'grid', gap: '4' })
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
#### Choose Currency or Symbol
|
|
254
|
+
|
|
255
|
+
* **Currency:** Money and converted values, such as a portfolio total.
|
|
256
|
+
* **Symbol:** Token amounts, such as what an account holds or sends.
|
|
257
|
+
|
|
258
|
+
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.
|
|
259
|
+
|
|
260
|
+
#### Pass Exact Decimal Strings
|
|
261
|
+
|
|
262
|
+
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.
|
|
263
|
+
|
|
264
|
+
**Do:** Pass decimal strings, such as `"0.30"`.
|
|
265
|
+
|
|
266
|
+
```tsx
|
|
267
|
+
/**
|
|
268
|
+
* Do example for "Pass Exact Decimal Strings" on the Amount page.
|
|
269
|
+
* Pass decimal strings, such as `"0.30"`.
|
|
270
|
+
* @module
|
|
271
|
+
*/
|
|
272
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
273
|
+
|
|
274
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
275
|
+
export function Demo() {
|
|
276
|
+
return (
|
|
277
|
+
<div {...styles.list()}>
|
|
278
|
+
<div {...styles.row()}>
|
|
279
|
+
<span {...styles.label()}>Available balance</span>
|
|
280
|
+
<Amount align="right" symbol="USDC" value="1250.10" />
|
|
281
|
+
</div>
|
|
282
|
+
<div {...styles.row()}>
|
|
283
|
+
<span {...styles.label()}>Total fees</span>
|
|
284
|
+
<Amount align="right" symbol="USDC" value="0.30" />
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
namespace styles {
|
|
291
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
292
|
+
|
|
293
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
294
|
+
|
|
295
|
+
export const row = style({
|
|
296
|
+
alignItems: 'baseline',
|
|
297
|
+
display: 'flex',
|
|
298
|
+
gap: '16',
|
|
299
|
+
justifyContent: 'space-between',
|
|
300
|
+
})
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Don't:** Pass numbers. They drop trailing zeros and show floating-point errors.
|
|
305
|
+
|
|
306
|
+
```tsx
|
|
307
|
+
/**
|
|
308
|
+
* Don't example for "Pass Exact Decimal Strings" on the Amount page.
|
|
309
|
+
* Don't pass numbers. They drop trailing zeros and show floating-point errors.
|
|
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.1} />
|
|
321
|
+
</div>
|
|
322
|
+
<div {...styles.row()}>
|
|
323
|
+
<span {...styles.label()}>Total fees</span>
|
|
324
|
+
<Amount align="right" symbol="USDC" value={0.1 + 0.2} />
|
|
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
|
+
#### Set Decimals by Purpose
|
|
345
|
+
|
|
346
|
+
* **With `currency`:** Shows the currency's own digits, two for USD. `maxDecimals={0}` renders `$5`.
|
|
347
|
+
* **Without `currency`:** Shows every digit of the string. Set `maxDecimals` in lists, and show the exact value in details and review screens.
|
|
348
|
+
* **Rounding:** `0.999` with `maxDecimals={2}` renders `1.00`. Show the exact balance wherever people choose how much to send.
|
|
349
|
+
|
|
350
|
+
**Do:** Use one decimal count down a column so decimal points line up.
|
|
351
|
+
|
|
352
|
+
```tsx
|
|
353
|
+
/**
|
|
354
|
+
* Do example for "Set Decimals by Purpose" on the Amount page.
|
|
355
|
+
* Use one decimal count down a column so decimal points line up.
|
|
356
|
+
* @module
|
|
357
|
+
*/
|
|
358
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
359
|
+
|
|
360
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
361
|
+
export function Demo() {
|
|
362
|
+
return (
|
|
363
|
+
<div {...styles.list()}>
|
|
364
|
+
<div {...styles.row()}>
|
|
365
|
+
<span {...styles.label()}>Main wallet</span>
|
|
366
|
+
<Amount align="right" symbol="USDC" value="1250.50" />
|
|
367
|
+
</div>
|
|
368
|
+
<div {...styles.row()}>
|
|
369
|
+
<span {...styles.label()}>Savings</span>
|
|
370
|
+
<Amount align="right" symbol="USDC" value="84.10" />
|
|
371
|
+
</div>
|
|
372
|
+
<div {...styles.row()}>
|
|
373
|
+
<span {...styles.label()}>Payroll</span>
|
|
374
|
+
<Amount align="right" symbol="USDC" value="312.00" />
|
|
375
|
+
</div>
|
|
376
|
+
</div>
|
|
377
|
+
)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
namespace styles {
|
|
381
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
382
|
+
|
|
383
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
384
|
+
|
|
385
|
+
export const row = style({
|
|
386
|
+
alignItems: 'baseline',
|
|
387
|
+
display: 'flex',
|
|
388
|
+
gap: '16',
|
|
389
|
+
justifyContent: 'space-between',
|
|
390
|
+
})
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
**Don't:** Mix decimal counts in one column.
|
|
395
|
+
|
|
396
|
+
```tsx
|
|
397
|
+
/**
|
|
398
|
+
* Don't example for "Set Decimals by Purpose" on the Amount page.
|
|
399
|
+
* Don't mix decimal counts in one column.
|
|
400
|
+
* @module
|
|
401
|
+
*/
|
|
402
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
403
|
+
|
|
404
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
405
|
+
export function Demo() {
|
|
406
|
+
return (
|
|
407
|
+
<div {...styles.list()}>
|
|
408
|
+
<div {...styles.row()}>
|
|
409
|
+
<span {...styles.label()}>Main wallet</span>
|
|
410
|
+
<Amount align="right" symbol="USDC" value="1250.504812" />
|
|
411
|
+
</div>
|
|
412
|
+
<div {...styles.row()}>
|
|
413
|
+
<span {...styles.label()}>Savings</span>
|
|
414
|
+
<Amount align="right" symbol="USDC" value="84.1" />
|
|
415
|
+
</div>
|
|
416
|
+
<div {...styles.row()}>
|
|
417
|
+
<span {...styles.label()}>Payroll</span>
|
|
418
|
+
<Amount align="right" symbol="USDC" value="312.0005" />
|
|
419
|
+
</div>
|
|
420
|
+
</div>
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
namespace styles {
|
|
425
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
426
|
+
|
|
427
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
428
|
+
|
|
429
|
+
export const row = style({
|
|
430
|
+
alignItems: 'baseline',
|
|
431
|
+
display: 'flex',
|
|
432
|
+
gap: '16',
|
|
433
|
+
justifyContent: 'space-between',
|
|
434
|
+
})
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
#### Show Values Below a Cent Precisely
|
|
439
|
+
|
|
440
|
+
A currency value below its smallest unit renders as a bound, such as `<$0.01`.
|
|
441
|
+
|
|
442
|
+
**Do:** Set `precise` on network fees to show two significant digits.
|
|
443
|
+
|
|
444
|
+
```tsx
|
|
445
|
+
/**
|
|
446
|
+
* Do example for "Show Values Below a Cent Precisely" on the Amount page.
|
|
447
|
+
* Set `precise` on network fees to show two significant digits.
|
|
448
|
+
* @module
|
|
449
|
+
*/
|
|
450
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
451
|
+
|
|
452
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
453
|
+
export function Demo() {
|
|
454
|
+
return (
|
|
455
|
+
<div {...styles.list()}>
|
|
456
|
+
<div {...styles.row()}>
|
|
457
|
+
<span {...styles.label()}>You send</span>
|
|
458
|
+
<Amount align="right" symbol="USDC" value="250.00" />
|
|
459
|
+
</div>
|
|
460
|
+
<div {...styles.row()}>
|
|
461
|
+
<span {...styles.label()}>Network fee</span>
|
|
462
|
+
<Amount align="right" currency="USD" precise value="0.0004" />
|
|
463
|
+
</div>
|
|
464
|
+
</div>
|
|
465
|
+
)
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
namespace styles {
|
|
469
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
470
|
+
|
|
471
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
472
|
+
|
|
473
|
+
export const row = style({
|
|
474
|
+
alignItems: 'baseline',
|
|
475
|
+
display: 'flex',
|
|
476
|
+
gap: '16',
|
|
477
|
+
justifyContent: 'space-between',
|
|
478
|
+
})
|
|
479
|
+
}
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
**Don't:** Show a fee people pay as a bound.
|
|
483
|
+
|
|
484
|
+
```tsx
|
|
485
|
+
/**
|
|
486
|
+
* Don't example for "Show Values Below a Cent Precisely" on the Amount page.
|
|
487
|
+
* Don't show a fee people pay as a bound.
|
|
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" 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
|
+
#### Show Direction With a Sign
|
|
523
|
+
|
|
524
|
+
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 `-`.
|
|
525
|
+
|
|
526
|
+
**Do:** Mark incoming and outgoing amounts with `+` and `−`.
|
|
527
|
+
|
|
528
|
+
```tsx
|
|
529
|
+
/**
|
|
530
|
+
* Do example for "Show Direction With a Sign" on the Amount page.
|
|
531
|
+
* Mark incoming and outgoing amounts with `+` and `−`.
|
|
532
|
+
* @module
|
|
533
|
+
*/
|
|
534
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
535
|
+
|
|
536
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
537
|
+
export function Demo() {
|
|
538
|
+
return (
|
|
539
|
+
<div {...styles.list()}>
|
|
540
|
+
<div {...styles.row()}>
|
|
541
|
+
<span {...styles.label()}>Received from Jane</span>
|
|
542
|
+
<Amount align="right" sign="+" symbol="USDC" value="120.00" />
|
|
543
|
+
</div>
|
|
544
|
+
<div {...styles.row()}>
|
|
545
|
+
<span {...styles.label()}>Sent to 0x91bd…07e1</span>
|
|
546
|
+
<Amount align="right" sign="−" symbol="USDC" value="48.50" />
|
|
547
|
+
</div>
|
|
548
|
+
</div>
|
|
549
|
+
)
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
namespace styles {
|
|
553
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
554
|
+
|
|
555
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
556
|
+
|
|
557
|
+
export const row = style({
|
|
558
|
+
alignItems: 'baseline',
|
|
559
|
+
display: 'flex',
|
|
560
|
+
gap: '16',
|
|
561
|
+
justifyContent: 'space-between',
|
|
562
|
+
})
|
|
563
|
+
}
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
**Don't:** Show direction with green and red alone.
|
|
567
|
+
|
|
568
|
+
```tsx
|
|
569
|
+
/**
|
|
570
|
+
* Don't example for "Show Direction With a Sign" on the Amount page.
|
|
571
|
+
* Don't show direction with green and red alone.
|
|
572
|
+
* @module
|
|
573
|
+
*/
|
|
574
|
+
import { 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
|
+
<span {...styles.credit()}>120.00 USDC</span>
|
|
583
|
+
</div>
|
|
584
|
+
<div {...styles.row()}>
|
|
585
|
+
<span {...styles.label()}>Sent to 0x91bd…07e1</span>
|
|
586
|
+
<span {...styles.debit()}>48.50 USDC</span>
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
)
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
namespace styles {
|
|
593
|
+
export const credit = style({
|
|
594
|
+
color: 'content.positive',
|
|
595
|
+
fontVariantNumeric: 'tabular-nums !custom',
|
|
596
|
+
typography: 'body.b2Strong',
|
|
597
|
+
})
|
|
598
|
+
|
|
599
|
+
export const debit = style({
|
|
600
|
+
color: 'content.negative',
|
|
601
|
+
fontVariantNumeric: 'tabular-nums !custom',
|
|
602
|
+
typography: 'body.b2Strong',
|
|
603
|
+
})
|
|
604
|
+
|
|
605
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
606
|
+
|
|
607
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
608
|
+
|
|
609
|
+
export const row = style({
|
|
610
|
+
alignItems: 'baseline',
|
|
611
|
+
display: 'flex',
|
|
612
|
+
gap: '16',
|
|
613
|
+
justifyContent: 'space-between',
|
|
614
|
+
})
|
|
615
|
+
}
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
#### Mark Superseded Amounts in Words
|
|
619
|
+
|
|
620
|
+
Use `strikethrough` for an amount that no longer applies, such as an expired fee quote, and show the new amount beside it.
|
|
621
|
+
|
|
622
|
+
**Do:** Say it in text, such as Was $0.02.
|
|
623
|
+
|
|
624
|
+
```tsx
|
|
625
|
+
/**
|
|
626
|
+
* Do example for "Mark Superseded Amounts in Words" on the Amount page.
|
|
627
|
+
* Say it in text, such as Was $0.02.
|
|
628
|
+
* @module
|
|
629
|
+
*/
|
|
630
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
631
|
+
|
|
632
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
633
|
+
export function Demo() {
|
|
634
|
+
return (
|
|
635
|
+
<div {...styles.row()}>
|
|
636
|
+
<span {...styles.label()}>Network fee</span>
|
|
637
|
+
<div {...styles.values()}>
|
|
638
|
+
<span {...styles.label()}>Was</span>
|
|
639
|
+
<Amount currency="USD" strikethrough value="0.02" />
|
|
640
|
+
<Amount currency="USD" value="0.01" />
|
|
641
|
+
</div>
|
|
642
|
+
</div>
|
|
643
|
+
)
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
namespace styles {
|
|
647
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
648
|
+
|
|
649
|
+
export const row = style({
|
|
650
|
+
alignItems: 'baseline',
|
|
651
|
+
display: 'flex',
|
|
652
|
+
gap: '16',
|
|
653
|
+
justifyContent: 'space-between',
|
|
654
|
+
width: '100% !custom',
|
|
655
|
+
})
|
|
656
|
+
|
|
657
|
+
export const values = style({ alignItems: 'baseline', display: 'flex', gap: '8' })
|
|
658
|
+
}
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
**Don't:** Rely on the line. Screen readers don't announce it.
|
|
662
|
+
|
|
663
|
+
```tsx
|
|
664
|
+
/**
|
|
665
|
+
* Don't example for "Mark Superseded Amounts in Words" on the Amount page.
|
|
666
|
+
* Don't rely on the line. Screen readers don't announce it.
|
|
667
|
+
* @module
|
|
668
|
+
*/
|
|
669
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
670
|
+
|
|
671
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
672
|
+
export function Demo() {
|
|
673
|
+
return (
|
|
674
|
+
<div {...styles.row()}>
|
|
675
|
+
<span {...styles.label()}>Network fee</span>
|
|
676
|
+
<div {...styles.values()}>
|
|
677
|
+
<Amount currency="USD" strikethrough value="0.02" />
|
|
678
|
+
<Amount currency="USD" value="0.01" />
|
|
679
|
+
</div>
|
|
680
|
+
</div>
|
|
681
|
+
)
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
namespace styles {
|
|
685
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
686
|
+
|
|
687
|
+
export const row = style({
|
|
688
|
+
alignItems: 'baseline',
|
|
689
|
+
display: 'flex',
|
|
690
|
+
gap: '16',
|
|
691
|
+
justifyContent: 'space-between',
|
|
692
|
+
width: '100% !custom',
|
|
693
|
+
})
|
|
694
|
+
|
|
695
|
+
export const values = style({ alignItems: 'baseline', display: 'flex', gap: '8' })
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
#### Size by Importance
|
|
700
|
+
|
|
701
|
+
* **Small (sm):** The default, for lists, tables, and rows.
|
|
702
|
+
* **Medium (md):** Card values and review totals.
|
|
703
|
+
* **Large (lg):** A balance at the top of a page.
|
|
704
|
+
* **Extra Large (xl):** The single balance on a home screen.
|
|
705
|
+
|
|
706
|
+
Amount renders as a block and ignores the alignment of a table cell. Set `align="right"` in an end-aligned column.
|
|
707
|
+
|
|
708
|
+
### Content
|
|
709
|
+
|
|
710
|
+
* Label each amount by its role, such as You send, Network fee, or Available balance.
|
|
711
|
+
* Don't repeat the unit in text, such as USD after $1,250.50.
|
|
712
|
+
* Don't abbreviate amounts people act on, such as 1.2K.
|
|
713
|
+
|
|
714
|
+
### Accessibility
|
|
715
|
+
|
|
716
|
+
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.
|
|
717
|
+
|
|
718
|
+
#### Semantics
|
|
719
|
+
|
|
720
|
+
* **Root (span):** Plain text. Screen readers read the number with its sign and unit.
|
|
721
|
+
* **Locale (locale):** Formats in `en-US`. Set `locale` to the page language for other separators.
|
|
722
|
+
* **Strikethrough (strikethrough):** Visual only. Say in text that an amount is superseded.
|
|
723
|
+
|
|
724
|
+
#### Your Responsibilities
|
|
725
|
+
|
|
726
|
+
* **Mark Inexact Amounts:** Say in text if an amount is a bound or estimate, such as "Less than $0.01".
|
|
727
|
+
* **Announce Live Updates (aria-live):** Amount does not announce updates. Put awaited ones, such as a quote, in a live region.
|
|
728
|
+
* **Label Direction in Words:** Keep the sign, and label direction in words, such as "Received" and "Sent".
|
|
729
|
+
|
|
730
|
+
### Related
|
|
731
|
+
|
|
732
|
+
[AmountInput](forms-and-inputs.md#amountinput)
|
|
733
|
+
|
|
734
|
+
Use for entering amounts.
|
|
735
|
+
|
|
736
|
+
[TokenLogo](#tokenlogo)
|
|
737
|
+
|
|
738
|
+
Use for the token icon beside an amount.
|
|
739
|
+
|
|
740
|
+
[Table](data-display.md#table)
|
|
741
|
+
|
|
742
|
+
Use for laying out amounts.
|
|
743
|
+
|
|
744
|
+
[ListGroup](data-display.md#listgroup)
|
|
745
|
+
|
|
746
|
+
Use for laying out amounts.
|
|
747
|
+
|
|
748
|
+
[Payments](../patterns.md#payments)
|
|
749
|
+
|
|
750
|
+
Covers send and review screens.
|
|
751
|
+
|
|
752
|
+
[Blockchain Values](../patterns.md#blockchain-values)
|
|
753
|
+
|
|
754
|
+
Covers token amounts and fees.
|
|
755
|
+
|
|
756
|
+
### Examples
|
|
757
|
+
|
|
758
|
+
#### Basic
|
|
759
|
+
|
|
760
|
+
```tsx
|
|
761
|
+
import { Amount } from '@tempoxyz/ds'
|
|
762
|
+
|
|
763
|
+
export function Demo() {
|
|
764
|
+
return <Amount symbol="PathUSD" value="1250.50" />
|
|
765
|
+
}
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Basic.tsx)
|
|
769
|
+
|
|
770
|
+
#### Size
|
|
771
|
+
|
|
772
|
+
Set `size` to `sm` (default), `md`, `lg`, or `xl`.
|
|
773
|
+
|
|
774
|
+
```tsx
|
|
775
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
776
|
+
|
|
777
|
+
export const fill = true
|
|
778
|
+
export function Demo() {
|
|
779
|
+
return (
|
|
780
|
+
<div {...styles.stack()}>
|
|
781
|
+
{(['sm', 'md', 'lg', 'xl'] as const).map((size) => (
|
|
782
|
+
<Amount key={size} size={size} symbol="PathUSD" value={1250.5} />
|
|
783
|
+
))}
|
|
784
|
+
</div>
|
|
785
|
+
)
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
namespace styles {
|
|
789
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
790
|
+
}
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Size.tsx)
|
|
794
|
+
|
|
795
|
+
#### Currency
|
|
796
|
+
|
|
797
|
+
Set `currency` to an ISO 4217 code for money, or `symbol` to follow the number with a token symbol. Pass one, not both.
|
|
798
|
+
|
|
799
|
+
```tsx
|
|
800
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
801
|
+
|
|
802
|
+
export const fill = true
|
|
803
|
+
export function Demo() {
|
|
804
|
+
return (
|
|
805
|
+
<div {...styles.stack()}>
|
|
806
|
+
<Amount currency="USD" size="lg" value={1234.5} />
|
|
807
|
+
<Amount currency="EUR" value={1234.5} />
|
|
808
|
+
<Amount size="lg" symbol="PathUSD" value={1234.5} />
|
|
809
|
+
</div>
|
|
810
|
+
)
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
namespace styles {
|
|
814
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
815
|
+
}
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Currency.tsx)
|
|
819
|
+
|
|
820
|
+
#### Align
|
|
821
|
+
|
|
822
|
+
Set `align` to `left` (default), `center`, or `right`.
|
|
823
|
+
|
|
824
|
+
```tsx
|
|
825
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
826
|
+
|
|
827
|
+
export const fill = true
|
|
828
|
+
export function Demo() {
|
|
829
|
+
return (
|
|
830
|
+
<div {...styles.stack()}>
|
|
831
|
+
{(['left', 'center', 'right'] as const).map((align) => (
|
|
832
|
+
<Amount align={align} currency="USD" key={align} size="md" value={1234.5} />
|
|
833
|
+
))}
|
|
834
|
+
</div>
|
|
835
|
+
)
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
namespace styles {
|
|
839
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
840
|
+
}
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Align.tsx)
|
|
844
|
+
|
|
845
|
+
#### Sign
|
|
846
|
+
|
|
847
|
+
Set `sign` to `+`, `-`, or `−` to prefix the amount.
|
|
848
|
+
|
|
849
|
+
```tsx
|
|
850
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
851
|
+
|
|
852
|
+
export const fill = true
|
|
853
|
+
export function Demo() {
|
|
854
|
+
return (
|
|
855
|
+
<div {...styles.stack()}>
|
|
856
|
+
<Amount align="center" sign="+" size="md" symbol="PathUSD" value="1250.50" />
|
|
857
|
+
<Amount align="right" currency="USD" sign="−" size="md" value={1234.5} />
|
|
858
|
+
</div>
|
|
859
|
+
)
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
namespace styles {
|
|
863
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
864
|
+
}
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Sign.tsx)
|
|
868
|
+
|
|
869
|
+
#### Strikethrough
|
|
870
|
+
|
|
871
|
+
Set `strikethrough` to mark a superseded amount.
|
|
872
|
+
|
|
873
|
+
```tsx
|
|
874
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
875
|
+
|
|
876
|
+
export const fill = true
|
|
877
|
+
export function Demo() {
|
|
878
|
+
return (
|
|
879
|
+
<div {...styles.stack()}>
|
|
880
|
+
<Amount size="md" strikethrough symbol="PathUSD" value={1250.5} />
|
|
881
|
+
</div>
|
|
882
|
+
)
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
namespace styles {
|
|
886
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
887
|
+
}
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Strikethrough.tsx)
|
|
891
|
+
|
|
892
|
+
#### Precise
|
|
893
|
+
|
|
894
|
+
Set `precise` to show two significant digits for a currency value below the smallest shown unit.
|
|
895
|
+
|
|
896
|
+
```tsx
|
|
897
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
898
|
+
|
|
899
|
+
export const fill = true
|
|
900
|
+
export function Demo() {
|
|
901
|
+
return (
|
|
902
|
+
<div {...styles.stack()}>
|
|
903
|
+
<Amount currency="USD" value={0.0004} />
|
|
904
|
+
<Amount currency="USD" precise value={0.0004} />
|
|
905
|
+
</div>
|
|
906
|
+
)
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
namespace styles {
|
|
910
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
911
|
+
}
|
|
912
|
+
```
|
|
913
|
+
|
|
914
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Precise.tsx)
|
|
915
|
+
|
|
916
|
+
#### Max Decimals
|
|
917
|
+
|
|
918
|
+
Set `maxDecimals` to cap the fraction digits shown.
|
|
919
|
+
|
|
920
|
+
```tsx
|
|
921
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
922
|
+
|
|
923
|
+
export const fill = true
|
|
924
|
+
export function Demo() {
|
|
925
|
+
return (
|
|
926
|
+
<div {...styles.stack()}>
|
|
927
|
+
<Amount symbol="PathUSD" value="1.23456" />
|
|
928
|
+
<Amount maxDecimals={2} symbol="PathUSD" value="1.23456" />
|
|
929
|
+
</div>
|
|
930
|
+
)
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
namespace styles {
|
|
934
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
935
|
+
}
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/MaxDecimals.tsx)
|
|
939
|
+
|
|
940
|
+
#### Locale
|
|
941
|
+
|
|
942
|
+
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.
|
|
943
|
+
|
|
944
|
+
```tsx
|
|
945
|
+
import { Amount, style } from '@tempoxyz/ds'
|
|
946
|
+
|
|
947
|
+
export const fill = true
|
|
948
|
+
export function Demo() {
|
|
949
|
+
return (
|
|
950
|
+
<div {...styles.stack()}>
|
|
951
|
+
<Amount currency="USD" value="1250.50" />
|
|
952
|
+
<Amount currency="USD" locale="de-DE" value="1250.50" />
|
|
953
|
+
</div>
|
|
954
|
+
)
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
namespace styles {
|
|
958
|
+
export const stack = style({ display: 'grid', gap: '12', maxWidth: '24rem !custom' })
|
|
959
|
+
}
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Amount/Locale.tsx)
|
|
963
|
+
|
|
964
|
+
## AssetChip
|
|
965
|
+
|
|
966
|
+
Labels a supported asset or network in a small chip, which can also pick one.
|
|
967
|
+
|
|
968
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/AssetChip.tsx)
|
|
969
|
+
|
|
970
|
+
Figma: [Elements/Asset Chip](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-2626)
|
|
971
|
+
|
|
972
|
+
### Overview
|
|
973
|
+
|
|
974
|
+
An asset chip renders a small gray label for something a row or value supports, such as the assets a network accepts. Place a [TokenLogo](#tokenlogo) before the text to add a 12px token logo. Give it an `onClick` to pick one asset from a short set.
|
|
975
|
+
|
|
976
|
+
### Anatomy
|
|
977
|
+
|
|
978
|
+
Import the component and assemble its parts.
|
|
979
|
+
|
|
980
|
+
```tsx
|
|
981
|
+
import { AssetChip, TokenLogo } from '@tempoxyz/ds'
|
|
982
|
+
|
|
983
|
+
<AssetChip>
|
|
984
|
+
<TokenLogo />
|
|
985
|
+
</AssetChip>
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
### Guidelines
|
|
989
|
+
|
|
990
|
+
#### When to Use
|
|
991
|
+
|
|
992
|
+
* List the assets a network supports under the title of a network row.
|
|
993
|
+
* Name a supported asset after a value, such as an address that accepts USDC.
|
|
994
|
+
* Pick one asset from a short set, such as the asset to pay with.
|
|
995
|
+
|
|
996
|
+
#### When Not to Use
|
|
997
|
+
|
|
998
|
+
* Use [Badge](data-display.md#badge) to show a status, such as Pending.
|
|
999
|
+
* Use [Token](#token-1) for a token that a person can change.
|
|
1000
|
+
* Use [Button](actions.md#button) for an action other than picking an asset.
|
|
1001
|
+
|
|
1002
|
+
#### List What a Row Supports
|
|
1003
|
+
|
|
1004
|
+
Asset chips stay quiet, so they don't compete with the row title or with status tags.
|
|
1005
|
+
|
|
1006
|
+
**Do:** Place the chips under the row title, one per supported asset.
|
|
1007
|
+
|
|
1008
|
+
```tsx
|
|
1009
|
+
/**
|
|
1010
|
+
* Do example for "List What a Row Supports" on the AssetChip page.
|
|
1011
|
+
* Place asset chips under the title of a network row.
|
|
1012
|
+
* @module
|
|
1013
|
+
*/
|
|
1014
|
+
import { AssetChip, NetworkLogo, style } from '@tempoxyz/ds'
|
|
1015
|
+
|
|
1016
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1017
|
+
export function Demo() {
|
|
1018
|
+
return (
|
|
1019
|
+
<div {...styles.row()}>
|
|
1020
|
+
<NetworkLogo network="base" size="large" />
|
|
1021
|
+
<div {...styles.text()}>
|
|
1022
|
+
<span {...styles.title()}>Base</span>
|
|
1023
|
+
<div {...styles.chips()}>
|
|
1024
|
+
<AssetChip>USDC</AssetChip>
|
|
1025
|
+
<AssetChip>USDT</AssetChip>
|
|
1026
|
+
</div>
|
|
1027
|
+
</div>
|
|
1028
|
+
</div>
|
|
1029
|
+
)
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
namespace styles {
|
|
1033
|
+
export const chips = style({ display: 'flex', gap: '4' })
|
|
1034
|
+
|
|
1035
|
+
// The row sits on a modal's elevated surface, as in the designs, so the chips keep their fill.
|
|
1036
|
+
export const row = style({
|
|
1037
|
+
alignItems: 'center',
|
|
1038
|
+
backgroundColor: 'background.elevated',
|
|
1039
|
+
borderRadius: 'xs',
|
|
1040
|
+
display: 'flex',
|
|
1041
|
+
gap: '12',
|
|
1042
|
+
padding: '16',
|
|
1043
|
+
})
|
|
1044
|
+
|
|
1045
|
+
export const text = style({ display: 'grid', gap: '4' })
|
|
1046
|
+
|
|
1047
|
+
export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
1048
|
+
}
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
**Don't:** Use an asset chip to show a status. Use a [Badge](data-display.md#badge).
|
|
1052
|
+
|
|
1053
|
+
```tsx
|
|
1054
|
+
/**
|
|
1055
|
+
* Don't example for "List What a Row Supports" on the AssetChip page.
|
|
1056
|
+
* An asset chip used as a status reads as a supported asset.
|
|
1057
|
+
* @module
|
|
1058
|
+
*/
|
|
1059
|
+
import { AssetChip, NetworkLogo, style } from '@tempoxyz/ds'
|
|
1060
|
+
|
|
1061
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1062
|
+
export function Demo() {
|
|
1063
|
+
return (
|
|
1064
|
+
<div {...styles.row()}>
|
|
1065
|
+
<NetworkLogo network="base" size="large" />
|
|
1066
|
+
<div {...styles.text()}>
|
|
1067
|
+
<span {...styles.title()}>Base</span>
|
|
1068
|
+
<div {...styles.chips()}>
|
|
1069
|
+
<AssetChip>Congested</AssetChip>
|
|
1070
|
+
</div>
|
|
1071
|
+
</div>
|
|
1072
|
+
</div>
|
|
1073
|
+
)
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
namespace styles {
|
|
1077
|
+
export const chips = style({ display: 'flex', gap: '4' })
|
|
1078
|
+
|
|
1079
|
+
// The row sits on a modal's elevated surface, as in the designs, so the chips keep their fill.
|
|
1080
|
+
export const row = style({
|
|
1081
|
+
alignItems: 'center',
|
|
1082
|
+
backgroundColor: 'background.elevated',
|
|
1083
|
+
borderRadius: 'xs',
|
|
1084
|
+
display: 'flex',
|
|
1085
|
+
gap: '12',
|
|
1086
|
+
padding: '16',
|
|
1087
|
+
})
|
|
1088
|
+
|
|
1089
|
+
export const text = style({ display: 'grid', gap: '4' })
|
|
1090
|
+
|
|
1091
|
+
export const title = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
1092
|
+
}
|
|
1093
|
+
```
|
|
1094
|
+
|
|
1095
|
+
#### Add a Logo Only When It Helps
|
|
1096
|
+
|
|
1097
|
+
* **Text:** The default, for a list of familiar assets.
|
|
1098
|
+
* **Logo:** For an asset that people find by its logo.
|
|
1099
|
+
|
|
1100
|
+
### Content
|
|
1101
|
+
|
|
1102
|
+
#### Use the Symbol
|
|
1103
|
+
|
|
1104
|
+
Write the asset's ticker symbol, such as USDC or pathUSD, or the network's name, such as Base. Don't add words such as Supported or Accepted. The row title gives that context.
|
|
1105
|
+
|
|
1106
|
+
### Accessibility
|
|
1107
|
+
|
|
1108
|
+
An asset chip renders a `<span>` with no role, so screen readers read its text inline. With an `onClick`, it renders a `<button>` that takes focus and announces `selected` as pressed.
|
|
1109
|
+
|
|
1110
|
+
#### Semantics
|
|
1111
|
+
|
|
1112
|
+
* **Root (span):** Screen readers read its text in place, as part of the surrounding content.
|
|
1113
|
+
* **Logo (alt):** A nested token logo has empty alt text, so screen readers read the symbol once, from the chip text.
|
|
1114
|
+
* **Selected (aria-pressed):** A chip with an `onClick` announces `selected` as pressed, so screen readers read the pick.
|
|
1115
|
+
|
|
1116
|
+
#### Keyboard
|
|
1117
|
+
|
|
1118
|
+
A static chip takes no focus. A chip with an `onClick` is a native button:
|
|
1119
|
+
|
|
1120
|
+
* **Move Focus to the Chip (Tab):** Moves focus to the next chip in the set.
|
|
1121
|
+
* **Pick the Asset (Enter or Space):** Runs the chip's `onClick`, which sets the picked asset.
|
|
1122
|
+
|
|
1123
|
+
#### Your Responsibilities
|
|
1124
|
+
|
|
1125
|
+
* **Keep Chips Beside Their Row:** Keep the chips next to the row title, so screen readers read the assets with it.
|
|
1126
|
+
* **Name the Set (aria-label):** Wrap selectable chips in a group with a label, so screen readers read what they pick.
|
|
1127
|
+
|
|
1128
|
+
### Related
|
|
1129
|
+
|
|
1130
|
+
[TokenLogo](#tokenlogo)
|
|
1131
|
+
|
|
1132
|
+
Use for token logos.
|
|
1133
|
+
|
|
1134
|
+
[Token](#token-1)
|
|
1135
|
+
|
|
1136
|
+
Use for a token that a person can change.
|
|
1137
|
+
|
|
1138
|
+
[NetworkLogo](#networklogo)
|
|
1139
|
+
|
|
1140
|
+
Use for network logos.
|
|
1141
|
+
|
|
1142
|
+
[Badge](data-display.md#badge)
|
|
1143
|
+
|
|
1144
|
+
Use for statuses.
|
|
1145
|
+
|
|
1146
|
+
[ListGroup](data-display.md#listgroup)
|
|
1147
|
+
|
|
1148
|
+
Use for network and asset lists.
|
|
1149
|
+
|
|
1150
|
+
### Examples
|
|
1151
|
+
|
|
1152
|
+
#### Basic
|
|
1153
|
+
|
|
1154
|
+
```tsx
|
|
1155
|
+
import { AssetChip, style } from '@tempoxyz/ds'
|
|
1156
|
+
|
|
1157
|
+
export function Demo() {
|
|
1158
|
+
return (
|
|
1159
|
+
<div {...styles.row()}>
|
|
1160
|
+
<AssetChip>USDC</AssetChip>
|
|
1161
|
+
<AssetChip>USDT</AssetChip>
|
|
1162
|
+
</div>
|
|
1163
|
+
)
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
namespace styles {
|
|
1167
|
+
// Chips sit on a modal's elevated surface in the designs, and share the page's fill otherwise.
|
|
1168
|
+
export const row = style({
|
|
1169
|
+
alignItems: 'center',
|
|
1170
|
+
backgroundColor: 'background.elevated',
|
|
1171
|
+
borderRadius: 'xs',
|
|
1172
|
+
display: 'flex',
|
|
1173
|
+
gap: '4',
|
|
1174
|
+
padding: '16',
|
|
1175
|
+
})
|
|
1176
|
+
}
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/AssetChip/Basic.tsx)
|
|
1180
|
+
|
|
1181
|
+
#### Logo
|
|
1182
|
+
|
|
1183
|
+
A nested [TokenLogo](#tokenlogo) renders at 12px, whatever its `size`.
|
|
1184
|
+
|
|
1185
|
+
```tsx
|
|
1186
|
+
import { AssetChip, style, TokenLogo } from '@tempoxyz/ds'
|
|
1187
|
+
|
|
1188
|
+
export function Demo() {
|
|
1189
|
+
return (
|
|
1190
|
+
<TokenLogo.Provider>
|
|
1191
|
+
<div {...styles.row()}>
|
|
1192
|
+
<AssetChip>
|
|
1193
|
+
<TokenLogo address="0x20c0000000000000000000000000000000000000" />
|
|
1194
|
+
pathUSD
|
|
1195
|
+
</AssetChip>
|
|
1196
|
+
<AssetChip>
|
|
1197
|
+
<TokenLogo address="0x20c000000000000000000000b9537d11c60e8b50" />
|
|
1198
|
+
USDC.e
|
|
1199
|
+
</AssetChip>
|
|
1200
|
+
</div>
|
|
1201
|
+
</TokenLogo.Provider>
|
|
1202
|
+
)
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
namespace styles {
|
|
1206
|
+
// Chips sit on a modal's elevated surface in the designs, and share the page's fill otherwise.
|
|
1207
|
+
export const row = style({
|
|
1208
|
+
alignItems: 'center',
|
|
1209
|
+
backgroundColor: 'background.elevated',
|
|
1210
|
+
borderRadius: 'xs',
|
|
1211
|
+
display: 'flex',
|
|
1212
|
+
gap: '4',
|
|
1213
|
+
padding: '16',
|
|
1214
|
+
})
|
|
1215
|
+
}
|
|
1216
|
+
```
|
|
1217
|
+
|
|
1218
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/AssetChip/Logo.tsx)
|
|
1219
|
+
|
|
1220
|
+
#### Selectable
|
|
1221
|
+
|
|
1222
|
+
An `onClick` renders a button. Set `selected` on the picked chip, which fills dark.
|
|
1223
|
+
|
|
1224
|
+
```tsx
|
|
1225
|
+
import { AssetChip, style } from '@tempoxyz/ds'
|
|
1226
|
+
import { useState } from 'react'
|
|
1227
|
+
|
|
1228
|
+
const assets = ['USDC', 'USDT', 'pathUSD'] as const
|
|
1229
|
+
|
|
1230
|
+
export function Demo() {
|
|
1231
|
+
const [asset, setAsset] = useState<(typeof assets)[number]>(assets[0])
|
|
1232
|
+
|
|
1233
|
+
return (
|
|
1234
|
+
<div aria-label="Pay with" role="group" {...styles.row()}>
|
|
1235
|
+
{assets.map((entry) => (
|
|
1236
|
+
<AssetChip key={entry} onClick={() => setAsset(entry)} selected={asset === entry}>
|
|
1237
|
+
{entry}
|
|
1238
|
+
</AssetChip>
|
|
1239
|
+
))}
|
|
1240
|
+
</div>
|
|
1241
|
+
)
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
namespace styles {
|
|
1245
|
+
// Chips sit on a modal's elevated surface in the designs, and share the page's fill otherwise.
|
|
1246
|
+
export const row = style({
|
|
1247
|
+
alignItems: 'center',
|
|
1248
|
+
backgroundColor: 'background.elevated',
|
|
1249
|
+
borderRadius: 'xs',
|
|
1250
|
+
display: 'flex',
|
|
1251
|
+
gap: '4',
|
|
1252
|
+
padding: '16',
|
|
1253
|
+
})
|
|
1254
|
+
}
|
|
1255
|
+
```
|
|
1256
|
+
|
|
1257
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/AssetChip/Selectable.tsx)
|
|
1258
|
+
|
|
1259
|
+
## BadgedLogo
|
|
1260
|
+
|
|
1261
|
+
Marks a token or an app with a small badge on the corner of its logo.
|
|
1262
|
+
|
|
1263
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/BadgedLogo.tsx)
|
|
1264
|
+
|
|
1265
|
+
Figma: [Elements/Badged Logo](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5606-2531) (`BadgedLogo.Root`)
|
|
1266
|
+
|
|
1267
|
+
### Overview
|
|
1268
|
+
|
|
1269
|
+
A badged logo insets a 44px logo in a 56px box and overlaps its lower trailing corner with a 20px badge. The badge holds one icon, such as an arrow that marks the destination of a transfer.
|
|
1270
|
+
|
|
1271
|
+
### Anatomy
|
|
1272
|
+
|
|
1273
|
+
Import the component and assemble its parts.
|
|
1274
|
+
|
|
1275
|
+
```tsx
|
|
1276
|
+
import { BadgedLogo } from '@tempoxyz/ds'
|
|
1277
|
+
|
|
1278
|
+
<BadgedLogo.Root>
|
|
1279
|
+
<BadgedLogo.Tile />
|
|
1280
|
+
<BadgedLogo.Badge />
|
|
1281
|
+
</BadgedLogo.Root>
|
|
1282
|
+
```
|
|
1283
|
+
|
|
1284
|
+
### Guidelines
|
|
1285
|
+
|
|
1286
|
+
#### When to Use
|
|
1287
|
+
|
|
1288
|
+
* Mark the token or the app at one end of a transfer, such as the destination of a send.
|
|
1289
|
+
|
|
1290
|
+
#### When Not to Use
|
|
1291
|
+
|
|
1292
|
+
* Use [TokenLogo](#tokenlogo) for a token without a badge.
|
|
1293
|
+
* Use [Avatar](data-display.md#avatar) for a person, a contact, or a wallet.
|
|
1294
|
+
* Use [IconTile](data-display.md#icontile) for one icon above the title of a modal.
|
|
1295
|
+
|
|
1296
|
+
#### Put the Logo First and the Badge Last
|
|
1297
|
+
|
|
1298
|
+
Pass one logo, then one `BadgedLogo.Badge`. The root sizes the logo to 44px, so leave its size unset.
|
|
1299
|
+
|
|
1300
|
+
#### Use One Small Icon in the Badge
|
|
1301
|
+
|
|
1302
|
+
The badge centers one 12px icon in the primary color. Do not put text or a second icon in it.
|
|
1303
|
+
|
|
1304
|
+
### Content
|
|
1305
|
+
|
|
1306
|
+
Fill a `BadgedLogo.Tile` with the first letter of the app's name, in uppercase.
|
|
1307
|
+
|
|
1308
|
+
### Accessibility
|
|
1309
|
+
|
|
1310
|
+
A badged logo renders `<span>` elements with no role and takes no focus.
|
|
1311
|
+
|
|
1312
|
+
* **Logo (img):** A token logo with `alt` announces its name.
|
|
1313
|
+
* **Badge (aria-hidden):** An icon without `aria-label` stays hidden.
|
|
1314
|
+
* **Meaning in Text:** Name what the badge means in text beside it.
|
|
1315
|
+
|
|
1316
|
+
### Related
|
|
1317
|
+
|
|
1318
|
+
[TokenLogo](#tokenlogo)
|
|
1319
|
+
|
|
1320
|
+
Use for a token logo without a badge.
|
|
1321
|
+
|
|
1322
|
+
[Avatar](data-display.md#avatar)
|
|
1323
|
+
|
|
1324
|
+
Use for people, contacts, and wallets.
|
|
1325
|
+
|
|
1326
|
+
[IconTile](data-display.md#icontile)
|
|
1327
|
+
|
|
1328
|
+
Use for one icon above the title of a modal.
|
|
1329
|
+
|
|
1330
|
+
### Examples
|
|
1331
|
+
|
|
1332
|
+
#### Token
|
|
1333
|
+
|
|
1334
|
+
```tsx
|
|
1335
|
+
/** Renders a token logo with an arrow badge on the BadgedLogo page. @module */
|
|
1336
|
+
import { BadgedLogo, TokenLogo } from '@tempoxyz/ds'
|
|
1337
|
+
import { ArrowRight } from '@tempoxyz/ds/icons'
|
|
1338
|
+
|
|
1339
|
+
export function Demo() {
|
|
1340
|
+
return (
|
|
1341
|
+
<BadgedLogo.Root>
|
|
1342
|
+
<TokenLogo symbol="USDC" />
|
|
1343
|
+
<BadgedLogo.Badge>
|
|
1344
|
+
<ArrowRight />
|
|
1345
|
+
</BadgedLogo.Badge>
|
|
1346
|
+
</BadgedLogo.Root>
|
|
1347
|
+
)
|
|
1348
|
+
}
|
|
1349
|
+
```
|
|
1350
|
+
|
|
1351
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/BadgedLogo/Basic.tsx)
|
|
1352
|
+
|
|
1353
|
+
#### App
|
|
1354
|
+
|
|
1355
|
+
An app without artwork takes a tile with the first letter of its name.
|
|
1356
|
+
|
|
1357
|
+
```tsx
|
|
1358
|
+
/** Renders an app tile with an arrow badge on the BadgedLogo page. @module */
|
|
1359
|
+
import { BadgedLogo } from '@tempoxyz/ds'
|
|
1360
|
+
import { ArrowRight } from '@tempoxyz/ds/icons'
|
|
1361
|
+
|
|
1362
|
+
export function Demo() {
|
|
1363
|
+
return (
|
|
1364
|
+
<BadgedLogo.Root>
|
|
1365
|
+
<BadgedLogo.Tile>A</BadgedLogo.Tile>
|
|
1366
|
+
<BadgedLogo.Badge>
|
|
1367
|
+
<ArrowRight />
|
|
1368
|
+
</BadgedLogo.Badge>
|
|
1369
|
+
</BadgedLogo.Root>
|
|
1370
|
+
)
|
|
1371
|
+
}
|
|
1372
|
+
```
|
|
1373
|
+
|
|
1374
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/BadgedLogo/App.tsx)
|
|
1375
|
+
|
|
1376
|
+
## Hex
|
|
1377
|
+
|
|
1378
|
+
Shows a hex string, such as an address, truncated to fit.
|
|
1379
|
+
|
|
1380
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Hex.tsx)
|
|
1381
|
+
|
|
1382
|
+
### Overview
|
|
1383
|
+
|
|
1384
|
+
Hex shows a hex string, such as an address or hash, middle-truncated to fit its container. Both ends stay visible, and screen readers read the full value.
|
|
1385
|
+
|
|
1386
|
+
### Anatomy
|
|
1387
|
+
|
|
1388
|
+
Import the component and assemble its parts.
|
|
1389
|
+
|
|
1390
|
+
```tsx
|
|
1391
|
+
import { Hex } from '@tempoxyz/ds'
|
|
1392
|
+
|
|
1393
|
+
<Hex />
|
|
1394
|
+
|
|
1395
|
+
<Hex.Root>
|
|
1396
|
+
<Hex.Text />
|
|
1397
|
+
<Hex.Copy />
|
|
1398
|
+
</Hex.Root>
|
|
1399
|
+
```
|
|
1400
|
+
|
|
1401
|
+
### Guidelines
|
|
1402
|
+
|
|
1403
|
+
#### When to Use
|
|
1404
|
+
|
|
1405
|
+
* Show an address or transaction hash in a row, table, or card where it may not fit.
|
|
1406
|
+
* Show a receive address as a standalone field with `variant="filled"`. The whole row copies.
|
|
1407
|
+
|
|
1408
|
+
#### When Not to Use
|
|
1409
|
+
|
|
1410
|
+
* Use [SecretValue](#secretvalue) for private keys and other secrets. Hex shows its value in the clear.
|
|
1411
|
+
* Use [Snippet](data-display.md#snippet) for URLs, commands, and other values that aren't hex.
|
|
1412
|
+
* Use [CopyButton](actions.md#copybutton) alone when the value isn't displayed.
|
|
1413
|
+
|
|
1414
|
+
#### Always Offer Copy
|
|
1415
|
+
|
|
1416
|
+
Set `copy` wherever people need the full value. To name the button, compose the parts and pass `aria-label` to `Hex.Copy`. Link a transaction hash to its block explorer page for verification.
|
|
1417
|
+
|
|
1418
|
+
```tsx
|
|
1419
|
+
<Hex.Root value={address}>
|
|
1420
|
+
<Hex.Text />
|
|
1421
|
+
<Hex.Copy aria-label="Copy address" />
|
|
1422
|
+
</Hex.Root>
|
|
1423
|
+
```
|
|
1424
|
+
|
|
1425
|
+
**Do:** Add a copy button, named by what it copies.
|
|
1426
|
+
|
|
1427
|
+
```tsx
|
|
1428
|
+
/** Do example for "Always Offer Copy" on the Hex page: add a copy button, named by what it copies. @module */
|
|
1429
|
+
import { Hex } from '@tempoxyz/ds'
|
|
1430
|
+
|
|
1431
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1432
|
+
export function Demo() {
|
|
1433
|
+
return (
|
|
1434
|
+
<Hex.Root value="0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060">
|
|
1435
|
+
<Hex.Text />
|
|
1436
|
+
<Hex.Copy aria-label="Copy transaction hash" />
|
|
1437
|
+
</Hex.Root>
|
|
1438
|
+
)
|
|
1439
|
+
}
|
|
1440
|
+
```
|
|
1441
|
+
|
|
1442
|
+
**Don't:** Show a truncated value without a way to copy it.
|
|
1443
|
+
|
|
1444
|
+
```tsx
|
|
1445
|
+
/**
|
|
1446
|
+
* Don't example for "Always Offer Copy" on the Hex page.
|
|
1447
|
+
* Don't show a truncated value without a way to copy it.
|
|
1448
|
+
* @module
|
|
1449
|
+
*/
|
|
1450
|
+
import { Hex } from '@tempoxyz/ds'
|
|
1451
|
+
|
|
1452
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1453
|
+
export function Demo() {
|
|
1454
|
+
return <Hex value="0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060" />
|
|
1455
|
+
}
|
|
1456
|
+
```
|
|
1457
|
+
|
|
1458
|
+
#### Truncate in the Middle
|
|
1459
|
+
|
|
1460
|
+
People check an address by its first and last characters. For plain strings, such as a [Toast](feedback-and-status.md#toast) message, `formatHex` keeps both ends too.
|
|
1461
|
+
|
|
1462
|
+
**Do:** Keep both ends of the value visible.
|
|
1463
|
+
|
|
1464
|
+
```tsx
|
|
1465
|
+
/** Do example for "Truncate in the Middle" on the Hex page: keep both ends of the value visible. @module */
|
|
1466
|
+
import { Hex, style } from '@tempoxyz/ds'
|
|
1467
|
+
|
|
1468
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1469
|
+
export function Demo() {
|
|
1470
|
+
return (
|
|
1471
|
+
<div {...styles.frame()}>
|
|
1472
|
+
<Hex copy value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />
|
|
1473
|
+
</div>
|
|
1474
|
+
)
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
namespace styles {
|
|
1478
|
+
export const frame = style({ maxWidth: '100% !custom', width: '12rem !custom' })
|
|
1479
|
+
}
|
|
1480
|
+
```
|
|
1481
|
+
|
|
1482
|
+
**Don't:** Truncate the end of an address with an ellipsis.
|
|
1483
|
+
|
|
1484
|
+
```tsx
|
|
1485
|
+
/**
|
|
1486
|
+
* Don't example for "Truncate in the Middle" on the Hex page.
|
|
1487
|
+
* Don't truncate the end of an address with an ellipsis.
|
|
1488
|
+
* @module
|
|
1489
|
+
*/
|
|
1490
|
+
import { style } from '@tempoxyz/ds'
|
|
1491
|
+
|
|
1492
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1493
|
+
export function Demo() {
|
|
1494
|
+
return <span {...styles.text()}>0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045</span>
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
namespace styles {
|
|
1498
|
+
export const text = style({
|
|
1499
|
+
color: 'content.primary',
|
|
1500
|
+
display: 'block',
|
|
1501
|
+
maxWidth: '100% !custom',
|
|
1502
|
+
overflow: 'hidden',
|
|
1503
|
+
textOverflow: 'ellipsis !custom',
|
|
1504
|
+
typography: 'mono.m1',
|
|
1505
|
+
whiteSpace: 'nowrap',
|
|
1506
|
+
width: '12rem !custom',
|
|
1507
|
+
})
|
|
1508
|
+
}
|
|
1509
|
+
```
|
|
1510
|
+
|
|
1511
|
+
#### Show the Full Address Before Sending
|
|
1512
|
+
|
|
1513
|
+
Look-alike addresses can match the first and last four characters of a real one. Hex truncates only when its container is narrower than the value, so give it room on a payment review and ask people to check it against its source.
|
|
1514
|
+
|
|
1515
|
+
**Do:** Show every character of the recipient on review.
|
|
1516
|
+
|
|
1517
|
+
```tsx
|
|
1518
|
+
/**
|
|
1519
|
+
* Do example for "Show the Full Address Before Sending" on the Hex page.
|
|
1520
|
+
* Show every character of the recipient on review.
|
|
1521
|
+
* @module
|
|
1522
|
+
*/
|
|
1523
|
+
import { Hex, style } from '@tempoxyz/ds'
|
|
1524
|
+
|
|
1525
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1526
|
+
export function Demo() {
|
|
1527
|
+
return (
|
|
1528
|
+
<div {...styles.field()}>
|
|
1529
|
+
<span {...styles.label()}>Recipient</span>
|
|
1530
|
+
<Hex copy value="0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc" variant="filled" />
|
|
1531
|
+
</div>
|
|
1532
|
+
)
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
namespace styles {
|
|
1536
|
+
export const field = style({ display: 'grid', gap: '4', width: '100% !custom' })
|
|
1537
|
+
|
|
1538
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
1539
|
+
}
|
|
1540
|
+
```
|
|
1541
|
+
|
|
1542
|
+
**Don't:** Truncate the address people confirm a payment to.
|
|
1543
|
+
|
|
1544
|
+
```tsx
|
|
1545
|
+
/**
|
|
1546
|
+
* Don't example for "Show the Full Address Before Sending" on the Hex page.
|
|
1547
|
+
* Don't truncate the address people confirm a payment to.
|
|
1548
|
+
* @module
|
|
1549
|
+
*/
|
|
1550
|
+
import { Hex, style } from '@tempoxyz/ds'
|
|
1551
|
+
|
|
1552
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1553
|
+
export function Demo() {
|
|
1554
|
+
return (
|
|
1555
|
+
<div {...styles.field()}>
|
|
1556
|
+
<span {...styles.label()}>Recipient</span>
|
|
1557
|
+
<Hex copy value="0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc" variant="filled" />
|
|
1558
|
+
</div>
|
|
1559
|
+
)
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
namespace styles {
|
|
1563
|
+
export const field = style({
|
|
1564
|
+
display: 'grid',
|
|
1565
|
+
gap: '4',
|
|
1566
|
+
maxWidth: '100% !custom',
|
|
1567
|
+
width: '12rem !custom',
|
|
1568
|
+
})
|
|
1569
|
+
|
|
1570
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
1571
|
+
}
|
|
1572
|
+
```
|
|
1573
|
+
|
|
1574
|
+
#### Label Every Value
|
|
1575
|
+
|
|
1576
|
+
**Do:** Put a label beside each value, such as Recipient or Transaction hash.
|
|
1577
|
+
|
|
1578
|
+
```tsx
|
|
1579
|
+
/**
|
|
1580
|
+
* Do example for "Label Every Value" on the Hex page.
|
|
1581
|
+
* Put a label beside each value, such as Recipient or Transaction hash.
|
|
1582
|
+
* @module
|
|
1583
|
+
*/
|
|
1584
|
+
import { Hex, style } from '@tempoxyz/ds'
|
|
1585
|
+
|
|
1586
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1587
|
+
export function Demo() {
|
|
1588
|
+
return (
|
|
1589
|
+
<div {...styles.list()}>
|
|
1590
|
+
<div {...styles.row()}>
|
|
1591
|
+
<span {...styles.label()}>Recipient</span>
|
|
1592
|
+
<Hex size="small" value="0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc" />
|
|
1593
|
+
</div>
|
|
1594
|
+
<div {...styles.row()}>
|
|
1595
|
+
<span {...styles.label()}>Transaction hash</span>
|
|
1596
|
+
<Hex
|
|
1597
|
+
size="small"
|
|
1598
|
+
value="0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060"
|
|
1599
|
+
/>
|
|
1600
|
+
</div>
|
|
1601
|
+
</div>
|
|
1602
|
+
)
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
namespace styles {
|
|
1606
|
+
export const label = style({
|
|
1607
|
+
color: 'content.secondary',
|
|
1608
|
+
flexShrink: '0 !custom',
|
|
1609
|
+
typography: 'body.b2',
|
|
1610
|
+
})
|
|
1611
|
+
|
|
1612
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
1613
|
+
|
|
1614
|
+
export const row = style({
|
|
1615
|
+
alignItems: 'baseline',
|
|
1616
|
+
display: 'flex',
|
|
1617
|
+
gap: '16',
|
|
1618
|
+
justifyContent: 'space-between',
|
|
1619
|
+
minWidth: '0',
|
|
1620
|
+
})
|
|
1621
|
+
}
|
|
1622
|
+
```
|
|
1623
|
+
|
|
1624
|
+
**Don't:** Show bare hex strings. They don't identify themselves.
|
|
1625
|
+
|
|
1626
|
+
```tsx
|
|
1627
|
+
/**
|
|
1628
|
+
* Don't example for "Label Every Value" on the Hex page.
|
|
1629
|
+
* Don't show bare hex strings. They don't identify themselves.
|
|
1630
|
+
* @module
|
|
1631
|
+
*/
|
|
1632
|
+
import { Hex, style } from '@tempoxyz/ds'
|
|
1633
|
+
|
|
1634
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1635
|
+
export function Demo() {
|
|
1636
|
+
return (
|
|
1637
|
+
<div {...styles.list()}>
|
|
1638
|
+
<Hex size="small" value="0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc" />
|
|
1639
|
+
<Hex
|
|
1640
|
+
size="small"
|
|
1641
|
+
value="0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060"
|
|
1642
|
+
/>
|
|
1643
|
+
</div>
|
|
1644
|
+
)
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
namespace styles {
|
|
1648
|
+
export const list = style({ display: 'grid', gap: '12', width: '100% !custom' })
|
|
1649
|
+
}
|
|
1650
|
+
```
|
|
1651
|
+
|
|
1652
|
+
#### Pick a Variant
|
|
1653
|
+
|
|
1654
|
+
* **Inline (inline):** The default, for text, rows, and table cells.
|
|
1655
|
+
* **Filled (filled):** A tinted field that copies on click, for standalone values.
|
|
1656
|
+
* **No Prefix (evm={false}):** For hex values without a `0x` prefix.
|
|
1657
|
+
|
|
1658
|
+
### Accessibility
|
|
1659
|
+
|
|
1660
|
+
Hex renders a `<span>` with the truncated value on screen and the full value for screen readers. With `copy`, the copy button follows the [WAI-ARIA Authoring Practices button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/).
|
|
1661
|
+
|
|
1662
|
+
#### Semantics
|
|
1663
|
+
|
|
1664
|
+
* **Truncated Text (aria-hidden):** Hidden. Screen readers read the full value from hidden text.
|
|
1665
|
+
* **Short Values:** Values that fit render as plain text, with no hidden copy of the value.
|
|
1666
|
+
* **Hex.Copy (button):** Named "Copy" and the value, or `aria-label`. A copy renames it "Copied" for two seconds and announces it.
|
|
1667
|
+
* **Filled Variant (filled):** A click anywhere on the row copies. The button stays the keyboard path.
|
|
1668
|
+
|
|
1669
|
+
#### Keyboard
|
|
1670
|
+
|
|
1671
|
+
* **Move to Copy (Tab):** Moves focus to the copy button. The value takes no focus.
|
|
1672
|
+
* **Copy the Value (Enter or Space):** Copies the full value. Focus stays on the button.
|
|
1673
|
+
|
|
1674
|
+
#### Your Responsibilities
|
|
1675
|
+
|
|
1676
|
+
* **Name the Copy Button (aria-label):** Name what it copies, such as "Copy address". The default name reads the full value.
|
|
1677
|
+
* **Show a Name:** If a name or contact label exists, show it with the address. A raw hex string is hard to listen to.
|
|
1678
|
+
|
|
1679
|
+
### Related
|
|
1680
|
+
|
|
1681
|
+
[CopyButton](actions.md#copybutton)
|
|
1682
|
+
|
|
1683
|
+
Use for copying without a visible value.
|
|
1684
|
+
|
|
1685
|
+
[Identicon](#identicon)
|
|
1686
|
+
|
|
1687
|
+
Use for an image beside an address.
|
|
1688
|
+
|
|
1689
|
+
[SecretValue](#secretvalue)
|
|
1690
|
+
|
|
1691
|
+
Use for secrets.
|
|
1692
|
+
|
|
1693
|
+
[Snippet](data-display.md#snippet)
|
|
1694
|
+
|
|
1695
|
+
Use for commands and URLs.
|
|
1696
|
+
|
|
1697
|
+
[Blockchain Values](../patterns.md#blockchain-values)
|
|
1698
|
+
|
|
1699
|
+
Covers addresses, hashes, and amounts.
|
|
1700
|
+
|
|
1701
|
+
### Examples
|
|
1702
|
+
|
|
1703
|
+
#### Basic
|
|
1704
|
+
|
|
1705
|
+
```tsx
|
|
1706
|
+
import { Hex, style } from '@tempoxyz/ds'
|
|
1707
|
+
|
|
1708
|
+
export function Demo() {
|
|
1709
|
+
return (
|
|
1710
|
+
<div {...styles.stack()}>
|
|
1711
|
+
<Hex value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />
|
|
1712
|
+
<Hex value="0x1234" />
|
|
1713
|
+
<div {...styles.frame()}>
|
|
1714
|
+
<Hex value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />
|
|
1715
|
+
</div>
|
|
1716
|
+
</div>
|
|
1717
|
+
)
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
namespace styles {
|
|
1721
|
+
export const frame = style({
|
|
1722
|
+
borderColor: 'line.secondary',
|
|
1723
|
+
borderRadius: '2xs',
|
|
1724
|
+
borderStyle: 'dashed',
|
|
1725
|
+
borderWidth: 'regular',
|
|
1726
|
+
boxSizing: 'border-box',
|
|
1727
|
+
maxWidth: '100% !custom',
|
|
1728
|
+
padding: '8',
|
|
1729
|
+
width: '6rem !custom',
|
|
1730
|
+
})
|
|
1731
|
+
|
|
1732
|
+
export const stack = style({ display: 'grid', gap: '12', justifyItems: 'start' })
|
|
1733
|
+
}
|
|
1734
|
+
```
|
|
1735
|
+
|
|
1736
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Hex/Basic.tsx)
|
|
1737
|
+
|
|
1738
|
+
#### Copy
|
|
1739
|
+
|
|
1740
|
+
Set `copy` to add a button that copies the full value.
|
|
1741
|
+
|
|
1742
|
+
```tsx
|
|
1743
|
+
import { CopyButton, Hex, style } from '@tempoxyz/ds'
|
|
1744
|
+
|
|
1745
|
+
const address = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
|
|
1746
|
+
const transaction = '0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060'
|
|
1747
|
+
|
|
1748
|
+
export function Demo() {
|
|
1749
|
+
return (
|
|
1750
|
+
<div {...styles.stack()}>
|
|
1751
|
+
<Hex copy value={transaction} />
|
|
1752
|
+
{(['32rem', '20rem', '12rem', '8rem'] as const).map((width) => (
|
|
1753
|
+
<div key={width} {...styles.frame({ style: { width } })}>
|
|
1754
|
+
<Hex copy value={transaction} />
|
|
1755
|
+
</div>
|
|
1756
|
+
))}
|
|
1757
|
+
<div {...styles.row()}>
|
|
1758
|
+
<CopyButton value={address} />
|
|
1759
|
+
<CopyButton value={address} variant="secondary" />
|
|
1760
|
+
<CopyButton size="large" value={address} variant="primary" />
|
|
1761
|
+
</div>
|
|
1762
|
+
</div>
|
|
1763
|
+
)
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
namespace styles {
|
|
1767
|
+
export const frame = style({
|
|
1768
|
+
borderColor: 'line.secondary',
|
|
1769
|
+
borderRadius: '2xs',
|
|
1770
|
+
borderStyle: 'dashed',
|
|
1771
|
+
borderWidth: 'regular',
|
|
1772
|
+
boxSizing: 'border-box',
|
|
1773
|
+
maxWidth: '100% !custom',
|
|
1774
|
+
padding: '8',
|
|
1775
|
+
})
|
|
1776
|
+
|
|
1777
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
|
|
1778
|
+
|
|
1779
|
+
export const stack = style({ display: 'grid', gap: '12', justifyItems: 'start' })
|
|
1780
|
+
}
|
|
1781
|
+
```
|
|
1782
|
+
|
|
1783
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Hex/Copy.tsx)
|
|
1784
|
+
|
|
1785
|
+
#### Evm
|
|
1786
|
+
|
|
1787
|
+
Set `evm={false}` for values without a `0x` prefix.
|
|
1788
|
+
|
|
1789
|
+
```tsx
|
|
1790
|
+
import { Hex } from '@tempoxyz/ds'
|
|
1791
|
+
|
|
1792
|
+
export function Demo() {
|
|
1793
|
+
return <Hex evm={false} value="a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f60718" />
|
|
1794
|
+
}
|
|
1795
|
+
```
|
|
1796
|
+
|
|
1797
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Hex/Evm.tsx)
|
|
1798
|
+
|
|
1799
|
+
#### Variant
|
|
1800
|
+
|
|
1801
|
+
Set `variant` to `inline` (default) or `filled`.
|
|
1802
|
+
|
|
1803
|
+
```tsx
|
|
1804
|
+
import { Hex, style } from '@tempoxyz/ds'
|
|
1805
|
+
|
|
1806
|
+
const transaction = '0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060'
|
|
1807
|
+
|
|
1808
|
+
export function Demo() {
|
|
1809
|
+
return (
|
|
1810
|
+
<div {...styles.stack()}>
|
|
1811
|
+
<Hex copy value={transaction} variant="inline" />
|
|
1812
|
+
<div {...styles.resizable()}>
|
|
1813
|
+
<Hex copy value={transaction} variant="filled" />
|
|
1814
|
+
</div>
|
|
1815
|
+
</div>
|
|
1816
|
+
)
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
namespace styles {
|
|
1820
|
+
export const resizable = style({
|
|
1821
|
+
maxWidth: '100% !custom',
|
|
1822
|
+
minWidth: 'min(10rem, 100%) !custom',
|
|
1823
|
+
overflow: 'hidden',
|
|
1824
|
+
resize: 'horizontal !custom',
|
|
1825
|
+
width: '28rem !custom',
|
|
1826
|
+
})
|
|
1827
|
+
|
|
1828
|
+
export const stack = style({ display: 'grid', gap: '12', justifyItems: 'start' })
|
|
1829
|
+
}
|
|
1830
|
+
```
|
|
1831
|
+
|
|
1832
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Hex/Variant.tsx)
|
|
1833
|
+
|
|
1834
|
+
#### Size
|
|
1835
|
+
|
|
1836
|
+
Set `size` to `small`, `medium` (default), or `large`.
|
|
1837
|
+
|
|
1838
|
+
```tsx
|
|
1839
|
+
import { Hex, style } from '@tempoxyz/ds'
|
|
1840
|
+
|
|
1841
|
+
export function Demo() {
|
|
1842
|
+
return (
|
|
1843
|
+
<div {...styles.stack()}>
|
|
1844
|
+
{(['small', 'medium', 'large'] as const).map((size) => (
|
|
1845
|
+
<Hex
|
|
1846
|
+
copy
|
|
1847
|
+
key={size}
|
|
1848
|
+
size={size}
|
|
1849
|
+
value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
|
|
1850
|
+
variant="filled"
|
|
1851
|
+
/>
|
|
1852
|
+
))}
|
|
1853
|
+
</div>
|
|
1854
|
+
)
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
namespace styles {
|
|
1858
|
+
export const stack = style({ display: 'grid', gap: '12', justifyItems: 'start' })
|
|
1859
|
+
}
|
|
1860
|
+
```
|
|
1861
|
+
|
|
1862
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Hex/Size.tsx)
|
|
1863
|
+
|
|
1864
|
+
## Identicon
|
|
1865
|
+
|
|
1866
|
+
Shows a unique gradient avatar derived from an address.
|
|
1867
|
+
|
|
1868
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Identicon.tsx)
|
|
1869
|
+
|
|
1870
|
+
### Overview
|
|
1871
|
+
|
|
1872
|
+
An identicon is a round gradient avatar derived from an address. The same address always renders the same colors.
|
|
1873
|
+
|
|
1874
|
+
### Anatomy
|
|
1875
|
+
|
|
1876
|
+
Import the component and assemble its parts.
|
|
1877
|
+
|
|
1878
|
+
```tsx
|
|
1879
|
+
import { Identicon } from '@tempoxyz/ds'
|
|
1880
|
+
|
|
1881
|
+
<Identicon />
|
|
1882
|
+
```
|
|
1883
|
+
|
|
1884
|
+
### Guidelines
|
|
1885
|
+
|
|
1886
|
+
#### When to Use
|
|
1887
|
+
|
|
1888
|
+
* Give an address an image beside its text, in recipient lists, activity rows, and account switchers.
|
|
1889
|
+
* Fill an `Avatar.Fallback` for an account known only by its address.
|
|
1890
|
+
|
|
1891
|
+
#### When Not to Use
|
|
1892
|
+
|
|
1893
|
+
* Use [Avatar](data-display.md#avatar) for people and organizations with a name.
|
|
1894
|
+
* Use [TokenLogo](#tokenlogo) for a token contract, which has its own icon.
|
|
1895
|
+
* Use [Hex](#hex) to read, compare, or copy the address.
|
|
1896
|
+
|
|
1897
|
+
#### Always Show the Address Beside It
|
|
1898
|
+
|
|
1899
|
+
Colors come from seven hue palettes, so addresses often look alike. Color alone doesn't identify an account ([SC 1.4.1](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html)).
|
|
1900
|
+
|
|
1901
|
+
**Do:** Place the address, with `copy`, or the account name beside each identicon.
|
|
1902
|
+
|
|
1903
|
+
```tsx
|
|
1904
|
+
/**
|
|
1905
|
+
* Do example for "Always Show the Address Beside It" on the Identicon page.
|
|
1906
|
+
* Place the address, with `copy`, or the account name beside each identicon.
|
|
1907
|
+
* @module
|
|
1908
|
+
*/
|
|
1909
|
+
import { Hex, Identicon, style } from '@tempoxyz/ds'
|
|
1910
|
+
|
|
1911
|
+
const addresses = [
|
|
1912
|
+
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
|
|
1913
|
+
'0x71C7656EC7ab88b098defB751B7401B5f6d8976F',
|
|
1914
|
+
] as const
|
|
1915
|
+
|
|
1916
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1917
|
+
export function Demo() {
|
|
1918
|
+
return (
|
|
1919
|
+
<div {...styles.list()}>
|
|
1920
|
+
{addresses.map((address) => (
|
|
1921
|
+
<div key={address} {...styles.row()}>
|
|
1922
|
+
<Identicon address={address} aria-hidden size="32" />
|
|
1923
|
+
<Hex copy value={address} />
|
|
1924
|
+
</div>
|
|
1925
|
+
))}
|
|
1926
|
+
</div>
|
|
1927
|
+
)
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
namespace styles {
|
|
1931
|
+
export const list = style({ display: 'grid', gap: '12', minWidth: '0' })
|
|
1932
|
+
|
|
1933
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12', minWidth: '0' })
|
|
1934
|
+
}
|
|
1935
|
+
```
|
|
1936
|
+
|
|
1937
|
+
**Don't:** Show identicons without the address or name they stand for.
|
|
1938
|
+
|
|
1939
|
+
```tsx
|
|
1940
|
+
/**
|
|
1941
|
+
* Don't example for "Always Show the Address Beside It" on the Identicon page.
|
|
1942
|
+
* Don't show identicons without the address or name they stand for.
|
|
1943
|
+
* @module
|
|
1944
|
+
*/
|
|
1945
|
+
import { Identicon, style } from '@tempoxyz/ds'
|
|
1946
|
+
|
|
1947
|
+
const addresses = [
|
|
1948
|
+
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
|
|
1949
|
+
'0x71C7656EC7ab88b098defB751B7401B5f6d8976F',
|
|
1950
|
+
'0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
|
|
1951
|
+
] as const
|
|
1952
|
+
|
|
1953
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1954
|
+
export function Demo() {
|
|
1955
|
+
return (
|
|
1956
|
+
<div {...styles.row()}>
|
|
1957
|
+
{addresses.map((address) => (
|
|
1958
|
+
<Identicon address={address} key={address} size="32" />
|
|
1959
|
+
))}
|
|
1960
|
+
</div>
|
|
1961
|
+
)
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
namespace styles {
|
|
1965
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
1966
|
+
}
|
|
1967
|
+
```
|
|
1968
|
+
|
|
1969
|
+
#### Don't Treat It as Verification
|
|
1970
|
+
|
|
1971
|
+
An identicon doesn't prove an address is correct. Before a send, show the full address on the review step.
|
|
1972
|
+
|
|
1973
|
+
**Do:** Ask people to compare characters.
|
|
1974
|
+
|
|
1975
|
+
```tsx
|
|
1976
|
+
/**
|
|
1977
|
+
* Do example for "Don't Treat It as Verification" on the Identicon page.
|
|
1978
|
+
* Ask people to compare characters.
|
|
1979
|
+
* @module
|
|
1980
|
+
*/
|
|
1981
|
+
import { Hex, Identicon, style } from '@tempoxyz/ds'
|
|
1982
|
+
|
|
1983
|
+
const address = '0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc'
|
|
1984
|
+
|
|
1985
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
1986
|
+
export function Demo() {
|
|
1987
|
+
return (
|
|
1988
|
+
<div {...styles.field()}>
|
|
1989
|
+
<span {...styles.label()}>Recipient</span>
|
|
1990
|
+
<div {...styles.row()}>
|
|
1991
|
+
<Identicon address={address} aria-hidden size="24" />
|
|
1992
|
+
<Hex size="small" value={address} />
|
|
1993
|
+
</div>
|
|
1994
|
+
<span {...styles.hint()}>Compare every character with the address you copied.</span>
|
|
1995
|
+
</div>
|
|
1996
|
+
)
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
namespace styles {
|
|
2000
|
+
export const field = style({ display: 'grid', gap: '8', width: '100% !custom' })
|
|
2001
|
+
|
|
2002
|
+
export const hint = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2003
|
+
|
|
2004
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
2005
|
+
|
|
2006
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '8', minWidth: '0' })
|
|
2007
|
+
}
|
|
2008
|
+
```
|
|
2009
|
+
|
|
2010
|
+
**Don't:** Ask people to compare colors.
|
|
2011
|
+
|
|
2012
|
+
```tsx
|
|
2013
|
+
/**
|
|
2014
|
+
* Don't example for "Don't Treat It as Verification" on the Identicon page.
|
|
2015
|
+
* Don't ask people to compare colors.
|
|
2016
|
+
* @module
|
|
2017
|
+
*/
|
|
2018
|
+
import { Hex, Identicon, style } from '@tempoxyz/ds'
|
|
2019
|
+
|
|
2020
|
+
const address = '0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc'
|
|
2021
|
+
|
|
2022
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2023
|
+
export function Demo() {
|
|
2024
|
+
return (
|
|
2025
|
+
<div {...styles.field()}>
|
|
2026
|
+
<span {...styles.label()}>Recipient</span>
|
|
2027
|
+
<div {...styles.row()}>
|
|
2028
|
+
<Identicon address={address} aria-hidden size="24" />
|
|
2029
|
+
<Hex size="small" value={address} />
|
|
2030
|
+
</div>
|
|
2031
|
+
<span {...styles.hint()}>Make sure the colors match your contact.</span>
|
|
2032
|
+
</div>
|
|
2033
|
+
)
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
namespace styles {
|
|
2037
|
+
export const field = style({ display: 'grid', gap: '8', width: '100% !custom' })
|
|
2038
|
+
|
|
2039
|
+
export const hint = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2040
|
+
|
|
2041
|
+
export const label = style({ color: 'content.secondary', typography: 'body.b2' })
|
|
2042
|
+
|
|
2043
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '8', minWidth: '0' })
|
|
2044
|
+
}
|
|
2045
|
+
```
|
|
2046
|
+
|
|
2047
|
+
#### Derive It From the Address
|
|
2048
|
+
|
|
2049
|
+
Letter case doesn't change the colors, so checksummed and lowercase forms match.
|
|
2050
|
+
|
|
2051
|
+
**Do:** Pass the address, so a rename keeps the same image.
|
|
2052
|
+
|
|
2053
|
+
```tsx
|
|
2054
|
+
/**
|
|
2055
|
+
* Do example for "Derive It From the Address" on the Identicon page.
|
|
2056
|
+
* Pass the address, so a rename keeps the same image.
|
|
2057
|
+
* @module
|
|
2058
|
+
*/
|
|
2059
|
+
import { Identicon, style } from '@tempoxyz/ds'
|
|
2060
|
+
|
|
2061
|
+
const address = '0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc'
|
|
2062
|
+
|
|
2063
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2064
|
+
export function Demo() {
|
|
2065
|
+
return (
|
|
2066
|
+
<div {...styles.list()}>
|
|
2067
|
+
<div {...styles.row()}>
|
|
2068
|
+
<Identicon address={address} aria-hidden size="32" />
|
|
2069
|
+
<span {...styles.name()}>Alice</span>
|
|
2070
|
+
</div>
|
|
2071
|
+
<div {...styles.row()}>
|
|
2072
|
+
<Identicon address={address} aria-hidden size="32" />
|
|
2073
|
+
<span {...styles.name()}>Alice Chen</span>
|
|
2074
|
+
</div>
|
|
2075
|
+
</div>
|
|
2076
|
+
)
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
namespace styles {
|
|
2080
|
+
export const list = style({ display: 'grid', gap: '12' })
|
|
2081
|
+
|
|
2082
|
+
export const name = style({ color: 'content.primary', typography: 'body.b2' })
|
|
2083
|
+
|
|
2084
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
2085
|
+
}
|
|
2086
|
+
```
|
|
2087
|
+
|
|
2088
|
+
**Don't:** Pass a display name. The image changes when the name does.
|
|
2089
|
+
|
|
2090
|
+
```tsx
|
|
2091
|
+
/**
|
|
2092
|
+
* Don't example for "Derive It From the Address" on the Identicon page.
|
|
2093
|
+
* Don't pass a display name. The image changes when the name does.
|
|
2094
|
+
* @module
|
|
2095
|
+
*/
|
|
2096
|
+
import { Identicon, style } from '@tempoxyz/ds'
|
|
2097
|
+
|
|
2098
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2099
|
+
export function Demo() {
|
|
2100
|
+
return (
|
|
2101
|
+
<div {...styles.list()}>
|
|
2102
|
+
<div {...styles.row()}>
|
|
2103
|
+
<Identicon address="Alice" aria-hidden size="32" />
|
|
2104
|
+
<span {...styles.name()}>Alice</span>
|
|
2105
|
+
</div>
|
|
2106
|
+
<div {...styles.row()}>
|
|
2107
|
+
<Identicon address="Alice Chen" aria-hidden size="32" />
|
|
2108
|
+
<span {...styles.name()}>Alice Chen</span>
|
|
2109
|
+
</div>
|
|
2110
|
+
</div>
|
|
2111
|
+
)
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
namespace styles {
|
|
2115
|
+
export const list = style({ display: 'grid', gap: '12' })
|
|
2116
|
+
|
|
2117
|
+
export const name = style({ color: 'content.primary', typography: 'body.b2' })
|
|
2118
|
+
|
|
2119
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
2120
|
+
}
|
|
2121
|
+
```
|
|
2122
|
+
|
|
2123
|
+
#### Size It With the Text Beside It
|
|
2124
|
+
|
|
2125
|
+
* **Inline (16):** Inline with body text.
|
|
2126
|
+
* **Dense Rows (24 or 32):** In dense rows and tables.
|
|
2127
|
+
* **List Rows (40):** The default, in list rows.
|
|
2128
|
+
* **Account Headers (48 or 64):** In account headers.
|
|
2129
|
+
* **Fill a Frame (fill):** Inside an avatar fallback or other sized frame.
|
|
2130
|
+
|
|
2131
|
+
### Accessibility
|
|
2132
|
+
|
|
2133
|
+
An identicon renders an `<svg>` with the `img` role. It takes no focus.
|
|
2134
|
+
|
|
2135
|
+
#### Semantics
|
|
2136
|
+
|
|
2137
|
+
* **Root (img):** Announced as an image by name.
|
|
2138
|
+
* **Name (aria-label):** Defaults to the full address, all 42 characters.
|
|
2139
|
+
|
|
2140
|
+
#### Your Responsibilities
|
|
2141
|
+
|
|
2142
|
+
* **Hide a Duplicate (aria-hidden):** If the address is in nearby text, hide the identicon so it isn't announced twice.
|
|
2143
|
+
* **Name a Standalone Identicon (aria-label):** If it stands alone, name the account, such as "Savings account".
|
|
2144
|
+
|
|
2145
|
+
### Related
|
|
2146
|
+
|
|
2147
|
+
[Avatar](data-display.md#avatar)
|
|
2148
|
+
|
|
2149
|
+
Use for people and organizations.
|
|
2150
|
+
|
|
2151
|
+
[Hex](#hex)
|
|
2152
|
+
|
|
2153
|
+
Use for showing and copying addresses.
|
|
2154
|
+
|
|
2155
|
+
[TokenLogo](#tokenlogo)
|
|
2156
|
+
|
|
2157
|
+
Use for token icons.
|
|
2158
|
+
|
|
2159
|
+
[Blockchain Values](../patterns.md#blockchain-values)
|
|
2160
|
+
|
|
2161
|
+
Covers displaying addresses.
|
|
2162
|
+
|
|
2163
|
+
### Examples
|
|
2164
|
+
|
|
2165
|
+
#### Basic
|
|
2166
|
+
|
|
2167
|
+
```tsx
|
|
2168
|
+
import { Identicon } from '@tempoxyz/ds'
|
|
2169
|
+
|
|
2170
|
+
export function Demo() {
|
|
2171
|
+
return <Identicon address="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />
|
|
2172
|
+
}
|
|
2173
|
+
```
|
|
2174
|
+
|
|
2175
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Identicon/Basic.tsx)
|
|
2176
|
+
|
|
2177
|
+
#### Size
|
|
2178
|
+
|
|
2179
|
+
Set `size` to `16`, `24`, `32`, `40` (default), `48`, or `64` pixels.
|
|
2180
|
+
|
|
2181
|
+
```tsx
|
|
2182
|
+
import { Identicon, style } from '@tempoxyz/ds'
|
|
2183
|
+
|
|
2184
|
+
export function Demo() {
|
|
2185
|
+
return (
|
|
2186
|
+
<div {...styles.row()}>
|
|
2187
|
+
{(['16', '24', '32', '40', '48', '64'] as const).map((size) => (
|
|
2188
|
+
<Identicon address="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" key={size} size={size} />
|
|
2189
|
+
))}
|
|
2190
|
+
</div>
|
|
2191
|
+
)
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
namespace styles {
|
|
2195
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
|
|
2196
|
+
}
|
|
2197
|
+
```
|
|
2198
|
+
|
|
2199
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Identicon/Size.tsx)
|
|
2200
|
+
|
|
2201
|
+
#### Address
|
|
2202
|
+
|
|
2203
|
+
Each `address` derives its own colors.
|
|
2204
|
+
|
|
2205
|
+
```tsx
|
|
2206
|
+
import { Identicon, style } from '@tempoxyz/ds'
|
|
2207
|
+
|
|
2208
|
+
const addresses = [
|
|
2209
|
+
'0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
|
|
2210
|
+
'0x71C7656EC7ab88b098defB751B7401B5f6d8976F',
|
|
2211
|
+
'0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
|
|
2212
|
+
'0x0000000000000000000000000000000000000000',
|
|
2213
|
+
'0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984',
|
|
2214
|
+
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
|
2215
|
+
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
2216
|
+
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
2217
|
+
]
|
|
2218
|
+
|
|
2219
|
+
export function Demo() {
|
|
2220
|
+
return (
|
|
2221
|
+
<div {...styles.row()}>
|
|
2222
|
+
{addresses.map((address) => (
|
|
2223
|
+
<Identicon address={address} key={address} size="64" />
|
|
2224
|
+
))}
|
|
2225
|
+
</div>
|
|
2226
|
+
)
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
namespace styles {
|
|
2230
|
+
export const row = style({ alignItems: 'center', display: 'flex', flexWrap: 'wrap', gap: '12' })
|
|
2231
|
+
}
|
|
2232
|
+
```
|
|
2233
|
+
|
|
2234
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Identicon/Address.tsx)
|
|
2235
|
+
|
|
2236
|
+
## NetworkLogo
|
|
2237
|
+
|
|
2238
|
+
Shows the logo of the network a token lives on.
|
|
2239
|
+
|
|
2240
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/NetworkLogo.tsx)
|
|
2241
|
+
|
|
2242
|
+
### Overview
|
|
2243
|
+
|
|
2244
|
+
A network logo renders a network's artwork as an inline SVG, cropped to a circle. The artwork keeps the network's brand colors in both color schemes.
|
|
2245
|
+
|
|
2246
|
+
### Anatomy
|
|
2247
|
+
|
|
2248
|
+
Import the component and assemble its parts.
|
|
2249
|
+
|
|
2250
|
+
```tsx
|
|
2251
|
+
import { NetworkLogo } from '@tempoxyz/ds'
|
|
2252
|
+
|
|
2253
|
+
<NetworkLogo />
|
|
2254
|
+
```
|
|
2255
|
+
|
|
2256
|
+
### Guidelines
|
|
2257
|
+
|
|
2258
|
+
#### When to Use
|
|
2259
|
+
|
|
2260
|
+
* Show which network a token, an address, or a deposit belongs to, such as in a Receive flow or a network picker.
|
|
2261
|
+
|
|
2262
|
+
#### When Not to Use
|
|
2263
|
+
|
|
2264
|
+
* Use [TokenLogo](#tokenlogo) for the token itself.
|
|
2265
|
+
* Use [Identicon](#identicon) for an account address.
|
|
2266
|
+
* Use [IconTile](data-display.md#icontile) for a feature or category icon.
|
|
2267
|
+
|
|
2268
|
+
#### Name the Network
|
|
2269
|
+
|
|
2270
|
+
Many people don't know every network's logo.
|
|
2271
|
+
|
|
2272
|
+
**Do:** Show the network name beside each logo.
|
|
2273
|
+
|
|
2274
|
+
```tsx
|
|
2275
|
+
/**
|
|
2276
|
+
* Do example for "Name the Network" on the NetworkLogo page.
|
|
2277
|
+
* Show the network name beside each logo.
|
|
2278
|
+
* @module
|
|
2279
|
+
*/
|
|
2280
|
+
import { NetworkLogo, style } from '@tempoxyz/ds'
|
|
2281
|
+
|
|
2282
|
+
const networks = [
|
|
2283
|
+
['tempo', 'Tempo'],
|
|
2284
|
+
['base', 'Base'],
|
|
2285
|
+
['ethereum', 'Ethereum'],
|
|
2286
|
+
] as const
|
|
2287
|
+
|
|
2288
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2289
|
+
export function Demo() {
|
|
2290
|
+
return (
|
|
2291
|
+
<div {...styles.list()}>
|
|
2292
|
+
{networks.map(([network, label]) => (
|
|
2293
|
+
<div key={network} {...styles.row()}>
|
|
2294
|
+
<NetworkLogo network={network} size="large" />
|
|
2295
|
+
<span {...styles.name()}>{label}</span>
|
|
2296
|
+
</div>
|
|
2297
|
+
))}
|
|
2298
|
+
</div>
|
|
2299
|
+
)
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
namespace styles {
|
|
2303
|
+
export const list = style({ display: 'grid', gap: '12' })
|
|
2304
|
+
|
|
2305
|
+
export const name = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
2306
|
+
|
|
2307
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
2308
|
+
}
|
|
2309
|
+
```
|
|
2310
|
+
|
|
2311
|
+
**Don't:** Ask people to tell networks apart by logo alone.
|
|
2312
|
+
|
|
2313
|
+
```tsx
|
|
2314
|
+
/**
|
|
2315
|
+
* Don't example for "Name the Network" on the NetworkLogo page.
|
|
2316
|
+
* Logos alone ask people to recognize every network's brand.
|
|
2317
|
+
* @module
|
|
2318
|
+
*/
|
|
2319
|
+
import { NetworkLogo, style } from '@tempoxyz/ds'
|
|
2320
|
+
|
|
2321
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2322
|
+
export function Demo() {
|
|
2323
|
+
return (
|
|
2324
|
+
<div {...styles.row()}>
|
|
2325
|
+
<NetworkLogo network="tempo" size="large" />
|
|
2326
|
+
<NetworkLogo network="base" size="large" />
|
|
2327
|
+
<NetworkLogo network="ethereum" size="large" />
|
|
2328
|
+
</div>
|
|
2329
|
+
)
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
namespace styles {
|
|
2333
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
2334
|
+
}
|
|
2335
|
+
```
|
|
2336
|
+
|
|
2337
|
+
#### Match Size to the Context
|
|
2338
|
+
|
|
2339
|
+
* **Medium (20px):** Beside a network name in a value or chip.
|
|
2340
|
+
* **Large (32px):** In network rows and network pickers.
|
|
2341
|
+
|
|
2342
|
+
#### Keep the Brand Artwork
|
|
2343
|
+
|
|
2344
|
+
**Do:** Use the logo as it renders, in its own colors.
|
|
2345
|
+
|
|
2346
|
+
```tsx
|
|
2347
|
+
<NetworkLogo network="ethereum" size="large" />
|
|
2348
|
+
```
|
|
2349
|
+
|
|
2350
|
+
**Don't:** Recolor the logo, or redraw it as a colored circle with a letter.
|
|
2351
|
+
|
|
2352
|
+
```tsx
|
|
2353
|
+
<span
|
|
2354
|
+
style={{
|
|
2355
|
+
alignItems: 'center',
|
|
2356
|
+
background: '#627eea',
|
|
2357
|
+
borderRadius: 999,
|
|
2358
|
+
color: 'white',
|
|
2359
|
+
display: 'inline-flex',
|
|
2360
|
+
font: '600 14px Inter',
|
|
2361
|
+
height: 32,
|
|
2362
|
+
justifyContent: 'center',
|
|
2363
|
+
width: 32,
|
|
2364
|
+
}}
|
|
2365
|
+
>
|
|
2366
|
+
E
|
|
2367
|
+
</span>
|
|
2368
|
+
```
|
|
2369
|
+
|
|
2370
|
+
### Accessibility
|
|
2371
|
+
|
|
2372
|
+
A network logo renders an `<svg>` that is hidden from screen readers by default. It is not interactive and takes no focus.
|
|
2373
|
+
|
|
2374
|
+
#### Semantics
|
|
2375
|
+
|
|
2376
|
+
* **Root (aria-hidden):** Hidden from screen readers, so the visible name beside it is read once.
|
|
2377
|
+
* **Named Logo (aria-label):** An `aria-label` gives the logo the `img` role, so screen readers announce it.
|
|
2378
|
+
|
|
2379
|
+
#### Your Responsibilities
|
|
2380
|
+
|
|
2381
|
+
* **Name a Standalone Logo (aria-label):** If no visible text names the network, pass the network name as `aria-label`.
|
|
2382
|
+
|
|
2383
|
+
### Related
|
|
2384
|
+
|
|
2385
|
+
[TokenLogo](#tokenlogo)
|
|
2386
|
+
|
|
2387
|
+
Use for token logos.
|
|
2388
|
+
|
|
2389
|
+
[AssetChip](#assetchip)
|
|
2390
|
+
|
|
2391
|
+
Use for listing the assets a network supports.
|
|
2392
|
+
|
|
2393
|
+
[ListGroup](data-display.md#listgroup)
|
|
2394
|
+
|
|
2395
|
+
Use for network lists.
|
|
2396
|
+
|
|
2397
|
+
[Blockchain Values](../patterns.md#blockchain-values)
|
|
2398
|
+
|
|
2399
|
+
Covers tokens, networks, and addresses.
|
|
2400
|
+
|
|
2401
|
+
### Examples
|
|
2402
|
+
|
|
2403
|
+
#### Basic
|
|
2404
|
+
|
|
2405
|
+
```tsx
|
|
2406
|
+
import { NetworkLogo, style } from '@tempoxyz/ds'
|
|
2407
|
+
|
|
2408
|
+
export function Demo() {
|
|
2409
|
+
return (
|
|
2410
|
+
<div {...styles.row()}>
|
|
2411
|
+
<NetworkLogo network="tempo" />
|
|
2412
|
+
Tempo
|
|
2413
|
+
</div>
|
|
2414
|
+
)
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
namespace styles {
|
|
2418
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '8' })
|
|
2419
|
+
}
|
|
2420
|
+
```
|
|
2421
|
+
|
|
2422
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/NetworkLogo/Basic.tsx)
|
|
2423
|
+
|
|
2424
|
+
#### Network
|
|
2425
|
+
|
|
2426
|
+
Set `network` to `base`, `ethereum`, `hyperevm`, `polygon`, `solana`, or `tempo`.
|
|
2427
|
+
|
|
2428
|
+
```tsx
|
|
2429
|
+
import { NetworkLogo, style } from '@tempoxyz/ds'
|
|
2430
|
+
|
|
2431
|
+
const networks = [
|
|
2432
|
+
['base', 'Base'],
|
|
2433
|
+
['ethereum', 'Ethereum'],
|
|
2434
|
+
['hyperevm', 'HyperEVM'],
|
|
2435
|
+
['polygon', 'Polygon'],
|
|
2436
|
+
['solana', 'Solana'],
|
|
2437
|
+
['tempo', 'Tempo'],
|
|
2438
|
+
] as const
|
|
2439
|
+
|
|
2440
|
+
export function Demo() {
|
|
2441
|
+
return (
|
|
2442
|
+
<div {...styles.grid()}>
|
|
2443
|
+
{networks.map(([network, label]) => (
|
|
2444
|
+
<div key={network} {...styles.row()}>
|
|
2445
|
+
<NetworkLogo network={network} />
|
|
2446
|
+
{label}
|
|
2447
|
+
</div>
|
|
2448
|
+
))}
|
|
2449
|
+
</div>
|
|
2450
|
+
)
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
namespace styles {
|
|
2454
|
+
export const grid = style({ display: 'grid', gap: '12' })
|
|
2455
|
+
|
|
2456
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '8' })
|
|
2457
|
+
}
|
|
2458
|
+
```
|
|
2459
|
+
|
|
2460
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/NetworkLogo/Network.tsx)
|
|
2461
|
+
|
|
2462
|
+
#### Size
|
|
2463
|
+
|
|
2464
|
+
Set `size` to `medium` (20px, default) or `large` (32px).
|
|
2465
|
+
|
|
2466
|
+
```tsx
|
|
2467
|
+
import { NetworkLogo, style } from '@tempoxyz/ds'
|
|
2468
|
+
|
|
2469
|
+
export function Demo() {
|
|
2470
|
+
return (
|
|
2471
|
+
<div {...styles.row()}>
|
|
2472
|
+
<NetworkLogo network="ethereum" size="medium" />
|
|
2473
|
+
<NetworkLogo network="ethereum" size="large" />
|
|
2474
|
+
</div>
|
|
2475
|
+
)
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
namespace styles {
|
|
2479
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
2480
|
+
}
|
|
2481
|
+
```
|
|
2482
|
+
|
|
2483
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/NetworkLogo/Size.tsx)
|
|
2484
|
+
|
|
2485
|
+
## Qr
|
|
2486
|
+
|
|
2487
|
+
Renders a value as a QR code.
|
|
2488
|
+
|
|
2489
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Qr.tsx)
|
|
2490
|
+
|
|
2491
|
+
### Overview
|
|
2492
|
+
|
|
2493
|
+
Qr renders a value as a QR code in the foreground color on a transparent ground.
|
|
2494
|
+
|
|
2495
|
+
### Anatomy
|
|
2496
|
+
|
|
2497
|
+
Import the component and assemble its parts.
|
|
2498
|
+
|
|
2499
|
+
```tsx
|
|
2500
|
+
import { Qr } from '@tempoxyz/ds'
|
|
2501
|
+
|
|
2502
|
+
<Qr />
|
|
2503
|
+
```
|
|
2504
|
+
|
|
2505
|
+
### Guidelines
|
|
2506
|
+
|
|
2507
|
+
#### When to Use
|
|
2508
|
+
|
|
2509
|
+
* Show a deposit address in a receive flow, for a scan from another wallet.
|
|
2510
|
+
* Move a link from a computer to a phone, such as a payment request.
|
|
2511
|
+
|
|
2512
|
+
#### When Not to Use
|
|
2513
|
+
|
|
2514
|
+
* Use a link or `Button.Link` ([Button](actions.md#button)) for a URL opened on the same device.
|
|
2515
|
+
* Use [Hex](#hex) with `copy` alone when the reader needs the value on the same device. A phone cannot scan its own screen.
|
|
2516
|
+
|
|
2517
|
+
#### Show the Address as Text Too
|
|
2518
|
+
|
|
2519
|
+
Many people cannot scan: someone on the same phone, a screen reader user, or someone without a camera.
|
|
2520
|
+
|
|
2521
|
+
* **Copy:** Put the address beside the code with [Hex](#hex) and `copy`.
|
|
2522
|
+
* **Match:** The text must match what the code encodes. If the code holds a URI, such as `tempo:` and the address, show the same address. Never encode a different value, such as a tracking link.
|
|
2523
|
+
* **Network:** A code does not show its network. State what the address accepts, such as Send USDC on Tempo to this address.
|
|
2524
|
+
|
|
2525
|
+
**Do:** Show the address with a copy button, and the network it accepts, beside the code.
|
|
2526
|
+
|
|
2527
|
+
```tsx
|
|
2528
|
+
/**
|
|
2529
|
+
* Do example for "Show the Address as Text Too" on the Qr page.
|
|
2530
|
+
* Show the address with a copy button, and the network it accepts, beside the code.
|
|
2531
|
+
* @module
|
|
2532
|
+
*/
|
|
2533
|
+
import { Hex, Qr, style } from '@tempoxyz/ds'
|
|
2534
|
+
|
|
2535
|
+
const address = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'
|
|
2536
|
+
|
|
2537
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2538
|
+
export function Demo() {
|
|
2539
|
+
return (
|
|
2540
|
+
<div {...styles.stack()}>
|
|
2541
|
+
<Qr aria-label="Deposit address QR code" size="small" value={address} />
|
|
2542
|
+
<span {...styles.note()}>Send USDC on Tempo to this address</span>
|
|
2543
|
+
<Hex copy size="small" value={address} variant="filled" {...styles.hex()} />
|
|
2544
|
+
</div>
|
|
2545
|
+
)
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
namespace styles {
|
|
2549
|
+
export const hex = style({ width: '100% !custom' })
|
|
2550
|
+
|
|
2551
|
+
export const note = style({
|
|
2552
|
+
color: 'content.secondary',
|
|
2553
|
+
textAlign: 'center',
|
|
2554
|
+
typography: 'body.b3',
|
|
2555
|
+
})
|
|
2556
|
+
|
|
2557
|
+
export const stack = style({
|
|
2558
|
+
display: 'grid',
|
|
2559
|
+
gap: '12',
|
|
2560
|
+
justifyItems: 'center',
|
|
2561
|
+
width: '100% !custom',
|
|
2562
|
+
})
|
|
2563
|
+
}
|
|
2564
|
+
```
|
|
2565
|
+
|
|
2566
|
+
**Don't:** Show a code without the value it encodes.
|
|
2567
|
+
|
|
2568
|
+
```tsx
|
|
2569
|
+
/**
|
|
2570
|
+
* Don't example for "Show the Address as Text Too" on the Qr page.
|
|
2571
|
+
* Don't show a code without the value it encodes.
|
|
2572
|
+
* @module
|
|
2573
|
+
*/
|
|
2574
|
+
import { Qr } from '@tempoxyz/ds'
|
|
2575
|
+
|
|
2576
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2577
|
+
export function Demo() {
|
|
2578
|
+
return <Qr size="small" value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />
|
|
2579
|
+
}
|
|
2580
|
+
```
|
|
2581
|
+
|
|
2582
|
+
#### Keep Contrast and Clear Space
|
|
2583
|
+
|
|
2584
|
+
* **Dark mode:** The modules turn light on a dark ground, and some scanners cannot read inverted codes. If older scanners matter, use a light panel and set `color` to a dark value with 3:1 contrast in both schemes.
|
|
2585
|
+
* **Clear space:** Keep borders, text, and controls off the edges of the code.
|
|
2586
|
+
|
|
2587
|
+
**Do:** Place the code on a plain background with space around it.
|
|
2588
|
+
|
|
2589
|
+
```tsx
|
|
2590
|
+
/**
|
|
2591
|
+
* Do example for "Keep Contrast and Clear Space" on the Qr page.
|
|
2592
|
+
* Place the code on a plain background with space around it.
|
|
2593
|
+
* @module
|
|
2594
|
+
*/
|
|
2595
|
+
import { Qr, style } from '@tempoxyz/ds'
|
|
2596
|
+
|
|
2597
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2598
|
+
export function Demo() {
|
|
2599
|
+
return (
|
|
2600
|
+
<div {...styles.panel()}>
|
|
2601
|
+
<Qr
|
|
2602
|
+
aria-label="Deposit address QR code"
|
|
2603
|
+
size="small"
|
|
2604
|
+
value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
|
|
2605
|
+
/>
|
|
2606
|
+
</div>
|
|
2607
|
+
)
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
namespace styles {
|
|
2611
|
+
export const panel = style({
|
|
2612
|
+
backgroundColor: 'background.primary',
|
|
2613
|
+
borderRadius: 'sm',
|
|
2614
|
+
padding: '24',
|
|
2615
|
+
})
|
|
2616
|
+
}
|
|
2617
|
+
```
|
|
2618
|
+
|
|
2619
|
+
**Don't:** Place the code over an image or gradient.
|
|
2620
|
+
|
|
2621
|
+
```tsx
|
|
2622
|
+
/**
|
|
2623
|
+
* Don't example for "Keep Contrast and Clear Space" on the Qr page.
|
|
2624
|
+
* Don't place the code over an image or gradient.
|
|
2625
|
+
* @module
|
|
2626
|
+
*/
|
|
2627
|
+
import { Qr, style } from '@tempoxyz/ds'
|
|
2628
|
+
|
|
2629
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2630
|
+
export function Demo() {
|
|
2631
|
+
return (
|
|
2632
|
+
<div {...styles.panel()}>
|
|
2633
|
+
<Qr
|
|
2634
|
+
aria-label="Deposit address QR code"
|
|
2635
|
+
size="small"
|
|
2636
|
+
value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
|
|
2637
|
+
/>
|
|
2638
|
+
</div>
|
|
2639
|
+
)
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
namespace styles {
|
|
2643
|
+
export const panel = style({
|
|
2644
|
+
backgroundImage: 'linear-gradient(135deg, #3b82f6, #a855f7 50%, #f97316) !custom',
|
|
2645
|
+
borderRadius: 'sm',
|
|
2646
|
+
padding: '4',
|
|
2647
|
+
})
|
|
2648
|
+
}
|
|
2649
|
+
```
|
|
2650
|
+
|
|
2651
|
+
#### Use a Logo Only at Larger Sizes
|
|
2652
|
+
|
|
2653
|
+
`arena` draws a logo in the center and raises error correction to medium, so scanners recover the covered modules. Use the token's logo or Tempo's.
|
|
2654
|
+
|
|
2655
|
+
**Do:** Add a logo only to a `medium` or `large` code.
|
|
2656
|
+
|
|
2657
|
+
```tsx
|
|
2658
|
+
/**
|
|
2659
|
+
* Do example for "Use a Logo Only at Larger Sizes" on the Qr page.
|
|
2660
|
+
* Add a logo only to a `medium` or `large` code.
|
|
2661
|
+
* @module
|
|
2662
|
+
*/
|
|
2663
|
+
import { Qr } from '@tempoxyz/ds'
|
|
2664
|
+
import pathUsd from '../../coins/PathUSD.svg'
|
|
2665
|
+
|
|
2666
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2667
|
+
export function Demo() {
|
|
2668
|
+
return (
|
|
2669
|
+
<Qr
|
|
2670
|
+
arena={pathUsd}
|
|
2671
|
+
aria-label="Deposit address QR code"
|
|
2672
|
+
size="medium"
|
|
2673
|
+
value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
|
|
2674
|
+
/>
|
|
2675
|
+
)
|
|
2676
|
+
}
|
|
2677
|
+
```
|
|
2678
|
+
|
|
2679
|
+
**Don't:** Add a logo to a `small` code.
|
|
2680
|
+
|
|
2681
|
+
```tsx
|
|
2682
|
+
/**
|
|
2683
|
+
* Don't example for "Use a Logo Only at Larger Sizes" on the Qr page.
|
|
2684
|
+
* Don't add a logo to a `small` code.
|
|
2685
|
+
* @module
|
|
2686
|
+
*/
|
|
2687
|
+
import { Qr } from '@tempoxyz/ds'
|
|
2688
|
+
import pathUsd from '../../coins/PathUSD.svg'
|
|
2689
|
+
|
|
2690
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2691
|
+
export function Demo() {
|
|
2692
|
+
return (
|
|
2693
|
+
<Qr
|
|
2694
|
+
arena={pathUsd}
|
|
2695
|
+
aria-label="Deposit address QR code"
|
|
2696
|
+
size="small"
|
|
2697
|
+
value="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
|
|
2698
|
+
/>
|
|
2699
|
+
)
|
|
2700
|
+
}
|
|
2701
|
+
```
|
|
2702
|
+
|
|
2703
|
+
#### Size for the Screen
|
|
2704
|
+
|
|
2705
|
+
* **Small (160px):** In a panel beside other content.
|
|
2706
|
+
* **Medium (240px):** The default, for a receive dialog.
|
|
2707
|
+
* **Large (320px):** The roomiest size, for a code with a logo.
|
|
2708
|
+
|
|
2709
|
+
### Accessibility
|
|
2710
|
+
|
|
2711
|
+
Qr renders an `<svg>` with the `img` role. It is not interactive and takes no focus.
|
|
2712
|
+
|
|
2713
|
+
#### Semantics
|
|
2714
|
+
|
|
2715
|
+
* **Root (img):** An image that screen readers announce by its name.
|
|
2716
|
+
* **Name (aria-label):** Defaults to "QR code for" and the full value.
|
|
2717
|
+
* **Arena (Arena):** Set `arena` to an image URL to add a logo, announced as a nested image.
|
|
2718
|
+
* **Modules (foreground):** On a transparent ground, so the code follows the light or dark scheme.
|
|
2719
|
+
|
|
2720
|
+
#### Your Responsibilities
|
|
2721
|
+
|
|
2722
|
+
* **Name It by Purpose (aria-label):** Describe what it encodes, such as "Deposit address QR code".
|
|
2723
|
+
* **Name the Logo (arena):** Pass a node with its own accessible name, or make sure the logo's name adds no noise.
|
|
2724
|
+
|
|
2725
|
+
### Related
|
|
2726
|
+
|
|
2727
|
+
[Hex](#hex)
|
|
2728
|
+
|
|
2729
|
+
Use for showing and copying the address.
|
|
2730
|
+
|
|
2731
|
+
[CopyButton](actions.md#copybutton)
|
|
2732
|
+
|
|
2733
|
+
Use for copying a value.
|
|
2734
|
+
|
|
2735
|
+
[Snippet](data-display.md#snippet)
|
|
2736
|
+
|
|
2737
|
+
Use for links and other values.
|
|
2738
|
+
|
|
2739
|
+
[Payments](../patterns.md#payments)
|
|
2740
|
+
|
|
2741
|
+
Covers send and receive flows.
|
|
2742
|
+
|
|
2743
|
+
[Tempo Wallet](../patterns.md#tempo-wallet)
|
|
2744
|
+
|
|
2745
|
+
Covers the receive screen.
|
|
2746
|
+
|
|
2747
|
+
### Examples
|
|
2748
|
+
|
|
2749
|
+
#### Basic
|
|
2750
|
+
|
|
2751
|
+
```tsx
|
|
2752
|
+
import { Qr } from '@tempoxyz/ds'
|
|
2753
|
+
|
|
2754
|
+
export function Demo() {
|
|
2755
|
+
return <Qr value="tempo:0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />
|
|
2756
|
+
}
|
|
2757
|
+
```
|
|
2758
|
+
|
|
2759
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Qr/Basic.tsx)
|
|
2760
|
+
|
|
2761
|
+
#### Size
|
|
2762
|
+
|
|
2763
|
+
Set `size` to `small`, `medium` (default), or `large`.
|
|
2764
|
+
|
|
2765
|
+
```tsx
|
|
2766
|
+
import { Qr, style } from '@tempoxyz/ds'
|
|
2767
|
+
|
|
2768
|
+
export function Demo() {
|
|
2769
|
+
return (
|
|
2770
|
+
<div {...styles.row()}>
|
|
2771
|
+
{(['small', 'medium', 'large'] as const).map((size) => (
|
|
2772
|
+
<Qr key={size} size={size} value="tempo:0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" />
|
|
2773
|
+
))}
|
|
2774
|
+
</div>
|
|
2775
|
+
)
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2778
|
+
namespace styles {
|
|
2779
|
+
export const row = style({ alignItems: 'start', display: 'flex', flexWrap: 'wrap', gap: '16' })
|
|
2780
|
+
}
|
|
2781
|
+
```
|
|
2782
|
+
|
|
2783
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Qr/Size.tsx)
|
|
2784
|
+
|
|
2785
|
+
#### Arena
|
|
2786
|
+
|
|
2787
|
+
Pass an image URL to `arena` to draw a logo in the center.
|
|
2788
|
+
|
|
2789
|
+
```tsx
|
|
2790
|
+
import { Qr } from '@tempoxyz/ds'
|
|
2791
|
+
import pathUsd from '../../coins/PathUSD.svg'
|
|
2792
|
+
|
|
2793
|
+
export function Demo() {
|
|
2794
|
+
return <Qr arena={pathUsd} value="https://example.org" />
|
|
2795
|
+
}
|
|
2796
|
+
```
|
|
2797
|
+
|
|
2798
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Qr/Arena.tsx)
|
|
2799
|
+
|
|
2800
|
+
## SecretValue
|
|
2801
|
+
|
|
2802
|
+
Masks a secret and adds reveal and copy buttons.
|
|
2803
|
+
|
|
2804
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/SecretValue.tsx)
|
|
2805
|
+
|
|
2806
|
+
### Overview
|
|
2807
|
+
|
|
2808
|
+
SecretValue masks a secret behind 16 dots and adds reveal and copy buttons. A click anywhere on the block copies the value without revealing it.
|
|
2809
|
+
|
|
2810
|
+
### Anatomy
|
|
2811
|
+
|
|
2812
|
+
Import the component and assemble its parts.
|
|
2813
|
+
|
|
2814
|
+
```tsx
|
|
2815
|
+
import { SecretValue } from '@tempoxyz/ds'
|
|
2816
|
+
|
|
2817
|
+
<SecretValue />
|
|
2818
|
+
```
|
|
2819
|
+
|
|
2820
|
+
### Guidelines
|
|
2821
|
+
|
|
2822
|
+
#### When to Use
|
|
2823
|
+
|
|
2824
|
+
* Show an API key, webhook signing secret, or access key that people copy into another system.
|
|
2825
|
+
* Show a recovery key that people must store, behind an explicit reveal.
|
|
2826
|
+
|
|
2827
|
+
#### When Not to Use
|
|
2828
|
+
|
|
2829
|
+
* Use [Snippet](data-display.md#snippet) for commands and values that are not secret, such as a webhook URL.
|
|
2830
|
+
* Use [Hex](#hex) with `copy` for public addresses and transaction hashes.
|
|
2831
|
+
* Use [TextInput](forms-and-inputs.md#textinput) with `type="password"` when people enter a secret.
|
|
2832
|
+
|
|
2833
|
+
#### Start Masked
|
|
2834
|
+
|
|
2835
|
+
Keep the value hidden until someone presses Reveal. Copy works without a reveal, and anyone near the screen or in a screen share can read a revealed value.
|
|
2836
|
+
|
|
2837
|
+
* **`defaultRevealed`:** Set it only on a screen that exists to show the value, such as a key creation confirmation.
|
|
2838
|
+
* **Mask again:** Control `revealed` with `onRevealedChange` to mask the value again, such as when the tab is hidden or after a minute.
|
|
2839
|
+
|
|
2840
|
+
**Do:** Show the secret masked, with its name above it.
|
|
2841
|
+
|
|
2842
|
+
```tsx
|
|
2843
|
+
/** Do example for "Start Masked" on the SecretValue page: show the secret masked, with its name above it. @module */
|
|
2844
|
+
import { SecretValue, style } from '@tempoxyz/ds'
|
|
2845
|
+
|
|
2846
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2847
|
+
export function Demo() {
|
|
2848
|
+
return (
|
|
2849
|
+
<div {...styles.field()}>
|
|
2850
|
+
<span {...styles.label()}>Production API key</span>
|
|
2851
|
+
<SecretValue label="Production API key" value="tk_live_9fA2c81bE07d4c55a3e6" />
|
|
2852
|
+
</div>
|
|
2853
|
+
)
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
namespace styles {
|
|
2857
|
+
export const field = style({ display: 'grid', gap: '8', width: '100% !custom' })
|
|
2858
|
+
|
|
2859
|
+
export const label = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
2860
|
+
}
|
|
2861
|
+
```
|
|
2862
|
+
|
|
2863
|
+
**Don't:** Reveal a secret by default on a page people return to, such as a key list.
|
|
2864
|
+
|
|
2865
|
+
```tsx
|
|
2866
|
+
/**
|
|
2867
|
+
* Don't example for "Start Masked" on the SecretValue page.
|
|
2868
|
+
* Don't reveal a secret by default on a page people return to, such as a key list.
|
|
2869
|
+
* @module
|
|
2870
|
+
*/
|
|
2871
|
+
import { SecretValue, style } from '@tempoxyz/ds'
|
|
2872
|
+
|
|
2873
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2874
|
+
export function Demo() {
|
|
2875
|
+
return (
|
|
2876
|
+
<div {...styles.field()}>
|
|
2877
|
+
<span {...styles.label()}>Production API key</span>
|
|
2878
|
+
<SecretValue
|
|
2879
|
+
defaultRevealed
|
|
2880
|
+
label="Production API key"
|
|
2881
|
+
value="tk_live_9fA2c81bE07d4c55a3e6"
|
|
2882
|
+
/>
|
|
2883
|
+
</div>
|
|
2884
|
+
)
|
|
2885
|
+
}
|
|
2886
|
+
|
|
2887
|
+
namespace styles {
|
|
2888
|
+
export const field = style({ display: 'grid', gap: '8', width: '100% !custom' })
|
|
2889
|
+
|
|
2890
|
+
export const label = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
2891
|
+
}
|
|
2892
|
+
```
|
|
2893
|
+
|
|
2894
|
+
#### Name Every Secret
|
|
2895
|
+
|
|
2896
|
+
`label` sets the group's `aria-label`, which gives each button context. It is not visible. The mask is always 16 dots, so it can't tell keys apart either.
|
|
2897
|
+
|
|
2898
|
+
**Do:** Show what each key unlocks above it, with a creation or last used date.
|
|
2899
|
+
|
|
2900
|
+
```tsx
|
|
2901
|
+
/**
|
|
2902
|
+
* Do example for "Name Every Secret" on the SecretValue page.
|
|
2903
|
+
* Show what each key unlocks above it, with a creation or last used date.
|
|
2904
|
+
* @module
|
|
2905
|
+
*/
|
|
2906
|
+
import { SecretValue, style } from '@tempoxyz/ds'
|
|
2907
|
+
|
|
2908
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2909
|
+
export function Demo() {
|
|
2910
|
+
return (
|
|
2911
|
+
<div {...styles.list()}>
|
|
2912
|
+
<div {...styles.field()}>
|
|
2913
|
+
<div {...styles.header()}>
|
|
2914
|
+
<span {...styles.label()}>Production API key</span>
|
|
2915
|
+
<span {...styles.meta()}>Last used 2 hours ago</span>
|
|
2916
|
+
</div>
|
|
2917
|
+
<SecretValue label="Production API key" size="small" value="tk_live_9fA2c81bE07d4c55a3e6" />
|
|
2918
|
+
</div>
|
|
2919
|
+
<div {...styles.field()}>
|
|
2920
|
+
<div {...styles.header()}>
|
|
2921
|
+
<span {...styles.label()}>Staging API key</span>
|
|
2922
|
+
<span {...styles.meta()}>Created Oct 2</span>
|
|
2923
|
+
</div>
|
|
2924
|
+
<SecretValue label="Staging API key" size="small" value="tk_test_41bD7e0aC93f2d18b6c5" />
|
|
2925
|
+
</div>
|
|
2926
|
+
</div>
|
|
2927
|
+
)
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
namespace styles {
|
|
2931
|
+
export const field = style({ display: 'grid', gap: '8' })
|
|
2932
|
+
|
|
2933
|
+
export const header = style({
|
|
2934
|
+
alignItems: 'baseline',
|
|
2935
|
+
display: 'flex',
|
|
2936
|
+
gap: '12',
|
|
2937
|
+
justifyContent: 'space-between',
|
|
2938
|
+
})
|
|
2939
|
+
|
|
2940
|
+
export const label = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
2941
|
+
|
|
2942
|
+
export const list = style({ display: 'grid', gap: '16', width: '100% !custom' })
|
|
2943
|
+
|
|
2944
|
+
export const meta = style({ color: 'content.secondary', typography: 'body.b3' })
|
|
2945
|
+
}
|
|
2946
|
+
```
|
|
2947
|
+
|
|
2948
|
+
**Don't:** Leave people to tell keys apart by revealing them.
|
|
2949
|
+
|
|
2950
|
+
```tsx
|
|
2951
|
+
/**
|
|
2952
|
+
* Don't example for "Name Every Secret" on the SecretValue page.
|
|
2953
|
+
* Don't leave people to tell keys apart by revealing them.
|
|
2954
|
+
* @module
|
|
2955
|
+
*/
|
|
2956
|
+
import { SecretValue, style } from '@tempoxyz/ds'
|
|
2957
|
+
|
|
2958
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
2959
|
+
export function Demo() {
|
|
2960
|
+
return (
|
|
2961
|
+
<div {...styles.list()}>
|
|
2962
|
+
<SecretValue label="Production API key" size="small" value="tk_live_9fA2c81bE07d4c55a3e6" />
|
|
2963
|
+
<SecretValue label="Staging API key" size="small" value="tk_test_41bD7e0aC93f2d18b6c5" />
|
|
2964
|
+
</div>
|
|
2965
|
+
)
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
namespace styles {
|
|
2969
|
+
export const list = style({ display: 'grid', gap: '16', width: '100% !custom' })
|
|
2970
|
+
}
|
|
2971
|
+
```
|
|
2972
|
+
|
|
2973
|
+
#### Keep Each Secret on One Line
|
|
2974
|
+
|
|
2975
|
+
The value does not wrap, and a long revealed value scrolls horizontally.
|
|
2976
|
+
|
|
2977
|
+
**Do:** Give a recovery phrase of 12 or 24 words its own numbered layout, behind the same explicit
|
|
2978
|
+
reveal.
|
|
2979
|
+
|
|
2980
|
+
```tsx
|
|
2981
|
+
/**
|
|
2982
|
+
* Do example for "Keep Each Secret on One Line" on the SecretValue page.
|
|
2983
|
+
* Give a recovery phrase of 12 or 24 words its own numbered layout, behind the same explicit reveal.
|
|
2984
|
+
* @module
|
|
2985
|
+
*/
|
|
2986
|
+
import { style } from '@tempoxyz/ds'
|
|
2987
|
+
|
|
2988
|
+
const words = [
|
|
2989
|
+
'orbit',
|
|
2990
|
+
'maple',
|
|
2991
|
+
'ledger',
|
|
2992
|
+
'canyon',
|
|
2993
|
+
'velvet',
|
|
2994
|
+
'harbor',
|
|
2995
|
+
'quartz',
|
|
2996
|
+
'ember',
|
|
2997
|
+
'signal',
|
|
2998
|
+
'meadow',
|
|
2999
|
+
'falcon',
|
|
3000
|
+
'summit',
|
|
3001
|
+
] as const
|
|
3002
|
+
|
|
3003
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3004
|
+
export function Demo() {
|
|
3005
|
+
return (
|
|
3006
|
+
<div {...styles.field()}>
|
|
3007
|
+
<span {...styles.label()}>Recovery phrase</span>
|
|
3008
|
+
<ol {...styles.grid()}>
|
|
3009
|
+
{words.map((word, index) => (
|
|
3010
|
+
<li key={word} {...styles.word()}>
|
|
3011
|
+
<span {...styles.index()}>{index + 1}</span>
|
|
3012
|
+
{word}
|
|
3013
|
+
</li>
|
|
3014
|
+
))}
|
|
3015
|
+
</ol>
|
|
3016
|
+
</div>
|
|
3017
|
+
)
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
namespace styles {
|
|
3021
|
+
export const field = style({ display: 'grid', gap: '8', width: '100% !custom' })
|
|
3022
|
+
|
|
3023
|
+
export const grid = style({
|
|
3024
|
+
display: 'grid',
|
|
3025
|
+
gap: '8',
|
|
3026
|
+
gridTemplateColumns: 'repeat(3, 1fr) !custom',
|
|
3027
|
+
listStyle: 'none',
|
|
3028
|
+
margin: '0',
|
|
3029
|
+
padding: '0',
|
|
3030
|
+
})
|
|
3031
|
+
|
|
3032
|
+
export const index = style({ color: 'content.secondary', minWidth: '1.25rem !custom' })
|
|
3033
|
+
|
|
3034
|
+
export const label = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
3035
|
+
|
|
3036
|
+
export const word = style({
|
|
3037
|
+
backgroundColor: 'container.regular',
|
|
3038
|
+
borderRadius: '2xs',
|
|
3039
|
+
color: 'content.primary',
|
|
3040
|
+
display: 'flex',
|
|
3041
|
+
gap: '4',
|
|
3042
|
+
padding: '8',
|
|
3043
|
+
typography: 'mono.m1',
|
|
3044
|
+
})
|
|
3045
|
+
}
|
|
3046
|
+
```
|
|
3047
|
+
|
|
3048
|
+
**Don't:** Put a recovery phrase in one scrolling line.
|
|
3049
|
+
|
|
3050
|
+
```tsx
|
|
3051
|
+
/**
|
|
3052
|
+
* Don't example for "Keep Each Secret on One Line" on the SecretValue page.
|
|
3053
|
+
* Don't put a recovery phrase in one scrolling line.
|
|
3054
|
+
* @module
|
|
3055
|
+
*/
|
|
3056
|
+
import { SecretValue, style } from '@tempoxyz/ds'
|
|
3057
|
+
|
|
3058
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3059
|
+
export function Demo() {
|
|
3060
|
+
return (
|
|
3061
|
+
<div {...styles.field()}>
|
|
3062
|
+
<span {...styles.label()}>Recovery phrase</span>
|
|
3063
|
+
<SecretValue
|
|
3064
|
+
defaultRevealed
|
|
3065
|
+
label="Recovery phrase"
|
|
3066
|
+
value="orbit maple ledger canyon velvet harbor quartz ember signal meadow falcon summit"
|
|
3067
|
+
/>
|
|
3068
|
+
</div>
|
|
3069
|
+
)
|
|
3070
|
+
}
|
|
3071
|
+
|
|
3072
|
+
namespace styles {
|
|
3073
|
+
export const field = style({ display: 'grid', gap: '8', width: '100% !custom' })
|
|
3074
|
+
|
|
3075
|
+
export const label = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
3076
|
+
}
|
|
3077
|
+
```
|
|
3078
|
+
|
|
3079
|
+
### Content
|
|
3080
|
+
|
|
3081
|
+
* **Visibility:** If a key is shown once, write Store this key now. You can't view it again.
|
|
3082
|
+
* **Leaks:** Link to the replacement action, such as Rotate key.
|
|
3083
|
+
|
|
3084
|
+
### Accessibility
|
|
3085
|
+
|
|
3086
|
+
SecretValue renders a named `group` with a masked `<code>` value, a reveal toggle, and a copy button. Both buttons follow the [WAI-ARIA Authoring Practices button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/button/).
|
|
3087
|
+
|
|
3088
|
+
#### Semantics
|
|
3089
|
+
|
|
3090
|
+
* **Root (group):** Takes its name from the `label` prop.
|
|
3091
|
+
* **Value (16 dots):** Screen readers read the dots, never the secret. The mask hides the length and blocks selection.
|
|
3092
|
+
* **Reveal Button (aria-pressed):** A native button named "Reveal" that reports whether the secret is shown.
|
|
3093
|
+
* **Copy Button (button):** A native button named "Copy". It reads "Copied" for two seconds, and a polite status region announces each copy.
|
|
3094
|
+
* **Pointer Shortcut (click):** A click on the block copies without a reveal. Keyboard users use the copy button.
|
|
3095
|
+
|
|
3096
|
+
#### Keyboard
|
|
3097
|
+
|
|
3098
|
+
* **Move Between Buttons (Tab):** Moves focus to the reveal button, then to the copy button. The value takes no focus.
|
|
3099
|
+
* **Reveal or Copy (Enter or Space):** The reveal button shows or hides the secret. The copy button copies it. Focus stays on the pressed button.
|
|
3100
|
+
|
|
3101
|
+
#### Your Responsibilities
|
|
3102
|
+
|
|
3103
|
+
* **Allow Paste (SC 3.3.8):** Do not block paste where people use the secret. [Accessible authentication](https://www.w3.org/WAI/WCAG22/Understanding/accessible-authentication-minimum.html) relies on it.
|
|
3104
|
+
|
|
3105
|
+
### Related
|
|
3106
|
+
|
|
3107
|
+
[Snippet](data-display.md#snippet)
|
|
3108
|
+
|
|
3109
|
+
Use for values that aren't secret.
|
|
3110
|
+
|
|
3111
|
+
[CopyButton](actions.md#copybutton)
|
|
3112
|
+
|
|
3113
|
+
Use for copying beside your own layout.
|
|
3114
|
+
|
|
3115
|
+
[TextInput](forms-and-inputs.md#textinput)
|
|
3116
|
+
|
|
3117
|
+
Use for entering a secret.
|
|
3118
|
+
|
|
3119
|
+
[Destructive Actions](../patterns.md#destructive-actions)
|
|
3120
|
+
|
|
3121
|
+
Covers revoking and rotating keys.
|
|
3122
|
+
|
|
3123
|
+
[Tempo Console](../patterns.md#tempo-console)
|
|
3124
|
+
|
|
3125
|
+
Covers API key screens.
|
|
3126
|
+
|
|
3127
|
+
### Examples
|
|
3128
|
+
|
|
3129
|
+
#### Basic
|
|
3130
|
+
|
|
3131
|
+
```tsx
|
|
3132
|
+
import { SecretValue, style } from '@tempoxyz/ds'
|
|
3133
|
+
|
|
3134
|
+
export const fill = true
|
|
3135
|
+
export function Demo() {
|
|
3136
|
+
return (
|
|
3137
|
+
<SecretValue label="API key" value="sk_demo_4eC39HqLyjWDarjtT1zdp7dc" {...styles.value()} />
|
|
3138
|
+
)
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
namespace styles {
|
|
3142
|
+
export const value = style({ maxWidth: '28rem !custom' })
|
|
3143
|
+
}
|
|
3144
|
+
```
|
|
3145
|
+
|
|
3146
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/SecretValue/Basic.tsx)
|
|
3147
|
+
|
|
3148
|
+
#### Size
|
|
3149
|
+
|
|
3150
|
+
Set `size` to `small`, `medium` (default), or `large`.
|
|
3151
|
+
|
|
3152
|
+
```tsx
|
|
3153
|
+
import { SecretValue, style } from '@tempoxyz/ds'
|
|
3154
|
+
|
|
3155
|
+
export function Demo() {
|
|
3156
|
+
return (
|
|
3157
|
+
<div {...styles.column()}>
|
|
3158
|
+
{(['small', 'medium', 'large'] as const).map((size) => (
|
|
3159
|
+
<SecretValue
|
|
3160
|
+
key={size}
|
|
3161
|
+
label="API key"
|
|
3162
|
+
size={size}
|
|
3163
|
+
value="sk_demo_4eC39HqLyjWDarjtT1zdp7dc"
|
|
3164
|
+
/>
|
|
3165
|
+
))}
|
|
3166
|
+
</div>
|
|
3167
|
+
)
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
namespace styles {
|
|
3171
|
+
export const column = style({
|
|
3172
|
+
display: 'grid',
|
|
3173
|
+
gap: '12',
|
|
3174
|
+
gridTemplateColumns: 'minmax(0, 28rem) !custom',
|
|
3175
|
+
})
|
|
3176
|
+
}
|
|
3177
|
+
```
|
|
3178
|
+
|
|
3179
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/SecretValue/Size.tsx)
|
|
3180
|
+
|
|
3181
|
+
#### DefaultRevealed
|
|
3182
|
+
|
|
3183
|
+
Set `defaultRevealed` to start with the value shown.
|
|
3184
|
+
|
|
3185
|
+
```tsx
|
|
3186
|
+
import { SecretValue, style } from '@tempoxyz/ds'
|
|
3187
|
+
|
|
3188
|
+
export const fill = true
|
|
3189
|
+
export function Demo() {
|
|
3190
|
+
return (
|
|
3191
|
+
<SecretValue
|
|
3192
|
+
defaultRevealed
|
|
3193
|
+
label="API key"
|
|
3194
|
+
value="sk_demo_4eC39HqLyjWDarjtT1zdp7dc"
|
|
3195
|
+
{...styles.value()}
|
|
3196
|
+
/>
|
|
3197
|
+
)
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3200
|
+
namespace styles {
|
|
3201
|
+
export const value = style({ maxWidth: '28rem !custom' })
|
|
3202
|
+
}
|
|
3203
|
+
```
|
|
3204
|
+
|
|
3205
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/SecretValue/DefaultRevealed.tsx)
|
|
3206
|
+
|
|
3207
|
+
## Token
|
|
3208
|
+
|
|
3209
|
+
Shows which token an amount is in, and opens a picker to change it.
|
|
3210
|
+
|
|
3211
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/Token.tsx)
|
|
3212
|
+
|
|
3213
|
+
Figma: [Elements/Token](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-1266)
|
|
3214
|
+
|
|
3215
|
+
### Overview
|
|
3216
|
+
|
|
3217
|
+
A token renders a pill with a [TokenLogo](#tokenlogo) and the token's symbol. By default it is a button with a chevron that opens a token picker. Set `readOnly` for a static pill.
|
|
3218
|
+
|
|
3219
|
+
### Anatomy
|
|
3220
|
+
|
|
3221
|
+
Import the component and assemble its parts.
|
|
3222
|
+
|
|
3223
|
+
```tsx
|
|
3224
|
+
import { Token } from '@tempoxyz/ds'
|
|
3225
|
+
|
|
3226
|
+
<Token />
|
|
3227
|
+
```
|
|
3228
|
+
|
|
3229
|
+
### Guidelines
|
|
3230
|
+
|
|
3231
|
+
#### When to Use
|
|
3232
|
+
|
|
3233
|
+
* Name the token after the digits in an [AmountInput](forms-and-inputs.md#amountinput), and let a person change it.
|
|
3234
|
+
* Name a fixed token in a review or a receipt with `readOnly`.
|
|
3235
|
+
|
|
3236
|
+
#### When Not to Use
|
|
3237
|
+
|
|
3238
|
+
* Use [TokenLogo](#tokenlogo) for a logo beside a symbol in a list row.
|
|
3239
|
+
* Use [AssetChip](#assetchip) to list the assets a row supports.
|
|
3240
|
+
* Use [Select](forms-and-inputs.md#select) to choose a token in a form field with a label.
|
|
3241
|
+
|
|
3242
|
+
#### Show the Chevron Only on a Picker
|
|
3243
|
+
|
|
3244
|
+
The chevron tells people that the token opens a picker.
|
|
3245
|
+
|
|
3246
|
+
**Do:** Set `readOnly` in reviews and receipts, where the token can't change.
|
|
3247
|
+
|
|
3248
|
+
```tsx
|
|
3249
|
+
/**
|
|
3250
|
+
* Do example for "Show the Chevron Only on a Picker" on the Token page.
|
|
3251
|
+
* Render a read-only pill where the token can't change.
|
|
3252
|
+
* @module
|
|
3253
|
+
*/
|
|
3254
|
+
import { style, Token, TokenLogo } from '@tempoxyz/ds'
|
|
3255
|
+
|
|
3256
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3257
|
+
export function Demo() {
|
|
3258
|
+
return (
|
|
3259
|
+
<TokenLogo.Provider>
|
|
3260
|
+
<div {...styles.row()}>
|
|
3261
|
+
<span {...styles.amount()}>25.00</span>
|
|
3262
|
+
<Token address="0x20c0000000000000000000000000000000000000" readOnly symbol="pathUSD" />
|
|
3263
|
+
</div>
|
|
3264
|
+
</TokenLogo.Provider>
|
|
3265
|
+
)
|
|
3266
|
+
}
|
|
3267
|
+
|
|
3268
|
+
namespace styles {
|
|
3269
|
+
export const amount = style({ color: 'content.primary', typography: 'heading.h2' })
|
|
3270
|
+
|
|
3271
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
3272
|
+
}
|
|
3273
|
+
```
|
|
3274
|
+
|
|
3275
|
+
**Don't:** Show the chevron on a token that opens nothing.
|
|
3276
|
+
|
|
3277
|
+
```tsx
|
|
3278
|
+
/**
|
|
3279
|
+
* Don't example for "Show the Chevron Only on a Picker" on the Token page.
|
|
3280
|
+
* A chevron on a token that can't change promises a picker that never opens.
|
|
3281
|
+
* @module
|
|
3282
|
+
*/
|
|
3283
|
+
import { style, Token, TokenLogo } from '@tempoxyz/ds'
|
|
3284
|
+
|
|
3285
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3286
|
+
export function Demo() {
|
|
3287
|
+
return (
|
|
3288
|
+
<TokenLogo.Provider>
|
|
3289
|
+
<div {...styles.row()}>
|
|
3290
|
+
<span {...styles.amount()}>25.00</span>
|
|
3291
|
+
<Token address="0x20c0000000000000000000000000000000000000" symbol="pathUSD" />
|
|
3292
|
+
</div>
|
|
3293
|
+
</TokenLogo.Provider>
|
|
3294
|
+
)
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
namespace styles {
|
|
3298
|
+
export const amount = style({ color: 'content.primary', typography: 'heading.h2' })
|
|
3299
|
+
|
|
3300
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
3301
|
+
}
|
|
3302
|
+
```
|
|
3303
|
+
|
|
3304
|
+
#### Prefer the Address
|
|
3305
|
+
|
|
3306
|
+
* **Address (address):** Loads the logo directly. `symbol` still labels the pill.
|
|
3307
|
+
* **Symbol (symbol):** Resolves the logo through the token list first.
|
|
3308
|
+
|
|
3309
|
+
### Content
|
|
3310
|
+
|
|
3311
|
+
#### Use the Token's Symbol
|
|
3312
|
+
|
|
3313
|
+
Write the symbol as the token defines it, such as pathUSD or USDC.e. Keep amounts, network names, and verbs outside the pill.
|
|
3314
|
+
|
|
3315
|
+
### Accessibility
|
|
3316
|
+
|
|
3317
|
+
A token renders a native `<button>` built on Base UI Button, or a `<span>` when `readOnly`. The logo and the chevron are hidden from screen readers.
|
|
3318
|
+
|
|
3319
|
+
#### Semantics
|
|
3320
|
+
|
|
3321
|
+
* **Root (button):** The symbol names the button. A picker trigger adds popup state.
|
|
3322
|
+
* **Read-Only (readOnly):** Renders a span, so screen readers read the symbol as text.
|
|
3323
|
+
|
|
3324
|
+
#### Keyboard
|
|
3325
|
+
|
|
3326
|
+
* **Move Focus to the Token (Tab):** Moves focus to the token.
|
|
3327
|
+
* **Open the Picker (Enter or Space):** Opens the picker that the token triggers.
|
|
3328
|
+
|
|
3329
|
+
#### Your Responsibilities
|
|
3330
|
+
|
|
3331
|
+
* **Open a Picker (render):** Pass the token to a picker trigger's `render`. If nothing opens, set `readOnly`.
|
|
3332
|
+
* **Describe the Action (aria-label):** If the symbol alone doesn't say what the token does, add a label that keeps the symbol.
|
|
3333
|
+
|
|
3334
|
+
### Related
|
|
3335
|
+
|
|
3336
|
+
[TokenLogo](#tokenlogo)
|
|
3337
|
+
|
|
3338
|
+
Use for token logos.
|
|
3339
|
+
|
|
3340
|
+
[AmountInput](forms-and-inputs.md#amountinput)
|
|
3341
|
+
|
|
3342
|
+
Use for entering an amount beside a token.
|
|
3343
|
+
|
|
3344
|
+
[AssetChip](#assetchip)
|
|
3345
|
+
|
|
3346
|
+
Use for listing the assets a row supports.
|
|
3347
|
+
|
|
3348
|
+
[Dialog](overlays.md#dialog)
|
|
3349
|
+
|
|
3350
|
+
Use for a token picker.
|
|
3351
|
+
|
|
3352
|
+
### Examples
|
|
3353
|
+
|
|
3354
|
+
#### Basic
|
|
3355
|
+
|
|
3356
|
+
```tsx
|
|
3357
|
+
import { Token, TokenLogo } from '@tempoxyz/ds'
|
|
3358
|
+
|
|
3359
|
+
export function Demo() {
|
|
3360
|
+
return (
|
|
3361
|
+
<TokenLogo.Provider>
|
|
3362
|
+
<Token address="0x20c0000000000000000000000000000000000000" symbol="pathUSD" />
|
|
3363
|
+
</TokenLogo.Provider>
|
|
3364
|
+
)
|
|
3365
|
+
}
|
|
3366
|
+
```
|
|
3367
|
+
|
|
3368
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Token/Basic.tsx)
|
|
3369
|
+
|
|
3370
|
+
#### Read-Only
|
|
3371
|
+
|
|
3372
|
+
Set `readOnly` to render a span without the chevron, for reviews and receipts.
|
|
3373
|
+
|
|
3374
|
+
```tsx
|
|
3375
|
+
import { Token, TokenLogo } from '@tempoxyz/ds'
|
|
3376
|
+
|
|
3377
|
+
export function Demo() {
|
|
3378
|
+
return (
|
|
3379
|
+
<TokenLogo.Provider>
|
|
3380
|
+
<Token address="0x20c0000000000000000000000000000000000000" readOnly symbol="pathUSD" />
|
|
3381
|
+
</TokenLogo.Provider>
|
|
3382
|
+
)
|
|
3383
|
+
}
|
|
3384
|
+
```
|
|
3385
|
+
|
|
3386
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Token/ReadOnly.tsx)
|
|
3387
|
+
|
|
3388
|
+
#### Picker
|
|
3389
|
+
|
|
3390
|
+
Pass the token to a trigger's `render`, such as a [Dialog](overlays.md#dialog) trigger, to open a token picker.
|
|
3391
|
+
|
|
3392
|
+
```tsx
|
|
3393
|
+
import { Dialog, style, Token, TokenLogo } from '@tempoxyz/ds'
|
|
3394
|
+
import { useState } from 'react'
|
|
3395
|
+
|
|
3396
|
+
const tokens = [
|
|
3397
|
+
['pathUSD', '0x20c0000000000000000000000000000000000000'],
|
|
3398
|
+
['USDC.e', '0x20c000000000000000000000b9537d11c60e8b50'],
|
|
3399
|
+
['USDT0', '0x20c00000000000000000000014f22ca97301eb73'],
|
|
3400
|
+
] as const
|
|
3401
|
+
|
|
3402
|
+
export function Demo() {
|
|
3403
|
+
const [selected, setSelected] = useState<(typeof tokens)[number]>(tokens[0])
|
|
3404
|
+
|
|
3405
|
+
return (
|
|
3406
|
+
<TokenLogo.Provider>
|
|
3407
|
+
<Dialog.Root>
|
|
3408
|
+
<Dialog.Trigger render={<Token address={selected[1]} symbol={selected[0]} />} />
|
|
3409
|
+
<Dialog.Popup closeButton>
|
|
3410
|
+
<Dialog.Header>
|
|
3411
|
+
<Dialog.Title>Select token</Dialog.Title>
|
|
3412
|
+
</Dialog.Header>
|
|
3413
|
+
<Dialog.Body>
|
|
3414
|
+
<div {...styles.list()}>
|
|
3415
|
+
{tokens.map((token) => (
|
|
3416
|
+
<Dialog.Close
|
|
3417
|
+
key={token[1]}
|
|
3418
|
+
onClick={() => setSelected(token)}
|
|
3419
|
+
render={<button type="button" {...styles.option()} />}
|
|
3420
|
+
>
|
|
3421
|
+
<TokenLogo address={token[1]} size="large" />
|
|
3422
|
+
{token[0]}
|
|
3423
|
+
</Dialog.Close>
|
|
3424
|
+
))}
|
|
3425
|
+
</div>
|
|
3426
|
+
</Dialog.Body>
|
|
3427
|
+
</Dialog.Popup>
|
|
3428
|
+
</Dialog.Root>
|
|
3429
|
+
</TokenLogo.Provider>
|
|
3430
|
+
)
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
namespace styles {
|
|
3434
|
+
export const list = style({ display: 'grid', gap: '4' })
|
|
3435
|
+
|
|
3436
|
+
export const option = style({
|
|
3437
|
+
alignItems: 'center',
|
|
3438
|
+
backgroundColor: 'transparent !custom',
|
|
3439
|
+
border: 'none !custom',
|
|
3440
|
+
borderRadius: 'xs',
|
|
3441
|
+
color: 'content.primary',
|
|
3442
|
+
cursor: 'pointer',
|
|
3443
|
+
display: 'flex',
|
|
3444
|
+
gap: '12',
|
|
3445
|
+
padding: '12',
|
|
3446
|
+
textAlign: 'start',
|
|
3447
|
+
typography: 'body.b2Strong',
|
|
3448
|
+
selectors: { '&:hover': { backgroundColor: 'container.regular' } },
|
|
3449
|
+
})
|
|
3450
|
+
}
|
|
3451
|
+
```
|
|
3452
|
+
|
|
3453
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/Token/Picker.tsx)
|
|
3454
|
+
|
|
3455
|
+
## TokenLogo
|
|
3456
|
+
|
|
3457
|
+
Shows a token logo by contract address or symbol.
|
|
3458
|
+
|
|
3459
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/TokenLogo.tsx)
|
|
3460
|
+
|
|
3461
|
+
Figma: [Elements/Logo](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-2546)
|
|
3462
|
+
|
|
3463
|
+
### Overview
|
|
3464
|
+
|
|
3465
|
+
A token logo renders a stablecoin's artwork, found by contract address or symbol, with its brand colors. Its `alt` is empty unless set, which suits a logo beside the token name.
|
|
3466
|
+
|
|
3467
|
+
### Anatomy
|
|
3468
|
+
|
|
3469
|
+
Import the component and assemble its parts.
|
|
3470
|
+
|
|
3471
|
+
```tsx
|
|
3472
|
+
import { TokenLogo } from '@tempoxyz/ds'
|
|
3473
|
+
|
|
3474
|
+
<TokenLogo.Provider>
|
|
3475
|
+
<TokenLogo />
|
|
3476
|
+
</TokenLogo.Provider>
|
|
3477
|
+
```
|
|
3478
|
+
|
|
3479
|
+
### Guidelines
|
|
3480
|
+
|
|
3481
|
+
#### When to Use
|
|
3482
|
+
|
|
3483
|
+
* Show a token's logo beside its symbol in balance lists, token selectors, payment reviews, and activity rows.
|
|
3484
|
+
|
|
3485
|
+
#### When Not to Use
|
|
3486
|
+
|
|
3487
|
+
* Use [Token](#token-1) to show which token an amount is in, and to let a person change it.
|
|
3488
|
+
* Use [Identicon](#identicon) for an account address.
|
|
3489
|
+
* Use [Avatar](data-display.md#avatar) for people and organizations.
|
|
3490
|
+
* Use [IconTile](data-display.md#icontile) for a feature or category icon.
|
|
3491
|
+
* Use [NetworkLogo](#networklogo) for the chain a token lives on.
|
|
3492
|
+
* Use [AssetChip](#assetchip) to list the assets a row supports.
|
|
3493
|
+
|
|
3494
|
+
#### Pair the Icon With the Symbol
|
|
3495
|
+
|
|
3496
|
+
Many token icons look alike, and an unknown token can copy a well-known icon.
|
|
3497
|
+
|
|
3498
|
+
**Do:** Show the symbol beside each token icon.
|
|
3499
|
+
|
|
3500
|
+
```tsx
|
|
3501
|
+
/**
|
|
3502
|
+
* Do example for "Pair the Icon With the Symbol" on the TokenLogo page.
|
|
3503
|
+
* Show the symbol beside each token icon.
|
|
3504
|
+
* @module
|
|
3505
|
+
*/
|
|
3506
|
+
import { style, TokenLogo } from '@tempoxyz/ds'
|
|
3507
|
+
|
|
3508
|
+
const tokens = [
|
|
3509
|
+
['pathUSD', '0x20c0000000000000000000000000000000000000'],
|
|
3510
|
+
['USDC.e', '0x20c000000000000000000000b9537d11c60e8b50'],
|
|
3511
|
+
['EURC.e', '0x20c0000000000000000000001621e21f71cf12fb'],
|
|
3512
|
+
] as const
|
|
3513
|
+
|
|
3514
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3515
|
+
export function Demo() {
|
|
3516
|
+
return (
|
|
3517
|
+
<TokenLogo.Provider>
|
|
3518
|
+
<div {...styles.list()}>
|
|
3519
|
+
{tokens.map(([symbol, address]) => (
|
|
3520
|
+
<div key={address} {...styles.row()}>
|
|
3521
|
+
<TokenLogo address={address} />
|
|
3522
|
+
<span {...styles.symbol()}>{symbol}</span>
|
|
3523
|
+
</div>
|
|
3524
|
+
))}
|
|
3525
|
+
</div>
|
|
3526
|
+
</TokenLogo.Provider>
|
|
3527
|
+
)
|
|
3528
|
+
}
|
|
3529
|
+
|
|
3530
|
+
namespace styles {
|
|
3531
|
+
export const list = style({ display: 'grid', gap: '12' })
|
|
3532
|
+
|
|
3533
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
3534
|
+
|
|
3535
|
+
export const symbol = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
3536
|
+
}
|
|
3537
|
+
```
|
|
3538
|
+
|
|
3539
|
+
**Don't:** Ask people to tell tokens apart by icon alone.
|
|
3540
|
+
|
|
3541
|
+
```tsx
|
|
3542
|
+
/**
|
|
3543
|
+
* Don't example for "Pair the Icon With the Symbol" on the TokenLogo page.
|
|
3544
|
+
* Don't ask people to tell tokens apart by icon alone.
|
|
3545
|
+
* @module
|
|
3546
|
+
*/
|
|
3547
|
+
import { style, TokenLogo } from '@tempoxyz/ds'
|
|
3548
|
+
|
|
3549
|
+
const addresses = [
|
|
3550
|
+
'0x20c0000000000000000000000000000000000000',
|
|
3551
|
+
'0x20c000000000000000000000b9537d11c60e8b50',
|
|
3552
|
+
'0x20c0000000000000000000001621e21f71cf12fb',
|
|
3553
|
+
] as const
|
|
3554
|
+
|
|
3555
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3556
|
+
export function Demo() {
|
|
3557
|
+
return (
|
|
3558
|
+
<TokenLogo.Provider>
|
|
3559
|
+
<div {...styles.row()}>
|
|
3560
|
+
{addresses.map((address) => (
|
|
3561
|
+
<TokenLogo address={address} key={address} />
|
|
3562
|
+
))}
|
|
3563
|
+
</div>
|
|
3564
|
+
</TokenLogo.Provider>
|
|
3565
|
+
)
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
namespace styles {
|
|
3569
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
3570
|
+
}
|
|
3571
|
+
```
|
|
3572
|
+
|
|
3573
|
+
#### Prefer the Address
|
|
3574
|
+
|
|
3575
|
+
* **Address (address):** Use it when you have it. It loads the image directly and names one contract.
|
|
3576
|
+
* **Symbol (symbol):** Resolves through the token list first, which adds a request. Different tokens can share a symbol.
|
|
3577
|
+
* **Lists (TokenLogo.Provider):** Wrap lists so tokens share one lookup per symbol and a default `chainId`.
|
|
3578
|
+
|
|
3579
|
+
Pass `resolveSrc` or `resolveAddress` to `TokenLogo.Provider` to load icons or addresses from your own source.
|
|
3580
|
+
|
|
3581
|
+
#### Show Unknown Tokens as Unknown
|
|
3582
|
+
|
|
3583
|
+
A gray circle renders while an icon loads or after it fails.
|
|
3584
|
+
|
|
3585
|
+
**Do:** Show the address in a [Hex](#hex) beside the symbol of a token that isn't on the
|
|
3586
|
+
list.
|
|
3587
|
+
|
|
3588
|
+
```tsx
|
|
3589
|
+
/**
|
|
3590
|
+
* Do example for "Show Unknown Tokens as Unknown" on the TokenLogo page.
|
|
3591
|
+
* Show the address in a Hex beside the symbol of a token that isn't on the list.
|
|
3592
|
+
* @module
|
|
3593
|
+
*/
|
|
3594
|
+
import { Hex, style, TokenLogo } from '@tempoxyz/ds'
|
|
3595
|
+
|
|
3596
|
+
const address = '0x20c00000000000000000000098a3f2c1e5d70b44'
|
|
3597
|
+
|
|
3598
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3599
|
+
export function Demo() {
|
|
3600
|
+
return (
|
|
3601
|
+
<div {...styles.row()}>
|
|
3602
|
+
<TokenLogo address={address} />
|
|
3603
|
+
<div {...styles.text()}>
|
|
3604
|
+
<span {...styles.symbol()}>USDC</span>
|
|
3605
|
+
<Hex size="small" value={address} />
|
|
3606
|
+
</div>
|
|
3607
|
+
</div>
|
|
3608
|
+
)
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
namespace styles {
|
|
3612
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12', minWidth: '0' })
|
|
3613
|
+
|
|
3614
|
+
export const symbol = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
3615
|
+
|
|
3616
|
+
export const text = style({ display: 'grid', gap: '4', minWidth: '0' })
|
|
3617
|
+
}
|
|
3618
|
+
```
|
|
3619
|
+
|
|
3620
|
+
**Don't:** Show only the symbol. Any token can claim it.
|
|
3621
|
+
|
|
3622
|
+
```tsx
|
|
3623
|
+
/**
|
|
3624
|
+
* Don't example for "Show Unknown Tokens as Unknown" on the TokenLogo page.
|
|
3625
|
+
* Don't show only the symbol. Any token can claim it.
|
|
3626
|
+
* @module
|
|
3627
|
+
*/
|
|
3628
|
+
import { style, TokenLogo } from '@tempoxyz/ds'
|
|
3629
|
+
|
|
3630
|
+
const address = '0x20c00000000000000000000098a3f2c1e5d70b44'
|
|
3631
|
+
|
|
3632
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
3633
|
+
export function Demo() {
|
|
3634
|
+
return (
|
|
3635
|
+
<div {...styles.row()}>
|
|
3636
|
+
<TokenLogo address={address} />
|
|
3637
|
+
<span {...styles.symbol()}>USDC</span>
|
|
3638
|
+
</div>
|
|
3639
|
+
)
|
|
3640
|
+
}
|
|
3641
|
+
|
|
3642
|
+
namespace styles {
|
|
3643
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
3644
|
+
|
|
3645
|
+
export const symbol = style({ color: 'content.primary', typography: 'body.b2Strong' })
|
|
3646
|
+
}
|
|
3647
|
+
```
|
|
3648
|
+
|
|
3649
|
+
#### Match Size to the Context
|
|
3650
|
+
|
|
3651
|
+
* **Small (16px):** Inline beside an amount.
|
|
3652
|
+
* **Medium (20px):** The default, and the logo in a [Token](#token-1).
|
|
3653
|
+
* **Large (32px):** In asset rows and token pickers.
|
|
3654
|
+
|
|
3655
|
+
### Accessibility
|
|
3656
|
+
|
|
3657
|
+
A token logo renders a native `<img>`, decorative by default. It is not interactive and takes no focus.
|
|
3658
|
+
|
|
3659
|
+
#### Semantics
|
|
3660
|
+
|
|
3661
|
+
* **Root (img):** Has empty alt text by default, so screen readers skip it beside a visible name.
|
|
3662
|
+
* **Loading and Errors:** Renders a gray circle while loading or after an error. Text must identify the token.
|
|
3663
|
+
* **Data Status (data-status):** Reports `loading`, `loaded`, or `error` for styling. Screen readers don't announce it.
|
|
3664
|
+
|
|
3665
|
+
#### Your Responsibilities
|
|
3666
|
+
|
|
3667
|
+
* **Name a Standalone Icon (alt):** If the icon stands alone, such as in an icon-only selector, pass the token name.
|
|
3668
|
+
|
|
3669
|
+
### Related
|
|
3670
|
+
|
|
3671
|
+
[Amount](#amount)
|
|
3672
|
+
|
|
3673
|
+
Use for token amounts.
|
|
3674
|
+
|
|
3675
|
+
[Token](#token-1)
|
|
3676
|
+
|
|
3677
|
+
Use for a token pill that labels or picks a token.
|
|
3678
|
+
|
|
3679
|
+
[AssetChip](#assetchip)
|
|
3680
|
+
|
|
3681
|
+
Use for listing the assets a row supports.
|
|
3682
|
+
|
|
3683
|
+
[NetworkLogo](#networklogo)
|
|
3684
|
+
|
|
3685
|
+
Use for the chain a token lives on.
|
|
3686
|
+
|
|
3687
|
+
[Identicon](#identicon)
|
|
3688
|
+
|
|
3689
|
+
Use for account addresses.
|
|
3690
|
+
|
|
3691
|
+
[Avatar](data-display.md#avatar)
|
|
3692
|
+
|
|
3693
|
+
Use for people and organizations.
|
|
3694
|
+
|
|
3695
|
+
[Select](forms-and-inputs.md#select)
|
|
3696
|
+
|
|
3697
|
+
Use for token selectors.
|
|
3698
|
+
|
|
3699
|
+
[Blockchain Values](../patterns.md#blockchain-values)
|
|
3700
|
+
|
|
3701
|
+
Covers tokens and addresses.
|
|
3702
|
+
|
|
3703
|
+
### Examples
|
|
3704
|
+
|
|
3705
|
+
#### Basic
|
|
3706
|
+
|
|
3707
|
+
```tsx
|
|
3708
|
+
import { style, TokenLogo } from '@tempoxyz/ds'
|
|
3709
|
+
|
|
3710
|
+
export function Demo() {
|
|
3711
|
+
return (
|
|
3712
|
+
<TokenLogo.Provider>
|
|
3713
|
+
<div {...styles.row()}>
|
|
3714
|
+
<TokenLogo address="0x20c0000000000000000000000000000000000000" />
|
|
3715
|
+
pathUSD
|
|
3716
|
+
</div>
|
|
3717
|
+
</TokenLogo.Provider>
|
|
3718
|
+
)
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3721
|
+
namespace styles {
|
|
3722
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
3723
|
+
}
|
|
3724
|
+
```
|
|
3725
|
+
|
|
3726
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/TokenLogo/Basic.tsx)
|
|
3727
|
+
|
|
3728
|
+
#### Size
|
|
3729
|
+
|
|
3730
|
+
Set `size` to `small` (16px), `medium` (20px, default), or `large` (32px).
|
|
3731
|
+
|
|
3732
|
+
```tsx
|
|
3733
|
+
import { style, TokenLogo } from '@tempoxyz/ds'
|
|
3734
|
+
|
|
3735
|
+
const tokens = [
|
|
3736
|
+
['pathUSD', '0x20c0000000000000000000000000000000000000'],
|
|
3737
|
+
['USDC.e', '0x20c000000000000000000000b9537d11c60e8b50'],
|
|
3738
|
+
['EURC.e', '0x20c0000000000000000000001621e21f71cf12fb'],
|
|
3739
|
+
['USDT0', '0x20c00000000000000000000014f22ca97301eb73'],
|
|
3740
|
+
['frxUSD', '0x20c0000000000000000000003554d28269e0f3c2'],
|
|
3741
|
+
] as const
|
|
3742
|
+
|
|
3743
|
+
export function Demo() {
|
|
3744
|
+
return (
|
|
3745
|
+
<TokenLogo.Provider>
|
|
3746
|
+
<div {...styles.grid()}>
|
|
3747
|
+
{tokens.map(([label, address]) => (
|
|
3748
|
+
<div key={address} {...styles.row()}>
|
|
3749
|
+
{(['small', 'medium', 'large'] as const).map((size) => (
|
|
3750
|
+
<TokenLogo address={address} key={size} size={size} />
|
|
3751
|
+
))}
|
|
3752
|
+
{label}
|
|
3753
|
+
</div>
|
|
3754
|
+
))}
|
|
3755
|
+
</div>
|
|
3756
|
+
</TokenLogo.Provider>
|
|
3757
|
+
)
|
|
3758
|
+
}
|
|
3759
|
+
|
|
3760
|
+
namespace styles {
|
|
3761
|
+
export const grid = style({ display: 'grid', gap: '12' })
|
|
3762
|
+
|
|
3763
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
3764
|
+
}
|
|
3765
|
+
```
|
|
3766
|
+
|
|
3767
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/TokenLogo/Size.tsx)
|
|
3768
|
+
|
|
3769
|
+
#### Symbol
|
|
3770
|
+
|
|
3771
|
+
Pass `symbol` instead of `address` to resolve the token through the token list.
|
|
3772
|
+
|
|
3773
|
+
```tsx
|
|
3774
|
+
import { style, TokenLogo } from '@tempoxyz/ds'
|
|
3775
|
+
|
|
3776
|
+
export function Demo() {
|
|
3777
|
+
return (
|
|
3778
|
+
<TokenLogo.Provider>
|
|
3779
|
+
<div {...styles.row()}>
|
|
3780
|
+
<TokenLogo size="large" symbol="pathUSD" />
|
|
3781
|
+
By symbol: pathUSD
|
|
3782
|
+
</div>
|
|
3783
|
+
</TokenLogo.Provider>
|
|
3784
|
+
)
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
namespace styles {
|
|
3788
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
3789
|
+
}
|
|
3790
|
+
```
|
|
3791
|
+
|
|
3792
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/TokenLogo/Symbol.tsx)
|
|
3793
|
+
|
|
3794
|
+
#### Fallback
|
|
3795
|
+
|
|
3796
|
+
An unknown address or symbol renders a placeholder.
|
|
3797
|
+
|
|
3798
|
+
```tsx
|
|
3799
|
+
import { style, TokenLogo } from '@tempoxyz/ds'
|
|
3800
|
+
|
|
3801
|
+
export function Demo() {
|
|
3802
|
+
return (
|
|
3803
|
+
<TokenLogo.Provider>
|
|
3804
|
+
<div {...styles.grid()}>
|
|
3805
|
+
<div {...styles.row()}>
|
|
3806
|
+
<TokenLogo address="0x0000000000000000000000000000000000000001" size="large" />
|
|
3807
|
+
Unknown address (service placeholder)
|
|
3808
|
+
</div>
|
|
3809
|
+
<div {...styles.row()}>
|
|
3810
|
+
<TokenLogo size="large" symbol="UNKNOWN" />
|
|
3811
|
+
Unknown symbol (fallback)
|
|
3812
|
+
</div>
|
|
3813
|
+
</div>
|
|
3814
|
+
</TokenLogo.Provider>
|
|
3815
|
+
)
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
namespace styles {
|
|
3819
|
+
export const grid = style({ display: 'grid', gap: '12' })
|
|
3820
|
+
|
|
3821
|
+
export const row = style({ alignItems: 'center', display: 'flex', gap: '12' })
|
|
3822
|
+
}
|
|
3823
|
+
```
|
|
3824
|
+
|
|
3825
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/TokenLogo/Fallback.tsx)
|