Skip to content

Commit

Permalink
feat(Comment): add size prop to Group (Semantic-Org#1327)
Browse files Browse the repository at this point in the history
* fix(Comment.Group): added size prop

* fix(Comment.Group): appending size prop value to className, added tests

* fix(Comment.Group): refactor to use SUI sizes

* fix(Comment.Group): fix typings

* Update index.d.ts

* Update CommentGroup-test.js

* Update CommentGroup.js

* Update index.d.ts

* docs(Comment.Group): added comment group size examples to doc site
  • Loading branch information
tarang9211 authored and harel committed Feb 18, 2017
1 parent 3b19184 commit 6079eb9
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 0 deletions.
129 changes: 129 additions & 0 deletions docs/app/Examples/views/Comment/Variations/CommentExampleGroupSize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import React from 'react'
import { Comment, Header } from 'semantic-ui-react'

const CommentExampleGroupSize = () => (
<div>
<Comment.Group size='mini'>
<Header as='h3' dividing>Mini Comments</Header>

<Comment>
<Comment.Avatar as='a' src='http://semantic-ui.com/images/avatar/small/matt.jpg' />
<Comment.Content>
<Comment.Author as='a'>Matt</Comment.Author>
<Comment.Metadata>
<span>Today at 5:42PM</span>
</Comment.Metadata>
<Comment.Text>How artistic!</Comment.Text>
<Comment.Actions>
<a>Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
<Comment>
<Comment.Avatar as='a' src='http://semantic-ui.com/images/avatar/small/joe.jpg' />
<Comment.Content>
<Comment.Author as='a'>Joe Henderson</Comment.Author>
<Comment.Metadata>
<span>5 days ago</span>
</Comment.Metadata>
<Comment.Text>Dude, this is awesome. Thanks so much</Comment.Text>
<Comment.Actions>
<a>Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
</Comment.Group>
<Comment.Group size='small'>
<Header as='h3' dividing>Small Comments</Header>

<Comment>
<Comment.Avatar as='a' src='http://semantic-ui.com/images/avatar/small/matt.jpg' />
<Comment.Content>
<Comment.Author as='a'>Matt</Comment.Author>
<Comment.Metadata>
<span>Today at 5:42PM</span>
</Comment.Metadata>
<Comment.Text>How artistic!</Comment.Text>
<Comment.Actions>
<a>Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
<Comment>
<Comment.Avatar as='a' src='http://semantic-ui.com/images/avatar/small/joe.jpg' />
<Comment.Content>
<Comment.Author as='a'>Joe Henderson</Comment.Author>
<Comment.Metadata>
<span>5 days ago</span>
</Comment.Metadata>
<Comment.Text>Dude, this is awesome. Thanks so much</Comment.Text>
<Comment.Actions>
<a>Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
</Comment.Group>
<Comment.Group size='large'>
<Header as='h3' dividing>Large Comments</Header>

<Comment>
<Comment.Avatar as='a' src='http://semantic-ui.com/images/avatar/small/matt.jpg' />
<Comment.Content>
<Comment.Author as='a'>Matt</Comment.Author>
<Comment.Metadata>
<span>Today at 5:42PM</span>
</Comment.Metadata>
<Comment.Text>How artistic!</Comment.Text>
<Comment.Actions>
<a>Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
<Comment>
<Comment.Avatar as='a' src='http://semantic-ui.com/images/avatar/small/joe.jpg' />
<Comment.Content>
<Comment.Author as='a'>Joe Henderson</Comment.Author>
<Comment.Metadata>
<span>5 days ago</span>
</Comment.Metadata>
<Comment.Text>Dude, this is awesome. Thanks so much</Comment.Text>
<Comment.Actions>
<a>Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
</Comment.Group>
<Comment.Group size='massive'>
<Header as='h3' dividing>Massive Comments</Header>

<Comment>
<Comment.Avatar as='a' src='http://semantic-ui.com/images/avatar/small/matt.jpg' />
<Comment.Content>
<Comment.Author as='a'>Matt</Comment.Author>
<Comment.Metadata>
<span>Today at 5:42PM</span>
</Comment.Metadata>
<Comment.Text>How artistic!</Comment.Text>
<Comment.Actions>
<a>Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
<Comment>
<Comment.Avatar as='a' src='http://semantic-ui.com/images/avatar/small/joe.jpg' />
<Comment.Content>
<Comment.Author as='a'>Joe Henderson</Comment.Author>
<Comment.Metadata>
<span>5 days ago</span>
</Comment.Metadata>
<Comment.Text>Dude, this is awesome. Thanks so much</Comment.Text>
<Comment.Actions>
<a>Reply</a>
</Comment.Actions>
</Comment.Content>
</Comment>
</Comment.Group>
</div>
)

export default CommentExampleGroupSize
5 changes: 5 additions & 0 deletions docs/app/Examples/views/Comment/Variations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ const CommentVariations = () => (
description='Comments can hide extra information unless a user shows intent to interact with a comment.'
examplePath='views/Comment/Variations/CommentExampleMinimal'
/>
<ComponentExample
title='Size'
description='Commments can have various sizes '
examplePath='views/Comment/Variations/CommentExampleGroupSize'
/>
</ExampleSection>
)

Expand Down
7 changes: 7 additions & 0 deletions src/views/Comment/CommentGroup.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import cx from 'classnames'
import _ from 'lodash'
import React, { PropTypes } from 'react'

import {
customPropTypes,
getElementType,
getUnhandledProps,
META,
SUI,
useKeyOnly,
} from '../../lib'

Expand All @@ -18,11 +20,13 @@ function CommentGroup(props) {
children,
collapsed,
minimal,
size,
threaded,
} = props

const classes = cx(
'ui',
size,
useKeyOnly(collapsed, 'collapsed'),
useKeyOnly(minimal, 'minimal'),
useKeyOnly(threaded, 'threaded'),
Expand Down Expand Up @@ -57,6 +61,9 @@ CommentGroup.propTypes = {
/** Comments can hide extra information unless a user shows intent to interact with a comment. */
minimal: PropTypes.bool,

/** Comments can have different sizes. */
size: PropTypes.oneOf(_.without(SUI.SIZES, 'medium')),

/** A comment list can be threaded to showing the relationship between conversations. */
threaded: PropTypes.bool,
}
Expand Down
3 changes: 3 additions & 0 deletions src/views/Comment/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ interface CommentGroupProps {
/** Comments can hide extra information unless a user shows intent to interact with a comment */
minimal?: boolean;

/** Comments can have different sizes. */
size?: 'mini' | 'tiny' | 'small' | 'large' | 'big' | 'huge' | 'massive';

/** A comment list can be threaded to showing the relationship between conversations */
threaded?: boolean;
}
Expand Down
5 changes: 5 additions & 0 deletions test/specs/views/Comment/CommentGroup-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import _ from 'lodash'

import { SUI } from 'src/lib'
import CommentGroup from 'src/views/Comment/CommentGroup'
import * as common from 'test/specs/commonTests'

Expand All @@ -8,4 +11,6 @@ describe('CommentGroup', () => {
common.propKeyOnlyToClassName(CommentGroup, 'collapsed')
common.propKeyOnlyToClassName(CommentGroup, 'minimal')
common.propKeyOnlyToClassName(CommentGroup, 'threaded')

common.propValueOnlyToClassName(CommentGroup, 'size', _.without(SUI.SIZES, 'medium'))
})

0 comments on commit 6079eb9

Please sign in to comment.