Skip to content
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

Merged
merged 12 commits into from
Oct 8, 2016
Merged

feat(Comment): Add component #584

merged 12 commits into from
Oct 8, 2016

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Oct 2, 2016

Adds Comment component.

Fixes #187.

@layershifter
Copy link
Member Author

layershifter commented Oct 2, 2016

@levithomason I added first doc example, LGTM.

@codecov-io
Copy link

codecov-io commented Oct 2, 2016

Current coverage is 100% (diff: 100%)

Merging #584 into master will not change coverage

@@           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          

Powered by Codecov. Last update 3fb0ca7...5b904ea

<Comment.Actions>
<Comment.Action active>Reply</Comment.Action>
</Comment.Actions>
<Comment.ReplyForm>
Copy link
Member

@levithomason levithomason Oct 3, 2016

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?

Copy link
Member Author

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 ?

Copy link
Member

@levithomason levithomason Oct 3, 2016

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.

Copy link
Member Author

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.

@layershifter
Copy link
Member Author

I've finished docs, tomorrow I'll add tests and finalize component.

What is the decision for Comment.ReplyForm? We add reply prop to form?

@levithomason
Copy link
Member

Let's go with the reply prop on Form for now. We can revisit later if necessary.

@layershifter
Copy link
Member Author

layershifter commented Oct 5, 2016

Added test, seems we need review there 👍
Pay attention to CommentAvatar, not sure that there is a good solution.

Also, there are no shorthands, I think we can do them in sepatate PR.

@levithomason
Copy link
Member

Agreed on separate PR for shorthand, I'll get a review here soon as I can.

Copy link
Member

@levithomason levithomason left a 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>
Copy link
Member

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

Copy link
Member Author

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.

@layershifter
Copy link
Member Author

Docs again with us.

Copy link
Member

@levithomason levithomason left a 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>
Copy link
Member

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'
Copy link
Member

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."

Copy link
Member Author

@layershifter layershifter Oct 6, 2016

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? 🤔

Copy link
Member

@levithomason levithomason Oct 6, 2016

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.

Copy link
Member Author

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'
/>
Copy link
Member

@levithomason levithomason Oct 5, 2016

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 {
Copy link
Member

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.

@layershifter
Copy link
Member Author

Updated to master, fixed review comments.

@layershifter
Copy link
Member Author

Hm... @levithomason can you restart build? Strange failure there.

@levithomason
Copy link
Member

levithomason commented Oct 6, 2016

Intermittent failures associated with the Search tests, I've seen this a couple times now:

  Search Component
    active item
      ✖ moves up on arrow up when open
        PhantomJS 2.1.1 (Linux 0.0.0)
        expected the node in <Search /> to have a 'active' propHTML: Not available due to: null is not an object (evaluating 'this.el.outerHTML')

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.

@layershifter
Copy link
Member Author

Added dots 😆 Seems, we ready to go

@levithomason levithomason merged commit 4d6b7e3 into master Oct 8, 2016
@levithomason levithomason deleted the feat/comment branch October 8, 2016 04:28
@levithomason
Copy link
Member

Another one down, thanks!

@levithomason
Copy link
Member

Released in [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants