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

[Numeric Input] Update UI of editor #2015

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

mark-fitzgerald
Copy link
Contributor

@mark-fitzgerald mark-fitzgerald commented Dec 16, 2024

Summary:

Many of the editor functions for Numeric Input were hidden behind a small configuration icon button, which was unintuitive. Also, the tooltip icons for the settings didn't align with their setting, making it difficult to understand where to get help for the options.

To fix these issues, and to modernize the UI, the editor screen was re-organized to make all functions easily findable. Also, Wonder Blocks components were used instead of custom items to make the editor experience consistent with other parts of the app.

Issue: LEMS-2456

Test plan:

  1. Open the Editor Demo page in Storybook.
  2. Add a Numeric Input widget to the page.
  3. Using the revised UI, all settings options function just like with the original editor.

Affected behavior:

Before

Editor - Before

After

Editor - After

Mark Fitzgerald and others added 23 commits December 3, 2024 16:35
Move editor components to appropriate sections under headings.
…hose options.

Update unit tests accordingly.
Convert user input of answer to be a single line for value and max error entry.
Group unsimplified options via fieldset
Update unit tests accordingly.
…aid with unit tests.

Update unit tests accordingly.
@mark-fitzgerald mark-fitzgerald self-assigned this Dec 16, 2024
Copy link
Contributor

github-actions bot commented Dec 16, 2024

Size Change: +595 B (+0.04%)

Total Size: 1.47 MB

Filename Size Change
packages/perseus-editor/dist/es/index.js 689 kB +595 B (+0.09%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 39 kB
packages/keypad-context/dist/es/index.js 760 B
packages/kmath/dist/es/index.js 86.8 kB
packages/math-input/dist/es/index.js 77.6 kB
packages/math-input/dist/es/strings.js 1.79 kB
packages/perseus-core/dist/es/index.js 27.1 kB
packages/perseus-linter/dist/es/index.js 22.2 kB
packages/perseus-score/dist/es/index.js 113 kB
packages/perseus/dist/es/index.js 395 kB
packages/perseus/dist/es/strings.js 5.1 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Dec 16, 2024

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (884693f) and published it to npm. You
can install it using the tag PR2015.

Example:

yarn add @khanacademy/perseus@PR2015

If you are working in Khan Academy's webapp, you can run:

./dev/tools/bump_perseus_version.sh -t PR2015

@mark-fitzgerald mark-fitzgerald marked this pull request as ready for review January 18, 2025 01:58
@mark-fitzgerald mark-fitzgerald requested a review from a team January 18, 2025 01:58
.inline-options {
float: inline-start; /* flexbox and inline-block don't work on <legend> elements, so going old-school here */
line-height: 24px; /* for alignment with items in same line (like pills or buttons) */
padding-inline-end: 0.5em;
Copy link
Contributor

@SonicScrewdriver SonicScrewdriver Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love these comments, thank you very much! It really helps with preventing regressions in the future imo.

Copy link
Contributor

@SonicScrewdriver SonicScrewdriver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOW. This looks SO MUCH better! Thank you for this amazing glow up!

I didn't see anything concerning in the PR, just had a bunch of ignorable nit comments that you're free to ignore as you wish. :)

NumberInput,
TextInput,
} = components;
const {InfoTip, NumberInput, TextInput} = components;
const {firstNumericalParse} = Util;

// NOTE(john): Copied from perseus-types.d.ts in the Perseus package.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total ignorable nit: I wonder if this comment should be updated with the recent changes from SSS. It's possible we might be able to import these types now rather than redeclare them.

@@ -121,18 +121,45 @@ class NumericInputEditor extends React.Component<Props, State> {
super(props);
this.state = {
lastStatus: "wrong",
showOptions: _.map(this.props.answers, () => false),
showAnswerDetails: _.map(this.props.answers, () => true),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good opportunity to remove another case of underscore!

<span className="tooltip-for-legend">
<InfoTip>
<p>
Normally select &quot;ungraded&quot;. This
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there something about our InfoTip that requires quotes to be designated in such a manner?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Come to think of it, could this be an opportunity for the Wonderblocks tooltip, or do we have other restrictions that make that not feasible here? (I recall that we can't use it for the examples tooltip on the Widget itself, but I'm less sure about the Editor)

size="medium"
role="radio"
style={{
marginRight: "8px",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignorable nit: It seems like this style could potentially be pulled out into a variable as it's used 7 times. I see you've declared it once in SettingOption already. You could possibly set all these shared props and then add it to each pill.

<div className="msg-title">
Message shown to user on attempt
<Heading
title="General Settings"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really love this separated section, it's much cleaner and helps Content Creators manage their screen space.

<NumberInput
value={answer.value}
className="numeric-input-value"
placeholder="answer"
Copy link
Contributor

@SonicScrewdriver SonicScrewdriver Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most ignorable of nits: Should the "answer" placeholder be capitalized?

)}
{answers[i]["status"] === "correct" && (
<>
<legend className="inline-options">
Copy link
Contributor

@SonicScrewdriver SonicScrewdriver Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'm noticing that this heading has the inline-options class, which pushes the (?) tooltip a little awkwardly to the right, while the "Possible answer formats" does not have this class. As a result, the balance between the two seems a little off.

Looking at the tooltips in General settings, I can see how the space is desirable for those cases. I wonder if we either want to remove the class from "Unsimplified answers are" or add it to "Possible answer formats", just for consistency.

placeholder="answer"
format={_.last(answer.answerForms || [])}
onFormatChange={(newValue, format) => {
// NOTE(charlie): The mobile web expression
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is this comment still relevant? I'm pretty sure expression uses MathJax / MathIput now, and I don't see it being used for either the Widget or the Editor! We do still need Pi in NumericInput, though, so perhaps we could just update the comment.

</fieldset>
{unsimplifiedAnswers(i)}
<div className="perseus-widget-row">
Message shown to user in article:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we had a way to identify which editor view we're in, as it'd be lovely to hide this option when adding Numeric Inputs in exercises.

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