-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(Comment): Add component #584
Conversation
@levithomason I added first doc example, LGTM. |
Current coverage is 100% (diff: 100%)@@ master #584 diff @@
====================================
Files 119 128 +9
Lines 1890 1962 +72
Methods 0 0
Messages 0 0
Branches 0 0
====================================
+ Hits 1890 1962 +72
Misses 0 0
Partials 0 0
|
<Comment.Actions> | ||
<Comment.Action active>Reply</Comment.Action> | ||
</Comment.Actions> | ||
<Comment.ReplyForm> |
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 see the reply
class is required for the form when used in a comment or after all comments. I think we should explore some other API options for adding the class.
This pattern reminds me of the label
and button
class being required for Inputs that are "labeled` or have an "action". In the Input case the label/action is passed through props, so we have an opportunity to add the className without requiring additional components or props to add the class.
Ideas:
Form reply
prop
We could simply add a reply
prop to the Form. It would clean this up and clarify things. However, this prop is not applicable anywhere except in comments, so it seems sub optimal.
Comment replyForm
prop
I think this one makes more sense since you'll want the same form in all comments. Rather than pasting a reply form in every comment and one at the end of all comments, we could create a single comment reply form and pass it as a prop to each comment:
const replyForm = <Form />
<Comment.Group replyForm={replyForm} />
// and/or
<Comment replyForm={replyForm} />
Looping Comments
This brings me to another realization, I think the actual React usage of the Comment will be to create a single comment component, query a server for a list of comments, then loop over the comments mapping the single comment component. Because of this, I don't think most users will ever build out a comment thread in a hard coded sense.
That would put the Form reply
prop back on the table since there would likely only be one comment component in your project (reply form included) that you would map over your comment data.
Feedback?
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.
We have same situation with List.Icon
, if we add reply
prop on Form
, seems we'll need to remove List.Icon
.
@jcarbo ?
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'm really torn on this one. While I agree entirely on the need for consistency with List.Icon, at the same time I really want to avoid this API:
<Comment.ReplyForm>
<Form.TextArea />
<Button labeled icon primary>
<Icon name='edit' />
Add Reply
</Button>
</Comment.ReplyForm>
I think it comes off very confusing IMHO. It would be great to get a single top level interface to creating a Comment form some how.
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.
In this way, reply
prop looks more reliable solution.
…nologyAdvice/stardust into feat/comment Conflicts: src/views/index.js
I've finished docs, tomorrow I'll add tests and finalize component. What is the decision for |
Let's go with the |
…nologyAdvice/stardust into feat/comment Conflicts: README.md
Added test, seems we need review there 👍 Also, there are no shorthands, I think we can do them in sepatate PR. |
Agreed on separate PR for shorthand, I'll get a review here soon as I can. |
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.
See comment on CommentExampleThreaded.js, will finish review after that.
</Comment.Content> | ||
</Comment> | ||
|
||
<Comment.ReplyForm> |
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 component no longer exists, docs fail to load at present:
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of `CommentExampleThreaded`.
CommentExampleThreaded.js?42c9:180
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.
Stupid miss, will fix soon.
Docs again with us. |
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.
Only a few comments, then I think we can merge this guy.
<Comment.Actions> | ||
<Comment.Action active>Reply</Comment.Action> | ||
</Comment.Actions> | ||
<Form reply> |
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.
To prevent page refresh on submit, let's add:
onSubmit={e => e.preventDefault()}
|
||
<ComponentExample | ||
title='Reply Form' | ||
description='A comment can contain a form to reply to a comment. This may have arbitrary content' |
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.
Needs a .
"This may have arbitrary content."
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.
Stupid question. Why we need add trailing dot there, but don't add it in other places? 🤔
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, it's a great question :) We need to get consistent. Currently, when there is a single sentence, the period is sometimes left out. I can see doing this as it is trying to keep it minimal and feeling like a heading.
When there are multiple sentences, the last sentence needs a period. Otherwise, there is one terminated sentence, and another not.
Because of all this, I propose we just always include the period. So it is consistent and we don't have issues with multi-sentence descriptions like this one.
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, I'll add trailing dot to all example descriptions tomorrow, revolutionary improvement :)
title='Reply Form' | ||
description='A comment can contain a form to reply to a comment. This may have arbitrary content' | ||
examplePath='views/Comment/Content/CommentExampleReplyForm' | ||
/> |
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.
Suggest we also add this info
Message from the SUI docs:
If a comment form is located inside a comment it will be formatted as a nested reply form. If the comment form is included after all comments, it will be formatted as a normal reply form.
import React, { Component } from 'react' | ||
import { Checkbox, Comment } from 'semantic-ui-react' | ||
|
||
export default class CommentExampleCollapsed extends Component { |
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 is a cool example, really like the simple interactivity to show how a prop works.
Updated to |
Hm... @levithomason can you restart build? Strange failure there. |
Intermittent failures associated with the Search tests, I've seen this a couple times now:
I restarted the build. I believe since you have access to the repo, you should also have access to the builds at https://circleci.com/gh/Semantic-Org/Semantic-UI-React. |
Added dots 😆 Seems, we ready to go |
Another one down, thanks! |
Released in |
Adds Comment component.
Fixes #187.