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

Refactor classifier layout per survey task #6297

Merged
merged 11 commits into from
Sep 26, 2024

Conversation

mcbouslog
Copy link
Contributor

@mcbouslog mcbouslog commented Sep 12, 2024

Package

  • lib-classifier

Linked Issue and/or Talk Post

Describe your changes

  • add usesSurveyTask view to Workflow store
  • pass usesSurveyTask from Layout to CurrentLayout
  • update CenteredLayout, MaxWidth, and NoMaxWidth with larger task area if usesSurveyTask
  • MaxWidth and NoMaxWidth between 769px-1120px use 9fr 5fr for viewer task areas, these changes include aligning viewer and task vertically at 1119px if usesSurveyTask
  • center task nav buttons (Done & Talk, Done, Next, Back)

How to Review

Helpful explanations that will make your reviewer happy:

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

@coveralls
Copy link

coveralls commented Sep 12, 2024

Coverage Status

coverage: 78.512% (-0.06%) from 78.571%
when pulling 86e06fc on lib-classifier_layout-with-survey-task
into db7bd5e on master.

@mcbouslog mcbouslog marked this pull request as ready for review September 13, 2024 19:24
@mcbouslog mcbouslog changed the title [DRAFT] Refactor classifier layout per survey task Refactor classifier layout per survey task Sep 13, 2024
@mcbouslog mcbouslog requested review from a team and seanmiller26 September 13, 2024 19:24
@goplayoutside3 goplayoutside3 self-assigned this Sep 16, 2024
Copy link
Contributor

@goplayoutside3 goplayoutside3 left a comment

Choose a reason for hiding this comment

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

A couple of things before approval:

  1. Functions that start with use are reserved for custom React hooks. Because the function to detect if a workflow has a survey task is a store view, it should instead be named hasSurveyTask. I think that'll be just a quick find + replace everywhere that says usesSurveyTask in this PR.
  2. In the survey task area, the choice carousel of images is left-aligned when it should be centered in the task area. This style bug is already present on production and can be seen if viewing the classifier layout on a mobile screen such an ipad. Here's a few screenshots:
Screenshot 2024-09-16 at 11 23 08 AM Screenshot 2024-09-16 at 11 22 46 AM

@seanmiller26
Copy link
Contributor

@goplayoutside3 Your 2nd concern might be better addressed in a separate PR related to #6239. Thoughts, @mcbouslog?

@mcbouslog
Copy link
Contributor Author

A couple of things before approval:

  1. Functions that start with use are reserved for custom React hooks. Because the function to detect if a workflow has a survey task is a store view, it should instead be named hasSurveyTask. I think that'll be just a quick find + replace everywhere that says usesSurveyTask in this PR.

@goplayoutside3 - the Workflow store also includes usesTranscriptionTask and usesMachineLearnt, I could do a quick find and replace for those as well?

@mcbouslog
Copy link
Contributor Author

  1. In the survey task area, the choice carousel of images is left-aligned when it should be centered in the task area. This style bug is already present on production and can be seen if viewing the classifier layout on a mobile screen such an ipad.

@goplayoutside3 Your 2nd concern might be better addressed in a separate PR related to #6239. Thoughts, @mcbouslog?

@seanmiller26 - yes the Choice image Carousel will be further refactored in #6239 (expanded to full width of choice box), but I will add a interim edit to center align the current image Carousel to fix the current issue that's more noticeable with the larger task area width.

@mcbouslog
Copy link
Contributor Author

mcbouslog commented Sep 17, 2024

@seanmiller26 - I'll deploy this to https://fe-project-branch.preview.zooniverse.org after homepage and stats pages deployment for your review. I'll message you on Slack once it's available.

I think the key question will be widths of 1040px and below, and how the subject and task areas alignment change in workflows with and without a survey task.

@seanmiller26
Copy link
Contributor

@mcbouslog I have some time to review today. Is this ready to preview?

@mcbouslog
Copy link
Contributor Author

@mcbouslog I have some time to review today. Is this ready to preview?

Yes!

@seanmiller26
Copy link
Contributor

seanmiller26 commented Sep 18, 2024

I'm not sure exactly the scope of this specific PR, but I have some styling to address.

  • Padding should be 20px on all sides except the bottom, underneath the Done buttons = 30px.

  • Padding between the choices and the Done buttons should be 30px. Note: the 'Showing x' and 'Clear Filters' won't be in this area anymore, but that rearrangement will probably in in another PR.

Otherwise the basic adjustment to 540px looks good. And I like where it switches to a vertical layout.

@seanmiller26
Copy link
Contributor

Noticed this behavior right around the 1279-1280px view.

Maybe this is better addressed in the choices PR.

Screenshot 2024-09-18 at 1 36 56 PM Screenshot 2024-09-18 at 1 37 05 PM

@mcbouslog
Copy link
Contributor Author

mcbouslog commented Sep 23, 2024

  • Padding should be 20px on all sides except the bottom, underneath the Done buttons = 30px.

Should this apply only to survey tasks or all tasks?

The task area padding is set here: zooniverse/front-end-monorepo/packages/lib-react-components/src/Tabs/theme.js . If the 20px is just for the survey task, I'll connect the workflow store similarly to how it is connected to Layout and conditionally style.

@seanmiller26
Copy link
Contributor

We discussed in person that we'll open a separate PR to address styling across all Tasks. So, no need to address them in this PR.

Copy link
Contributor

@goplayoutside3 goplayoutside3 left a comment

Choose a reason for hiding this comment

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

I tested a few projects locally (active projects), and noticed in this PR transcription projects are incorrectly given MaxWidth layout styling. For example, PRINT run locally and PRINT on production. Please double check your changes to the lib-classifier Layout components do not affect non survey task projects.

Comment on lines +76 to +82
get hasSurveyTask() {
const anySurveyTasks = self.tasks && Object.values(self.tasks).some(task => {
return task.type === 'survey'
})

return anySurveyTasks
},
Copy link
Contributor

Choose a reason for hiding this comment

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

If I can make a code design suggestion here, I would add a check for self.hasSurveyTask to workflow.layout, then return a new layout for survey tasks. The advantage of that would be that you avoid accidentally introducing side effects into layouts that are already in use for other projects. For example, that would avoid accidental changes to transcription workflows, when all you want to do is change the layout for camera survey workflows.

That change would also mean that you don't change the API design for layouts in general. At the moment, each existing layout has to handle a new hasSurveyTask argument.

Copy link
Contributor

@goplayoutside3 goplayoutside3 Sep 24, 2024

Choose a reason for hiding this comment

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

Agreed! That would make much more sense to create a SurveyTaskLayout component rather than impact the existing ones.

Copy link
Contributor

Choose a reason for hiding this comment

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

Although what would happen if a workflow has a survey task, but also configuration.limit_subject_height set as true 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, that’s a good point. Layout settings can’t be easily combined.

Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of ideas:

  1. use a boolean attribute/prop to limit the subject height:
<SurveyTaskLayout limitSubjectHeight />
  1. use composition to limit the subject height:
<LimitedHeightLayout>
  <SurveyTaskLayout />
</LimitedHeightLayout>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A workflow with a survey task could use the default MaxWidth, subject height limited CenteredLayout, or if the workflow tasks also contain a transcription task the NoMaxWidth layout.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mcbouslog
Copy link
Contributor Author

@goplayoutside3 - I fixed the transcription project (NoMaxWidth) issue in 0eeffc9. I tested a lot of the live projects, including transcription, question, and survey task workflows and the layout was consistent or changed as expected if the workflow tasks contain a survey task.

I'm sure the layouts could use additional refactoring as noted, but I'm not sure if we want to further refactor in this branch or iterate on subsequently.

<Box direction='row'>
<Box
direction='row'
justify='center'
Copy link
Contributor

Choose a reason for hiding this comment

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

What project was this needed for? The buttons in this component grow to their container, so why is justify added?

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 think this is needed for survey task workflows per these changes, because the viewer and task area change from horizontal to vertical at a wider screen width than previously.

With a survey task, and a screen width of less than 1120px (70rem) per these changes - the task area drops below the viewer (vertical layout) and the task area is wide enough that the PrimaryButtons (Back, Done, etc.) hit their max-width. The container div aligns the buttons at the start without the justify: center.

Without justify: center:
survey_task_area_without_justify_center

With justify: center:
survey_task_area_with_justify_center

Copy link
Contributor

@goplayoutside3 goplayoutside3 left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-actions github-actions bot added the approved This PR is approved for merging label Sep 25, 2024
@mcbouslog mcbouslog merged commit 6b8f322 into master Sep 26, 2024
7 checks passed
@mcbouslog mcbouslog deleted the lib-classifier_layout-with-survey-task branch September 26, 2024 05:04
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
Projects
5 participants