-
Notifications
You must be signed in to change notification settings - Fork 29
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
Conversation
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.
A couple of things before approval:
- 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 namedhasSurveyTask
. I think that'll be just a quick find + replace everywhere that saysusesSurveyTask
in this PR. - 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:
@goplayoutside3 Your 2nd concern might be better addressed in a separate PR related to #6239. Thoughts, @mcbouslog? |
@goplayoutside3 - the Workflow store also includes |
@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. |
@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. |
@mcbouslog I have some time to review today. Is this ready to preview? |
Yes! |
I'm not sure exactly the scope of this specific PR, but I have some styling to address.
Otherwise the basic adjustment to 540px looks good. And I like where it switches to a vertical layout. |
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. |
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. |
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 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.
get hasSurveyTask() { | ||
const anySurveyTasks = self.tasks && Object.values(self.tasks).some(task => { | ||
return task.type === 'survey' | ||
}) | ||
|
||
return anySurveyTasks | ||
}, |
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.
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.
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.
Agreed! That would make much more sense to create a SurveyTaskLayout component rather than impact the existing ones.
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.
Although what would happen if a workflow has a survey task, but also configuration.limit_subject_height
set as 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.
Oh, that’s a good point. Layout settings can’t be easily combined.
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.
A couple of ideas:
- use a boolean attribute/prop to limit the subject height:
<SurveyTaskLayout limitSubjectHeight />
- use composition to limit the subject height:
<LimitedHeightLayout>
<SurveyTaskLayout />
</LimitedHeightLayout>
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.
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.
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.
The limited height setting causes some weird layout bugs too.
@goplayoutside3 - I fixed the transcription project ( 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' |
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 project was this needed for? The buttons in this component grow to their container, so why is justify
added?
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 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
.
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.
LGTM!
Package
Linked Issue and/or Talk Post
Describe your changes
usesSurveyTask
view to Workflow storeusesSurveyTask
from Layout to CurrentLayoutusesSurveyTask
usesSurveyTask
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
yarn panic && yarn bootstrap
ordocker-compose up --build
and FEM works as expectedGeneral UX
Example Staging Project: i-fancy-cats
Refactoring