-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add a <number> component #217
Conversation
@@ -12,6 +12,8 @@ import { serializedComponentsReviver } from "@doenet/utils"; | |||
import { Action, PointProps } from "@doenet/doenetml-worker-rust"; | |||
import { useAppDispatch } from "../../state/hooks"; | |||
import { coreActions } from "../../state/redux-slices/core"; | |||
//@ts-ignore |
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 a bit frustrating. Maybe we could re-export some typed versions of the functions that we're using?
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.
Sounds like a worthwhile goal. Seems overwhelming to me, so I could use some help getting started!
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 wasn't suggesting doing the whole thing. Just create and re-export the function you used in this file.
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.
Do you mean within DoenetML rather than in math-expressions
? I could try that.
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 can only do that for a function that returns something simple like a number. The math expression object itself has a zillion attributes, so just describing that type would be non-trivial.
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.
done for this example
use crate::general_prop::NumberToStringProp; | ||
use crate::props::UpdaterObject; | ||
|
||
/// The `<number>` component calculates a numerical value from its contents and display the result as text |
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.
Does it display fractions as well as decimals?
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.
No, it is an f64
representation, so only decimals. This is approximately equivalent to the legacy <number>
component, which uses a Javascript Number
. At this point, if you want fractions, you have to stick with <math>
.
This PR adds a
<number>
component, updates the number and math props, and adds additional number, math, and point tests.