2020-02-11 14:01:35 +00:00
|
|
|
import React from 'react';
|
2022-08-19 19:53:40 +00:00
|
|
|
import { ScrollView, StyleSheet } from 'react-native';
|
2020-02-11 14:01:35 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
import MessageContext from '../message/Context';
|
|
|
|
import { UiKitMessage } from '.';
|
|
|
|
import { themes } from '../../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',
|
2022-08-19 19:53:40 +00:00
|
|
|
token: 'abc'
|
2021-04-19 16:57:19 +00:00
|
|
|
};
|
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
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export default {
|
|
|
|
title: 'UIKit/UiKitMessage',
|
|
|
|
decorators: [
|
|
|
|
(Story: any) => (
|
|
|
|
<ScrollView style={[styles.container, styles.padding]} keyboardShouldPersistTaps='always'>
|
|
|
|
<MessageContext.Provider
|
|
|
|
value={{
|
|
|
|
user,
|
|
|
|
baseUrl,
|
|
|
|
onPress: () => {},
|
|
|
|
onLongPress: () => {},
|
|
|
|
reactionInit: () => {},
|
|
|
|
onErrorPress: () => {},
|
|
|
|
replyBroadcast: () => {},
|
|
|
|
onReactionPress: () => {},
|
|
|
|
onDiscussionPress: () => {},
|
|
|
|
onReactionLongPress: () => {},
|
|
|
|
threadBadgeColor: themes.light.tunreadColor
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Story />
|
|
|
|
</MessageContext.Provider>
|
|
|
|
</ScrollView>
|
|
|
|
)
|
|
|
|
]
|
|
|
|
};
|
2020-02-11 14:01:35 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Section = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
UiKitMessage([
|
|
|
|
{
|
|
|
|
type: 'section',
|
|
|
|
text: {
|
|
|
|
type: 'mrkdwn',
|
|
|
|
text: 'Section'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
2020-02-11 14:01:35 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const SectionMarkdownList = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
UiKitMessage([
|
|
|
|
{
|
|
|
|
type: 'section',
|
|
|
|
text: {
|
|
|
|
type: 'mrkdwn',
|
|
|
|
text: '*List*:\n1. Item'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
SectionMarkdownList.storyName = 'Section + Markdown List';
|
2021-04-19 16:57:19 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const SectionOverflow = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
SectionOverflow.storyName = 'Section + Overflow';
|
2020-02-11 14:01:35 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const SectionImage = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
SectionImage.storyName = 'Section + image';
|
2020-02-11 14:01:35 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const SectionButton = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
SectionButton.storyName = 'Section + button';
|
2021-04-19 16:57:19 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const SectionSelect = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
SectionSelect.storyName = 'Section + Select';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const SectionDatePicker = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
SectionDatePicker.storyName = 'Section + DatePicker';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const SectionMultiSelect = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
SectionMultiSelect.storyName = 'Section + Multi Select';
|
2021-04-19 16:57:19 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Image = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
Image.storyName = 'Image';
|
2020-02-11 14:01:35 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Context = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
Context.storyName = 'Context';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const ActionButton = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
ActionButton.storyName = 'Action - Buttons';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const Fields = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
Fields.storyName = 'Fields';
|
2021-09-13 20:41:05 +00:00
|
|
|
|
2022-08-19 19:53:40 +00:00
|
|
|
export const ActionSelect = () =>
|
2021-09-13 20:41:05 +00:00
|
|
|
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
|
|
|
]);
|
2022-08-19 19:53:40 +00:00
|
|
|
ActionSelect.storyName = 'Action - Select';
|