2020-10-30 17:35:07 +00:00
|
|
|
/* eslint-disable import/no-extraneous-dependencies, import/no-unresolved, import/extensions, react/prop-types */
|
|
|
|
import React from 'react';
|
|
|
|
import { storiesOf } from '@storybook/react-native';
|
|
|
|
import { ScrollView } from 'react-native';
|
|
|
|
import { combineReducers, createStore } from 'redux';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
|
|
|
|
import Item from './Item';
|
|
|
|
import * as List from '../../containers/List';
|
|
|
|
import { themes } from '../../constants/colors';
|
|
|
|
import { ThemeContext } from '../../theme';
|
|
|
|
|
|
|
|
const author = {
|
|
|
|
_id: 'userid',
|
|
|
|
username: 'rocket.cat',
|
|
|
|
name: 'Rocket Cat'
|
|
|
|
};
|
|
|
|
const baseUrl = 'https://open.rocket.chat';
|
|
|
|
const date = new Date(2020, 10, 10, 10);
|
|
|
|
const longText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
|
|
|
|
const defaultItem = {
|
|
|
|
msg: 'Message content',
|
|
|
|
tcount: 1,
|
|
|
|
replies: [1],
|
|
|
|
ts: date,
|
|
|
|
tlm: date,
|
|
|
|
u: author,
|
|
|
|
attachments: []
|
|
|
|
};
|
|
|
|
|
|
|
|
const BaseItem = ({ item, ...props }) => (
|
|
|
|
<Item
|
|
|
|
baseUrl={baseUrl}
|
|
|
|
item={{
|
|
|
|
...defaultItem,
|
|
|
|
...item
|
|
|
|
}}
|
|
|
|
onPress={() => alert('pressed')}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const listDecorator = story => (
|
|
|
|
<ScrollView>
|
|
|
|
<List.Separator />
|
|
|
|
{story()}
|
|
|
|
<List.Separator />
|
|
|
|
</ScrollView>
|
|
|
|
);
|
|
|
|
|
|
|
|
const reducers = combineReducers({
|
|
|
|
login: () => ({
|
|
|
|
user: {
|
|
|
|
id: 'abc',
|
|
|
|
username: 'rocket.cat',
|
|
|
|
name: 'Rocket Cat'
|
|
|
|
}
|
|
|
|
}),
|
2020-11-04 16:53:44 +00:00
|
|
|
server: () => ({
|
|
|
|
server: 'https://open.rocket.chat',
|
|
|
|
version: '3.7.0'
|
|
|
|
}),
|
2020-10-30 17:35:07 +00:00
|
|
|
share: () => ({
|
2020-11-04 16:53:44 +00:00
|
|
|
server: 'https://open.rocket.chat',
|
|
|
|
version: '3.7.0'
|
2020-10-30 17:35:07 +00:00
|
|
|
}),
|
|
|
|
settings: () => ({
|
|
|
|
blockUnauthenticatedAccess: false
|
|
|
|
})
|
|
|
|
});
|
|
|
|
const store = createStore(reducers);
|
|
|
|
|
|
|
|
const stories = storiesOf('Thread Messages.Item', module)
|
|
|
|
.addDecorator(listDecorator)
|
|
|
|
.addDecorator(story => <Provider store={store}>{story()}</Provider>);
|
|
|
|
|
|
|
|
stories.add('content', () => (
|
|
|
|
<>
|
|
|
|
<BaseItem />
|
|
|
|
<List.Separator />
|
|
|
|
<BaseItem
|
|
|
|
item={{
|
|
|
|
msg: longText
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
<BaseItem
|
|
|
|
item={{
|
|
|
|
tcount: 1000,
|
|
|
|
replies: [...new Array(1000)]
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
<BaseItem
|
|
|
|
item={{
|
|
|
|
msg: '',
|
|
|
|
attachments: [{ title: 'Attachment title' }]
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
<BaseItem useRealName />
|
|
|
|
</>
|
|
|
|
));
|
|
|
|
|
|
|
|
stories.add('badge', () => (
|
|
|
|
<>
|
|
|
|
<BaseItem
|
2020-12-17 17:39:45 +00:00
|
|
|
badgeColor={themes.light.mentionMeColor}
|
2020-10-30 17:35:07 +00:00
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
<BaseItem
|
2020-12-17 17:39:45 +00:00
|
|
|
badgeColor={themes.light.mentionGroupColor}
|
2020-10-30 17:35:07 +00:00
|
|
|
/>
|
|
|
|
<List.Separator />
|
|
|
|
<BaseItem
|
2020-12-17 17:39:45 +00:00
|
|
|
badgeColor={themes.light.tunreadColor}
|
2020-10-30 17:35:07 +00:00
|
|
|
/>
|
|
|
|
<BaseItem
|
|
|
|
item={{
|
|
|
|
msg: longText
|
|
|
|
}}
|
2020-12-17 17:39:45 +00:00
|
|
|
badgeColor={themes.light.tunreadColor}
|
2020-10-30 17:35:07 +00:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
));
|
|
|
|
|
|
|
|
const ThemeStory = ({ theme }) => (
|
|
|
|
<ThemeContext.Provider
|
|
|
|
value={{ theme }}
|
|
|
|
>
|
|
|
|
<BaseItem
|
2020-12-17 17:39:45 +00:00
|
|
|
badgeColor={themes[theme].mentionMeColor}
|
2020-10-30 17:35:07 +00:00
|
|
|
/>
|
|
|
|
</ThemeContext.Provider>
|
|
|
|
);
|
|
|
|
|
|
|
|
stories.add('themes', () => (
|
|
|
|
<>
|
|
|
|
<ThemeStory theme='light' />
|
|
|
|
<ThemeStory theme='dark' />
|
|
|
|
<ThemeStory theme='black' />
|
|
|
|
</>
|
|
|
|
));
|