Merge pull request #81 from Bouncey/feat/searchInNav

Feat: Search in nav
This commit is contained in:
Stuart Taylor
2018-05-21 13:28:22 +01:00
committed by Mrugesh Mohapatra
parent cb9358243d
commit aa9e498bc3
6 changed files with 203 additions and 12 deletions

View File

@ -114,12 +114,16 @@ exports.modifyWebpackConfig = ({ config, stage }) => {
return generateBabelConfig(program, stage).then(babelConfig => {
config.removeLoader('js').loader('js', {
test: /\.jsx?$/,
/* eslint-disable max-len */
exclude: modulePath => {
return (
/node_modules/.test(modulePath) &&
!(/node_modules\/(ansi-styles|chalk)/).test(modulePath)
!(/(ansi-styles|chalk|strict-uri-encode|react-freecodecamp-search)/).test(
modulePath
)
);
},
/* eslint-enable max-len*/
loader: 'babel',
query: babelConfig
});
@ -145,6 +149,7 @@ exports.modifyBabelrc = ({ babelrc }) =>
Object.assign({}, babelrc, {
plugins: babelrc.plugins.concat([
[
'transform-es2015-arrow-functions',
'transform-imports',
{
'react-bootstrap': {

View File

@ -35,8 +35,10 @@
"react": "16",
"react-bootstrap": "^0.32.1",
"react-dom": "16",
"react-freecodecamp-search": "^2.0.2",
"react-ga": "^2.5.2",
"react-helmet": "^5.2.0",
"react-media": "^1.8.0",
"react-monaco-editor": "^0.14.1",
"react-redux": "^5.0.7",
"react-reflex": "^2.2.1",
@ -84,6 +86,7 @@
},
"devDependencies": {
"babel-eslint": "^8.2.2",
"babel-plugin-transform-es2015-arrow-functions": "^6.22.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "^4.19.1",
"eslint-config-freecodecamp": "^1.1.1",

View File

@ -0,0 +1,31 @@
import React from 'react';
import Media from 'react-media';
const fCClogo = 'https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg';
const fCCglyph = 'https://s3.amazonaws.com/freecodecamp/FFCFire.png';
function NavLogo() {
return (
<Media query='(min-width: 735px)'>
{matches =>
matches ? (
<img
alt='learn to code at freeCodeCamp logo'
className='nav-logo logo'
src={fCClogo}
/>
) : (
<img
alt='learn to code at freeCodeCamp logo'
className='nav-logo logo'
src={fCCglyph}
/>
)
}
</Media>
);
}
NavLogo.displayName = 'NavLogo';
export default NavLogo;

View File

@ -14,6 +14,13 @@ header {
border: none;
display: flex;
justify-content: space-between;
padding: 0 30px 0 15px;
}
@media screen, (max-width: 630px) {
#top-nav {
padding: 0;
}
}
#top-nav .home-link {
@ -22,7 +29,7 @@ header {
}
#top-nav img {
max-height: 36px;
max-height: 25px;
margin: 0 5px 0 10px;
}
@ -41,9 +48,23 @@ header {
#top-right-nav li > a {
color:#fff;
font-size: 17px;
font-weight: 700;
}
#top-right-nav li > a:hover, #top-right-nav li > a:focus {
text-decoration: none;
font-weight: 700;
}
/* Search bar */
.fcc_searchBar {
flex-grow: 0.8;
padding: 2px 10px 0;
}
.ais-SearchBox-form {
margin-bottom: 0;
}
.ais-Hits {
background-color: #fff;
}

View File

@ -1,5 +1,8 @@
import React from 'react';
import Link from 'gatsby-link';
import FCCSearch from 'react-freecodecamp-search';
import NavLogo from './components/NavLogo';
import './header.css';
@ -8,12 +11,9 @@ function Header() {
<header>
<nav id='top-nav'>
<Link className='home-link' to='/'>
<img
alt='Logo - freeCodeCamp | Learn to code'
src='https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg'
title='freeCodeCamp | Learn to code'
/>
<NavLogo />
</Link>
<FCCSearch />
<ul id='top-right-nav'>
<li>
<a href='https://learn.freecodecamp.org'>Learn</a>
@ -21,6 +21,9 @@ function Header() {
<li>
<a href='https://forum.freecodecamp.org'>Forum</a>
</li>
<li>
<a href='#'>Log in</a>
</li>
</ul>
</nav>
</header>

View File

@ -220,6 +220,10 @@ after@0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f"
agentkeepalive@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-2.2.0.tgz#c5d1bd4b129008f1163f236f86e5faea2026e2ef"
ajv-keywords@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762"
@ -253,6 +257,35 @@ ajv@^6.1.0:
json-schema-traverse "^0.3.0"
uri-js "^3.0.2"
algoliasearch-helper@^2.21.0:
version "2.26.0"
resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-2.26.0.tgz#cb784b692a5aacf17062493cb0b94f6d60d30d0f"
dependencies:
events "^1.1.1"
lodash "^4.17.5"
qs "^6.5.1"
util "^0.10.3"
algoliasearch@^3.24.0:
version "3.27.1"
resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-3.27.1.tgz#e1af42b97dbf44a2dd3a8c907be99c0c34e48414"
dependencies:
agentkeepalive "^2.2.0"
debug "^2.6.8"
envify "^4.0.0"
es6-promise "^4.1.0"
events "^1.1.0"
foreach "^2.0.5"
global "^4.3.2"
inherits "^2.0.1"
isarray "^2.0.1"
load-script "^1.0.0"
object-keys "^1.0.11"
querystring-es3 "^0.2.1"
reduce "^1.0.1"
semver "^5.1.0"
tunnel-agent "^0.6.0"
align-text@^0.1.1, align-text@^0.1.3:
version "0.1.4"
resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117"
@ -3154,6 +3187,13 @@ entities@^1.1.1, entities@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"
envify@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/envify/-/envify-4.1.0.tgz#f39ad3db9d6801b4e6b478b61028d3f0b6819f7e"
dependencies:
esprima "^4.0.0"
through "~2.3.4"
enzyme-adapter-react-15@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/enzyme-adapter-react-15/-/enzyme-adapter-react-15-1.0.5.tgz#99f9a03ff2c2303e517342935798a6bdfbb75fac"
@ -3478,7 +3518,7 @@ eventemitter3@1.x.x:
version "1.2.0"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508"
events@^1.0.0:
events@^1.0.0, events@^1.1.0, events@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924"
@ -3902,6 +3942,12 @@ flush-write-stream@^1.0.0:
inherits "^2.0.1"
readable-stream "^2.0.4"
for-each@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
dependencies:
is-function "~1.0.0"
for-in@^1.0.1, for-in@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
@ -4498,7 +4544,7 @@ global-prefix@^1.0.1:
is-windows "^1.0.1"
which "^1.2.14"
global@^4.3.0:
global@^4.3.0, global@^4.3.2, global@~4.3.0:
version "4.3.2"
resolved "https://registry.yarnpkg.com/global/-/global-4.3.2.tgz#e76989268a6c74c38908b1305b10fc0e394e9d0f"
dependencies:
@ -5279,6 +5325,10 @@ is-fullwidth-code-point@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
is-function@^1.0.1, is-function@~1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
is-generator-fn@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-1.0.0.tgz#969d49e1bb3329f6bb7f09089be26578b2ddd46a"
@ -5520,6 +5570,10 @@ isarray@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e"
isarray@^2.0.1:
version "2.0.4"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.4.tgz#38e7bcbb0f3ba1b7933c86ba1894ddfc3781bbb7"
isemail@2.x.x:
version "2.2.1"
resolved "https://registry.yarnpkg.com/isemail/-/isemail-2.2.1.tgz#0353d3d9a62951080c262c2aa0a42b8ea8e9e2a6"
@ -6028,6 +6082,12 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
json2mq@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/json2mq/-/json2mq-0.2.0.tgz#b637bd3ba9eabe122c83e9720483aeb10d2c904a"
dependencies:
string-convert "^0.2.0"
json3@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1"
@ -6225,6 +6285,10 @@ load-json-file@^2.0.0:
pify "^2.0.0"
strip-bom "^3.0.0"
load-script@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/load-script/-/load-script-1.0.0.tgz#0491939e0bee5643ee494a7e3da3d2bac70c6ca4"
loader-utils@^0.2.11, loader-utils@^0.2.15, loader-utils@^0.2.16, loader-utils@^0.2.3, loader-utils@~0.2.5:
version "0.2.17"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348"
@ -7176,7 +7240,7 @@ object-is@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.0.1.tgz#0aa60ec9989a0b3ed795cf4d06f62cf1ad6539b6"
object-keys@^1.0.11, object-keys@^1.0.8:
object-keys@^1.0.11, object-keys@^1.0.8, object-keys@~1.0.0:
version "1.0.11"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
@ -7480,6 +7544,13 @@ parse-glob@^3.0.4:
is-extglob "^1.0.0"
is-glob "^2.0.0"
parse-headers@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/parse-headers/-/parse-headers-2.0.1.tgz#6ae83a7aa25a9d9b700acc28698cd1f1ed7e9536"
dependencies:
for-each "^0.3.2"
trim "0.0.1"
parse-json@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"
@ -8390,7 +8461,14 @@ query-string@^4.1.0:
object-assign "^4.1.0"
strict-uri-encode "^1.0.0"
querystring-es3@^0.2.0:
query-string@^6.0.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.1.0.tgz#01e7d69f6a0940dac67a937d6c6325647aa4532a"
dependencies:
decode-uri-component "^0.2.0"
strict-uri-encode "^2.0.0"
querystring-es3@^0.2.0, querystring-es3@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
@ -8544,6 +8622,15 @@ react-error-overlay@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-3.0.0.tgz#c2bc8f4d91f1375b3dad6d75265d51cd5eeaf655"
react-freecodecamp-search@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/react-freecodecamp-search/-/react-freecodecamp-search-2.0.2.tgz#2fde10f5a44b1aa15e6a6b8f932d6435eb284f32"
dependencies:
query-string "^6.0.0"
react-instantsearch "^5.0.1"
rxjs "^5.5.7"
xhr "^2.4.1"
react-ga@^2.5.2:
version "2.5.2"
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-2.5.2.tgz#1574b26e30ed668e4e74735527314393b22c55a9"
@ -8570,6 +8657,16 @@ react-hot-loader@^3.0.0-beta.6:
redbox-react "^1.3.6"
source-map "^0.6.1"
react-instantsearch@^5.0.1:
version "5.0.3"
resolved "https://registry.yarnpkg.com/react-instantsearch/-/react-instantsearch-5.0.3.tgz#4d082e86678f819949537f2b35acf831325b5a97"
dependencies:
algoliasearch "^3.24.0"
algoliasearch-helper "^2.21.0"
classnames "^2.2.5"
lodash "^4.17.4"
prop-types "^15.5.10"
react-is@^16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.3.1.tgz#ee66e6d8283224a83b3030e110056798488359ba"
@ -8588,6 +8685,14 @@ react-measure@^2.0.2:
prop-types "^15.5.10"
resize-observer-polyfill "^1.4.2"
react-media@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/react-media/-/react-media-1.8.0.tgz#b86d6d62313f95d53af7d06e23d4f49adfb131d3"
dependencies:
invariant "^2.2.2"
json2mq "^0.2.0"
prop-types "^15.5.10"
react-monaco-editor@^0.14.1:
version "0.14.1"
resolved "https://registry.yarnpkg.com/react-monaco-editor/-/react-monaco-editor-0.14.1.tgz#f5163e119e8a7dc79b992cb3fd7af887547d7efd"
@ -8886,6 +8991,12 @@ reduce-reducers@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/reduce-reducers/-/reduce-reducers-0.1.2.tgz#fa1b4718bc5292a71ddd1e5d839c9bea9770f14b"
reduce@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/reduce/-/reduce-1.0.1.tgz#14fa2e5ff1fc560703a020cbb5fbaab691565804"
dependencies:
object-keys "~1.0.0"
redux-actions@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/redux-actions/-/redux-actions-2.3.0.tgz#4e9967d86594b8c235bab6e08960b5c185f296d3"
@ -10135,6 +10246,14 @@ strict-uri-encode@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
strict-uri-encode@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
string-convert@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/string-convert/-/string-convert-0.2.1.tgz#6982cc3049fbb4cd85f8b24568b9d9bf39eeff97"
string-length@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/string-length/-/string-length-1.0.1.tgz#56970fb1c38558e9e70b728bf3de269ac45adfac"
@ -10452,7 +10571,7 @@ through2@^2.0.0, through2@^2.0.1:
readable-stream "^2.1.5"
xtend "~4.0.1"
through@^2.3.6:
through@^2.3.6, through@~2.3.4:
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
@ -11366,6 +11485,15 @@ xdg-basedir@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"
xhr@^2.4.1:
version "2.5.0"
resolved "https://registry.yarnpkg.com/xhr/-/xhr-2.5.0.tgz#bed8d1676d5ca36108667692b74b316c496e49dd"
dependencies:
global "~4.3.0"
is-function "^1.0.1"
parse-headers "^2.0.0"
xtend "^4.0.0"
xml-name-validator@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"