-
Notifications
You must be signed in to change notification settings - Fork 75
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
Pages Editor: add Drawing Task #7100
Conversation
68740ea
to
a197faf
Compare
3510e15
to
2d601eb
Compare
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! A couple small comments but nothing preventing merging.
I did notice that if I create 2nd drawing task in the Overlay and leave it empty without a tool, it stays there on page change. Not sure if this should be default behavior. Because it doesn't break anything and it does what's expected (nothing), it isn't a dealbreaker for the PR.
const TOOL_COLOR_OPTIONS = [ | ||
{ value: '#ff0000', label: 'Red' }, | ||
{ value: '#ffff00', label: 'Yellow' }, | ||
{ value: '#00ff00', label: 'Green' }, | ||
{ value: '#00ffff', label: 'Cyan' }, | ||
{ value: '#0000ff', label: 'Blue' }, | ||
{ value: '#ff00ff', label: 'Magenta' } | ||
]; |
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'd consider inverting this as an Object so it's more useful.. For example:
TOOL_COLOR_OPTIONS = { 'Red': '#ff0000' }
Then, when you need a color you're able to use the name of the color instead of searching through an array to find a hex value. It makes your loop through a little different (Object.keys(TOOL_COLOR_OPTIONS).map) but from a readability perspective it's a little more clear. It also creates the opportunity to abstract this bit of code out and up for anywhere we want color selection like this.
Not a dealbreaker but a thought to consider.
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 actually structured it as an object first, before turning it into an array!
I can't remember 100% why I changed it to an array, but I think it was following a discussion with Sam & Sean about 1. the choice of colours we want to present to users, and 2. the name of those colours (e.g. "#89e097 apple" instead of "#00ff00 green"). (I probably just left this as an array until we sorted out that question. 🤔 )
Bonus trivia: the following are some random half-remembered bits from the discussion, just for interest:
- The PFE colour choices are extremely garish and not part of any branding...
- ...but garish colours happen to provide excellent contrast for marks drawn on top of camera trap photos and documents.
- Nobody knows why #00ff00 green is the default.
- I think we could technically allow users to set any colour they want, since Panoptes just stores the hex code and both PFE & FEM classifiers renders any valid hex colour, but we wanted to make this selection as simple as possible for project owners.
export default function DrawingToolIcon({ | ||
alt, | ||
className = 'icon', | ||
color = 'currentColor', | ||
size = 24, | ||
thickness = 5, | ||
type | ||
}) { |
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 clever file! It'd be cool if we created a shared area for all these SVG icons defined in JS once this gets moved into FEM. I've seen a couple across the codebase and it'd be nice to know what resources are available like 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.
Thanks! I agree, it'd be good to organise these SVG icons better once Pages Editor gets moved to FEM. The Drawing Tool icons should definitely be something that sits in a shared, uh... "lib-icons" package, maybe?
Right now, in FEM, they're buried in lib-classifier/src/plugins/tasks/drawing/components/icons and you'd only know it's there when you need to dig for it.
a197faf
to
4bac969
Compare
2d601eb
to
ede1d82
Compare
Thanks Travis! Noted on the ability to create a Drawing Task with 0 Tools. That's technically valid (data-wise), but doesn't make sense (volunteer-wise). (The same applies to other questions like a Question Task with 0 Answers.) We didn't implement any programmatic guardrails for nonsensical workflows yet, we're just assuming project owners would know not to do this - I'd be interested to see the feedback we get from testers on this. |
PR Overview
Part of: Pages Editor MVP project and FEM Lab super-project
Follows #7093
Staging branch URL: https://pr-7100.pfe-preview.zooniverse.org/lab/1982/workflows/editor/3711?env=staging
This PR adds the Drawing Task to the list of supported Tasks in the Pages Editor. Some miscellaneous cleanup was also performed.
Main:
/icons
Misc Cleanup:
Screenshot: example of a Drawing Task with 2 drawing tools
Dev Notes
DrawingTask.update()
call.Testing
Status
Ready for review. 🖊️
Requires 7093 to be merged first before this can be merged.