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

Classifier: Move MetaTools into same grid area as subject viewer #4021

Merged
merged 19 commits into from
Jan 16, 2023

Conversation

goplayoutside3
Copy link
Contributor

@goplayoutside3 goplayoutside3 commented Dec 17, 2022

Package

lib-classifier

Linked Issue and/or Talk Post

Includes #4019
Includes #4005

Describe your changes

This PR moves the MetaTools component into the same grid area as the SubjectViewer, which allows its buttons to always display directly below the subject image regardless of viewport aspect ratio. Screenshots below.

This PR also includes refactoring from class to functional components and RTL unit tests for Metadata, MetadataModal, and MetadataButton.

Previously, the MetaTools buttons displayed below the toolbar height:
old

The changes in this PR display them like this:
new

How to Review

Run yarn bootstrap with this branch and view any project with a subject image. Examples:
- i-fancy-cats
- TESS
- Poets & Lovers

I also added a story for the MetaTools container with a specific case for smaller subject viewer styling.

See corresponding ImageToolbar refactoring in #4008.

Checklist

PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.

General

  • Tests are passing locally and on Github
  • Documentation is up to date and changelog has been updated if appropriate
  • You can yarn panic && yarn bootstrap or docker-compose up --build and FEM works as expected
  • FEM works in all major desktop browsers: Firefox, Chrome, Edge, Safari (Use Browserstack account as needed)
  • FEM works in a mobile browser

General UX

Example Staging Project: i-fancy-cats

  • All pages of a FEM project load: Home Page, Classify Page, and About Pages
  • Can submit a classification
  • Can sign-in and sign-out
  • The component is accessible

Refactoring

  • The PR creator has described the reason for refactoring
  • The refactored component(s) continue to work as expected

@goplayoutside3 goplayoutside3 added refactor Refactoring existing code ui labels Dec 17, 2022
@coveralls
Copy link

coveralls commented Dec 17, 2022

Coverage Status

Coverage: 82.226% (-0.03%) from 82.254% when pulling 5cb7796 on metatools-refactor into 4d08e18 on master.

@eatyourgreens
Copy link
Contributor

This is going to break MetaTools on desktop, where it is supposed to extend under the Field Guide button.

Maybe small screens need to define a new grid layout, not use DefaultLayout.

@eatyourgreens
Copy link
Contributor

New layouts can be added to the classifier here:

See also Shaun’s ADR about layouts.
https://github.com/zooniverse/front-end-monorepo/blob/master/docs/arch/adr-32.md

@goplayoutside3
Copy link
Contributor Author

  1. Noting that this change was initially requested by @seanmiller26 during development of custom video controls Classifier: Custom Video Controls #3684 (review). Further discussion is planned around layouts, so no rush to merge this PR while waiting for a final design decision.

  2. This is going to break MetaTools on desktop, where it is supposed to extend under the Field Guide button.

    On desktop, when I view SuperWASP Black Hole hunters on production and locally, the classify page looks the same. When you say "break", do you mean the styling of MetaTools will respond differently to varying viewport widths?

@eatyourgreens
Copy link
Contributor

Weird that the layout doesn’t change. The subject area is designed to match the height of the toolbar, so I assumed the SVG subject height would shrink to allow for the height of the toolbar in the subject area.

My concern was that this changes the height of the subject for live projects. If that’s not happening, then there’s no problem.

@eatyourgreens
Copy link
Contributor

By the way, if you want to try out design ideas for new layouts, but don’t want to change PH-TESS etc., then adding a new layout to the layouts map would give you a layout that you can experiment with while also controlling which projects and workflows use it.

That might be useful for testing big changes, rather than editing the default layout directly.

@mcbouslog mcbouslog self-assigned this Jan 9, 2023
Comment on lines +49 to +61
<Metadata
isThereMetadata={isThereMetadata}
metadata={subject && subject.metadata}
/>
<FavouritesButton
checked={subject?.favorite}
disabled={!subject || !upp}
onClick={subject?.toggleFavorite}
/>
<CollectionsButton
disabled={!subject || !upp}
onClick={addToCollection}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

When I run locally, signed in, and load https://local.zooniverse.org:3000/projects/brooke/i-fancy-cats/classify/workflow/693 or https://local.zooniverse.org:3000/projects/pmlogan/poets-and-lovers/classify/workflow/21362/subject-set/104809?env=production the Metadata, FavouritesButton, and CollectionsButton are unexpectedly disabled. Console logging the subject from MetaTools returns null and the component doesn't appear to rerender once the subject (and related isThereMetadata) is defined.

Copy link
Contributor

@mcbouslog mcbouslog Jan 10, 2023

Choose a reason for hiding this comment

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

Oh I think the mobx observer should wrap the MetaTools export.
export default withResponsiveContext(observer(MetaTools)) with related mobx observer import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right! I think adding observer restored some of the expected functionality, but I also noticed that you can visit i-fancy-cats on frontend.preview, sign-in to enable FavouritesButton and CollectionsButton, but then upon sign-out the upp from the store still contains user data, and the buttons are all still enabled. I think this is a bug of the UserProjectPreferences store so I'll do a quick search for an already existing Github Issue or open a new one.

Copy link
Contributor

@mcbouslog mcbouslog left a comment

Choose a reason for hiding this comment

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

Looks good! Big improvement for small screens. Looked strange to me at first on desktop, but only because I'm used to current grid.

Refactors look good 👍 . Only blocking comment is regarding MetaTools missing observer (I think), otherwise a few other comments for consideration, but not blocking.

@mcbouslog
Copy link
Contributor

Unrelated to these changes, but while reviewing I noticed the Hide Previous Marks svg icon is 24px while the other MetaTools icons are 15px. The difference isn't noticeable (to me anyway) on desktop, but when stacked for a small screen the alignment is a little more noticeable. Not sure if want to include a fix for in these changes, we can convert this comment to an issue, or other option.

@goplayoutside3
Copy link
Contributor Author

...icon is 24px while the other MetaTools icons are 15px. The difference isn't noticeable (to me anyway) on desktop, but when stacked for a small screen the alignment is a little more noticeable.

I agree the difference is annoying when all meta buttons are stacked on top of each other when its column is of smaller width. I plan to follow-up with Sean to get his approval on this PR as well, and my review with him will include minor adjustments of icon size, margins, etc

Copy link
Contributor

@mcbouslog mcbouslog left a comment

Choose a reason for hiding this comment

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

Changes LGTM 👍

@github-actions github-actions bot added the approved This PR is approved for merging label Jan 12, 2023
@goplayoutside3
Copy link
Contributor Author

goplayoutside3 commented Jan 16, 2023

Met with @seanmiller26 to review MetaTools design. A few notes on what will follow in a separate PR:

  • Align all icons of meta tools buttons if stacked on top of each other
  • Work toward minor refactor of meta tools button responsive design (will open an Issue with design reference)
  • Make the MultiFrameViewer's Filmstrip sticky like the image toolbar

@goplayoutside3 goplayoutside3 merged commit b7b7ad0 into master Jan 16, 2023
@goplayoutside3 goplayoutside3 deleted the metatools-refactor branch January 16, 2023 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This PR is approved for merging refactor Refactoring existing code ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants