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

[Dev UI] Display info about background image of current question #1222

Merged
merged 8 commits into from May 6, 2024

Conversation

jeremywiebe
Copy link
Collaborator

@jeremywiebe jeremywiebe commented Apr 25, 2024

Summary:

With our migration to Mafs, we still need to draw any interactive-graph backgrounds. But, when we do, it can become difficult to determine which UI elements are coming from the background and which are drawn by Mafs.

This PR introduces a little "status" icon that, when hovered, shows the background image, if there is one. If it is a Graphie, it provides a link to view/edit the Graphie in the graphie-to-png editor.

image

Issue: "none"

Test plan:

yarn dev

Paste the following into the Flipbook:

{"content":"The graph of $y=h(x)$ is a line segment joining the points $(1,9)$ and $(3,2)$. \n\n**Drag the endpoints of the segment below to graph $y=h^{-1}(x)$.\n **\n\n[[☃ interactive-graph 1]]","images":{},"widgets":{"interactive-graph 1":{"alignment":"default","graded":true,"options":{"backgroundImage":{"bottom":0,"height":425,"left":0,"scale":1,"url":"web+graphie://ka-perseus-graphie.s3.amazonaws.com/a82b4098da55c75b68d2c1fd9f348923b8935ccb","width":425},"correct":{"coords":[[[9,1],[2,3]]],"type":"segment"},"graph":{"type":"segment"},"gridStep":[1,1],"labels":["x","y"],"markings":"none","range":[[-10,10],[-10,10]],"rulerLabel":"","rulerTicks":10,"showProtractor":false,"showRuler":false,"snapStep":[0.5,0.5],"step":[1,1]},"type":"interactive-graph","version":{"major":0,"minor":0}}}}

Hover over the little icon below the <textarea> on the right side.

Paste the following into the Flipbook:

{"content":"$f$ is a finite function whose domain is the letters $a$ to $e$. The following table lists the output for each input in $f$'s domain.\n\n$x$|$a$|$b$|$c$|$d$|$e$\n:-|-:|-:|-:|-:\n$f(x)$|$1$|$2$|$2$|$3$|$4$\n\n**Build the mapping diagram of $f$ by dragging the endpoints of the segments in the graph below so that they pair each domain element with its correct range element. **\n\n**Then, determine if $f$ is invertible.**\n\n[[☃ interactive-graph 1]]\n\n\n\n[[☃ radio 2]]\n\n\n","images":{},"widgets":{"interactive-graph 1":{"type":"interactive-graph","alignment":"default","static":false,"graded":true,"options":{"step":[1,1],"backgroundImage":{"url":"https://ka-perseus-graphie.s3.amazonaws.com/a86c03713a29d33e2a5f8d2abfa578594dbba2e0.png","scale":1,"bottom":0,"left":0,"width":400,"height":400},"markings":"none","labels":["x","y"],"showProtractor":false,"showRuler":false,"rulerLabel":"","rulerTicks":10,"range":[[-10,10],[-10,10]],"gridStep":[1,1],"snapStep":[1,1],"graph":{"type":"segment","numSegments":5},"correct":{"type":"segment","numSegments":5,"coords":[[[-5,6],[5,4]],[[-5,3],[5,1]],[[-5,0],[5,1]],[[-5,-3],[5,-2]],[[-5,-6],[5,-5]]]}},"version":{"major":0,"minor":0}},"radio 2":{"type":"radio","alignment":"default","static":false,"graded":true,"options":{"choices":[{"correct":false,"content":"$f$ is invertible"},{"correct":true,"content":"$f$ is not invertible"}],"randomize":false,"multipleSelect":false,"displayCount":null,"hasNoneOfTheAbove":false,"onePerLine":true,"deselectEnabled":false},"version":{"major":1,"minor":0}}}}

Note that the icon changes and it says the image is a "regular image" background.

@jeremywiebe jeremywiebe self-assigned this Apr 25, 2024
@jeremywiebe jeremywiebe marked this pull request as ready for review April 25, 2024 19:57
@khan-actions-bot khan-actions-bot requested a review from a team April 25, 2024 19:57
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Apr 25, 2024

Gerald

Required Reviewers
  • @Khan/perseus for changes to .changeset/eighty-items-repeat.md, .changeset/six-melons-knock.md, dev/flipbook.tsx, dev/package.json, config/test/test.config.js, packages/perseus/src/widgets/explanation.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Contributor

github-actions bot commented Apr 25, 2024

Size Change: -7 B (0%)

Total Size: 833 kB

Filename Size Change
packages/perseus/dist/es/index.js 398 kB -7 B (0%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 38.1 kB
packages/kmath/dist/es/index.js 4.27 kB
packages/math-input/dist/es/index.js 80.5 kB
packages/math-input/dist/es/strings.js 1.73 kB
packages/perseus-core/dist/es/index.js 908 B
packages/perseus-editor/dist/es/index.js 267 kB
packages/perseus-error/dist/es/index.js 878 B
packages/perseus-linter/dist/es/index.js 21.8 kB
packages/perseus/dist/es/strings.js 3.22 kB
packages/pure-markdown/dist/es/index.js 3.68 kB
packages/simple-markdown/dist/es/index.js 12.4 kB

compressed-size-action

Copy link
Member

@benchristel benchristel left a comment

Choose a reason for hiding this comment

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

This is so good! Love the UI polish 😀

dev/flipbook.tsx Outdated Show resolved Hide resolved
Comment on lines +89 to +91
.map((w) => w.options.backgroundImage?.url ?? "")
.filter((url) => url.length > 0),
Copy link
Member

Choose a reason for hiding this comment

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

Empty string, null, and undefined are all falsey, so this could be simplified to

Suggested change
.map((w) => w.options.backgroundImage?.url ?? "")
.filter((url) => url.length > 0),
.map((w) => w.options.backgroundImage?.url)
.filter(Boolean),

That might be too much magic, though?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jeremywiebe jeremywiebe force-pushed the jer/dev-graphie-2 branch 2 times, most recently from 69478e4 to bd8b693 Compare April 27, 2024 03:15
Base automatically changed from jer/dev-graphie-2 to main April 29, 2024 16:00
Copy link
Contributor

github-actions bot commented Apr 29, 2024

npm Snapshot: Published

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

Example:

yarn add @khanacademy/perseus@PR1222

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

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

Copy link

codecov bot commented May 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.87%. Comparing base (cf1dc61) to head (631270b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1222      +/-   ##
==========================================
+ Coverage   68.64%   69.87%   +1.23%     
==========================================
  Files         470      474       +4     
  Lines      100733   100798      +65     
  Branches     7146    10774    +3628     
==========================================
+ Hits        69148    70436    +1288     
+ Misses      31406    30362    -1044     
+ Partials      179        0     -179     

Impacted file tree graph

Files Coverage Δ
packages/perseus/src/widgets/explanation.tsx 92.43% <100.00%> (+0.42%) ⬆️

... and 131 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf1dc61...631270b. Read the comment docs.

@jeremywiebe jeremywiebe merged commit 44cf734 into main May 6, 2024
13 checks passed
@jeremywiebe jeremywiebe deleted the jer/dev-graphie-3 branch May 6, 2024 21:07
nishasy added a commit that referenced this pull request May 7, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @khanacademy/perseus@22.4.0

### Minor Changes

- [#1229](#1229)
[`3c1e398d5`](3c1e398)
Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - Show
Arrowheads on Locked Lines in Interactive Graphs


- [#1237](#1237)
[`54689a18f`](54689a1)
Thanks [@handeyeco](https://github.com/handeyeco)! - Rough out new
Circle Graph behind a feature flag

### Patch Changes

- [#1222](#1222)
[`44cf7348c`](44cf734)
Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Fix
@phosphor-icon paths in `explanation` widget


- [#1243](#1243)
[`ee89a1b01`](ee89a1b)
Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Fix dash style
for locked lines when kind is 'ray'

## @khanacademy/perseus-editor@6.2.1

### Patch Changes

- [#1237](#1237)
[`54689a18f`](54689a1)
Thanks [@handeyeco](https://github.com/handeyeco)! - Rough out new
Circle Graph behind a feature flag


- [#1246](#1246)
[`d66b79e44`](d66b79e)
Thanks [@nishasy](https://github.com/nishasy)! - Change locked figures'
initial color to grayH (previusly green)


- [#1242](#1242)
[`7d172698e`](7d17269)
Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Adds a warning
above the protractor and ruler checkboxes in interactive-graph settings


- [#1245](#1245)
[`45a6647cf`](45a6647)
Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - Fix location of
DeviceFramer and ViewportResizer in Storybook

- Updated dependencies
\[[`44cf7348c`](44cf734),
[`3c1e398d5`](3c1e398),
[`ee89a1b01`](ee89a1b),
[`54689a18f`](54689a1)]:
    -   @khanacademy/perseus@22.4.0

## @khanacademy/perseus-dev-ui@1.5.5

### Patch Changes

- [#1222](#1222)
[`44cf7348c`](44cf734)
Thanks [@jeremywiebe](https://github.com/jeremywiebe)! - ✨ Display image
background info in Dev UI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants