Remove BaseLink component (#5682)

* Remove BaseLink component

* Fix StarterPackCard Link component

* Rm flex_1 causing overflow

* Make newskie usage full width
This commit is contained in:
Eric Bailey
2024-10-17 14:35:45 -05:00
committed by GitHub
parent 7ca1789d6f
commit 0d5af050d3
3 changed files with 7 additions and 53 deletions
+1 -48
View File
@@ -1,10 +1,5 @@
import React from 'react' import React from 'react'
import { import {GestureResponderEvent} from 'react-native'
GestureResponderEvent,
Pressable,
StyleProp,
ViewStyle,
} from 'react-native'
import {sanitizeUrl} from '@braintree/sanitize-url' import {sanitizeUrl} from '@braintree/sanitize-url'
import {StackActions, useLinkProps} from '@react-navigation/native' import {StackActions, useLinkProps} from '@react-navigation/native'
@@ -348,48 +343,6 @@ export function createStaticClick(
} }
} }
/**
* A Pressable that uses useLink to handle navigation. It is unstyled, so can be used in cases where the Button styles
* in Link are not desired.
* @param displayText
* @param style
* @param children
* @param rest
* @constructor
*/
export function BaseLink({
displayText,
onPress: onPressOuter,
style,
children,
...rest
}: {
style?: StyleProp<ViewStyle>
children: React.ReactNode
to: string
action: 'push' | 'replace' | 'navigate'
onPress?: () => false | void
shareOnLongPress?: boolean
label: string
displayText?: string
}) {
const {onPress, ...btnProps} = useLink({
displayText: displayText ?? rest.to,
...rest,
})
return (
<Pressable
style={style}
onPress={e => {
onPressOuter?.()
onPress(e)
}}
{...btnProps}>
{children}
</Pressable>
)
}
export function WebOnlyInlineLinkText({ export function WebOnlyInlineLinkText({
children, children,
to, to,
+1 -1
View File
@@ -127,7 +127,7 @@ export function NewskieDialog({
}}> }}>
<View <View
style={[ style={[
a.flex_1, a.w_full,
a.mt_sm, a.mt_sm,
a.p_lg, a.p_lg,
a.border, a.border,
@@ -13,7 +13,7 @@ import {precacheStarterPack} from '#/state/queries/starter-packs'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useTheme} from '#/alf'
import {StarterPack} from '#/components/icons/StarterPack' import {StarterPack} from '#/components/icons/StarterPack'
import {BaseLink} from '#/components/Link' import {Link as BaseLink, LinkProps as BaseLinkProps} from '#/components/Link'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
export function Default({ export function Default({
@@ -62,7 +62,7 @@ export function Card({
} }
return ( return (
<View style={[a.flex_1, a.gap_md]}> <View style={[a.w_full, a.gap_md]}>
<View style={[a.flex_row, a.gap_sm]}> <View style={[a.flex_row, a.gap_sm]}>
{!noIcon ? <StarterPack width={40} gradient="sky" /> : null} {!noIcon ? <StarterPack width={40} gradient="sky" /> : null}
<View> <View>
@@ -96,7 +96,7 @@ export function Link({
}: { }: {
starterPack: AppBskyGraphDefs.StarterPackViewBasic starterPack: AppBskyGraphDefs.StarterPackViewBasic
onPress?: () => void onPress?: () => void
children: React.ReactNode children: BaseLinkProps['children']
}) { }) {
const {_} = useLingui() const {_} = useLingui()
const queryClient = useQueryClient() const queryClient = useQueryClient()
@@ -123,7 +123,8 @@ export function Link({
starterPack.creator.did, starterPack.creator.did,
) )
precacheStarterPack(queryClient, starterPack) precacheStarterPack(queryClient, starterPack)
}}> }}
style={[a.flex_col, a.align_start]}>
{children} {children}
</BaseLink> </BaseLink>
) )