Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 650344d

Browse files
committed
- addressed comments;
- improved examples; - added fix for gutter being created by default;
1 parent 4fb0e96 commit 650344d

File tree

6 files changed

+71
-6
lines changed

6 files changed

+71
-6
lines changed

docs/src/examples/components/Chat/Types/ChatExample.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const ChatExample = () => (
1414
}
1515
/>
1616
<Chat.Item
17-
gutterPosition="start"
1817
gutter={
1918
<Chat.Gutter>
2019
<Avatar {...janeAvatar} />
@@ -24,7 +23,6 @@ const ChatExample = () => (
2423
/>
2524
<Chat.Item content={<Chat.Message content="What's up?" />} />
2625
<Chat.Item
27-
gutterPosition="start"
2826
content={
2927
<Chat.Message
3028
content="Would you like to grab a lunch?"
@@ -35,7 +33,6 @@ const ChatExample = () => (
3533
}
3634
/>
3735
<Chat.Item
38-
gutterPosition="start"
3936
gutter={
4037
<Chat.Gutter>
4138
<Avatar {...janeAvatar} />
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react'
2+
import { Avatar, Chat } from '@stardust-ui/react'
3+
4+
const [janeAvatar, johnAvatar] = [
5+
'public/images/avatar/small/ade.jpg',
6+
'public/images/avatar/small/joe.jpg',
7+
].map(src => ({
8+
image: src,
9+
status: { color: 'green', icon: 'check' },
10+
}))
11+
12+
const items = [
13+
{
14+
gutterPosition: 'start',
15+
gutter: { content: <Avatar {...johnAvatar} /> },
16+
content: <Chat.Message content="Hello" author="John Doe" timestamp="Yesterday, 10:15 PM" />,
17+
key: 'message-id-1',
18+
},
19+
{
20+
gutterPosition: 'end',
21+
gutter: { content: <Avatar {...janeAvatar} /> },
22+
content: <Chat.Message content="Hi" author="Jane Doe" timestamp="Yesterday, 10:15 PM" mine />,
23+
key: 'message-id-2',
24+
},
25+
]
26+
27+
const ChatExampleGutterPosition = () => <Chat items={items} />
28+
29+
export default ChatExampleGutterPosition
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react'
2+
import { Avatar, Chat } from '@stardust-ui/react'
3+
4+
const [janeAvatar, johnAvatar] = [
5+
'public/images/avatar/small/ade.jpg',
6+
'public/images/avatar/small/joe.jpg',
7+
].map(src => ({
8+
image: src,
9+
status: { color: 'green', icon: 'check' },
10+
}))
11+
12+
const ChatExampleGutterPosition = () => (
13+
<Chat>
14+
<Chat.Item
15+
gutterPosition="start"
16+
gutter={
17+
<Chat.Gutter>
18+
<Avatar {...johnAvatar} />
19+
</Chat.Gutter>
20+
}
21+
content={<Chat.Message content="Hello" author="John Doe" timestamp="Yesterday, 10:15 PM" />}
22+
/>
23+
<Chat.Item
24+
gutterPosition="end"
25+
gutter={
26+
<Chat.Gutter>
27+
<Avatar {...janeAvatar} />
28+
</Chat.Gutter>
29+
}
30+
content={<Chat.Message content="Hi" author="Jane Doe" timestamp="Yesterday, 10:15 PM" mine />}
31+
/>
32+
</Chat>
33+
)
34+
35+
export default ChatExampleGutterPosition

docs/src/examples/components/Chat/Types/ChatMessageExampleStyled.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ const ChatMessageExampleStyled = () => (
7979
}
8080
/>
8181
<Chat.Item
82-
gutterPosition="start"
8382
gutter={{ content: <Avatar {...janeAvatar} /> }}
8483
content={
8584
<Chat.Message content={{ content }} author="Jane Doe" timestamp="Yesterday, 10:15 PM" />

docs/src/examples/components/Chat/Types/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ const Types = () => (
99
description="A default Chat."
1010
examplePath="components/Chat/Types/ChatExample"
1111
/>
12+
<ComponentExample
13+
title="Gutter"
14+
description="A Chat can have a gutter positioned at the start or at the end of a message."
15+
examplePath="components/Chat/Types/ChatExampleGutterPosition"
16+
/>
1217
<ComponentExample
1318
title="Styled Chat Item"
1419
description="A Chat item with custom styles for every slot."

src/components/Chat/ChatItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class ChatItem extends UIComponent<Extendable<ChatItemProps>, any> {
4545

4646
static defaultProps = {
4747
as: 'li',
48-
gutterPosition: 'end',
48+
gutterPosition: 'start',
4949
}
5050

5151
renderComponent({ ElementType, classes, rest, styles }: RenderResultConfig<ChatItemProps>) {
@@ -60,7 +60,7 @@ class ChatItem extends UIComponent<Extendable<ChatItemProps>, any> {
6060

6161
private renderChatItem() {
6262
const { content, gutter, gutterPosition } = this.props
63-
const gutterElement = ChatGutter.create(gutter)
63+
const gutterElement = gutter && ChatGutter.create(gutter)
6464

6565
return (
6666
<>

0 commit comments

Comments
 (0)