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