Skip to content

Commit

Permalink
Increase Example List Density (#46080)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46080

1. Force the examples to be alphabetized, where the hand-maintained list has some examples that are not
2. Remove reundant/not useful UI

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D61430910

fbshipit-source-id: 1f3e116fe81502faa7a72f2720912e26c9f04bb2
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Aug 20, 2024
1 parent d713349 commit 3cd6d18
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 53 deletions.
14 changes: 5 additions & 9 deletions packages/rn-tester/js/components/RNTPressableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
import RNTesterComponentTitle from './RNTesterComponentTitle';
import {RNTesterThemeContext} from './RNTesterTheme';
import * as React from 'react';
import {Platform, Pressable, StyleSheet, Text, View} from 'react-native';
import {Pressable, StyleSheet, Text, View} from 'react-native';

type ViewStyleProp = $ElementType<React.ElementConfig<typeof View>, 'style'>;
type Props = {
accessibilityLabel?: ?string,
testID?: ?string,
onPressIn?: ?() => mixed,
onPressOut?: ?() => mixed,
bottomAddOn?: ?React.Node,
children?: ?React.Node,
title: string,
description?: ?string,
Expand All @@ -32,7 +31,6 @@ export default function RNTPressableRow({
onPressOut,
title,
description,
bottomAddOn,
onPress,
style,
accessibilityLabel,
Expand Down Expand Up @@ -60,25 +58,23 @@ export default function RNTPressableRow({
style={[styles.descriptionText, {color: theme.SecondaryLabelColor}]}>
{description}
</Text>
{bottomAddOn}
</Pressable>
);
}

const styles = StyleSheet.create({
row: {
justifyContent: 'center',
paddingHorizontal: 15,
paddingVertical: 12,
marginVertical: 4,
paddingHorizontal: 16,
paddingVertical: 16,
marginVertical: 5,
marginHorizontal: 16,
experimental_boxShadow: '0 2px 4px -1px rgba(0, 0, 0, 0.25)',
borderRadius: 8,
},
descriptionText: {
marginTop: 6,
fontSize: 12,
lineHeight: 20,
marginBottom: 5,
},
topRowStyle: {
flexDirection: 'row',
Expand Down
3 changes: 1 addition & 2 deletions packages/rn-tester/js/components/RNTesterComponentTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ class RNTesterComponentTitle extends React.Component<Props> {

const styles = StyleSheet.create({
titleText: {
fontSize: 20,
fontSize: 18,
fontWeight: '400',
marginBottom: 5,
},
});

Expand Down
44 changes: 4 additions & 40 deletions packages/rn-tester/js/components/RNTesterModuleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@ import RNTPressableRow from './RNTPressableRow';

const RNTesterExampleFilter = require('./RNTesterExampleFilter');
const React = require('react');
const {Platform, SectionList, StyleSheet, Text, View} = require('react-native');
const {SectionList, StyleSheet, Text, View} = require('react-native');

/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
* LTI update could not be added via codemod */
const ExampleModuleRow = ({
function ExampleModuleRow({
onShowUnderlay,
onHideUnderlay,
item,
handlePress,
}) => {
const theme = React.useContext(RNTesterThemeContext);
const platform = item.module.platform;
const onIos = !platform || platform === 'ios';
const onAndroid = !platform || platform === 'android';
}): React.Node {
return (
<RNTPressableRow
title={item.module.title}
Expand All @@ -35,29 +31,6 @@ const ExampleModuleRow = ({
onPressIn={onShowUnderlay}
onPressOut={onHideUnderlay}
accessibilityLabel={item.module.title + ' ' + item.module.description}
bottomAddOn={
<View style={styles.bottomRowStyle}>
<Text style={{color: theme.SecondaryLabelColor, width: 65}}>
{item.module.category || 'Other'}
</Text>
<View style={styles.platformLabelStyle}>
<Text
style={{
color: onIos ? '#787878' : theme.SeparatorColor,
fontWeight: onIos ? '500' : '300',
}}>
iOS
</Text>
<Text
style={{
color: onAndroid ? '#787878' : theme.SeparatorColor,
fontWeight: onAndroid ? '500' : '300',
}}>
Android
</Text>
</View>
</View>
}
onPress={() =>
handlePress({
exampleType: item.exampleType,
Expand All @@ -67,7 +40,7 @@ const ExampleModuleRow = ({
}
/>
);
};
}

const renderSectionHeader = ({section}: {section: any, ...}) => (
<RNTesterThemeContext.Consumer>
Expand Down Expand Up @@ -149,10 +122,6 @@ const styles = StyleSheet.create({
justifyContent: 'space-between',
flex: 1,
},
bottomRowStyle: {
flexDirection: 'row',
justifyContent: 'space-between',
},
imageViewStyle: {
height: 30,
width: 30,
Expand All @@ -166,11 +135,6 @@ const styles = StyleSheet.create({
height: 25,
width: 25,
},
platformLabelStyle: {
flexDirection: 'row',
width: 100,
justifyContent: 'space-between',
},
});

module.exports = RNTesterModuleList;
6 changes: 4 additions & 2 deletions packages/rn-tester/js/utils/testerStateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export const getExamplesListWithRecentlyUsed = ({
},
{
key: 'COMPONENTS',
data: components,
data: components.sort((a, b) =>
a.module.title.localeCompare(b.module.title),
),
title: 'Components',
},
],
Expand All @@ -109,7 +111,7 @@ export const getExamplesListWithRecentlyUsed = ({
},
{
key: 'APIS',
data: apis,
data: apis.sort((a, b) => a.module.title.localeCompare(b.module.title)),
title: 'APIs',
},
],
Expand Down

0 comments on commit 3cd6d18

Please sign in to comment.