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

Plotter defaults #2148

Merged
merged 4 commits into from
Jan 24, 2025
Merged

Plotter defaults #2148

merged 4 commits into from
Jan 24, 2025

Conversation

handeyeco
Copy link
Contributor

@handeyeco handeyeco commented Jan 23, 2025

Summary:

This actually includes a logic change, get picUrl seemed over-engineered and unnecessary.

Issue: LEMS-2737

Test plan:

Plotter can be edited, Plotters edited with this change can be rendered.

@handeyeco handeyeco self-assigned this Jan 23, 2025
@handeyeco handeyeco changed the title [LEMS-2737/default-plotter] plotter Plotter defaults Jan 23, 2025
Comment on lines -106 to -114
// @ts-expect-error - TS2322
get picUrl() {
const staticUrl = Dependencies.getDependencies().staticUrl;
if (staticUrl) {
return staticUrl("/images/badges/earth-small.png");
}

return null;
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just felt like this was a little much just to have a placeholder image.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I've always really disliked that default props has behaviour embedded in it via a getter!

What does the Plotter show by default in the editor with this now defaulting to null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out this was kind of a hard question to answer.

  1. I added a story, but SB didn't properly resolve the URL for the image; it looked the same in main and this branch
  2. I tried to look in the content editor, but Plotter is a hidden widget so I couldn't make new widget to test

I think I might just merge this PR since the widget is hidden anyway. Shouldn't change the editing experience since they'll never see an empty Plotter widget right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I might just merge this PR since the widget is hidden anyway. Shouldn't change the editing experience since they'll never see an empty Plotter widget right?

Good point! For hidden widgets, they can never be "created" in the editor anyways, so defaults for these widgets feel like a fading concern.

Copy link
Contributor

github-actions bot commented Jan 23, 2025

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR2148

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

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

Copy link
Contributor

github-actions bot commented Jan 23, 2025

Size Change: -39 B (0%)

Total Size: 1.48 MB

Filename Size Change
packages/perseus-core/dist/es/index.js 31.3 kB +123 B (+0.39%)
packages/perseus-editor/dist/es/index.js 688 kB -162 B (-0.02%)
ℹ️ 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-linter/dist/es/index.js 22.2 kB
packages/perseus-score/dist/es/index.js 113 kB
packages/perseus/dist/es/index.js 397 kB
packages/perseus/dist/es/strings.js 5.74 kB
packages/pure-markdown/dist/es/index.js 3.66 kB
packages/simple-markdown/dist/es/index.js 12.5 kB

compressed-size-action

@handeyeco handeyeco requested a review from a team January 23, 2025 21:11

picSize: 30,
picBoxHeight: 36,
plotDimensions: [275, 200],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Woah, that's some random size. 😂 Our graphs are usually 400x400.

No action needed.

Comment on lines -106 to -114
// @ts-expect-error - TS2322
get picUrl() {
const staticUrl = Dependencies.getDependencies().staticUrl;
if (staticUrl) {
return staticUrl("/images/badges/earth-small.png");
}

return null;
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've always really disliked that default props has behaviour embedded in it via a getter!

What does the Plotter show by default in the editor with this now defaulting to null.

@handeyeco handeyeco merged commit 685774f into main Jan 24, 2025
8 checks passed
@handeyeco handeyeco deleted the LEMS-2737/default-plotter branch January 24, 2025 21:33
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