-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat(annotations): add ftux cursor logic #1281
Conversation
src/lib/viewers/image/ImageViewer.js
Outdated
if (!this.cache.get(IMAGE_FTUX_CURSOR_DISABLED_KEY)) { | ||
this.cache.set(IMAGE_FTUX_CURSOR_DISABLED_KEY, true, true /* useLocalStorage */); | ||
} else { | ||
this.annotator.emit('annotations_image_explicit_create_toggled'); |
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.
It looks like we're both passing in options to the annotator and emitting events to it. Are they related? Can this be simplified?
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.
They are related:
- On a fresh reload of the page, we want to pass the ftux cursor flag via options to the annotator. That will need to be done within
initAnnotations
. That logic can't be done here because this method is for handling the user click event on the Create Region button. - The first time that the the user clicks on the Create Region button, we want to update the flag within localStorage. The second time that they click on the Create Region button, we no longer want to update the flag (it's already set), but we do want to emit an event that would cause a rerender of RegionCreator.
I'm not aware of how this could be simplified but would be open to suggestions.
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.
We no longer need to pass in options to the annotator after implementing the css approach.
676eb8d
to
de18983
Compare
src/lib/viewers/doc/DocBaseViewer.js
Outdated
@@ -1596,6 +1596,11 @@ class DocBaseViewer extends BaseViewer { | |||
|
|||
handleAnnotationControlsClick({ mode }) { | |||
const nextMode = this.annotationControlsFSM.transition(AnnotationInput.CLICK, mode); | |||
|
|||
if (nextMode === AnnotationMode.REGION) { |
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.
annotationControlsFSM
currently subscribes to the transition changes but calls updateDiscoverabilityResinTag
directly, perhaps we could introduce a handler
that also checks for this condition and applies the class there.
Also it seems like we would want to update localStorage on the transition from REGION
to NONE
, or even to REGION
but only trigger the logic to apply the class on any subsequent transition to REGION
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.
Discussed offline that since the transition changes only happen when the user clicks, we're okay with not needing the handler.
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'm still debating whether this should be moved out to a fsm callback. This method is pretty mode agnostic so I'm wary of cluttering it with some region specific code. Let's do the callback because that'll be easier to strip out eventually too since it'll be it's own separate function. Something like:
this.annotationControlsFSM.subscribe(this.applyCursorFtux);
src/lib/viewers/BaseViewer.js
Outdated
*/ | ||
handleFtuxCursorToggle(key) { | ||
if (!this.cache.get(key)) { | ||
this.cache.set(key, true, 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.
Also, should we perform this ftux on a per user id basis?
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.
After doing some digging, it looks like we don't need to do it on a per user id basis because localStorage sessions are different for unique users.
src/lib/viewers/BaseViewer.js
Outdated
@@ -162,13 +167,15 @@ class BaseViewer extends EventEmitter { | |||
this.mobileZoomEndHandler = this.mobileZoomEndHandler.bind(this); | |||
this.handleAnnotatorEvents = this.handleAnnotatorEvents.bind(this); | |||
this.handleAnnotationControlsEscape = this.handleAnnotationControlsEscape.bind(this); | |||
this.applyCursorFtux = this.applyCursorFtux.bind(this); |
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.
Are these binds required? and L178
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.
They weren't required previously, but with the addition of the subscribe
call, they are now required.
src/lib/viewers/doc/DocBaseViewer.js
Outdated
@@ -1596,6 +1596,11 @@ class DocBaseViewer extends BaseViewer { | |||
|
|||
handleAnnotationControlsClick({ mode }) { | |||
const nextMode = this.annotationControlsFSM.transition(AnnotationInput.CLICK, mode); | |||
|
|||
if (nextMode === AnnotationMode.REGION) { |
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'm still debating whether this should be moved out to a fsm callback. This method is pretty mode agnostic so I'm wary of cluttering it with some region specific code. Let's do the callback because that'll be easier to strip out eventually too since it'll be it's own separate function. Something like:
this.annotationControlsFSM.subscribe(this.applyCursorFtux);
src/lib/viewers/image/Image.scss
Outdated
|
||
.bp-content { | ||
&.bp-annotations-ftux-image-cursor-seen { | ||
.bp-image { |
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.
Is the .bp-image
a needed specificity?
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.
Yes it is required.
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.
What about if we did &.bp-annotations--create-region.bp-annotations-ftux-image-cursor-seen
?
Yes it's needed. |
30ceb72
to
ad04d4c
Compare
src/lib/viewers/doc/_docBase.scss
Outdated
@@ -370,6 +370,12 @@ $thumbnail-sidebar-width: 226px; | |||
} | |||
} | |||
|
|||
&.bp-annotations-ftux-document-cursor-seen { |
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.
Could this be moved into &.bp-annotations-create--region
above?
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.
Yep this works as well.
src/lib/viewers/image/Image.scss
Outdated
|
||
.bp-content { | ||
&.bp-annotations-ftux-image-cursor-seen { | ||
.bp-image { |
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.
What about if we did &.bp-annotations--create-region.bp-annotations-ftux-image-cursor-seen
?
Dismissing as this PR has been approved
Changes in this PR:
Todo:
Demo: