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 #392

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions docs/app/Examples/views/Comment/Types/CommentCommentsExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import React from 'react'
import { Comment } from 'stardust'

const CommentCommentsExample = () => (
<Comment.Group>
<Header dividing>Comments</Header>
<Comment>
<Comment.Avatar>
<img src='http://semantic-ui.com/images/avatar/small/matt.jpg' />
</Comment.Avatar>
<Comment.Content>
<Comment.Author>Matt</Comment.Author>
<Comment.Meta>
<span class="date">Today at 5:42PM</span>
</Comment.Meta>
<Comment.Text>
How artistic!
</Comment.Text>
<Comment.Actions class="actions">
<a class="reply">Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
<Comment>
<Comment.Avatar>
<img src='http://semantic-ui.com/images/avatar/small/matt.jpg' />
</Comment.Avatar>
<Comment.Content>
<Comment.Author>Elliot Fu</Comment.Author>
<Comment.Meta>
<span class="date">Yesterday at 12:30AM</span>
</Comment.Meta>
<Comment.Text>
<p>This has been very useful for my research. Thanks as well!</p>
</Comment.Text>
<Comment.Actions class="actions">
<a class="reply">Reply</a>
</Comment.Actions>
</Comment.Content>
<Comment.Group>
<Comment>
<Comment.Avatar>
<img src='http://semantic-ui.com/images/avatar/small/jenny.jpg' />
</Comment.Avatar>
<Comment.Content>
<Comment.Author>Jenny Hess</Comment.Author>
<Comment.Meta>
<span class="date">Just now</span>
</Comment.Meta>
<Comment.Text>
Elliot you are always so right :)
</Comment.Text>
<Comment.Actions>
<a class="reply">Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
</Comment.Group>
</Comment>
<Comment>
<Comment.Avatar>
<img src='http://semantic-ui.com/images/avatar/small/joe.jpg' />
</Comment.Avatar>
<Comment.Content>
<Comment.Author>Joe Henderson</Comment.Author>
<Comment.Meta>
<span class="date">5 days ago</span>
</Comment.Meta>
<Comment.Text>
Dude, this is awesome. Thanks so much
</Commment.Text>
<Comment.Actions>
<a class="reply">Reply</a>
</Comment.Actions>
</Comment.Conent>
Copy link
Contributor

@typehorror typehorror Sep 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</Comment.Content>

</Comment>
</Comment.Group>
)
39 changes: 39 additions & 0 deletions src/views/Comment/Comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React, { PropTypes } from 'react'
import cx from 'classnames'
import { META, getUnhandledProps } from '../../lib'
import CommentActions from './CommentActions'
import CommentAuthor from './CommentAuthor'
import CommentAvatar from './CommentAvatar'
import CommentContent from './CommentContent'
import CommentMeta from './CommentMeta'
import CommentText from './CommentText'

const _meta = {
name: 'Comment',
type: META.TYPES.VIEW,
}

function Comment(props) {
const { className, children } = props
const rest = getUnhandledProps(Comment, props)
const classes = cx(
'comment',
className
)
return (
<div {...rest} className={classes}>
{children}
</div>
)
}

Comment._meta = _meta

Comment.Actions = CommentActions
Comment.Author = CommentAuthor
Comment.Avatar = CommentAvatar
Comment.Content = CommentContent
Comment.Meta = CommentMeta
Comment.Text = CommentText

export default Comment
22 changes: 22 additions & 0 deletions src/views/Comment/CommentActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'

import { META, getUnhandledProps } from '../../lib'

const _meta = {
name: 'CommentActions',
type: META.TYPES.VIEW,
}

function CommentActions(props) {
const rest = getUnhandledProps(CommentActions, props)
return (
<div {...rest}>

</div>
)
}

CommentActions._meta = _meta


export default CommentActions
21 changes: 21 additions & 0 deletions src/views/Comment/CommentAuthor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

import { META, getUnhandledProps } from '../../lib'

const _meta = {
name: 'CommentAuthor',
type: META.TYPES.VIEW,
}

function CommentAuthor(props) {
const rest = getUnhandledProps(CommentAuthor, props)
return (
<div {...rest}>
</div>
)
}

CommentAuthor._meta = _meta


export default CommentAuthor
22 changes: 22 additions & 0 deletions src/views/Comment/CommentAvatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'

import { META, getUnhandledProps } from '../../lib'

const _meta = {
name: 'CommentAvatar',
type: META.TYPES.VIEW,
}

function CommentAvatar(props) {
const rest = getUnhandledProps(CommentAvatar, props)
return (
<div {...rest}>

</div>
)
}

CommentAvatar._meta = _meta


export default CommentAvatar
22 changes: 22 additions & 0 deletions src/views/Comment/CommentContent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'

import { META, getUnhandledProps } from '../../lib'

const _meta = {
name: 'CommentContent',
type: META.TYPES.VIEW,
}

function CommentContent(props) {
const rest = getUnhandledProps(CommentContent, props)
return (
<div {...rest}>

</div>
)
}

CommentContent._meta = _meta


export default CommentContent
22 changes: 22 additions & 0 deletions src/views/Comment/CommentGroup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'

import { META, getUnhandledProps } from '../../lib'

const _meta = {
name: 'CommentGroup',
type: META.TYPES.VIEW,
}

function CommentGroup(props) {
const rest = getUnhandledProps(CommentGroup, props)
return (
<div {...rest}>

</div>
)
}

CommentGroup._meta = _meta


export default CommentGroup
22 changes: 22 additions & 0 deletions src/views/Comment/CommentMeta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'

import { META, getUnhandledProps } from '../../lib'

const _meta = {
name: 'CommentMeta',
type: META.TYPES.VIEW,
}

function CommentMeta(props) {
const rest = getUnhandledProps(CommentMeta, props)
return (
<div {...rest}>

</div>
)
}

CommentMeta._meta = _meta


export default CommentMeta
21 changes: 21 additions & 0 deletions src/views/Comment/CommentText.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'

import { META, getUnhandledProps } from '../../lib'

const _meta = {
name: 'CommentText',
type: META.TYPES.VIEW,
}

function CommentText(props) {
const rest = getUnhandledProps(CommentText, props)
return (
<div {...rest}>

</div>
)
}

CommentText._meta = _meta

export default CommentText
1 change: 1 addition & 0 deletions src/views/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as Item } from './Item/Item'
export { default as Statistic } from './Statistic/Statistic'
export { default as Comment } from './Comment/Comment'
2 changes: 1 addition & 1 deletion test/specs/commonTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const componentCtx = require.context(

const componentInfo = componentCtx.keys().map(key => {
const Component = componentCtx(key).default

const componentType = typeof Component

if (componentType !== 'function') {
throw new Error([
`${key} is not properly exported.`,
Expand Down
20 changes: 20 additions & 0 deletions test/specs/views/Comment/Comment-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Comment from 'src/views/Comment/Comment'
import CommentActions from 'src/views/Comment/CommentActions'
import CommentAuthor from 'src/views/Comment/CommentAuthor'
import CommentAvatar from 'src/views/Comment/CommentAvatar'
import CommentContent from 'src/views/Comment/CommentContent'
import CommentMeta from 'src/views/Comment/CommentMeta'
import CommentText from 'src/views/Comment/CommentText'
import * as common from 'test/specs/commonTests'
describe.only('Comment', () => {
common.isConformant(Comment)
common.rendersChildren(Comment)
common.hasSubComponents(Comment, [
CommentActions,
CommentAuthor,
CommentAvatar,
CommentContent,
CommentMeta,
CommentText,
])
})
6 changes: 6 additions & 0 deletions test/specs/views/Comment/CommentActions-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import CommentActions from 'src/views/CommentActions/CommentActions'
import * as common from 'test/specs/commonTests'
describe.only('CommentActions', () => {
common.isConformant(CommentActions)
common.rendersChildren(CommentActions)
})
6 changes: 6 additions & 0 deletions test/specs/views/Comment/CommentAuthor-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import CommentAuthor from 'src/views/CommentAuthor/CommentAuthor'
import * as common from 'test/specs/commonTests'
describe.only('CommentAuthor', () => {
common.isConformant(CommentAuthor)
common.rendersChildren(CommentAuthor)
})
6 changes: 6 additions & 0 deletions test/specs/views/Comment/CommentAvatar-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import CommentAvatar from 'src/views/CommentAvatar/CommentAvatar'
import * as common from 'test/specs/commonTests'
describe.only('CommentAvatar', () => {
common.isConformant(CommentAvatar)
common.rendersChildren(CommentAvatar)
})
6 changes: 6 additions & 0 deletions test/specs/views/Comment/CommentContent-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import CommentContent from 'src/views/CommentContent/CommentContent'
import * as common from 'test/specs/commonTests'
describe.only('CommentContent', () => {
common.isConformant(CommentContent)
common.rendersChildren(CommentContent)
})
6 changes: 6 additions & 0 deletions test/specs/views/Comment/CommentGroup-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import CommentGroup from 'src/views/CommentGroup/CommentGroup'
import * as common from 'test/specs/commonTests'
describe.only('CommentGroup', () => {
common.isConformant(CommentGroup)
common.rendersChildren(CommentGroup)
})
6 changes: 6 additions & 0 deletions test/specs/views/Comment/CommentMeta-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import CommentMeta from 'src/views/CommentMeta/CommentMeta'
import * as common from 'test/specs/commonTests'
describe.only('CommentMeta', () => {
common.isConformant(CommentMeta)
common.rendersChildren(CommentMeta)
})
6 changes: 6 additions & 0 deletions test/specs/views/Comment/CommentText-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import CommentText from 'src/views/CommentText/CommentText'
import * as common from 'test/specs/commonTests'
describe.only('CommentText', () => {
common.isConformant(CommentText)
common.rendersChildren(CommentText)
})