-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(rebuild): finish navigation refactoring #2048
Changes from 4 commits
3642fd0
027be8f
2ce2315
d9fc15b
94dd928
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
// Import External Dependencies | ||
import React from 'react'; | ||
import Banner from 'react-banner'; | ||
import DocSearch from 'docsearch.js'; | ||
|
||
// Import Utilities/Images | ||
import GitHubIcon from '../../styles/icons/github.svg'; | ||
|
||
// Import Components | ||
import Link from '../Link/Link'; | ||
import Container from '../Container/Container'; | ||
import Logo from '../Logo/Logo'; | ||
import Dropdown from '../Dropdown/Dropdown'; | ||
|
||
// Load Styling | ||
import 'docsearch.js/dist/cdn/docsearch.css'; | ||
import './Navigation.scss'; | ||
import './Search.scss'; | ||
|
||
// TODO: Re-incorporate the icon links | ||
// <Link | ||
// className="navigation__icon" | ||
// title="GitHub Repository" | ||
// to="//github.com/webpack/webpack"> | ||
// <i className="sidecar__icon icon-github" /> | ||
// </Link> | ||
// <Link | ||
// className="navigation__icon" | ||
// title="See Questions on Stack Overflow" | ||
// to="//stackoverflow.com/questions/tagged/webpack"> | ||
// <i className="sidecar__icon icon-stack-overflow" /> | ||
// </Link> | ||
// <Dropdown | ||
// className="navigation__languages" | ||
// items={[ | ||
// { title: 'English', url: 'https://webpack.js.org/' }, | ||
// { title: '中文', url: 'https://doc.webpack-china.org/' } | ||
// ]} /> | ||
|
||
// TODO: Re-incorporate docsearch (see `react-banner` docs and `SearchResults` component/discussion) | ||
// componentDidMount() { | ||
// if (typeof window !== 'undefined') { | ||
// let docsearch = () => {}; | ||
|
||
// // XXX: hack around docsearch | ||
// if (window.docsearch) { | ||
// docsearch = window.docsearch.default || window.docsearch; | ||
// } | ||
|
||
// docsearch({ | ||
// apiKey: 'fac401d1a5f68bc41f01fb6261661490', | ||
// indexName: 'webpack-js-org', | ||
// inputSelector: '.navigation__search-input' | ||
// }); | ||
|
||
// window.addEventListener('keyup', e => { | ||
// if (e.which === 9 && e.target.classList.contains('navigation__search-input')) { | ||
// this._openSearch(); | ||
// } | ||
// }); | ||
// } | ||
// } | ||
|
||
export default class Navigation extends React.Component { | ||
render() { | ||
let { pathname, links, toggleSidebar } = this.props; | ||
|
||
return ( | ||
<Banner | ||
blockName="navigation" | ||
logo={ <Logo light={ true } /> } | ||
url={ pathname } | ||
links={ links } | ||
items={[ | ||
...links, | ||
{ | ||
title: 'GitHub Repository', | ||
url: 'https://github.com/webpack/webpack', | ||
className: 'navigation__item--icon', | ||
content: <i className="icon-github" /> | ||
}, | ||
{ | ||
title: 'Webpack on Stack Overflow', | ||
url: 'https://stackoverflow.com/questions/tagged/webpack', | ||
className: 'navigation__item--icon', | ||
content: <i className="icon-stack-overflow" /> | ||
}, | ||
{ | ||
className: 'navigation__item--icon', | ||
content: ( | ||
<Dropdown | ||
className="navigation__languages" | ||
items={[ | ||
{ title: 'English', url: 'https://webpack.js.org/' }, | ||
{ title: '中文', url: 'https://doc.webpack-china.org/' } | ||
]} /> | ||
) | ||
} | ||
]} | ||
link={ Link } | ||
onMenuClick={ toggleSidebar } /> | ||
); | ||
} | ||
|
||
componentDidMount() { | ||
DocSearch({ | ||
apiKey: 'fac401d1a5f68bc41f01fb6261661490', | ||
indexName: 'webpack-js-org', | ||
inputSelector: '.navigation-search__input' | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,16 +62,16 @@ class Site extends React.Component { | |
toggleSidebar={ this._toggleSidebar } | ||
links={[ | ||
{ | ||
title: 'Documentation', | ||
content: 'Documentation', | ||
url: '/concepts', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to rethink how URLs are formed, when trying to build the site to work under a path I had to do a lot of changes (https://github.com/webpack/webpack.js.org/tree/fix/v3-docs), we need to work on it now in order to be able to support multiple versions in the future There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's definitely something we need to tackle at some point, but is that something that needs to happen before Personally I think figure out version management as a follow up after finishing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is indeed a pain point for community, though lets try to keep it to the plan and get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, after merging I have tried to push that change, without success #1992 :/ |
||
isActive: url => /^\/(api|concepts|configuration|guides|loaders|plugins)/.test(url), | ||
children: this._strip( | ||
sections.filter(item => item.name !== 'contribute') | ||
) | ||
}, | ||
{ title: 'Contribute', url: '/contribute' }, | ||
{ title: 'Vote', url: '/vote' }, | ||
{ title: 'Blog', url: '//medium.com/webpack' } | ||
{ content: 'Contribute', url: '/contribute' }, | ||
{ content: 'Vote', url: '/vote' }, | ||
{ content: 'Blog', url: 'https://medium.com/webpack' } | ||
]} /> | ||
|
||
{ window.document !== undefined ? ( | ||
|
@@ -165,6 +165,7 @@ class Site extends React.Component { | |
_strip = array => { | ||
return array.map(({ title, name, url, group, sort, anchors, children }) => ({ | ||
title: title || name, | ||
content: title || name, | ||
url, | ||
group, | ||
sort, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this dependency used? I can't spot it. I'm seeing we are using the class for the icon font instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I’ll remove it. Played around with it momentarily and the fixed font metrics instead.