Introduces AppText, Link and FramedSegment redesign

This commit is contained in:
mashazyu
2020-03-23 09:39:55 +01:00
committed by Sofiya Tepikin
parent 1fc7bc17b9
commit 8c1c72ccc9
8 changed files with 116 additions and 21 deletions
+18 -8
View File
@@ -1,29 +1,39 @@
import React from 'react'
import PropTypes from 'prop-types'
import Hyperlink from 'react-native-hyperlink'
import styles from '../../styles'
import { StyleSheet } from 'react-native'
import { Colors, Typography } from '../../styles/redesign'
import links from '../../i18n/en/links'
export default function Link(props) {
const Link = ({ children }) => {
return (
<Hyperlink
linkStyle={styles.link}
linkText={replaceUrlWithText}
linkDefault
>
{props.children}
{children}
</Hyperlink>
)
}
Link.propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node
])
children: PropTypes.node
}
const styles = StyleSheet.create({
link: {
color: Colors.purple,
...Typography.mainText,
...Typography.underline,
}
})
function replaceUrlWithText(url) {
const link = Object.values(links).find(l => l.url === url)
return (link && link.text) || url
}
}
export default Link