README
Link
The link component wraps its children and makes them clickable (web) or touchable (native) elements. There are two exported components:
Link
- wraps any element, effectively making it clickableTextLink
- makes any inline text a link
How to use
import Link, { TextLink } from "@times-components/link";
// works with block elements
<Link url="https://thetimes.co.uk" onPress={doSomeNavigation(url)}>
<View style={{ width: 100, height: 100, backgroundColor: "pink" }} />
</Link>
// and also with inline text
<TextLink url="https://thetimes.co.uk/" onPress={doSomeNavigation(url)}>
The Times
</TextLink>
The web version of link also accepts a responsiveLinkStyles
prop that allows
the resulting <a>
tag to be styled responsively.
Typically, apps will need to use the onPress
callback to bubble up navigation
so that the parent native Activity or UIViewContoller can handle the navigation,
rather than multiple Activities or UIViewContollers mistakingly navigating
multiple times in native land.
Contributing
Please read CONTRIBUTING.md before contributing to this package
Running the code
Please see our main README.md to get the project running locally
Development
The code can be formatted and linted in accordance with the agreed standards.
yarn fmt
yarn lint
Testing
This package uses yarn (latest) to run unit tests on each platform with jest.
yarn test:web
Visit the official storybook to see our available link templates.