Skip to content

Commit 3d5eede

Browse files
committed
chore: address PR comments
1 parent 3781e5b commit 3d5eede

6 files changed

Lines changed: 30 additions & 20 deletions

File tree

packages/ui-components/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# UI Components
22

3+
Reusable UI Components for [Agoric](https://agoric.com) [Dapps](https://agoric.com/documentation/dapps/), built with [React](https://reactjs.org) and [MaterialUI](https://materialui.com).
4+
35
## NatAmountInput
46

5-
A [MaterialUI TextField
7+
A [React](https://reactjs.org) [MaterialUI TextField
68
Input](https://material-ui.com/api/text-field/) which allows the user
79
to enter a `Nat`. Handles `decimalPlaces` appropriately. This is a
810
controlled component.

packages/ui-components/jsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file can contain .js-specific Typescript compiler config.
22
{
33
"compilerOptions": {
4-
"target": "es2020",
4+
"target": "esnext",
55

66
"noEmit": true,
77
/*

packages/ui-components/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "ui-components",
2+
"name": "@agoric/ui-components",
33
"version": "0.0.1",
44
"description": "Reusable UI Components for Agoric Dapps, built with React and MaterialUI",
5-
"main": "dist/index.js",
5+
"main": "src/index.js",
66
"peerDependencies": {
77
"@agoric/assert": "^0.2.3",
88
"@agoric/ertp": "^0.10.0",

packages/ui-components/src/display/display.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { stringifySet } from './setValue/stringifySet';
1111
/**
1212
*
1313
* @param {string} str - string to parse as a value
14-
* @param {AmountMathKind=} mathKind - mathKind of the value
15-
* @param {number=} decimalPlaces - places to move the decimal to the left
14+
* @param {AmountMathKind} [mathKind] - mathKind of the value
15+
* @param {number} [decimalPlaces] - places to move the decimal to the left
1616
* @returns {Value}
1717
*/
1818
export const parseAsValue = (
@@ -26,14 +26,14 @@ export const parseAsValue = (
2626
if (mathKind === MathKind.SET) {
2727
return parseAsSet(str);
2828
}
29-
assert.fail(details`MathKind must be NAT or SET`);
29+
assert.fail(details`MathKind ${mathKind} must be NAT or SET`);
3030
};
3131

3232
/**
3333
* @param {string} str - string to parse as a value
3434
* @param {Brand} brand - brand to use in the amount
35-
* @param {AmountMathKind=} mathKind - mathKind of the value
36-
* @param {number=} decimalPlaces - places to move the decimal to the left
35+
* @param {AmountMathKind} [mathKind] - mathKind of the value
36+
* @param {number} [decimalPlaces] - places to move the decimal to the left
3737
* @returns {Amount}
3838
*/
3939
export const parseAsAmount = (
@@ -48,10 +48,10 @@ export const parseAsAmount = (
4848
/**
4949
*
5050
* @param {Value} value - value to stringify
51-
* @param {AmountMathKind=} mathKind - mathKind of the value
52-
* @param {number=} decimalPlaces - places to move the decimal to the
51+
* @param {AmountMathKind} [mathKind] - mathKind of the value
52+
* @param {number} [decimalPlaces] - places to move the decimal to the
5353
* right in the string
54-
* @param {number=} placesToShow - places after the decimal to show
54+
* @param {number} [placesToShow] - places after the decimal to show
5555
* @returns {string}
5656
*/
5757
export const stringifyValue = (
@@ -68,7 +68,7 @@ export const stringifyValue = (
6868
// @ts-ignore Value is a SetValue
6969
return stringifySet(value);
7070
}
71-
assert.fail(details`MathKind must be NAT or SET`);
71+
assert.fail(details`MathKind ${mathKind} must be NAT or SET`);
7272
};
7373

7474
/**
@@ -92,10 +92,10 @@ export const stringifyPurseValue = purse => {
9292
* Stringify the value in an amount
9393
*
9494
* @param {Amount} amount
95-
* @param {AmountMathKind=} mathKind - mathKind of the value
96-
* @param {number=} decimalPlaces - places to move the decimal to the
95+
* @param {AmountMathKind} [mathKind] - mathKind of the value
96+
* @param {number} [decimalPlaces] - places to move the decimal to the
9797
* right in the string
98-
* @param {number=} placesToShow - places after the decimal to show
98+
* @param {number} [placesToShow] - places after the decimal to show
9999
* @returns {string}
100100
*/
101101
export function stringifyAmountValue(

packages/ui-components/src/display/natValue/parseAsNat.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ import { captureNum } from './captureNum';
77
import { roundToDecimalPlaces } from './roundToDecimalPlaces';
88

99
/**
10-
* Parse a string as a Nat, given displayInfo such as `decimalPlaces`,
11-
* the number of places to move the decimal over to create an integer
10+
* Parse a string as a Nat, using `decimalPlaces`, the number of
11+
* places to move the decimal over to the right to create an integer.
12+
* For example, "3.00" dollars turns into 300n cents with
13+
* decimalPlaces = 2.
14+
*
15+
* Note that if places beyond the decimalPlaces are specified, the
16+
* number is rounded to the floor. For instance, "3.009" dollars is
17+
* still 300n cents with decimalPlaces =2 because the thousandths place is dropped.
18+
*
19+
* In the future, we may add a parameter to change the rounding rules.
1220
*
1321
* @param {string} str
1422
* @param {number} decimalPlaces

packages/ui-components/src/display/natValue/stringifyNat.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const CONVENTIONAL_DECIMAL_PLACES = 2;
44

55
/**
66
* @param {NatValue} natValue
7-
* @param {number=} decimalPlaces
8-
* @param {number=} placesToShow
7+
* @param {number} [decimalPlaces]
8+
* @param {number} [placesToShow]
99
* @returns {string}
1010
*/
1111
export const stringifyNat = (

0 commit comments

Comments
 (0)