Skip to content

Commit

Permalink
chore: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
katelynsills committed Mar 22, 2021
1 parent 3781e5b commit 3d5eede
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 20 deletions.
4 changes: 3 additions & 1 deletion packages/ui-components/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# UI Components

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).

## NatAmountInput

A [MaterialUI TextField
A [React](https://reactjs.org) [MaterialUI TextField
Input](https://material-ui.com/api/text-field/) which allows the user
to enter a `Nat`. Handles `decimalPlaces` appropriately. This is a
controlled component.
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-components/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "es2020",
"target": "esnext",

"noEmit": true,
/*
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-components/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "ui-components",
"name": "@agoric/ui-components",
"version": "0.0.1",
"description": "Reusable UI Components for Agoric Dapps, built with React and MaterialUI",
"main": "dist/index.js",
"main": "src/index.js",
"peerDependencies": {
"@agoric/assert": "^0.2.3",
"@agoric/ertp": "^0.10.0",
Expand Down
24 changes: 12 additions & 12 deletions packages/ui-components/src/display/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { stringifySet } from './setValue/stringifySet';
/**
*
* @param {string} str - string to parse as a value
* @param {AmountMathKind=} mathKind - mathKind of the value
* @param {number=} decimalPlaces - places to move the decimal to the left
* @param {AmountMathKind} [mathKind] - mathKind of the value
* @param {number} [decimalPlaces] - places to move the decimal to the left
* @returns {Value}
*/
export const parseAsValue = (
Expand All @@ -26,14 +26,14 @@ export const parseAsValue = (
if (mathKind === MathKind.SET) {
return parseAsSet(str);
}
assert.fail(details`MathKind must be NAT or SET`);
assert.fail(details`MathKind ${mathKind} must be NAT or SET`);
};

/**
* @param {string} str - string to parse as a value
* @param {Brand} brand - brand to use in the amount
* @param {AmountMathKind=} mathKind - mathKind of the value
* @param {number=} decimalPlaces - places to move the decimal to the left
* @param {AmountMathKind} [mathKind] - mathKind of the value
* @param {number} [decimalPlaces] - places to move the decimal to the left
* @returns {Amount}
*/
export const parseAsAmount = (
Expand All @@ -48,10 +48,10 @@ export const parseAsAmount = (
/**
*
* @param {Value} value - value to stringify
* @param {AmountMathKind=} mathKind - mathKind of the value
* @param {number=} decimalPlaces - places to move the decimal to the
* @param {AmountMathKind} [mathKind] - mathKind of the value
* @param {number} [decimalPlaces] - places to move the decimal to the
* right in the string
* @param {number=} placesToShow - places after the decimal to show
* @param {number} [placesToShow] - places after the decimal to show
* @returns {string}
*/
export const stringifyValue = (
Expand All @@ -68,7 +68,7 @@ export const stringifyValue = (
// @ts-ignore Value is a SetValue
return stringifySet(value);
}
assert.fail(details`MathKind must be NAT or SET`);
assert.fail(details`MathKind ${mathKind} must be NAT or SET`);
};

/**
Expand All @@ -92,10 +92,10 @@ export const stringifyPurseValue = purse => {
* Stringify the value in an amount
*
* @param {Amount} amount
* @param {AmountMathKind=} mathKind - mathKind of the value
* @param {number=} decimalPlaces - places to move the decimal to the
* @param {AmountMathKind} [mathKind] - mathKind of the value
* @param {number} [decimalPlaces] - places to move the decimal to the
* right in the string
* @param {number=} placesToShow - places after the decimal to show
* @param {number} [placesToShow] - places after the decimal to show
* @returns {string}
*/
export function stringifyAmountValue(
Expand Down
12 changes: 10 additions & 2 deletions packages/ui-components/src/display/natValue/parseAsNat.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ import { captureNum } from './captureNum';
import { roundToDecimalPlaces } from './roundToDecimalPlaces';

/**
* Parse a string as a Nat, given displayInfo such as `decimalPlaces`,
* the number of places to move the decimal over to create an integer
* Parse a string as a Nat, using `decimalPlaces`, the number of
* places to move the decimal over to the right to create an integer.
* For example, "3.00" dollars turns into 300n cents with
* decimalPlaces = 2.
*
* Note that if places beyond the decimalPlaces are specified, the
* number is rounded to the floor. For instance, "3.009" dollars is
* still 300n cents with decimalPlaces =2 because the thousandths place is dropped.
*
* In the future, we may add a parameter to change the rounding rules.
*
* @param {string} str
* @param {number} decimalPlaces
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-components/src/display/natValue/stringifyNat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const CONVENTIONAL_DECIMAL_PLACES = 2;

/**
* @param {NatValue} natValue
* @param {number=} decimalPlaces
* @param {number=} placesToShow
* @param {number} [decimalPlaces]
* @param {number} [placesToShow]
* @returns {string}
*/
export const stringifyNat = (
Expand Down

0 comments on commit 3d5eede

Please sign in to comment.