2020-03-04 13:57:07 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { ScrollView, StyleSheet, View } from 'react-native';
|
2021-04-19 16:57:19 +00:00
|
|
|
import { storiesOf } from '@storybook/react-native';
|
2022-05-27 17:18:51 +00:00
|
|
|
import { Provider } from 'react-redux';
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-02-17 15:27:01 +00:00
|
|
|
import Markdown, { MarkdownPreview } from '../../app/containers/markdown';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../../app/lib/constants';
|
2022-02-17 15:27:01 +00:00
|
|
|
import { TGetCustomEmoji, IEmoji } from '../../app/definitions/IEmoji';
|
2022-05-27 17:18:51 +00:00
|
|
|
import { store } from '.';
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
const theme = 'light';
|
|
|
|
|
2020-03-04 13:57:07 +00:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
2021-04-19 16:57:19 +00:00
|
|
|
marginHorizontal: 15,
|
|
|
|
backgroundColor: themes[theme].backgroundColor,
|
|
|
|
marginVertical: 50
|
2020-03-04 13:57:07 +00:00
|
|
|
},
|
|
|
|
separator: {
|
|
|
|
marginHorizontal: 10,
|
|
|
|
marginVertical: 10
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const baseUrl = 'https://open.rocket.chat';
|
2021-09-13 20:41:05 +00:00
|
|
|
const longText =
|
|
|
|
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
|
2020-03-04 13:57:07 +00:00
|
|
|
const lineBreakText = `a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
|
|
|
|
d
|
|
|
|
|
|
|
|
|
|
|
|
e`;
|
2020-12-18 14:14:25 +00:00
|
|
|
const sequentialEmptySpacesText = 'a b c';
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2022-02-17 15:27:01 +00:00
|
|
|
const getCustomEmoji: TGetCustomEmoji = content => {
|
2020-03-04 13:57:07 +00:00
|
|
|
const customEmoji = {
|
|
|
|
marioparty: { name: content, extension: 'gif' },
|
|
|
|
react_rocket: { name: content, extension: 'png' },
|
|
|
|
nyan_rocket: { name: content, extension: 'png' }
|
2022-02-17 15:27:01 +00:00
|
|
|
}[content] as IEmoji;
|
2020-03-04 13:57:07 +00:00
|
|
|
return customEmoji;
|
|
|
|
};
|
|
|
|
|
2022-05-27 17:18:51 +00:00
|
|
|
const stories = storiesOf('Markdown', module).addDecorator(story => <Provider store={store}>{story()}</Provider>);
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Text', () => (
|
|
|
|
<View style={styles.container}>
|
2022-06-27 21:27:22 +00:00
|
|
|
<Markdown msg='This is Rocket.Chat' />
|
|
|
|
<Markdown msg={longText} />
|
|
|
|
<Markdown msg={lineBreakText} />
|
|
|
|
<Markdown msg={sequentialEmptySpacesText} />
|
|
|
|
<Markdown msg='Strong emphasis, aka bold, with **asterisks** or __underscores__' />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
|
|
|
));
|
2020-12-18 14:14:25 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Preview', () => (
|
|
|
|
<View style={styles.container}>
|
2022-02-17 15:27:01 +00:00
|
|
|
<MarkdownPreview msg={longText} />
|
|
|
|
<MarkdownPreview msg={lineBreakText} />
|
|
|
|
<MarkdownPreview msg={sequentialEmptySpacesText} />
|
|
|
|
<MarkdownPreview msg='@rocket.cat @name1 @all @here @unknown #general #unknown' />
|
|
|
|
<MarkdownPreview msg='Testing: 😃 :+1: :marioparty:' />
|
|
|
|
<MarkdownPreview msg='Fallback from new md to old' />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Mentions', () => (
|
|
|
|
<ScrollView style={styles.container}>
|
|
|
|
<Markdown
|
|
|
|
msg='@rocket.cat @name1 @all @here @unknown'
|
|
|
|
mentions={[
|
|
|
|
{ _id: 'random', name: 'Rocket Cat', username: 'rocket.cat' },
|
|
|
|
{ _id: 'random2', name: 'Name', username: 'name1' },
|
|
|
|
{ _id: 'here', username: 'here' },
|
|
|
|
{ _id: 'all', username: 'all' }
|
|
|
|
]}
|
|
|
|
username='rocket.cat'
|
|
|
|
/>
|
|
|
|
<Markdown
|
|
|
|
msg='@rocket.cat @name1 @all @here @unknown'
|
|
|
|
mentions={[
|
|
|
|
{ _id: 'random', name: 'Rocket Cat', username: 'rocket.cat' },
|
|
|
|
{ _id: 'random2', name: 'Name', username: 'name1' },
|
|
|
|
{ _id: 'here', username: 'here' },
|
|
|
|
{ _id: 'all', username: 'all' }
|
|
|
|
]}
|
|
|
|
username='rocket.cat'
|
|
|
|
useRealName
|
|
|
|
/>
|
|
|
|
</ScrollView>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Hashtag', () => (
|
|
|
|
<View style={styles.container}>
|
2022-06-27 21:27:22 +00:00
|
|
|
<Markdown msg='#test-channel #unknown' channels={[{ _id: '123', name: 'test-channel' }]} />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Emoji', () => (
|
|
|
|
<View style={styles.container}>
|
2022-06-27 21:27:22 +00:00
|
|
|
<Markdown msg='Unicode: 😃😇👍' />
|
|
|
|
<Markdown msg='Shortnames: :joy::+1:' />
|
|
|
|
<Markdown msg='Custom emojis: :react_rocket: :nyan_rocket: :marioparty:' getCustomEmoji={getCustomEmoji} baseUrl={baseUrl} />
|
|
|
|
<Markdown msg='😃 :+1: :marioparty:' getCustomEmoji={getCustomEmoji} baseUrl={baseUrl} />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Block quote', () => (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<Markdown
|
|
|
|
msg={`> This is block quote
|
2020-03-04 13:57:07 +00:00
|
|
|
this is a normal line`}
|
2021-04-19 16:57:19 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Links', () => (
|
|
|
|
<View style={styles.container}>
|
2022-06-27 21:27:22 +00:00
|
|
|
<Markdown msg='[Markdown link](https://rocket.chat): `[description](url)`' />
|
|
|
|
<Markdown msg='<https://rocket.chat|Formatted Link>: `<url|description>`' />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Image', () => (
|
|
|
|
<View style={styles.container}>
|
2022-06-27 21:27:22 +00:00
|
|
|
<Markdown msg='![alt text](https://play.google.com/intl/en_us/badges/images/badge_new.png)' />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Headers', () => (
|
|
|
|
<View style={styles.container}>
|
2022-06-27 21:27:22 +00:00
|
|
|
<Markdown msg='# Header 1' />
|
|
|
|
<Markdown msg='## Header 2' />
|
|
|
|
<Markdown msg='### Header 3' />
|
|
|
|
<Markdown msg='#### Header 4' />
|
|
|
|
<Markdown msg='##### Header 5' />
|
|
|
|
<Markdown msg='###### Header 6' />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Code', () => (
|
|
|
|
<View style={styles.container}>
|
2022-06-27 21:27:22 +00:00
|
|
|
<Markdown msg='This is `inline code`' />
|
2021-04-19 16:57:19 +00:00
|
|
|
<Markdown
|
|
|
|
msg='Inline `code` has `back-ticks around` it.
|
2020-03-04 13:57:07 +00:00
|
|
|
```
|
|
|
|
Code block
|
|
|
|
```'
|
2021-04-19 16:57:19 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Lists', () => (
|
|
|
|
<View style={styles.container}>
|
2022-06-27 21:27:22 +00:00
|
|
|
<Markdown msg={'* Open Source\n* Rocket.Chat\n - nodejs\n - ReactNative'} />
|
|
|
|
<Markdown msg={'1. Open Source\n2. Rocket.Chat'} />
|
2021-04-19 16:57:19 +00:00
|
|
|
</View>
|
|
|
|
));
|
2020-03-04 13:57:07 +00:00
|
|
|
|
2021-04-19 16:57:19 +00:00
|
|
|
stories.add('Table', () => (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<Markdown
|
|
|
|
msg='First Header | Second Header
|
2020-03-04 13:57:07 +00:00
|
|
|
------------ | -------------
|
|
|
|
Content from cell 1 | Content from cell 2
|
|
|
|
Content in the first column | Content in the second column'
|
2021-04-19 16:57:19 +00:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
));
|