-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathComposer.stories.js
97 lines (90 loc) · 3.32 KB
/
Composer.stories.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import React, {useState} from 'react';
import {View, Image} from 'react-native';
import Composer from '../components/Composer';
import RenderHTML from '../components/RenderHTML';
import Text from '../components/Text';
import styles from '../styles/styles';
import themeColors from '../styles/themes/default';
import * as StyleUtils from '../styles/StyleUtils';
import CONST from '../CONST';
/**
* We use the Component Story Format for writing stories. Follow the docs here:
*
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format
*/
const story = {
title: 'Components/Composer',
component: Composer,
};
const parser = new ExpensiMark();
const Default = (args) => {
const [pastedFile, setPastedFile] = useState(null);
const [comment, setComment] = useState(args.defaultValue);
const renderedHTML = parser.replace(comment);
return (
<View>
<View style={[styles.border, styles.p4]}>
<Composer
// eslint-disable-next-line react/jsx-props-no-spreading
{...args}
multiline
textAlignVertical="top"
onChangeText={setComment}
onPasteFile={setPastedFile}
style={[styles.textInputCompose, styles.w100]}
/>
</View>
<View style={[styles.flexRow, styles.mv5, styles.flexWrap, styles.w100]}>
<View
style={[
styles.border,
styles.noLeftBorderRadius,
styles.noRightBorderRadius,
styles.p5,
styles.flex1,
]}
nativeID={CONST.REPORT.DROP_NATIVE_ID}
>
<Text style={[styles.mb2, styles.textLabelSupporting]}>Entered Comment (Drop Enabled)</Text>
<Text>{comment}</Text>
</View>
<View
style={[
styles.p5,
styles.borderBottom,
styles.borderRight,
styles.borderTop,
styles.flex1,
]}
>
<Text style={[styles.mb2, styles.textLabelSupporting]}>Rendered Comment</Text>
{Boolean(renderedHTML) && <RenderHTML html={renderedHTML} />}
{pastedFile && (
<View style={styles.mv3}>
<Image
source={{uri: URL.createObjectURL(pastedFile)}}
resizeMode="contain"
style={StyleUtils.getWidthAndHeightStyle(250, 250)}
/>
</View>
)}
</View>
</View>
</View>
);
};
Default.args = {
autoFocus: true,
placeholder: 'Compose Text Here',
placeholderTextColor: themeColors.placeholderText,
defaultValue: `Composer can do the following:
* It can contain MD e.g. *bold* _italic_
* Supports Pasted Images via Ctrl+V`,
isDisabled: false,
maxLines: 16,
};
export default story;
export {
Default,
};