-
Notifications
You must be signed in to change notification settings - Fork 3k
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 #32670 from VickyStash/ts-migration/anchorForComme…
…ntsOnly-component [TS migration] Migrate 'AnchorForCommentsOnly' component to TypeScript
- Loading branch information
Showing
19 changed files
with
292 additions
and
278 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
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
35 changes: 0 additions & 35 deletions
35
src/components/AnchorForCommentsOnly/anchorForCommentsOnlyPropTypes.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
import React from 'react'; | ||
import {Linking} from 'react-native'; | ||
import BaseAnchorForCommentsOnly from './BaseAnchorForCommentsOnly'; | ||
import type {AnchorForCommentsOnlyProps} from './types'; | ||
|
||
function AnchorForCommentsOnly({onPress, href = '', ...props}: AnchorForCommentsOnlyProps) { | ||
const onLinkPress = () => { | ||
if (onPress) { | ||
onPress(); | ||
} else { | ||
Linking.openURL(href); | ||
} | ||
}; | ||
|
||
return ( | ||
<BaseAnchorForCommentsOnly | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...props} | ||
href={href} | ||
onPress={onLinkPress} | ||
/> | ||
); | ||
} | ||
|
||
AnchorForCommentsOnly.displayName = 'AnchorForCommentsOnly'; | ||
|
||
export default AnchorForCommentsOnly; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {StyleProp, TextStyle} from 'react-native'; | ||
import ChildrenProps from '@src/types/utils/ChildrenProps'; | ||
|
||
type AnchorForCommentsOnlyProps = ChildrenProps & { | ||
/** The URL to open */ | ||
href?: string; | ||
|
||
/** What headers to send to the linked page (usually noopener and noreferrer) | ||
This is unused in native, but is here for parity with web */ | ||
rel?: string; | ||
|
||
/** Used to determine where to open a link ("_blank" is passed for a new tab) | ||
This is unused in native, but is here for parity with web */ | ||
target?: string; | ||
|
||
/** Any additional styles to apply */ | ||
style: StyleProp<TextStyle>; | ||
|
||
/** Press handler for the link, when not passed, default href is used to create a link like behaviour */ | ||
onPress?: () => void; | ||
}; | ||
|
||
type BaseAnchorForCommentsOnlyProps = AnchorForCommentsOnlyProps & { | ||
/** Press in handler for the link */ | ||
onPressIn?: () => void; | ||
|
||
/** Press out handler for the link */ | ||
onPressOut?: () => void; | ||
}; | ||
|
||
type LinkProps = { | ||
/** Press handler for the link, when not passed, default href is used to create a link like behaviour */ | ||
onPress?: () => void; | ||
|
||
/** The URL to open */ | ||
href?: string; | ||
}; | ||
|
||
export type {AnchorForCommentsOnlyProps, BaseAnchorForCommentsOnlyProps, LinkProps}; |
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
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
Oops, something went wrong.