Skip to content

Commit

Permalink
Merge branch 'develop' into issue-#652
Browse files Browse the repository at this point in the history
  • Loading branch information
IanCStewart committed Jun 21, 2017
2 parents bbb04d7 + 46c4af1 commit 7d97c7c
Show file tree
Hide file tree
Showing 57 changed files with 1,870 additions and 147 deletions.
1 change: 1 addition & 0 deletions docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ rm -rf components/message/message-header
rm -rf components/message/image-message
rm -rf components/message/sticker-message
rm -rf components/message/text-message
rm -rf components/message/typing-message
npm run docs
rm -rf components
117 changes: 113 additions & 4 deletions docs/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,8 @@
},
"description": {
"name": "node",
"description": "The command's description",
"required": true
"description": "Optional command description",
"required": false
},
"param": {
"name": "node",
Expand All @@ -900,7 +900,7 @@
}
},
"required": true,
"description": "The list of commands. Must be an array of objects containing the following:\n{ title: Node, description: Node, param: Node (optional) }"
"description": "The list of commands. Must be an array of objects containing the following:\n\n{ title: Node, description: Node (optional), param: Node (optional), avatar: String (optional) }"
},
"value": {
"type": {
Expand Down Expand Up @@ -992,6 +992,88 @@
}
}
},
"components/date-separator/index.jsx": {
"description": "A separator to show above a Message",
"displayName": "DateSeparator",
"methods": [],
"props": {
"date": {
"type": {
"name": "union",
"value": [
{
"name": "string"
},
{
"name": "instanceOf",
"value": "Date"
}
]
},
"required": true,
"description": "The date to display"
},
"format": {
"type": {
"name": "string"
},
"required": false,
"description": "The format of displaying date\n\nhttps://date-fns.org/docs/format",
"defaultValue": {
"value": "'DD MMM'",
"computed": false
}
},
"style": {
"type": {
"name": "instanceOf",
"value": "Object"
},
"required": false,
"description": "Override the styles of the root element",
"defaultValue": {
"value": "{}",
"computed": false
}
},
"textStyle": {
"type": {
"name": "instanceOf",
"value": "Object"
},
"required": false,
"description": "Override the styles of the text element",
"defaultValue": {
"value": "{}",
"computed": false
}
},
"hrStyle": {
"type": {
"name": "instanceOf",
"value": "Object"
},
"required": false,
"description": "Override the styles of the hr element",
"defaultValue": {
"value": "{}",
"computed": false
}
},
"locale": {
"type": {
"name": "instanceOf",
"value": "Object"
},
"required": false,
"description": "Internationalization, defaults to English\n\nhttps://date-fns.org/docs/I18n",
"defaultValue": {
"value": "en",
"computed": true
}
}
}
},
"components/dialog/index.jsx": {
"description": "General purpose dialog",
"displayName": "Dialog",
Expand Down Expand Up @@ -3756,6 +3838,10 @@
{
"value": "'sticker'",
"computed": false
},
{
"value": "'typing'",
"computed": false
}
],
"description": "The message's type",
Expand All @@ -3771,7 +3857,7 @@
"name": "string"
},
"required": false,
"description": "The format of displaying message.createdAt",
"description": "The format of displaying message.createdAt\n\nhttps://date-fns.org/docs/format",
"defaultValue": {
"value": "'HH:mm'",
"computed": false
Expand Down Expand Up @@ -3982,6 +4068,29 @@
"computed": false
}
},
"locale": {
"type": {
"name": "instanceOf",
"value": "Object"
},
"required": false,
"description": "Internationalization, defaults to English\n\nhttps://date-fns.org/docs/I18n",
"defaultValue": {
"value": "en",
"computed": true
}
},
"separator": {
"type": {
"name": "node"
},
"required": false,
"description": "Show a separator above the message",
"defaultValue": {
"value": "null",
"computed": false
}
},
"color": {
"type": {
"name": "string"
Expand Down
2 changes: 2 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"dependencies": {
"classnames": "^2.2.5",
"color": "^1.0.3",
"date-fns": "^1.28.5",
"emojione": "^2.2.7",
"escape-html": "^1.0.3",
"prop-types": "^15.5.6",
"radium": "^0.19.1",
"react": "^15.5.3",
Expand Down
24 changes: 23 additions & 1 deletion docs/src/components/commands.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ class CommandsDoc extends Component {
description: 'mute the channel'
}
];
const mentions = [
{
title: '@IanCStewart',
avatar: 'https://avatars0.githubusercontent.com/u/14125280?v=3&s=400'
},
{
title: '@sjaakluthart',
avatar: 'https://avatars1.githubusercontent.com/u/6596471?v=3&s=400'
},
{
title: '@larstadema',
avatar: 'https://avatars2.githubusercontent.com/u/16486197?v=3&s=400'
},
];

return (
<article className="doc">
Expand All @@ -123,9 +137,17 @@ class CommandsDoc extends Component {
onMouseOver={this.handleMouseOver}
onSelect={this.handleSelect}
/>
<Commands
header="Mentions"
style={style.commands}
value={this.state.value}
commands={mentions}
onMouseOver={this.handleMouseOver}
onSelect={this.handleSelect}
/>
<MessageInput
onChange={this.changeValue}
placeholder="Type / to view and filter the commands"
placeholder="Type / to view and filter the commands, type @ to filter mentions"
value={this.state.command || this.state.value}
sendMessage={() => {}}
style={style.messageInput}
Expand Down
110 changes: 110 additions & 0 deletions docs/src/components/date-separator.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import React from 'react';
import ReactMarkdown from 'react-markdown';
import _ from 'underscore';
import addDays from 'date-fns/add_days';
import differenceInCalendarDays from 'date-fns/difference_in_calendar_days';
import Message from '../../../dist/message';
import MessageList from '../../../dist/message-list';
import Props from './props';
import components from '../../components.json';
import background from '../assets/images/channel-background.jpg';
import Paper from '../../../dist/paper';
import DateSeparator from '../../../dist/date-separator';

const usage = '```js\n import DateSeparator from \'anchor-ui/date-separator\';';

const messages = [
{
body: 'Stop talking, brain thinking. Hush. You know when grown-ups tell you \'everything\'s going to be fine\' and you think they\'re probably lying to make you feel better? I\'m the Doctor. Well, they call me the Doctor. I don\'t know why. I call me the Doctor too. I still don\'t know why.',
createdAt: new Date(),
username: 'Sjaak',
avatar: 'https://avatars1.githubusercontent.com/u/6596471?v=3&s=400',
id: 1
},
{
body: 'Daleks have no concept of elegance.',
createdAt: new Date(),
username: 'Ian',
avatar: 'https://avatars0.githubusercontent.com/u/14125280?v=3&s=400',
id: 2
},
{
body: ':pig2:',
createdAt: addDays(new Date(), 1),
username: 'Sjaak',
avatar: 'https://avatars1.githubusercontent.com/u/6596471?v=3&s=400',
id: 3
},
];

const currentUser = 'Ian';

const DateSeparatorDoc = () => {
const componentData = _.find(components, component => component.displayName === 'DateSeparator');

const style = {
paper: {
margin: 0,
padding: '20px'
},
messageList: {
backgroundImage: `url(${background})`,
backgroundSize: '500px',
height: '475px',
margin: '10px'
}
};

let lastDate = new Date();

return (
<article className="doc">
<h1>{componentData.displayName}</h1>
<section>
<h1>Description</h1>
<p>{componentData.description}</p>
</section>
<section>
<h1>Usage</h1>
<ReactMarkdown source={usage} className="markdown" />
</section>
<section>
<h1>Examples</h1>
<Paper style={style.paper}>
<MessageList style={style.messageList}>
{messages.map((message, index) => {
let showDateSeparator = false;

if (index === 0) {
showDateSeparator = true;
}

const date = message.createdAt;
const dateIsAfterLastDate = differenceInCalendarDays(date, lastDate);

if (!showDateSeparator && dateIsAfterLastDate) {
showDateSeparator = true;
}

lastDate = date;

return (
<Message
message={message}
key={`message-${message.id}`}
myMessage={message.username === currentUser}
avatar={message.avatar}
emoji
separator={showDateSeparator ? <DateSeparator date={message.createdAt} /> : null}
/>
);
})}
</MessageList>
</Paper>
</section>
<Props props={componentData.props} />
</article>
);
};

export default DateSeparatorDoc;
8 changes: 8 additions & 0 deletions docs/src/components/message.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ const messages = [
id: 6,
type: 'image'
},
{
body: 'is typing',
createdAt: new Date(),
username: 'Lars',
avatar: 'https://avatars0.githubusercontent.com/u/16486197?v=3&s=400',
id: 7,
type: 'typing'
},
];

const currentUser = 'Sjaak';
Expand Down
1 change: 1 addition & 0 deletions docs/src/components/nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const Nav = (props, context) => {
<MenuItem onClick={() => router.push('/channel-header')} active={router.isActive('/channel-header')} text="ChannelHeader" />
<MenuItem onClick={() => router.push('/checkbox')} active={router.isActive('/checkbox')} text="Checkbox" />
<MenuItem onClick={() => router.push('/commands')} active={router.isActive('/commands')} text="Commands" />
<MenuItem onClick={() => router.push('/date-separator')} active={router.isActive('/date-separator')} text="DateSeparator" />
<MenuItem onClick={() => router.push('/dialog')} active={router.isActive('/dialog')} text="Dialog" />
<MenuItem onClick={() => router.push('/divider')} active={router.isActive('/divider')} text="Divider" />
<MenuItem onClick={() => router.push('/emoji-menu')} active={router.isActive('/emoji-menu')} text="EmojiMenu" />
Expand Down
Loading

0 comments on commit 7d97c7c

Please sign in to comment.