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 WB Tooltip to StyledMovablePoint #1192
Conversation
Tooltip only shows when 'showTooltips' is true. Add tooltip toggle to gallery page for testing. Add tooltip functionality to segment graph.
…the tooltip will follow the point when it is moved. Add unit tests for including/excluding a tooltip based upon graph options.
… set and the user hovers or focuses on the point). Add "graphOptions" to the graph context to aid in passing graph settings to child components that need them for rendering. Adjust hairlines and tooltip colors to match movable point color. Add unit tests.
Make the tooltip background match the point color.
Resolve merge conflicts. Update unit tests that reference WB Tooltip to mock the component instead of inferring its existence.
Size Change: +260 B (0%) Total Size: 827 kB
ℹ️ View Unchanged
|
.map(([question, i]) => ( | ||
<QuestionRenderer | ||
key={i} | ||
key={`${i}${showTooltips ? "-with-tooltips" : ""}`} |
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.
Adding text to the key to force a re-render when toggling the "Show Tooltips" switch.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1192 +/- ##
==========================================
+ Coverage 68.56% 69.95% +1.39%
==========================================
Files 464 467 +3
Lines 99360 99451 +91
Branches 7043 10694 +3651
==========================================
+ Hits 68126 69572 +1446
+ Misses 31119 29879 -1240
+ Partials 115 0 -115
... and 121 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (980d700) and published it to npm. You Example: yarn add @khanacademy/perseus@PR1192 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR1192 |
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.
Very exciting! Could we consider giving the tooltip a fixed width if it's possible? To stop the size change from being so jarring while moving the point with the half steps adding more digits?
@@ -95,6 +95,9 @@ export function Gallery() { | |||
); | |||
|
|||
const [isMobile, setIsMobile] = useState(params.get("mobile") === "true"); | |||
const [showTooltips, setShowTooltips] = useState( | |||
params.get("tooltips") === "true", |
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.
Can this be shortened to useState(params.get("tooltips"))
? or !!useState(params.get("tooltips"))
?
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 didn't see that "true" is a string. You can ignore my suggestion!
const hitboxRef = useRef<SVGCircleElement>(null); | ||
const {point, onMove, color = WBColor.blue} = props; | ||
|
||
// WB Tooltip requires a color name for the background color. | ||
// Since the color in props is a hex value, a reverse lookup is needed. |
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.
😭
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 love these tests! 🎉
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.
Overall I think this looks really good. I think the ability to color the movable point predates this PR so you can leave that for now, but I do know that currently Graphie doesn't allow you to change the color of the movables and so I think we want to do the same (ie. default to WB Blue and not allow customization).
.changeset/dry-lemons-doubt.md
Outdated
"@khanacademy/perseus": minor | ||
--- | ||
|
||
Display tooltip for movable point when option is indicated |
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.
Our changelogs aren't critically important, but I think it'd be good to clarify here that we're talking about the interactive-graph
widget.
@@ -20,10 +21,16 @@ type Props = { | |||
const hitboxSizePx = 48; | |||
|
|||
export const StyledMovablePoint = (props: Props) => { | |||
const {range, snapStep, markings} = useGraphConfig(); | |||
const {range, snapStep, markings, showTooltips} = useGraphConfig(); | |||
const hitboxRef = useRef<SVGCircleElement>(null); | |||
const {point, onMove, color = WBColor.blue} = props; |
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.
Note that as far as I know, there are no plans to allow content authors to adjust the color of any of the movables. That is something that is strictly reserved for Locked Features.
So if it simplifies things, I think we can remove the ability to change the color of this StyledMovablePoint.
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.
You can ignore my suggestion about the width, since the current implementation matches the previous tooltip behavior. (Also just adding when we talked about online for the paper trail: it doesn't look that much better with a fixed/min width anyway, as the numbers are still kind of jumping back and forth.)
After looking into setting a minimum width for the tooltip bubble, the jarring aspect that occurs when moving is still there due to the snap-to-grid nature of the movement. Keeping the width consistent didn't produce the "smoothness" that we were hoping for. Leaving it without for now. |
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/math-input@18.0.0 ### Major Changes - [#1168](#1168) [`a9c2308f9`](a9c2308) Thanks [@jeresig](https://github.com/jeresig)! - Remove wonder-blocks-i18n usage from perseus and perseus-editor packages. - [#1153](#1153) [`22709bd9b`](22709bd) Thanks [@jeresig](https://github.com/jeresig)! - Remove wonder-blocks-i18n from math-input, support multiple exports in rollup. ## @khanacademy/perseus@22.0.0 ### Major Changes - [#1168](#1168) [`a9c2308f9`](a9c2308) Thanks [@jeresig](https://github.com/jeresig)! - Remove wonder-blocks-i18n usage from perseus and perseus-editor packages. - [#1153](#1153) [`22709bd9b`](22709bd) Thanks [@jeresig](https://github.com/jeresig)! - Remove wonder-blocks-i18n from math-input, support multiple exports in rollup. ### Minor Changes - [#1186](#1186) [`d7fbe3e99`](d7fbe3e) Thanks [@nishasy](https://github.com/nishasy)! - Add UI within InteractiveGraphEditor to add/edit locked lines - [#1192](#1192) [`e86ed507e`](e86ed50) Thanks [@mark-fitzgerald](https://github.com/mark-fitzgerald)! - Display tooltip for movable point when option is indicated (Interactive Graph) - [#1195](#1195) [`9b5a9a40a`](9b5a9a4) Thanks [@nishasy](https://github.com/nishasy)! - Use MathJax colors for Interactive Graph locked figures - [#1195](#1195) [`9b5a9a40a`](9b5a9a4) Thanks [@nishasy](https://github.com/nishasy)! - View locked lines on Interactive Graph ### Patch Changes - [#1196](#1196) [`52b57c95d`](52b57c9) Thanks [@nishasy](https://github.com/nishasy)! - Rename ColorCircle to ColorSwatch - [#1198](#1198) [`890587ef1`](890587e) Thanks [@benchristel](https://github.com/benchristel)! - Internal: Add Storybook stories for visual regression testing of Mafs interactive graphs - Updated dependencies \[[`a9c2308f9`](a9c2308), [`22709bd9b`](22709bd)]: - @khanacademy/math-input@18.0.0 - @khanacademy/pure-markdown@0.3.2 ## @khanacademy/perseus-editor@6.0.0 ### Major Changes - [#1168](#1168) [`a9c2308f9`](a9c2308) Thanks [@jeresig](https://github.com/jeresig)! - Remove wonder-blocks-i18n usage from perseus and perseus-editor packages. - [#1153](#1153) [`22709bd9b`](22709bd) Thanks [@jeresig](https://github.com/jeresig)! - Remove wonder-blocks-i18n from math-input, support multiple exports in rollup. ### Minor Changes - [#1186](#1186) [`d7fbe3e99`](d7fbe3e) Thanks [@nishasy](https://github.com/nishasy)! - Add UI within InteractiveGraphEditor to add/edit locked lines - [#1195](#1195) [`9b5a9a40a`](9b5a9a4) Thanks [@nishasy](https://github.com/nishasy)! - Use MathJax colors for Interactive Graph locked figures - [#1195](#1195) [`9b5a9a40a`](9b5a9a4) Thanks [@nishasy](https://github.com/nishasy)! - View locked lines on Interactive Graph ### Patch Changes - [#1196](#1196) [`52b57c95d`](52b57c9) Thanks [@nishasy](https://github.com/nishasy)! - Rename ColorCircle to ColorSwatch - [#1201](#1201) [`125394c94`](125394c) Thanks [@jeanettehead](https://github.com/jeanettehead)! - Default a new radio widget to having four options - [#1200](#1200) [`d733aeaec`](d733aea) Thanks [@jeanettehead](https://github.com/jeanettehead)! - Prevent horizontal scrolling of radio widget options in the editor - Updated dependencies \[[`52b57c95d`](52b57c9), [`890587ef1`](890587e), [`d7fbe3e99`](d7fbe3e), [`e86ed507e`](e86ed50), [`a9c2308f9`](a9c2308), [`22709bd9b`](22709bd), [`9b5a9a40a`](9b5a9a4), [`9b5a9a40a`](9b5a9a4)]: - @khanacademy/perseus@22.0.0 - @khanacademy/math-input@18.0.0 ## @khanacademy/perseus-dev-ui@1.5.0 ### Minor Changes - [#1168](#1168) [`a9c2308f9`](a9c2308) Thanks [@jeresig](https://github.com/jeresig)! - Remove wonder-blocks-i18n usage from perseus and perseus-editor packages. ### Patch Changes - Updated dependencies \[[`a9c2308f9`](a9c2308), [`22709bd9b`](22709bd)]: - @khanacademy/math-input@18.0.0 - @khanacademy/pure-markdown@0.3.2 ## @khanacademy/pure-markdown@0.3.2 ## perseus-build-settings@0.4.0 ### Minor Changes - [#1168](#1168) [`a9c2308f9`](a9c2308) Thanks [@jeresig](https://github.com/jeresig)! - Remove wonder-blocks-i18n usage from perseus and perseus-editor packages. - [#1153](#1153) [`22709bd9b`](22709bd) Thanks [@jeresig](https://github.com/jeresig)! - Remove wonder-blocks-i18n from math-input, support multiple exports in rollup.
Summary:
A tooltip for a movable point can be requested at the content creator's discretion. When this option is toggled "on" in the editor, a tooltip with the point's coordinates should appear whenever the user interacts with the point (either via mouse dragging or via keyboard movement).
Issue: LEMS-1860
Test plan:
yarn dev
).localhost:5173
to view the various graphs.Affected Behavior
New Tooltip Functionality
Tooltip.on.Movable.Point.mov