Skip to content
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

Merged
merged 5 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,13 @@
},
"dependencies": {
"ajv": "^5.5.2",
"docsearch.js": "^2.5.2",
"gitter-sidecar": "^1.2.3",
"preact": "^8.2.7",
"preact-compat": "3.17.0",
"prop-types": "^15.5.10",
"react": "^16.2.0",
"react-banner": "^0.5.0",
"react-banner": "^1.0.0-rc.0",
"react-dom": "^16.2.0",
"react-hot-loader": "^4.0.0-beta.12",
"react-router": "^4.2.0",
Expand Down
1 change: 1 addition & 0 deletions src/components/Dropdown/Dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
position: absolute;
top: 100%;
right: 0;
font-size: getFontSize(-1);
margin: auto;
background-color: #2B3A42;
z-index: 1;
Expand Down
90 changes: 45 additions & 45 deletions src/components/Navigation/Navigation.jsx
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';
Copy link
Member

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.

Copy link
Collaborator Author

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.


// 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'
});
}
}
64 changes: 31 additions & 33 deletions src/components/Navigation/Navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@
@import 'mixins';
@import 'functions';

// TODO: Re-incorporate language dropdown and github links although
// this may require linking and re-releasing `react-banner`
//
// .navigation__languages {
// margin-left: 1em;
// margin-top: -4px;
// }

.banner {
.navigation {
flex: 0 0 auto;
transition: background 250ms;
background: getColor(elephant);
}

.banner__inner {
.navigation__inner {
position: relative;
display: flex;
align-items: center;
Expand All @@ -30,7 +22,7 @@
}
}

.banner__mobile {
.navigation__mobile {
display: none;
fill: white;
padding: 0;
Expand All @@ -43,12 +35,12 @@
transition: color 250ms;
}

.banner__mobile svg {
.navigation__mobile svg {
width: 20px;
height: 20px;
}

.banner__logo {
.navigation__logo {
margin: auto;
text-decoration: none;
text-transform: uppercase;
Expand All @@ -58,20 +50,20 @@
transition: all 250ms;
}

.banner__links {
.navigation__items {
flex: 1 1 auto;
display: flex;
height: 56px;
align-items: center;
justify-content: flex-end;
}

.banner__link {
.navigation__item {
position: relative;
display: inline-block;
font-size: getFontSize(-1);
padding-bottom: 0.1em;
margin-right: 1.5em;
margin-right: 18px;
text-transform: uppercase;
letter-spacing: 0.5px;
color: getColor(white);
Expand All @@ -82,6 +74,12 @@
color: getColor(malibu);
}

&--icon {
font-size: 16px;
margin-top: 2px;
-webkit-font-smoothing: antialiased;
}

&--active {
color: #fff;

Expand All @@ -101,14 +99,14 @@
}
}

.banner-search {
.navigation-search {
flex: 0 0 auto;
position: relative;
display: flex;
justify-content: flex-end;
}

.banner-search__input {
.navigation-search__input {
font-size: 14px;
width: 0;
max-width: calc(100vw - 8.5em);
Expand All @@ -128,7 +126,7 @@
}
}

.banner-search__icon {
.navigation-search__icon {
font-size: 1em;
width: 1em;
height: 1em;
Expand All @@ -140,35 +138,35 @@
transition: color 250ms;
}

.banner-search__input:focus,
.banner-search__icon:focus {
.navigation-search__input:focus,
.navigation-search__icon:focus {
outline: none;
}

.banner-search__clear {
.navigation-search__clear {
display: none;
margin-right: 0.25em;
margin-bottom: -1px;
}

.banner-search--active .banner-search__input {
.navigation-search--active .navigation-search__input {
margin-right: 0.5em;
width: 400px;
}

.banner-search--active .banner-search__clear {
.navigation-search--active .navigation-search__clear {
display: block;
}

.banner-search__results {
.navigation-search__results {
position: absolute;
top: 100%;
right: 0;
width: 100%;
margin-top: 5px;
}

.banner--search .banner__link {
.navigation--search .navigation__item {
pointer-events: none;
overflow: hidden;
white-space: nowrap;
Expand All @@ -177,19 +175,19 @@
opacity: 0;
}

.banner-sub {
.navigation-sub {
display: block;
background: getColor(concrete);
}

.banner-sub__inner {
.navigation-sub__inner {
max-width: map-get($screens, large);
margin: 0 auto;
padding: 0 1.5em;
text-align: right;
}

.banner-sub__link {
.navigation-sub__link {
display: inline-block;
font-size: 0.8em;
margin-left: 1.5em;
Expand All @@ -209,15 +207,15 @@
}

@media (max-width: 720px) {
.banner-sub {
.navigation-sub {
display: none;
}
}

@media (max-width: 720px) {
.banner__mobile { display: block; }
.banner__links { display: none; }
.banner--search .banner__logo {
.navigation__mobile { display: block; }
.navigation__items { display: none; }
.navigation--search .navigation__logo {
pointer-events: none;
overflow: hidden;
white-space: nowrap;
Expand Down
2 changes: 2 additions & 0 deletions src/components/Navigation/Search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

.ds-dropdown-menu {
box-shadow: none;
margin-top: 19px;
margin-right: -37px;

&:before {
content: none;
Expand Down
9 changes: 5 additions & 4 deletions src/components/Site/Site.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ class Site extends React.Component {
toggleSidebar={ this._toggleSidebar }
links={[
{
title: 'Documentation',
content: 'Documentation',
url: '/concepts',
Copy link
Member

@montogeek montogeek Apr 14, 2018

Choose a reason for hiding this comment

The 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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 rebuild is merged? Will these routes conflict with the /v3 route you created?

Personally I think figure out version management as a follow up after finishing rebuild (though I understand we did need to get something up quickly before for v3 when deploying v4).

Copy link
Member

Choose a reason for hiding this comment

The 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 rebuild into master asap before diving into much detail on doc versioning

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, after merging rebuild is fine, would be better to do it before so we can launch new website with multiple versions support, that would make headlines! (jk).

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 ? (
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/styles/icons/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/styles/icons/medium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading