-
Notifications
You must be signed in to change notification settings - Fork 9
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
Update notes components #419
Conversation
…rops" This reverts commit 63dc209.
…assName to card; additional cleanup and testing
…h other note classes
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 changes to the components look good overall (one small comment there). The main feedback is in regard to the Stories.
stories/Note.js
Outdated
onDelete={action('onDelete')} | ||
onEdit={action('onEdit')} | ||
onSave={action('onSave')} | ||
onUndelete={action('onUndelete')} | ||
> |
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.
Might be good to add the rows
and saving
knob here too.
stories/Notes.js
Outdated
onSave={n => alert(`Save Add: ${JSON.stringify(n)}`)} | ||
onCancel={action('onCancel')} | ||
onChange={action('onChange')} | ||
onSave={action('onSave')} | ||
/>} | ||
adding={adding} |
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 adding
prop was removed by your recent changes, so this prop and the knob should be removed.
stories/Notes.js
Outdated
onSave={n => alert(`Save Add: ${JSON.stringify(n)}`)} | ||
onCancel={action('onCancel')} | ||
onChange={action('onChange')} | ||
onSave={action('onSave')} | ||
/>} | ||
adding={adding} |
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 adding
prop was removed by your recent changes, so this prop and the knob should be removed.
stories/Notes.js
Outdated
@@ -78,27 +78,26 @@ storiesOf('Notes', module) | |||
<Notes | |||
addControl={<EditableNote |
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 addControl
prop was removed by your recent changes, so should be removed from the example.
stories/Notes.js
Outdated
@@ -1,5 +1,5 @@ | |||
import React from 'react'; | |||
import { storiesOf } from '@storybook/react'; | |||
import { action, storiesOf } from '@storybook/react'; | |||
import { boolean, text } from '@storybook/addon-knobs'; | |||
import { EditableNote, Note, Notes } from '../src'; | |||
|
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 description below should have the last sentence (the one referring to addControl
) removed.
stories/Notes.js
Outdated
@@ -43,20 +44,18 @@ storiesOf('Notes', module) | |||
<Notes | |||
addControl={<EditableNote |
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 addControl
prop was removed by your recent changes, so should be removed from the example.
stories/Notes.js
Outdated
onDelete={action('onDelete')} | ||
onEdit={action('onEdit')} | ||
onSave={action('onSave')} | ||
onUndelete={action('onUndelete')} |
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.
For some reason, when I view the Storybook, select the "deleted" knob, then click on the "undo" link in the DeletedNote
view, it reroutes the page rather than recording the onUndelete
action. Are you seeing this too?
stories/Notes.js
Outdated
@@ -78,27 +78,26 @@ storiesOf('Notes', module) | |||
<Notes |
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.
This example can be simplified. With children, we can remove all props that would have been forwarded to internally-created Note
components. Since these props are explicitly passed to each Note
in the child body, there's no need to pass them into Notes
(now that it has no unique props itself), e.g.,
<Notes>
{notes.map(note => (
<Note
note={note}
onCancel={action('onCancel')}
onChange={action('onChange')}
onDelete={action('onDelete')}
onEdit={action('onEdit')}
onSave={action('onSave')}
onUndelete={action('onUndelete')}
saving={note.saving}
/>
))}
</Notes>
(plus you can get rid of the <div>
in the map
body)
src/components/NoteHeader.js
Outdated
<div | ||
className="d-inline-flex align-items-center" | ||
ref="title" | ||
> |
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 text-muted
property seems to have been dropped. It appears to be a part of the Saffron standard.
In use: https://qa.qa.appfolio.com/maintenance/mobile?assignedUserId=any#/133920/notes
stories/EditableNote.js
Outdated
const saving = boolean('saving', false); | ||
|
||
const note = withNote ? noteToEdit : { text: '' }; | ||
note.saving = saving; |
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.
Since saving
is a component prop now, this should be removed and the knob should be added to the EditableNote
inputs. (same for the next doc block)
<Input | ||
autoFocus | ||
disabled={saving} | ||
ref="text" |
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 is this ref for?
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.
These were left over from the original impl. The unit test uses these refs to find elements. We should get away from that, IMHO, but I didn't go that far.
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.
No worries, just curious
src/components/EditableNote.js
Outdated
@@ -35,7 +35,7 @@ class EditableNote extends React.Component { | |||
const { date, errors, text } = note; | |||
|
|||
return ( | |||
<Card className={className}> | |||
<Card outline color="info" className={className}> |
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.
Explanation of change: Editable note card should have white background; info border
src/components/NoteHeader.js
Outdated
className="d-inline-flex align-items-center" | ||
ref="title" | ||
> | ||
<div className="d-inline-flex align-items-center text-muted"> |
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.
Explanation of change: remove unused ref, add text-muted
<span className="m-0 my-1 mr-auto"> | ||
<span className="hidden-xs-down"> | ||
{edited ? 'Last edited' : 'Posted'} | ||
{from ? <span className="js-note-header__from">{` by ${from}`}</span> : ' '} on <span className="js-note-header__date">{dateFormat(date, 'ddd, MMMM D, YYYY "at" h:mm A')}</span> |
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.
It's a bit odd to me that there are different date formats for Edited and non-edited notes, but that's the way it is in APM. Perhaps it makes sense to have these customizable. Not a big deal though
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.
Just to be clear, the date format is the same, only the labeling of that date changes:
"Posted by Gary Thomas on Mon, July 2, 2018 at 2:33 PM"
vs.
"Last edited by Gary Thomas on Mon, July 2, 2018 at 2:33 PM"
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 meant compared to short dateformat below on line 52: dateFormat(date, 'M/D/YY h:mm A')
but I see now that's for small viewport widths.
30b132e
to
c680435
Compare
c680435
to
66e68c4
Compare
…y, recommended practice)
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.
👍
#408
Sorry for the large change set, but there were lots of changes needed to make this usable for a generic use case, but also add some flexibility for the custom ones (e.g., where notes had attachments).