-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial version of package page concept
- Loading branch information
Showing
12 changed files
with
45,517 additions
and
14,459 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { type ReactNode } from 'react'; | ||
import { Image, StyleSheet, View } from 'react-native'; | ||
|
||
import { A, H3, P } from '../common/styleguide'; | ||
|
||
type Props = { | ||
header?: string; | ||
alt?: string; | ||
bottomSlot?: ReactNode; | ||
}; | ||
|
||
export function NotFoundContent({ | ||
header = 'Nothing was found! Try another search.', | ||
alt = 'No results', | ||
bottomSlot, | ||
}: Props) { | ||
return ( | ||
<View style={styles.container}> | ||
<Image style={styles.img} source={require('../assets/notfound.png')} alt={alt} /> | ||
<H3 style={styles.text}>{header}</H3> | ||
{bottomSlot} | ||
<View style={{ marginTop: 20 }} /> | ||
<P style={styles.text}> | ||
Want to contribute a library you like? Submit a PR to the{' '} | ||
<A href="https://github.com/react-native-community/react-native-directory">Github Repo</A>. | ||
</P> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
alignItems: 'center', | ||
width: '100%', | ||
paddingHorizontal: 24, | ||
marginTop: 40, | ||
marginBottom: 80, | ||
}, | ||
librariesContainer: { | ||
paddingTop: 8, | ||
}, | ||
img: { | ||
marginTop: 48, | ||
marginBottom: 24, | ||
width: 64, | ||
height: 64, | ||
}, | ||
text: { | ||
textAlign: 'center', | ||
}, | ||
}); |
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,81 @@ | ||
import { View } from 'react-native'; | ||
|
||
import { A, Caption, Label } from '../common/styleguide'; | ||
import { PackageJsonData } from '../types'; | ||
|
||
type Props = { | ||
author?: PackageJsonData['author']; | ||
size?: 'sm' | 'md'; | ||
}; | ||
|
||
export function PackageAuthor({ author }: Props) { | ||
if (!author) { | ||
return ( | ||
<View> | ||
<Label>Unknown</Label> | ||
</View> | ||
); | ||
} | ||
|
||
if (typeof author !== 'string') { | ||
if (author?.url) { | ||
return ( | ||
<View> | ||
<A href={author?.url} target="_blank"> | ||
<Label>{author?.name ?? 'Unknown'}</Label> | ||
</A> | ||
</View> | ||
); | ||
} | ||
return ( | ||
<View> | ||
<Label>{author?.name ?? 'Unknown'}</Label> | ||
</View> | ||
); | ||
} | ||
|
||
if (author.includes('github.com/')) { | ||
const [potentialName, potentialGHUsername] = author.split('github.com/'); | ||
const ghUsername = potentialGHUsername.replace(/[<>()]/g, ''); | ||
const validName = getValidName(potentialName); | ||
|
||
return ( | ||
<View> | ||
<A | ||
href={`https://github.com/${ghUsername}`} | ||
target="_blank" | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
gap: 12, | ||
alignItems: 'center', | ||
backgroundColor: 'transparent', | ||
}}> | ||
<img | ||
src={`https://github.com/${ghUsername}.png`} | ||
style={{ width: 36, height: 36, borderRadius: '100%' }} | ||
alt={`${ghUsername} avatar`} | ||
/> | ||
<View> | ||
<Caption style={{ lineHeight: 16 }}>{ghUsername}</Caption> | ||
<Label>{validName}</Label> | ||
</View> | ||
</A> | ||
</View> | ||
); | ||
} | ||
|
||
return ( | ||
<View> | ||
<Label>{getValidName(author) ?? author ?? 'Unknown'}</Label> | ||
</View> | ||
); | ||
} | ||
|
||
function getValidName(potentialName: string): string { | ||
const cleanName = potentialName | ||
.split(' ') | ||
.filter(word => !(word.includes('(') || word.includes('/') || word.includes('<'))) | ||
.join(' '); | ||
return cleanName.length ? cleanName : potentialName.replace(/[<>()]/g, ''); | ||
} |
Oops, something went wrong.