/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import { ScrollView, StyleSheet, SafeAreaView } from 'react-native';
import { storiesOf } from '@storybook/react-native';
import MessageContext from '../../app/containers/message/Context';
import { UiKitMessage } from '../../app/containers/UIKit';
import { themes } from '../../app/constants/colors';
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff'
},
padding: {
paddingHorizontal: 16
}
});
const user = {
id: 'y8bd77ptZswPj3EW8',
username: 'diego.mello',
token: '79q6lH40W4ZRGLOshDiDiVlQaCc4f_lU9HNdHLAzuHz'
};
const baseUrl = 'https://open.rocket.chat';
const messageDecorator = story => (
<MessageContext.Provider
value={{
user,
baseUrl,
onPress: () => {},
onLongPress: () => {},
reactionInit: () => {},
onErrorPress: () => {},
replyBroadcast: () => {},
onReactionPress: () => {},
onDiscussionPress: () => {},
onReactionLongPress: () => {},
threadBadgeColor: themes.light.tunreadColor
}}
>
{story()}
</MessageContext.Provider>
);
const stories = storiesOf('UiKitMessage', module)
.addDecorator(story => <SafeAreaView style={styles.container}>{story()}</SafeAreaView>)
.addDecorator(story => <ScrollView style={[styles.container, styles.padding]} keyboardShouldPersistTaps='always'>{story()}</ScrollView>)
.addDecorator(messageDecorator);
const Section = () => UiKitMessage([{
type: 'section',
text: {
type: 'mrkdwn',
text: 'Section'
}]);
stories.add('Section', () => <Section />);
const SectionMarkdownList = () => UiKitMessage([{
text: '*List*:\n1. Item'
stories.add('Section + Markdown List', () => <SectionMarkdownList />);
const SectionOverflow = () => UiKitMessage([
{
text: 'Section + Overflow'
accessory: {
type: 'overflow',
options: [
type: 'plain_text',
text: 'Option 1',
emoji: true
value: 'value-0'
text: 'Option 2',
value: 'value-1'
text: 'Option 3',
value: 'value-2'
text: 'Option 4',
value: 'value-3'
]
]);
stories.add('Section + Overflow', () => <SectionOverflow />);
const SectionImage = () => UiKitMessage([{
text: 'Section + Image'
type: 'image',
imageUrl: 'https://raw.githubusercontent.com/RocketChat/Rocket.Chat.Artwork/master/Logos/icon-circle-256.png',
altText: 'plants'
stories.add('Section + image', () => <SectionImage />);
const SectionButton = () => UiKitMessage([{
text: 'Section + button'
type: 'button',
text: 'button'
stories.add('Section + button', () => <SectionButton />);
const SectionSelect = () => UiKitMessage([{
text: 'Section + select'
type: 'static_select',
value: 1,
}, {
value: 2,
text: 'second button'
}]
stories.add('Section + Select', () => <SectionSelect />);
const SectionDatePicker = () => UiKitMessage([{
text: 'Section + DatePicker'
type: 'datepicker',
initial_date: '1990-04-28',
placeholder: {
text: 'Select a date',
stories.add('Section + DatePicker', () => <SectionDatePicker />);
const SectionMultiSelect = () => UiKitMessage([{
type: 'multi_static_select',
options: [{
value: 1
text: 'opt 1'
value: 2
text: 'opt 2'
value: 3
text: 'opt 3'
value: 4
stories.add('Section + Multi Select', () => <SectionMultiSelect />);
const Image = () => UiKitMessage([{
title: {
text: 'Example Image',
altText: 'Example Image'
stories.add('Image', () => <Image />);
const Context = () => UiKitMessage([{
type: 'context',
elements: [{
text: 'context'
stories.add('Context', () => <Context />);
const ActionButton = () => UiKitMessage([{
type: 'actions',
elements: [
emoji: true,
text: 'Approve'
style: 'primary',
value: 'click_me_123'
text: 'Deny'
style: 'danger',
stories.add('Action - Buttons', () => <ActionButton />);
const Fields = () => UiKitMessage([
fields: [
text: '*this is plain_text text*',
stories.add('Fields', () => <Fields />);
const ActionSelect = () => UiKitMessage([{
type: 'conversations_select',
text: 'Select a conversation',
type: 'channels_select',
text: 'Select a channel',
type: 'users_select',
text: 'Select a user',
text: 'Select an item',
text: 'Excellent item 1',
text: 'Fantastic item 2',
text: 'Nifty item 3',
text: 'Pretty good item 4',
stories.add('Action - Select', () => <ActionSelect />);
// stories.add('Section', () => UiKitMessage([{
// type: 'section',
// text: {
// type: 'mrkdwn',
// text: 'Section'
// }
// }]));