Skip to content

Commit bb0e7ef

Browse files
layershifterharel
authored andcommitted
style(Feed): update typings and propTypes usage (Semantic-Org#1285)
1 parent a886aaa commit bb0e7ef

20 files changed

+194
-79
lines changed

src/views/Feed/Feed.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -20,8 +20,19 @@ import FeedSummary from './FeedSummary'
2020
import FeedUser from './FeedUser'
2121

2222
function Feed(props) {
23-
const { children, className, events, size } = props
24-
const classes = cx('ui', className, size, 'feed')
23+
const {
24+
children,
25+
className,
26+
events,
27+
size,
28+
} = props
29+
30+
const classes = cx(
31+
'ui',
32+
size,
33+
'feed',
34+
className,
35+
)
2536
const rest = getUnhandledProps(Feed, props)
2637
const ElementType = getElementType(Feed, props)
2738

@@ -50,9 +61,6 @@ function Feed(props) {
5061
Feed._meta = {
5162
name: 'Feed',
5263
type: META.TYPES.VIEW,
53-
props: {
54-
size: _.without(SUI.SIZES, 'mini', 'tiny', 'medium', 'big', 'huge', 'massive'),
55-
},
5664
}
5765

5866
Feed.propTypes = {
@@ -69,7 +77,7 @@ Feed.propTypes = {
6977
events: customPropTypes.collectionShorthand,
7078

7179
/** A feed can have different sizes. */
72-
size: PropTypes.oneOf(Feed._meta.props.size),
80+
size: PropTypes.oneOf(_.without(SUI.SIZES, 'mini', 'tiny', 'medium', 'big', 'huge', 'massive')),
7381
}
7482

7583
Feed.Content = FeedContent

src/views/Feed/FeedContent.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -15,8 +15,18 @@ import FeedMeta from './FeedMeta'
1515
import FeedSummary from './FeedSummary'
1616

1717
function FeedContent(props) {
18-
const { children, className, content, extraImages, extraText, date, meta, summary } = props
19-
const classes = cx(className, 'content')
18+
const {
19+
children,
20+
className,
21+
content,
22+
extraImages,
23+
extraText,
24+
date,
25+
meta,
26+
summary,
27+
} = props
28+
29+
const classes = cx('content', className)
2030
const rest = getUnhandledProps(FeedContent, props)
2131
const ElementType = getElementType(FeedContent, props)
2232

src/views/Feed/FeedDate.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -8,16 +8,21 @@ import {
88
getUnhandledProps,
99
META,
1010
} from '../../lib'
11+
1112
/**
12-
* Show a feed date
13+
* An event or an event summary can contain a date.
1314
*/
1415
function FeedDate(props) {
1516
const { children, className, content } = props
16-
const classes = cx(className, 'date')
17+
const classes = cx('date', className)
1718
const rest = getUnhandledProps(FeedDate, props)
1819
const ElementType = getElementType(FeedDate, props)
1920

20-
return <ElementType {...rest} className={classes}>{_.isNil(children) ? content : children}</ElementType>
21+
return (
22+
<ElementType {...rest} className={classes}>
23+
{_.isNil(children) ? content : children}
24+
</ElementType>
25+
)
2126
}
2227

2328
FeedDate._meta = {

src/views/Feed/FeedEvent.js

+23-8
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,24 @@ import {
1111
import FeedContent from './FeedContent'
1212
import FeedLabel from './FeedLabel'
1313

14+
/**
15+
* A feed contains an event.
16+
*/
1417
function FeedEvent(props) {
15-
const { content, children, className, date, extraImages, extraText, image, icon, meta, summary } = props
16-
const classes = cx(className, 'event')
18+
const {
19+
content,
20+
children,
21+
className,
22+
date,
23+
extraImages,
24+
extraText,
25+
image,
26+
icon,
27+
meta,
28+
summary,
29+
} = props
30+
31+
const classes = cx('event', className)
1732
const rest = getUnhandledProps(FeedEvent, props)
1833
const ElementType = getElementType(FeedEvent, props)
1934

@@ -47,16 +62,16 @@ FeedEvent.propTypes = {
4762
className: PropTypes.string,
4863

4964
/** Shorthand for FeedContent. */
50-
content: FeedContent.propTypes.content,
65+
content: customPropTypes.itemShorthand,
5166

5267
/** Shorthand for FeedDate. */
53-
date: FeedContent.propTypes.date,
68+
date: customPropTypes.itemShorthand,
5469

5570
/** Shorthand for FeedExtra with images. */
56-
extraImages: FeedContent.propTypes.extraImages,
71+
extraImages: customPropTypes.itemShorthand,
5772

5873
/** Shorthand for FeedExtra with content. */
59-
extraText: FeedContent.propTypes.extraText,
74+
extraText: customPropTypes.itemShorthand,
6075

6176
/** An event can contain icon label. */
6277
icon: customPropTypes.itemShorthand,
@@ -65,10 +80,10 @@ FeedEvent.propTypes = {
6580
image: customPropTypes.itemShorthand,
6681

6782
/** Shorthand for FeedMeta. */
68-
meta: FeedContent.propTypes.meta,
83+
meta: customPropTypes.itemShorthand,
6984

7085
/** Shorthand for FeedSummary. */
71-
summary: FeedContent.propTypes.summary,
86+
summary: customPropTypes.itemShorthand,
7287
}
7388

7489
export default FeedEvent

src/views/Feed/FeedExtra.js

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -11,13 +11,22 @@ import {
1111
useKeyOnly,
1212
} from '../../lib'
1313

14+
/**
15+
* A feed can contain an extra content.
16+
*/
1417
function FeedExtra(props) {
15-
const { children, className, content, images, text } = props
16-
const classes = cx(
18+
const { children,
1719
className,
20+
content,
21+
images,
22+
text,
23+
} = props
24+
25+
const classes = cx(
1826
useKeyOnly(images, 'images'),
1927
useKeyOnly(content || text, 'text'),
20-
'extra'
28+
'extra',
29+
className,
2130
)
2231
const rest = getUnhandledProps(FeedExtra, props)
2332
const ElementType = getElementType(FeedExtra, props)

src/views/Feed/FeedLabel.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -11,9 +11,19 @@ import {
1111
} from '../../lib'
1212
import Icon from '../../elements/Icon'
1313

14+
/**
15+
* An event can contain an image or icon label.
16+
*/
1417
function FeedLabel(props) {
15-
const { children, className, content, icon, image } = props
16-
const classes = cx(className, 'label')
18+
const {
19+
children,
20+
className,
21+
content,
22+
icon,
23+
image,
24+
} = props
25+
26+
const classes = cx('label', className)
1727
const rest = getUnhandledProps(FeedLabel, props)
1828
const ElementType = getElementType(FeedLabel, props)
1929

src/views/Feed/FeedLike.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -10,9 +10,18 @@ import {
1010
} from '../../lib'
1111
import Icon from '../../elements/Icon'
1212

13+
/**
14+
* A feed can contain a like element.
15+
*/
1316
function FeedLike(props) {
14-
const { children, className, content, icon } = props
15-
const classes = cx(className, 'like')
17+
const {
18+
children,
19+
className,
20+
content,
21+
icon,
22+
} = props
23+
24+
const classes = cx('like', className)
1625
const rest = getUnhandledProps(FeedLike, props)
1726
const ElementType = getElementType(FeedLike, props)
1827

src/views/Feed/FeedMeta.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -11,9 +11,18 @@ import {
1111
} from '../../lib'
1212
import FeedLike from './FeedLike'
1313

14+
/**
15+
* A feed can contain a meta.
16+
*/
1417
function FeedMeta(props) {
15-
const { children, className, content, like } = props
16-
const classes = cx(className, 'meta')
18+
const {
19+
children,
20+
className,
21+
content,
22+
like,
23+
} = props
24+
25+
const classes = cx('meta', className)
1726
const rest = getUnhandledProps(FeedMeta, props)
1827
const ElementType = getElementType(FeedMeta, props)
1928

src/views/Feed/FeedSummary.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -12,9 +12,19 @@ import {
1212
import FeedDate from './FeedDate'
1313
import FeedUser from './FeedUser'
1414

15+
/**
16+
* A feed can contain a summary.
17+
*/
1518
function FeedSummary(props) {
16-
const { children, className, content, date, user } = props
17-
const classes = cx(className, 'summary')
19+
const {
20+
children,
21+
className,
22+
content,
23+
date,
24+
user,
25+
} = props
26+
27+
const classes = cx('summary', className)
1828
const rest = getUnhandledProps(FeedSummary, props)
1929
const ElementType = getElementType(FeedSummary, props)
2030

src/views/Feed/FeedUser.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import _ from 'lodash'
21
import cx from 'classnames'
2+
import _ from 'lodash'
33
import React, { PropTypes } from 'react'
44

55
import {
@@ -9,13 +9,20 @@ import {
99
META,
1010
} from '../../lib'
1111

12+
/**
13+
* A feed can contain a user element.
14+
*/
1215
function FeedUser(props) {
1316
const { children, className, content } = props
14-
const classes = cx(className, 'user')
17+
const classes = cx('user', className)
1518
const rest = getUnhandledProps(FeedUser, props)
1619
const ElementType = getElementType(FeedUser, props)
1720

18-
return <ElementType {...rest} className={classes}>{_.isNil(children) ? content : children}</ElementType>
21+
return (
22+
<ElementType {...rest} className={classes}>
23+
{_.isNil(children) ? content : children}
24+
</ElementType>
25+
)
1926
}
2027

2128
FeedUser._meta = {

0 commit comments

Comments
 (0)