Editable project instructions#1387
Conversation
|
Nice! I think it makes sense for @jwang1919 to do the first review pass on this? |
|
Will see if I have time later to review later today. I will be out next week for work. |
jwang1919
left a comment
There was a problem hiding this comment.
Some minor change requests and comments on functionality regarding the Hamburger menu and when isEditingInstructions is active.
| "export-gist": "Export Gist", | ||
| "export-repo": "Export Repo", | ||
| "share-to-classroom": "Share To Classroom", | ||
| "add-or-edit-instructions": "Add/Edit Instructions", |
There was a problem hiding this comment.
I prefer having "Add Instructions" and "Edit Instructions" as two different strings. And have these strings show up whether or not instructions are present in the Popcode project.
| "output": "Output" | ||
| "output": "Output", | ||
| "instructions": { | ||
| "cancel": "Cancel" |
There was a problem hiding this comment.
Not quite sure why this string is separate from "add-or-edit-instructions".
Couldn't we do...
"instructions": {
"add": "Add Instructions",
"edit": "Edit Instructions",
"cancel": "Cancel"
}
There was a problem hiding this comment.
Purposely omitted "Save" because you haven't accomplished that yet, but same deal as with the other strings.
There was a problem hiding this comment.
I separated them because add-or-edit-instructions (soon to be split into two separate strings) is in the top-bar, while cancel and save are in the Instructions component. But I don't feel strongly about that separation, so I'm happy to group them all together if you think that would be better.
| } | ||
| } | ||
|
|
||
| .instructions-editor-menu { |
There was a problem hiding this comment.
Suggest to follow BEM naming rules like the rest of the selectors.
.instructions-editor-menu to .instructions-editor__menu
| export default function InstructionsEditor({instructions, onCancelEditing}) { | ||
| return ( | ||
| <div className="instructions-editor"> | ||
| <div className="instructions-editor-menu"> |
There was a problem hiding this comment.
Suggest to follow BEM naming rules like the rest of the selectors.
"instructions-editor-menu" to "instructions-editor__menu"
| items.push( | ||
| <MenuItem | ||
| key="addOrEditInstructions" | ||
| onClick={isEditingInstructions ? noop : onStartEditingInstructions} |
There was a problem hiding this comment.
When isEditingInstructions is true, I think we should change the Menu Item in someway so it's clear that this menu item is active.
My ideas:
- Disable the Edit Menu Item
- Change the text to "Stop Editing Instructions" (this will cancel and close the instructions)
- Change the text to "Save Instructions" (this will save and close the instructions).
|
@jwang1919 I think I've addressed all your feedback (on one point I added a comment, but GitHub has collapsed it.) I decided to opt for idea 1 when
Let me know what you think! |
|
Also, I added the ability to save the new instructions using a The contentious "nodes" in this case aren't actually React elements. It's just a |
|
Added a couple tests—let me know if there are any more you'd like to see! |
|
@ajgreenb what’s the reasoning behind the |
|
I think it gets the job done more simply than using a Using |
|
@ajgreenb so it looks like what you’ve got here is basically an uncontrolled component implementation using a However, there’s no reason you couldn’t have an uncontrolled WDYT? Definitely possible there is some subtlety I am missing here… |
|
Ah, yeah of course. It’s been a while since I worked with React so I had forgotten about uncontrolled components. I’ll make that change; thanks for the suggestion!
|
|
@ajgreenb Checked this out - this is so awesome! Not sure if you addressed this already or have it on the backlog- I found myself wanting to have the "edit instructions" button appear in the instructions pane rather than having to go back to the hamburger menu. That way I could make changes to the markdown => save => edit to fix changes more quickly. I think "add instructions" should still live in the hamburger menu though. Thoughts? |
|
That sounds like a great idea! I’ll try implementing it as soon as I have some time. Thanks for the suggestion!
|
|
Cool! The upside to the current implementation is that the edit instructions button is less accessible to students under the hamburger menu. But as an instructor much prefer it in the instructions pane. |
|
I think a fairly subtle (maybe only appearing on hover?) edit icon in the instructions would be the move here—not super eye-catching if you’re not looking for it, but easily accessible if you’re looking doing a quick edit-save-edit-save workflow. Anyway, seems like we could follow up with that. @ajgreenb @jwang1919 please let me know when you’re ready for me to do final review on this—would love to get it released! Very excited to never export a gist just to add an |
|
Okay, in the interest of getting this out, let's leave the edit icon in the instructions for a small follow-up PR. This is pretty close to ready for final review—hopefully I'll have some time this weekend to put the final touches on it. |
1c2d44f to
3f986c0
Compare
|
@outoftime I think this is ready for feedback! The styles could use some love, but they don't need to block a review. |
3f986c0 to
459cdf1
Compare
| } | ||
|
|
||
| _ref(editorElement) { | ||
| this.editor = editorElement; |
There was a problem hiding this comment.
We should underscore-prefix this._editor as well as it is “private” state
| </MenuItem>, | ||
| ); | ||
|
|
||
| if (isExperimental) { |
There was a problem hiding this comment.
I don’t think there’s any need to release this in experimental mode? Seems pretty ready for prime time to me!
| <MenuItem | ||
| isDisabled={isEditingInstructions} | ||
| key="addOrEditInstructions" | ||
| onClick={isEditingInstructions ? noop : onStartEditingInstructions} |
There was a problem hiding this comment.
Shouldn’t the isDisabled prop be sufficient to make onClick a noop?
| get(this.props, ['currentProject', 'projectKey']), | ||
| 'instructions', | ||
| )); | ||
| if (!this.props.isEditingInstructions) { |
There was a problem hiding this comment.
Small thing, but if clicking the instructions bar doesn’t do anything when editing is enabled (which seems sensible), I think we should take away the cursor: pointer in that case too : )
There was a problem hiding this comment.
Oh lol this is one of your pending checklist items!
| 'START_EDITING_INSTRUCTIONS', | ||
| ); | ||
|
|
||
| export const stopEditingInstructions = createAction( |
There was a problem hiding this comment.
I don’t feel strongly about this, but I think cancelEditingInstructions might be a clearer name here—stopEditingInstructions intuitively feels like it would be dispatched any time you are done editing instructions, whether or not you’re going to save your changes.
|
|
||
| /* postcss-bem-linter: ignore */ | ||
| & textarea { | ||
| height: 100%; |
There was a problem hiding this comment.
This doesn’t seem to be having the desired effect in Chrome 65—the editor is just a couple lines high. I find absolute positioning with all four sides pinned works wonders in this kind of situation ; )
| } | ||
|
|
||
| .instructions-editor__input { | ||
| padding: 1rem 1rem 0; |
There was a problem hiding this comment.
I think we could do with less padding, and maybe none at all?
| width: 100%; | ||
| padding: 0.5rem; | ||
| box-sizing: border-box; | ||
| font-family: monospace; |
There was a problem hiding this comment.
Let’s use Roboto to match the code editors?
| .instructions-editor__footer { | ||
| margin: 1rem; | ||
| padding-top: 1rem; | ||
| border-top: 1px solid var(--color-light-gray); |
There was a problem hiding this comment.
I think this text could stand to be a bit smaller.
| /> | ||
| </div> | ||
| <div className="instructions-editor__footer"> | ||
| Styling with Markdown is supported |
There was a problem hiding this comment.
Let’s make this a link to a suitable Markdown guide?
This commit also extracts the editable pre element into a separate InstructionsEditor React component.
936ef74 to
667fd47
Compare
|
@outoftime I think I addressed all your feedback! Let me know what you think. I'm not in love with styling of the Save and Cancel buttons (lack thereof)—should I spend some time trying to make them look more like the buttons in the top bar? |
outoftime
left a comment
There was a problem hiding this comment.
@ajgreenb awesome!! gonna release this now. a couple of things i think would be good for a follow up:
- It’d be nice if the edit textarea were focused when it’s first rendered (especially when there are no preexisting instructions, it’s not immediately visually obvious what’s going on)
- Along the same lines, perhaps a
placeholderin the textarea? - I meant to suggest we use Hack (the editor font) rather than Roboto (the UI font) in the textarea. My bad!!!
- I think we should consider renaming the
isEnabledprop thatMenuItemtakes—it’s confusing to have bothisEnabledandisDisabled, talking about different things. MaybeisActiveinstead ofisEnabled?
A basic first pass at making the Popcode instructions panel editable from within the app.
To Do
instructionsstate.InstructionsEditor.cursor: defaultfor the instructions bar when in editing mode.Closes #1311