-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from Expensify/jack-fixFooterLinks
Fix the weird links on the Footer
- Loading branch information
Showing
5 changed files
with
66 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import _ from 'underscore'; | ||
import {Linking, Text} from 'react-native'; | ||
|
||
/** | ||
* Text based component that is passed a URL to open onPress | ||
*/ | ||
|
||
const propTypes = { | ||
// The URL to open | ||
href: PropTypes.string.isRequired, | ||
|
||
// Any children to display | ||
children: PropTypes.node, | ||
|
||
// Any additional styles to apply | ||
// eslint-disable-next-line react/forbid-prop-types | ||
style: PropTypes.any, | ||
}; | ||
|
||
const defaultProps = { | ||
children: null, | ||
style: {}, | ||
}; | ||
|
||
const Anchor = ({ | ||
href, | ||
children, | ||
style, | ||
...props | ||
}) => { | ||
// If the style prop is an array of styles, we need to mix them all together | ||
const mergedStyles = !_.isArray(style) ? style : _.reduce(style, (finalStyles, s) => ({ | ||
...finalStyles, | ||
...s | ||
}), {}); | ||
|
||
return ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<Text style={mergedStyles} onPress={() => Linking.openURL(href)} {...props}> | ||
{children} | ||
</Text> | ||
); | ||
}; | ||
|
||
Anchor.propTypes = propTypes; | ||
Anchor.defaultProps = defaultProps; | ||
Anchor.displayName = 'Anchor'; | ||
|
||
export default Anchor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters