mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: This Pull request adds the UI changes to the RNTester app as discussed in the MLH Fellowship. This list is not exhaustive. - The initial App screen is redesigned. - A bottom Navbar has been added. - Filter pills are added. - The list card UI is updated. - The example page UI is updated. - Recently Viewed Sections are added. It shows the last 5 recently viewed components/APIs. - Bookmarking functionality is added. - The documentation URL is added to the example page. - RNTester doesn't lose its state on a hard refresh (even on iOS). <img width="373" src="https://user-images.githubusercontent.com/22813027/90530113-20346180-e192-11ea-8ef6-789fa25b402b.png" /> <img width="373" src="https://user-images.githubusercontent.com/22813027/90530112-20346180-e192-11ea-9539-706b540fcc5f.png" /> <img width="373" src="https://user-images.githubusercontent.com/22813027/90530100-1d397100-e192-11ea-8836-b88070643233.png" /> <img width="373" src="https://user-images.githubusercontent.com/22813027/90530110-1f9bcb00-e192-11ea-936b-64ee75fa4289.png" /> Pull Request resolved: https://github.com/facebook/react-native/pull/29685 Test Plan: Imported from GitHub, without a `Test Plan:` line. {F302717939} Note: this failed **before** this diff too: {F302745716} Reviewed By: mdvacca, cpojer Differential Revision: D23240434 fbshipit-source-id: 65e2766a6a097eca0e0d0fda8dadf6871e9276c2 Co-authored-by: agarwalmanya <manya18ag@gmail.com> Co-authored-by: chirag-singhal <csinghal208@gmail.com> Co-authored-by: Ansh Godha <ag759@cornell.edu> Co-authored-by: Yash Kumar Verma <yk.verma2000@gmail.com> Co-authored-by: Sanskar Jethi <sansyrox@gmail.com> Co-authored-by: Aniketh Saha <anik220798@gmail.com> Co-authored-by: Xtremilicious <nilarjundas@outlook.com> Co-authored-by: Jani Evakallio <jani.evakallio@gmail.com>
105 lines
2.9 KiB
JavaScript
105 lines
2.9 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const React = require('react');
|
|
const {Platform} = require('react-native');
|
|
const RNTesterBlock = require('./RNTesterBlock');
|
|
const RNTesterExampleFilter = require('./RNTesterExampleFilter');
|
|
|
|
const invariant = require('invariant');
|
|
import ExamplePage from './ExamplePage';
|
|
|
|
class RNTesterExampleContainer extends React.Component {
|
|
renderExample(example, i) {
|
|
// Filter platform-specific examples
|
|
const {description, platform} = example;
|
|
let {title} = example;
|
|
if (platform) {
|
|
if (Platform.OS !== platform) {
|
|
return null;
|
|
}
|
|
title += ' (' + platform + ' only)';
|
|
}
|
|
return (
|
|
<RNTesterBlock key={i} title={title} description={description}>
|
|
{example.render()}
|
|
</RNTesterBlock>
|
|
);
|
|
}
|
|
|
|
render(): React.Element<any> {
|
|
const {module} = this.props;
|
|
if (module.simpleExampleContainer) {
|
|
invariant(
|
|
module.examples.length === 1,
|
|
'If noExampleContainer is specified, only one example is allowed',
|
|
);
|
|
return (
|
|
<ExamplePage
|
|
title={module.title}
|
|
description={module.description}
|
|
android={!module.platform || module.platform === 'android'}
|
|
ios={!module.platform || module.platform === 'ios'}
|
|
documentationURL={module.documentationURL}
|
|
category={module.category}>
|
|
{module.examples[0].render()}
|
|
</ExamplePage>
|
|
);
|
|
}
|
|
if (module.examples.length === 1) {
|
|
return (
|
|
<ExamplePage
|
|
title={module.title}
|
|
description={module.description}
|
|
android={!module.platform || module.platform === 'android'}
|
|
ios={!module.platform || module.platform === 'ios'}
|
|
documentationURL={module.documentationURL}
|
|
category={module.category}>
|
|
{module.examples[0].render()}
|
|
</ExamplePage>
|
|
);
|
|
}
|
|
|
|
const filter = ({example, filterRegex}) => filterRegex.test(example.title);
|
|
|
|
const sections = [
|
|
{
|
|
data: module.examples,
|
|
title: 'EXAMPLES',
|
|
key: 'e',
|
|
},
|
|
];
|
|
|
|
return (
|
|
<ExamplePage
|
|
title={module.title}
|
|
description={module.description}
|
|
android={!module.platform || module.platform === 'android'}
|
|
ios={!module.platform || module.platform === 'ios'}
|
|
documentationURL={module.documentationURL}
|
|
category={module.category}>
|
|
<RNTesterExampleFilter
|
|
testID="example_search"
|
|
page="examples_page"
|
|
hideFilterPills={true}
|
|
sections={sections}
|
|
filter={filter}
|
|
render={({filteredSections}) =>
|
|
filteredSections[0].data.map(this.renderExample)
|
|
}
|
|
/>
|
|
</ExamplePage>
|
|
);
|
|
}
|
|
}
|
|
|
|
module.exports = RNTesterExampleContainer;
|