-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add ui-components package #2321
Conversation
These messages are likely describing the source of the errors. SES is finding nonstandard properties on Object.assign and Object.values. We don't want Babel to polyfill anything, IIUC. Can you disable |
Thanks for the tip! Let me see what I can do |
There are two separate issues here:
(I had forgotten that I had Enzyme setup code running before each test, so that explains how Enzyme was able to execute before lockdown.) |
External PR to change the |
Update as of 2/10/2021:
With these two fixes, my tests pass. I'm going to put this on the back-burner to work on ERTP Beta tasks, but will come back to this once JSS gets a new release, or if we reprioritize this. |
d4f76a8
to
279ea22
Compare
The new version of JSS has been released, and tests now pass on Node 14! (have not tried Node 15). |
21f6983
to
a321a7b
Compare
@michaelfig, I think the NatAmountInput itself is good, with correct decimalPlaces handling and tests. However, I'm having trouble importing it in dapp-token-economy, especally since |
3951bc8
to
76d1a31
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor optional comments. GREAT tests.
* @param {number=} decimalPlaces - places to move the decimal to the left | ||
* @returns {Value} | ||
*/ | ||
export const parseAsValue = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why clutter the name with As
? parseValue
says what I want it to do and what I'm expecting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, it wasn't clear in parseX
whether x
was the input type or the output type. In parseValue
, value is the output type, but that doesn't match how we usually say it in English: "parse this string as a value". In English, the input directly follows parse
, and the output is prefixed with as
. So to make the name clearer since it is the opposite of how we would speak normally, I added the As
.
* @param {number=} decimalPlaces - places to move the decimal to the left | ||
* @returns {Amount} | ||
*/ | ||
export const parseAsAmount = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless it's well motivated, the As
is also an unnecessary renaming over what's there, resulting in merge overhead. Of course it might be well-motivated.
packages/ui-components/src/display/natValue/roundToDecimalPlaces.js
Outdated
Show resolved
Hide resolved
I'm happy for you to make forward progress by merging this, and deal with the finicky (mostly unrelated to your PR) import/export issues later. I may get to review this on the weekend, but don't feel obligated to wait for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few suggestions. Take or leave them.
packages/ui-components/package.json
Outdated
"name": "ui-components", | ||
"version": "0.0.1", | ||
"description": "Reusable UI Components for Agoric Dapps, built with React and MaterialUI", | ||
"main": "dist/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably the source of the import problems. React components can't easily be imported from bundles, IIUC. The build step has to be performed only once, in the app that imports all the other components. Otherwise, your app can't tree-shake the components that it doesn't use that are already bundled with other things.
If this change doesn't fix it for you, you might have instead to import the components as import NatAmountInput from '@agoric/ui-components/src/components/NatAmountInput'
"main": "dist/index.js", | |
"main": "src/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using the src
directly, and it doesn't work in dapp-token-economy. I get an error message telling me to change my Babel settings to allow for JSX, but since we haven't ejected, I haven't found an easy way to change the Babel settings :/ There must be a way to bundle it correctly, though, since we can import MaterialUI components from packages.
// @ts-ignore path is correct for compiled output | ||
import { NatAmountInput } from '../../../dist'; // eslint-disable-line import/no-unresolved |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please try this out? With the "main"
change in package.json
this should always work.
// @ts-ignore path is correct for compiled output | |
import { NatAmountInput } from '../../../dist'; // eslint-disable-line import/no-unresolved | |
import { NatAmountInput } from '../../..'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work, because the source needs to be compiled for the tests to run. I am compiling manually through babel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and confirmed that the compiled version is necessary because of the JSX:
Uncaught exception in compiled/test/components/test-NatAmountInput.js
/Users/katesills/code/agoric-sdk/packages/ui-components/src/components/NatAmountInput.js:31
<TextField
^
SyntaxError: Invalid or unexpected token
e3f131c
to
3d5eede
Compare
Add ui-components package to agoric-sdk, with tests.
Still to do:
@agoric/assert
)Closes: #2320