Skip to content

Commit 618fbb5

Browse files
layershifterharel
authored andcommitted
style(Comment): update typings and propTypes usage (Semantic-Org#1293)
* style(Comment): update typings and propTypes usage * docs(CommentContent): update component description * docs(CommentText): update component description
1 parent 68c4aaa commit 618fbb5

19 files changed

+73
-41
lines changed

src/views/Comment/Comment.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@ import CommentMetadata from './CommentMetadata'
1818
import CommentText from './CommentText'
1919

2020
/**
21-
* A comment displays user feedback to site content
21+
* A comment displays user feedback to site content.
2222
* */
2323
function Comment(props) {
24-
const {
25-
className,
26-
children,
27-
collapsed,
28-
} = props
24+
const { className, children, collapsed } = props
2925

3026
const classes = cx(
3127
useKeyOnly(collapsed, 'collapsed'),

src/views/Comment/CommentAction.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import {
99
useKeyOnly,
1010
} from '../../lib'
1111

12+
/**
13+
* A comment can contain an action.
14+
*/
1215
function CommentAction(props) {
13-
const {
14-
active,
15-
className,
16-
children,
17-
} = props
16+
const { active, className, children } = props
1817

1918
const classes = cx(
2019
useKeyOnly(active, 'active'),

src/views/Comment/CommentActions.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
META,
99
} from '../../lib'
1010

11+
/**
12+
* A comment can contain an list of actions a user may perform related to this comment.
13+
*/
1114
function CommentActions(props) {
1215
const { className, children } = props
1316
const classes = cx('actions', className)

src/views/Comment/CommentAuthor.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
META,
99
} from '../../lib'
1010

11+
/**
12+
* A comment can contain an author.
13+
*/
1114
function CommentAuthor(props) {
1215
const { className, children } = props
1316
const classes = cx('author', className)

src/views/Comment/CommentAvatar.js

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
META,
1010
} from '../../lib'
1111

12+
/**
13+
* A comment can contain an image or avatar.
14+
*/
1215
function CommentAvatar(props) {
1316
const { className, src } = props
1417
const classes = cx('avatar', className)

src/views/Comment/CommentContent.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import {
88
META,
99
} from '../../lib'
1010

11+
/**
12+
* A comment can contain content.
13+
*/
1114
function CommentContent(props) {
1215
const { className, children } = props
13-
const classes = cx('content', className)
16+
const classes = cx(className, 'content')
1417
const rest = getUnhandledProps(CommentContent, props)
1518
const ElementType = getElementType(CommentContent, props)
1619

src/views/Comment/CommentGroup.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
useKeyOnly,
1010
} from '../../lib'
1111

12+
/**
13+
* Comments can be grouped.
14+
*/
1215
function CommentGroup(props) {
1316
const {
1417
className,
@@ -51,10 +54,10 @@ CommentGroup.propTypes = {
5154
/** Comments can be collapsed, or hidden from view. */
5255
collapsed: PropTypes.bool,
5356

54-
/** Comments can hide extra information unless a user shows intent to interact with a comment */
57+
/** Comments can hide extra information unless a user shows intent to interact with a comment. */
5558
minimal: PropTypes.bool,
5659

57-
/** A comment list can be threaded to showing the relationship between conversations */
60+
/** A comment list can be threaded to showing the relationship between conversations. */
5861
threaded: PropTypes.bool,
5962
}
6063

src/views/Comment/CommentMetadata.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
META,
99
} from '../../lib'
1010

11+
/**
12+
* A comment can contain metadata about the comment, an arbitrary amount of metadata may be defined.
13+
*/
1114
function CommentMetadata(props) {
1215
const { className, children } = props
1316
const classes = cx('metadata', className)

src/views/Comment/CommentText.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ import {
88
META,
99
} from '../../lib'
1010

11+
/**
12+
* A comment can contain text.
13+
*/
1114
function CommentText(props) {
1215
const { className, children } = props
13-
const classes = cx('text', className)
16+
const classes = cx(className, 'text')
1417
const rest = getUnhandledProps(CommentText, props)
1518
const ElementType = getElementType(CommentText, props)
1619

src/views/Comment/index.d.ts

+33-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as React from 'react';
22

33
interface CommentProps {
4+
[key: string]: any;
5+
46
/** An element type to render as (string or function). */
57
as?: any;
68

@@ -14,35 +16,39 @@ interface CommentProps {
1416
collapsed?: boolean;
1517
}
1618

17-
interface CommentClass extends React.ComponentClass<CommentProps> {
18-
Author: typeof CommentAuthor;
19+
interface CommentComponent extends React.StatelessComponent<CommentProps> {
1920
Action: typeof CommentAction;
2021
Actions: typeof CommentActions;
22+
Author: typeof CommentAuthor;
2123
Avatar: typeof CommentAvatar;
2224
Content: typeof CommentContent;
2325
Group: typeof CommentGroup;
2426
Metadata: typeof CommentMetadata;
2527
Text: typeof CommentText;
2628
}
2729

28-
export const Comment: CommentClass;
30+
export const Comment: CommentComponent;
31+
32+
interface CommentActionProps {
33+
[key: string]: any;
2934

30-
interface CommentAuthorProps {
3135
/** An element type to render as (string or function). */
3236
as?: any;
3337

38+
/** Style as the currently active action. */
39+
active?: boolean;
40+
3441
/** Primary content. */
3542
children?: React.ReactNode;
3643

3744
/** Additional classes. */
3845
className?: string;
3946
}
4047

41-
export const CommentAuthor: React.ComponentClass<CommentAuthorProps>;
48+
export const CommentAction: React.ComponentClass<CommentActionProps>;
4249

43-
interface CommentActionProps {
44-
/** Style as the currently active action. */
45-
active?: boolean;
50+
interface CommentActionsProps {
51+
[key: string]: any;
4652

4753
/** An element type to render as (string or function). */
4854
as?: any;
@@ -54,11 +60,13 @@ interface CommentActionProps {
5460
className?: string;
5561
}
5662

57-
export const CommentAction: React.ComponentClass<CommentActionProps>;
63+
export const CommentActions: React.StatelessComponent<CommentActionsProps>;
64+
65+
interface CommentAuthorProps {
66+
[key: string]: any;
5867

59-
interface CommentActionsProps {
6068
/** An element type to render as (string or function). */
61-
as?: any;
69+
as?: any;
6270

6371
/** Primary content. */
6472
children?: React.ReactNode;
@@ -67,9 +75,11 @@ interface CommentActionsProps {
6775
className?: string;
6876
}
6977

70-
export const CommentActions: React.ComponentClass<CommentActionsProps>;
78+
export const CommentAuthor: React.StatelessComponent<CommentAuthorProps>;
7179

7280
interface CommentAvatarProps {
81+
[key: string]: any;
82+
7383
/** An element type to render as (string or function). */
7484
as?: any;
7585

@@ -80,9 +90,11 @@ interface CommentAvatarProps {
8090
src?: string;
8191
}
8292

83-
export const CommentAvatar: React.ComponentClass<CommentAvatarProps>;
93+
export const CommentAvatar: React.StatelessComponent<CommentAvatarProps>;
8494

8595
interface CommentContentProps {
96+
[key: string]: any;
97+
8698
/** An element type to render as (string or function). */
8799
as?: any;
88100

@@ -93,9 +105,11 @@ interface CommentContentProps {
93105
className?: string;
94106
}
95107

96-
export const CommentContent: React.ComponentClass<CommentContentProps>;
108+
export const CommentContent: React.StatelessComponent<CommentContentProps>;
97109

98110
interface CommentGroupProps {
111+
[key: string]: any;
112+
99113
/** An element type to render as (string or function). */
100114
as?: any;
101115

@@ -115,9 +129,10 @@ interface CommentGroupProps {
115129
threaded?: boolean;
116130
}
117131

118-
export const CommentGroup: React.ComponentClass<CommentGroupProps>;
132+
export const CommentGroup: React.StatelessComponent<CommentGroupProps>;
119133

120134
interface CommentMetadataProps {
135+
[key: string]: any;
121136

122137
/** An element type to render as (string or function). */
123138
as?: any;
@@ -129,9 +144,10 @@ interface CommentMetadataProps {
129144
className?: string;
130145
}
131146

132-
export const CommentMetadata: React.ComponentClass<CommentMetadataProps>;
147+
export const CommentMetadata: React.StatelessComponent<CommentMetadataProps>;
133148

134149
interface CommentTextProps {
150+
[key: string]: any;
135151

136152
/** An element type to render as (string or function). */
137153
as?: any;
@@ -143,4 +159,4 @@ interface CommentTextProps {
143159
className?: string;
144160
}
145161

146-
export const CommentText: React.ComponentClass<CommentTextProps>;
162+
export const CommentText: React.StatelessComponent<CommentTextProps>;

test/specs/views/Comment/Comment-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as common from 'test/specs/commonTests'
21
import Comment from 'src/views/Comment/Comment'
32
import CommentAction from 'src/views/Comment/CommentAction'
43
import CommentActions from 'src/views/Comment/CommentActions'
@@ -8,6 +7,7 @@ import CommentContent from 'src/views/Comment/CommentContent'
87
import CommentGroup from 'src/views/Comment/CommentGroup'
98
import CommentMetadata from 'src/views/Comment/CommentMetadata'
109
import CommentText from 'src/views/Comment/CommentText'
10+
import * as common from 'test/specs/commonTests'
1111

1212
describe('Comment', () => {
1313
common.isConformant(Comment)

test/specs/views/Comment/CommentAction-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22

3-
import * as common from 'test/specs/commonTests'
43
import CommentAction from 'src/views/Comment/CommentAction'
4+
import * as common from 'test/specs/commonTests'
55

66
describe('CommentAction', () => {
77
common.isConformant(CommentAction)

test/specs/views/Comment/CommentActions-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as common from 'test/specs/commonTests'
21
import CommentActions from 'src/views/Comment/CommentActions'
2+
import * as common from 'test/specs/commonTests'
33

44
describe('CommentActions', () => {
55
common.isConformant(CommentActions)

test/specs/views/Comment/CommentAuthor-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as common from 'test/specs/commonTests'
21
import CommentAuthor from 'src/views/Comment/CommentAuthor'
2+
import * as common from 'test/specs/commonTests'
33

44
describe('CommentAuthor', () => {
55
common.isConformant(CommentAuthor)

test/specs/views/Comment/CommentAvatar-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import faker from 'faker'
22
import React from 'react'
33

4-
import * as common from 'test/specs/commonTests'
54
import CommentAvatar from 'src/views/Comment/CommentAvatar'
5+
import * as common from 'test/specs/commonTests'
66

77
describe('CommentAvatar', () => {
88
common.isConformant(CommentAvatar)

test/specs/views/Comment/CommentContent-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as common from 'test/specs/commonTests'
21
import CommentContent from 'src/views/Comment/CommentContent'
2+
import * as common from 'test/specs/commonTests'
33

44
describe('CommentContent', () => {
55
common.isConformant(CommentContent)

test/specs/views/Comment/CommentGroup-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as common from 'test/specs/commonTests'
21
import CommentGroup from 'src/views/Comment/CommentGroup'
2+
import * as common from 'test/specs/commonTests'
33

44
describe('CommentGroup', () => {
55
common.isConformant(CommentGroup)

test/specs/views/Comment/CommentMetadata-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as common from 'test/specs/commonTests'
21
import CommentMetadata from 'src/views/Comment/CommentMetadata'
2+
import * as common from 'test/specs/commonTests'
33

44
describe('CommentMetadata', () => {
55
common.isConformant(CommentMetadata)

test/specs/views/Comment/CommentText-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as common from 'test/specs/commonTests'
21
import CommentText from 'src/views/Comment/CommentText'
2+
import * as common from 'test/specs/commonTests'
33

44
describe('CommentText', () => {
55
common.isConformant(CommentText)

0 commit comments

Comments
 (0)