Skip to content
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

Merged
merged 13 commits into from
Jul 15, 2024
Merged

Add a <number> component #217

merged 13 commits into from
Jul 15, 2024

Conversation

dqnykamp
Copy link
Member

@dqnykamp dqnykamp commented Jul 13, 2024

This PR adds a <number> component, updates the number and math props, and adds additional number, math, and point tests.

@dqnykamp dqnykamp requested a review from siefkenj July 13, 2024 17:14
@@ -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
Copy link
Contributor

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?

Copy link
Member Author

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!

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member Author

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
Copy link
Contributor

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?

Copy link
Member Author

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

@dqnykamp dqnykamp merged commit 7fa5beb into Doenet:0.9 Jul 15, 2024
4 checks passed
@dqnykamp dqnykamp deleted the number branch July 15, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants