/* eslint-disable import/no-extraneous-dependencies */
import React from 'react';
import { ScrollView, StyleSheet, View } from 'react-native';
import { storiesOf } from '@storybook/react-native';
import Markdown from '../../app/containers/markdown';
import { themes } from '../../app/constants/colors';
const theme = 'light';
const styles = StyleSheet.create({
container: {
marginHorizontal: 15,
backgroundColor: themes[theme].backgroundColor,
marginVertical: 50
},
separator: {
marginHorizontal: 10,
marginVertical: 10
}
});
const baseUrl = 'https://open.rocket.chat';
const longText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
const lineBreakText = `a
b
c
d
e`;
const sequentialEmptySpacesText = 'a b c';
const getCustomEmoji = (content) => {
const customEmoji = {
marioparty: { name: content, extension: 'gif' },
react_rocket: { name: content, extension: 'png' },
nyan_rocket: { name: content, extension: 'png' }
}[content];
return customEmoji;
};
const stories = storiesOf('Markdown', module);
stories.add('Text', () => (
<View style={styles.container}>
<Markdown msg='This is Rocket.Chat' theme={theme} />
<Markdown
msg={longText}
theme={theme}
/>
msg={lineBreakText}
msg={sequentialEmptySpacesText}
msg='Strong emphasis, aka bold, with **asterisks** or __underscores__'
</View>
));
stories.add('Edited', () => (
msg='This is edited'
isEdited
stories.add('Preview', () => (
numberOfLines={1}
preview
msg='@rocket.cat @name1 @all @here @unknown #general #unknown'
mentions={[
{ _id: 'random', name: 'Rocket Cat', username: 'rocket.cat' },
{ _id: 'random2', name: 'Name', username: 'name1' },
{ _id: 'here', username: 'here' },
{ _id: 'all', username: 'all' }
]}
channels={[{ _id: '123', name: 'test-channel' }]}
username='rocket.cat'
msg='Testing: 😃 :+1: :marioparty:'
getCustomEmoji={getCustomEmoji}
stories.add('Mentions', () => (
<ScrollView style={styles.container}>
msg='@rocket.cat @name1 @all @here @unknown'
useRealName
</ScrollView>
stories.add('Hashtag', () => (
msg='#test-channel #unknown'
stories.add('Emoji', () => (
<Markdown msg='Unicode: 😃😇👍' theme={theme} />
<Markdown msg='Shortnames: :joy::+1:' theme={theme} />
msg='Custom emojis: :react_rocket: :nyan_rocket: :marioparty:'
baseUrl={baseUrl}
msg='😃 :+1: :marioparty:'
stories.add('Block quote', () => (
msg={`> This is block quote
this is a normal line`}
stories.add('Links', () => (
<Markdown msg='[Markdown link](https://rocket.chat): `[description](url)`' theme={theme} />
<Markdown msg='<https://rocket.chat|Formatted Link>: `<url|description>`' theme={theme} />
stories.add('Image', () => (
<Markdown msg='![alt text](https://play.google.com/intl/en_us/badges/images/badge_new.png)' theme={theme} />
stories.add('Headers', () => (
msg='# Header 1'
msg='## Header 2'
msg='### Header 3'
msg='#### Header 4'
msg='##### Header 5'
msg='###### Header 6'
stories.add('Code', () => (
msg='This is `inline code`'
msg='Inline `code` has `back-ticks around` it.
```
Code block
```'
stories.add('Lists', () => (
msg={'* Open Source\n* Rocket.Chat\n - nodejs\n - ReactNative'}
msg={'1. Open Source\n2. Rocket.Chat'}
stories.add('Table', () => (
msg='First Header | Second Header
------------ | -------------
Content from cell 1 | Content from cell 2
Content in the first column | Content in the second column'