From 5b79ee68084de5462cb696ebd169ab3ddd935550 Mon Sep 17 00:00:00 2001 From: Hector Ramos Date: Fri, 1 Sep 2017 17:50:22 -0700 Subject: [PATCH] Move tabbing logic back to individual docs Summary: In preparation for an upcoming website update, we need to host the tabbing logic used by Getting Started, Integration with Existing Apps, and Running on Device, in the individual documents themselves. The website update will allow us to use actual React components to implement this behavior. When the website update is live, we can work on the React alternative. Ran website, verified tabbing worked as expected in all three documents. Closes https://github.com/facebook/react-native/pull/15758 Differential Revision: D5758202 Pulled By: hramos fbshipit-source-id: bd00c6c2ac9377b4427022b30ca7ed7787eb3a86 --- docs/GettingStarted.md | 137 ++++++++++++++++++++++-- docs/IntegrationWithExistingApps.md | 134 ++++++++++++++++++++++-- docs/RunningOnDevice.md | 132 ++++++++++++++++++++++- website/src/react-native/js/scripts.js | 138 ------------------------- 4 files changed, 384 insertions(+), 157 deletions(-) diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index b7ec6d708..5549e1fa9 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -1,5 +1,5 @@ --- -id: quick-start-getting-started +id: getting-started title: Getting Started layout: docs category: The Basics @@ -638,12 +638,133 @@ to the [Tutorial](docs/tutorial.html). If you're curious to learn more about React Native, continue on to the [Tutorial](docs/tutorial.html). - diff --git a/docs/IntegrationWithExistingApps.md b/docs/IntegrationWithExistingApps.md index fc99c2fc3..c3cef9c48 100644 --- a/docs/IntegrationWithExistingApps.md +++ b/docs/IntegrationWithExistingApps.md @@ -812,10 +812,132 @@ Now just create a release build of your native app from within Android Studio as At this point you can continue developing your app as usual. Refer to our [debugging](docs/debugging.html) and [deployment](docs/running-on-device.html) docs to learn more about working with React Native. diff --git a/docs/RunningOnDevice.md b/docs/RunningOnDevice.md index 07e98dd19..e4ef2dff9 100644 --- a/docs/RunningOnDevice.md +++ b/docs/RunningOnDevice.md @@ -360,9 +360,131 @@ You can now build your app for release by tapping `⌘B` or selecting **Product* You have built a great app using React Native, and you are now itching to release it in the Play Store. The process is the same as any other native Android app, with some additional considerations to take into account. Follow the guide for [generating a signed APK](docs/signed-apk-android.html) to learn more. diff --git a/website/src/react-native/js/scripts.js b/website/src/react-native/js/scripts.js index 7b8a27288..7200b866c 100644 --- a/website/src/react-native/js/scripts.js +++ b/website/src/react-native/js/scripts.js @@ -75,10 +75,6 @@ } } - // handle tabs in docs - convertBlocks(); - guessPlatformAndOS(); - var backdrop = document.querySelector( '.modal-backdrop' ); @@ -160,138 +156,4 @@ navigator.userAgent ); } - - function convertBlocks() { - // Convert
......
- // Into
......
- var blocks = document.querySelectorAll('block'); - for (var i = 0; i < blocks.length; ++i) { - var block = blocks[i]; - var span = blocks[i].parentNode; - var container = span.parentNode; - container.insertBefore(block, span); - container.removeChild(span); - } - // Convert
...content...
- // Into
...content...
- blocks = document.querySelectorAll('block'); - for (var i = 0; i < blocks.length; ++i) { - var block = blocks[i]; - while ( - block.nextSibling && - block.nextSibling.tagName !== 'BLOCK' - ) { - block.appendChild(block.nextSibling); - } - } - } - - function displayTab(type, value) { - var container = document.querySelectorAll('block')[ - 0 - ].parentNode; - container.className = 'display-' + - type + - '-' + - value + - ' ' + - container.className.replace( - RegExp('display-' + type + '-[a-z]+ ?'), - '' - ); - } - - function guessPlatformAndOS() { - if (!document.querySelector('block')) { - return; - } - - // If we are coming to the page with a hash in it (i.e. from a search, for example), try to get - // us as close as possible to the correct platform and dev os using the hashtag and block walk up. - var foundHash = false; - if ( - window.location.hash !== '' && - window.location.hash !== 'content' - ) { - // content is default - var hashLinks = document.querySelectorAll( - 'a.hash-link' - ); - for ( - var i = 0; - i < hashLinks.length && !foundHash; - ++i - ) { - if (hashLinks[i].hash === window.location.hash) { - var parent = hashLinks[i].parentElement; - while (parent) { - if (parent.tagName === 'BLOCK') { - // Could be more than one target os and dev platform, but just choose some sort of order - // of priority here. - - // Dev OS - if (parent.className.indexOf('mac') > -1) { - displayTab('os', 'mac'); - foundHash = true; - } else if ( - parent.className.indexOf('linux') > -1 - ) { - displayTab('os', 'linux'); - foundHash = true; - } else if ( - parent.className.indexOf('windows') > -1 - ) { - displayTab('os', 'windows'); - foundHash = true; - } else { - break; - } - - // Target Platform - if (parent.className.indexOf('ios') > -1) { - displayTab('platform', 'ios'); - foundHash = true; - } else if ( - parent.className.indexOf('android') > -1 - ) { - displayTab('platform', 'android'); - foundHash = true; - } else { - break; - } - - // Guide - if (parent.className.indexOf('native') > -1) { - displayTab('guide', 'native'); - foundHash = true; - } else if ( - parent.className.indexOf('quickstart') > -1 - ) { - displayTab('guide', 'quickstart'); - foundHash = true; - } else { - break; - } - - break; - } - parent = parent.parentElement; - } - } - } - } - - // Do the default if there is no matching hash - if (!foundHash) { - var isMac = navigator.platform === 'MacIntel'; - var isWindows = navigator.platform === 'Win32'; - displayTab('platform', isMac ? 'ios' : 'android'); - displayTab( - 'os', - isMac ? 'mac' : isWindows ? 'windows' : 'linux' - ); - displayTab('guide', 'quickstart'); - displayTab('language', 'objc'); - } - } })();