Skip to content

Commit 9b510aa

Browse files
committed
fix: Add TextLink to provide styles for Next Link
1 parent 44ed437 commit 9b510aa

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

features/app-core/components/Typography.tsx

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { styled } from 'nativewind'
2+
import { Text as RNText, View as RNView } from 'react-native'
3+
import { Link as UniversalLink } from './Link'
4+
5+
/* --- Primitives ------------------------------------------------------------------------------ */
6+
7+
export const View = styled(RNView, '')
8+
export const Text = styled(RNText, '')
9+
10+
/* --- Typography ------------------------------------------------------------------------------ */
11+
12+
export const H1 = styled(RNText, 'font-bold text-2xl')
13+
export const H2 = styled(RNText, 'font-bold text-xl')
14+
export const H3 = styled(RNText, 'font-bold text-lg')
15+
16+
export const P = styled(RNText, 'text-base')
17+
18+
/* --- Fix for Next Link ----------------------------------------------------------------------- */
19+
20+
export const LinkText = styled(RNText, 'text-blue-500 underline')
21+
export const TextLink = (props: Omit<React.ComponentProps<typeof UniversalLink>, 'className'> & { className?: string }) => {
22+
const { className, style, children, ...universalLinkProps } = props
23+
return (
24+
<LinkText className={className} style={style}>
25+
<UniversalLink {...universalLinkProps}>
26+
{children}
27+
</UniversalLink>
28+
</LinkText>
29+
)
30+
}

features/app-core/navigation/Link.types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export type UniversalLinkProps = {
1313
/** Universal - Style prop: https://reactnative.dev/docs/text#style */
1414
style?: ExpoLinkProps['style'];
1515

16+
/** -!- Nativewind classNames should be applied to either the parent or children of Link. Ideally, create or use a TextLink component instead */
17+
className?: never;
18+
1619
/** Universal - Should replace the current route without adding to the history - Default: false. */
1720
replace?: boolean;
1821

0 commit comments

Comments
 (0)