Rocket.Chat.ReactNative/storybook/stories/RoomItem.js

128 lines
2.8 KiB
JavaScript
Raw Normal View History

2019-03-29 19:36:07 +00:00
import React from 'react';
import { ScrollView, Dimensions } from 'react-native';
2019-03-29 19:36:07 +00:00
// import moment from 'moment';
2019-12-04 16:39:53 +00:00
import { themes } from '../../app/constants/colors';
import RoomItemComponent from '../../app/presentation/RoomItem/RoomItem';
import { longText } from '../utils';
2019-03-29 19:36:07 +00:00
import StoriesSeparator from './StoriesSeparator';
const baseUrl = 'https://open.rocket.chat';
const { width } = Dimensions.get('window');
2019-12-04 16:39:53 +00:00
let _theme = 'light';
const lastMessage = {
u: {
username: 'diego.mello'
},
msg: longText
};
const updatedAt = {
date: '10:00',
roomUpdatedAt: new Date('2020-01-01')
};
2019-03-29 19:36:07 +00:00
const RoomItem = props => (
<RoomItemComponent
rid='abc'
2019-03-29 19:36:07 +00:00
type='d'
name='rocket.cat'
avatar='rocket.cat'
2019-03-29 19:36:07 +00:00
baseUrl={baseUrl}
width={width}
2019-12-04 16:39:53 +00:00
theme={_theme}
{...updatedAt}
2019-03-29 19:36:07 +00:00
{...props}
/>
);
2019-12-04 16:39:53 +00:00
// eslint-disable-next-line react/prop-types
const Separator = ({ title }) => <StoriesSeparator title={title} theme={_theme} />;
2019-03-29 19:36:07 +00:00
2019-12-04 16:39:53 +00:00
// eslint-disable-next-line react/prop-types
export default ({ theme }) => {
_theme = theme;
return (
<ScrollView style={{ backgroundColor: themes[theme].auxiliaryBackground }}>
<Separator title='Basic' />
<RoomItem />
2019-03-29 19:36:07 +00:00
2019-12-04 16:39:53 +00:00
<Separator title='User' />
<RoomItem name='diego.mello' avatar='diego.mello' />
2019-12-04 16:39:53 +00:00
<RoomItem
name={longText}
2019-12-04 16:39:53 +00:00
/>
2019-03-29 19:36:07 +00:00
2019-12-04 16:39:53 +00:00
<Separator title='Type' />
<RoomItem type='d' />
<RoomItem type='c' />
<RoomItem type='p' />
<RoomItem type='l' />
<RoomItem type='discussion' />
<RoomItem type='d' isGroupChat />
2019-12-04 16:39:53 +00:00
<RoomItem type='&' />
2019-03-29 19:36:07 +00:00
<Separator title='User status' />
<RoomItem status='online' />
<RoomItem status='away' />
<RoomItem status='busy' />
<RoomItem status='offline' />
<RoomItem status='wrong' />
2019-03-29 19:36:07 +00:00
2019-12-04 16:39:53 +00:00
<Separator title='Alerts' />
<RoomItem alert />
<RoomItem alert name='unread' unread={1} />
<RoomItem alert name='unread' unread={1000} />
<RoomItem alert name='user mentions' unread={1} userMentions={1} />
<RoomItem alert name='group mentions' unread={1} groupMentions={1} />
<RoomItem alert name='thread unread' tunread={[1]} />
<RoomItem name='user mentions > group mentions' alert unread={1} userMentions={1} groupMentions={1} />
2019-12-04 16:39:53 +00:00
<Separator title='Last Message' />
<RoomItem
showLastMessage
/>
<RoomItem
showLastMessage
lastMessage={{
u: {
username: 'rocket.chat'
},
msg: '2'
}}
/>
<RoomItem
showLastMessage
lastMessage={{
u: {
username: 'diego.mello'
},
msg: '1'
}}
username='diego.mello'
2019-12-04 16:39:53 +00:00
/>
<RoomItem
showLastMessage
lastMessage={lastMessage}
2019-12-04 16:39:53 +00:00
/>
<RoomItem
showLastMessage
alert
unread={1}
lastMessage={lastMessage}
2019-12-04 16:39:53 +00:00
/>
<RoomItem
showLastMessage
alert
unread={1000}
lastMessage={lastMessage}
/>
<RoomItem
showLastMessage
alert
unread={1000}
lastMessage={lastMessage}
2019-12-04 16:39:53 +00:00
/>
</ScrollView>
);
};