@digidem/wcmc-mapeo-mobile-intro
Version:
Intro screens for Mapeo Mobile for the WCMC ICCA registration app
221 lines (208 loc) • 5.44 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
/* Copyright (C) 2018-2019 The Manyverse Authors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const remark = require('remark');
const ReactMarkdown = require('react-markdown');
const normalizeForReactNative = require('mdast-normalize-react-native');
const $ = _react.createElement;
const textProps = {
selectable: true,
textBreakStrategy: 'simple'
}; // Fix for remark
process.cwd = () => '/';
const BASE_TEXT_SIZE = 15;
const LIST_INDENT = 16;
const styles = _reactNative.StyleSheet.create({
paragraph: {
flexWrap: 'wrap',
flexDirection: 'row',
alignItems: 'flex-start',
justifyContent: 'flex-start',
marginVertical: 7
},
paragraphText: {
flexWrap: 'wrap',
overflow: 'visible',
color: '#212529'
},
text: {
fontSize: BASE_TEXT_SIZE,
lineHeight: BASE_TEXT_SIZE * 1.4
},
listItemText: {
color: '#212529',
flex: 1
},
heading1: {
fontWeight: 'bold',
marginVertical: 10,
fontSize: BASE_TEXT_SIZE * 1.125 * 1.125,
color: '#212529'
},
heading2: {
fontWeight: 'bold',
marginVertical: 10,
fontSize: BASE_TEXT_SIZE * 1.125,
color: '#212529'
},
heading3: {
fontWeight: 'bold',
marginVertical: 7,
fontSize: BASE_TEXT_SIZE,
color: '#212529'
},
heading4: {
fontWeight: 'bold',
fontSize: BASE_TEXT_SIZE * 1.125,
color: '#212529'
},
heading5: {
fontWeight: 'bold',
fontSize: BASE_TEXT_SIZE * 1.125 * 1.125,
color: '#212529'
},
heading6: {
fontWeight: 'bold',
fontSize: BASE_TEXT_SIZE * 1.125 * 1.125 * 1.125,
color: '#212529'
},
em: {
fontStyle: 'italic'
},
strong: {
fontWeight: 'bold'
},
link: {
textDecorationLine: 'underline'
},
inlineCode: {
backgroundColor: '#f1f3f5',
color: '#495057',
paddingLeft: 4,
paddingRight: 4,
borderRadius: 2,
fontFamily: _reactNative.Platform.select({
ios: 'Courier New',
default: 'monospace'
})
},
strikethrough: {
textDecorationLine: 'line-through'
},
blockquote: {
backgroundColor: '#f1f3f5',
borderLeftWidth: 3,
borderLeftColor: '#adb5bd',
paddingLeft: 7,
paddingRight: 1
},
codeBlock: {
backgroundColor: '#f1f3f5',
marginVertical: 2,
paddingVertical: 3,
paddingHorizontal: 5,
borderRadius: 2
},
codeText: {
color: '#495057',
fontSize: BASE_TEXT_SIZE / 1.125,
fontWeight: 'normal',
fontFamily: _reactNative.Platform.select({
ios: 'Courier New',
default: 'monospace'
})
},
horizontalLine: {
backgroundColor: '#dee2e6',
height: 2,
marginTop: 7,
marginBottom: 7
},
orderedBullet: {
fontWeight: 'normal',
width: BASE_TEXT_SIZE * 1.5
}
});
const renderers = {
root: props => $(_reactNative.View, null, props.children),
paragraph: props => $(_reactNative.View, {
style: styles.paragraph
}, $(_reactNative.Text, { ...textProps,
style: styles.paragraphText
}, props.children)),
text: props => $(_reactNative.Text, { ...textProps,
style: styles.text
}, props.children.split('\n').join(' ')),
heading: props => $(_reactNative.Text, { ...textProps,
style: styles['heading' + props.level]
}, props.children),
emphasis: props => $(_reactNative.Text, { ...textProps,
style: styles.em
}, props.children),
strong: props => $(_reactNative.Text, { ...textProps,
style: styles.strong
}, props.children),
link: props => {
return $(_reactNative.Text, { ...textProps,
style: styles.link,
onPress: () => _reactNative.Linking.openURL(props.href)
}, props.children);
},
inlineCode: props => $(_reactNative.Text, { ...textProps,
style: styles.inlineCode
}, props.children),
delete: props => $(_reactNative.Text, { ...textProps,
style: styles.strikethrough
}, props.children),
blockquote: props => $(_reactNative.View, {
style: styles.blockquote
}, props.children),
code: props => $(_reactNative.View, {
style: styles.codeBlock
}, $(_reactNative.Text, { ...textProps,
style: styles.codeText
}, props.value)),
thematicBreak: () => $(_reactNative.View, {
style: styles.horizontalLine
}),
list: props => $(_reactNative.View, {
style: {
paddingLeft: LIST_INDENT * props.depth + 5
}
}, props.children),
listItem: props => {
return $(_reactNative.View, {
style: {
flexDirection: 'row',
alignItems: 'flex-start',
marginBottom: 5
}
}, [props.ordered ? $(_reactNative.Text, {
style: [styles.text, styles.orderedBullet],
key: 0
}, `${props.index + 1}.`) : $(_reactNative.Text, null, '\u2022 '), $(_reactNative.Text, { ...textProps,
style: styles.listItemText,
key: 1
}, props.children)]);
}
};
function Markdown(markdownText) {
return $(ReactMarkdown, {
source: remark().processSync(markdownText).contents,
astPlugins: [normalizeForReactNative()],
allowedTypes: Object.keys(renderers),
renderers
});
}
var _default = Markdown;
exports.default = _default;
//# sourceMappingURL=Markdown.js.map