* Add modal state provider, replace usage except methods * Replace easy spots * Fix sticky spots * Replace final usages * Memorize context objects * Add more warnings
44 lines
1,008 B
TypeScript
44 lines
1,008 B
TypeScript
import React from 'react'
|
|
import {Pressable, StyleProp, ViewStyle} from 'react-native'
|
|
import {Link} from './Link'
|
|
import {isWeb} from 'platform/detection'
|
|
import {makeProfileLink} from 'lib/routes/links'
|
|
import {useModalControls} from '#/state/modals'
|
|
|
|
interface UserPreviewLinkProps {
|
|
did: string
|
|
handle: string
|
|
style?: StyleProp<ViewStyle>
|
|
}
|
|
export function UserPreviewLink(
|
|
props: React.PropsWithChildren<UserPreviewLinkProps>,
|
|
) {
|
|
const {openModal} = useModalControls()
|
|
|
|
if (isWeb) {
|
|
return (
|
|
<Link
|
|
href={makeProfileLink(props)}
|
|
title={props.handle}
|
|
asAnchor
|
|
style={props.style}>
|
|
{props.children}
|
|
</Link>
|
|
)
|
|
}
|
|
return (
|
|
<Pressable
|
|
onPress={() =>
|
|
openModal({
|
|
name: 'profile-preview',
|
|
did: props.did,
|
|
})
|
|
}
|
|
accessibilityRole="button"
|
|
accessibilityLabel={props.handle}
|
|
accessibilityHint=""
|
|
style={props.style}>
|
|
{props.children}
|
|
</Pressable>
|
|
)
|
|
}
|