Skip to content

Commit 2eb14b8

Browse files
committed
chore(navigation): migrate to react-banner@next and re-integrate icon links
The `next` version of `react-banner` supports more generic `items` rather than focusing solely on `links` which customizations like icons and dropdowns much easier to handle.
1 parent fc37bd0 commit 2eb14b8

File tree

6 files changed

+76
-62
lines changed

6 files changed

+76
-62
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
"preact-compat": "3.17.0",
110110
"prop-types": "^15.5.10",
111111
"react": "^16.2.0",
112-
"react-banner": "^0.5.0",
112+
"react-banner": "^1.0.0-rc.0",
113113
"react-dom": "^16.2.0",
114114
"react-hot-loader": "^4.0.0-beta.12",
115115
"react-router": "^4.2.0",

src/components/Dropdown/Dropdown.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
position: absolute;
2525
top: 100%;
2626
right: 0;
27+
font-size: getFontSize(-1);
2728
margin: auto;
2829
background-color: #2B3A42;
2930
z-index: 1;

src/components/Navigation/Navigation.jsx

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
1+
// Import External Dependencies
12
import React from 'react';
23
import Banner from 'react-banner';
4+
5+
// Import Utilities/Images
6+
import GitHubIcon from '../../styles/icons/github.svg';
7+
8+
// Import Components
39
import Link from '../Link/Link';
410
import Container from '../Container/Container';
511
import Logo from '../Logo/Logo';
612
import Dropdown from '../Dropdown/Dropdown';
13+
14+
// Load Styling
715
import './Navigation.scss';
816
import './Search.scss';
917

10-
// TODO: Re-incorporate the icon links
11-
// <Link
12-
// className="navigation__icon"
13-
// title="GitHub Repository"
14-
// to="//github.com/webpack/webpack">
15-
// <i className="sidecar__icon icon-github" />
16-
// </Link>
17-
// <Link
18-
// className="navigation__icon"
19-
// title="See Questions on Stack Overflow"
20-
// to="//stackoverflow.com/questions/tagged/webpack">
21-
// <i className="sidecar__icon icon-stack-overflow" />
22-
// </Link>
23-
// <Dropdown
24-
// className="navigation__languages"
25-
// items={[
26-
// { title: 'English', url: 'https://webpack.js.org/' },
27-
// { title: '中文', url: 'https://doc.webpack-china.org/' }
28-
// ]} />
29-
3018
// TODO: Re-incorporate docsearch (see `react-banner` docs and `SearchResults` component/discussion)
3119
// componentDidMount() {
3220
// if (typeof window !== 'undefined') {
@@ -57,9 +45,35 @@ export default class Navigation extends React.Component {
5745

5846
return (
5947
<Banner
48+
blockName="navigation"
6049
logo={ <Logo light={ true } /> }
6150
url={ pathname }
62-
links={ links }
51+
items={[
52+
...links,
53+
{
54+
title: 'GitHub Repository',
55+
url: '//github.com/webpack/webpack',
56+
className: 'navigation__item--icon',
57+
content: <i className="icon-github" />
58+
},
59+
{
60+
title: 'Webpack on Stack Overflow',
61+
url: '//stackoverflow.com/questions/tagged/webpack',
62+
className: 'navigation__item--icon',
63+
content: <i className="icon-stack-overflow" />
64+
},
65+
{
66+
className: 'navigation__item--icon',
67+
content: (
68+
<Dropdown
69+
className="navigation__languages"
70+
items={[
71+
{ title: 'English', url: 'https://webpack.js.org/' },
72+
{ title: '中文', url: 'https://doc.webpack-china.org/' }
73+
]} />
74+
)
75+
}
76+
]}
6377
link={ Link }
6478
onMenuClick={ toggleSidebar } />
6579
);

src/components/Navigation/Navigation.scss

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,13 @@
22
@import 'mixins';
33
@import 'functions';
44

5-
// TODO: Re-incorporate language dropdown and github links although
6-
// this may require linking and re-releasing `react-banner`
7-
//
8-
// .navigation__languages {
9-
// margin-left: 1em;
10-
// margin-top: -4px;
11-
// }
12-
13-
.banner {
5+
.navigation {
146
flex: 0 0 auto;
157
transition: background 250ms;
168
background: getColor(elephant);
179
}
1810

19-
.banner__inner {
11+
.navigation__inner {
2012
position: relative;
2113
display: flex;
2214
align-items: center;
@@ -30,7 +22,7 @@
3022
}
3123
}
3224

33-
.banner__mobile {
25+
.navigation__mobile {
3426
display: none;
3527
fill: white;
3628
padding: 0;
@@ -43,12 +35,12 @@
4335
transition: color 250ms;
4436
}
4537

46-
.banner__mobile svg {
38+
.navigation__mobile svg {
4739
width: 20px;
4840
height: 20px;
4941
}
5042

51-
.banner__logo {
43+
.navigation__logo {
5244
margin: auto;
5345
text-decoration: none;
5446
text-transform: uppercase;
@@ -58,20 +50,20 @@
5850
transition: all 250ms;
5951
}
6052

61-
.banner__links {
53+
.navigation__items {
6254
flex: 1 1 auto;
6355
display: flex;
6456
height: 56px;
6557
align-items: center;
6658
justify-content: flex-end;
6759
}
6860

69-
.banner__link {
61+
.navigation__item {
7062
position: relative;
7163
display: inline-block;
7264
font-size: getFontSize(-1);
7365
padding-bottom: 0.1em;
74-
margin-right: 1.5em;
66+
margin-right: 18px;
7567
text-transform: uppercase;
7668
letter-spacing: 0.5px;
7769
color: getColor(white);
@@ -82,6 +74,12 @@
8274
color: getColor(malibu);
8375
}
8476

77+
&--icon {
78+
font-size: 16px;
79+
margin-top: 2px;
80+
-webkit-font-smoothing: antialiased;
81+
}
82+
8583
&--active {
8684
color: #fff;
8785

@@ -101,14 +99,14 @@
10199
}
102100
}
103101

104-
.banner-search {
102+
.navigation-search {
105103
flex: 0 0 auto;
106104
position: relative;
107105
display: flex;
108106
justify-content: flex-end;
109107
}
110108

111-
.banner-search__input {
109+
.navigation-search__input {
112110
font-size: 14px;
113111
width: 0;
114112
max-width: calc(100vw - 8.5em);
@@ -128,7 +126,7 @@
128126
}
129127
}
130128

131-
.banner-search__icon {
129+
.navigation-search__icon {
132130
font-size: 1em;
133131
width: 1em;
134132
height: 1em;
@@ -140,35 +138,35 @@
140138
transition: color 250ms;
141139
}
142140

143-
.banner-search__input:focus,
144-
.banner-search__icon:focus {
141+
.navigation-search__input:focus,
142+
.navigation-search__icon:focus {
145143
outline: none;
146144
}
147145

148-
.banner-search__clear {
146+
.navigation-search__clear {
149147
display: none;
150148
margin-right: 0.25em;
151149
margin-bottom: -1px;
152150
}
153151

154-
.banner-search--active .banner-search__input {
152+
.navigation-search--active .navigation-search__input {
155153
margin-right: 0.5em;
156154
width: 400px;
157155
}
158156

159-
.banner-search--active .banner-search__clear {
157+
.navigation-search--active .navigation-search__clear {
160158
display: block;
161159
}
162160

163-
.banner-search__results {
161+
.navigation-search__results {
164162
position: absolute;
165163
top: 100%;
166164
right: 0;
167165
width: 100%;
168166
margin-top: 5px;
169167
}
170168

171-
.banner--search .banner__link {
169+
.navigation--search .navigation__item {
172170
pointer-events: none;
173171
overflow: hidden;
174172
white-space: nowrap;
@@ -177,19 +175,19 @@
177175
opacity: 0;
178176
}
179177

180-
.banner-sub {
178+
.navigation-sub {
181179
display: block;
182180
background: getColor(concrete);
183181
}
184182

185-
.banner-sub__inner {
183+
.navigation-sub__inner {
186184
max-width: map-get($screens, large);
187185
margin: 0 auto;
188186
padding: 0 1.5em;
189187
text-align: right;
190188
}
191189

192-
.banner-sub__link {
190+
.navigation-sub__link {
193191
display: inline-block;
194192
font-size: 0.8em;
195193
margin-left: 1.5em;
@@ -209,15 +207,15 @@
209207
}
210208

211209
@media (max-width: 720px) {
212-
.banner-sub {
210+
.navigation-sub {
213211
display: none;
214212
}
215213
}
216214

217215
@media (max-width: 720px) {
218-
.banner__mobile { display: block; }
219-
.banner__links { display: none; }
220-
.banner--search .banner__logo {
216+
.navigation__mobile { display: block; }
217+
.navigation__items { display: none; }
218+
.navigation--search .navigation__logo {
221219
pointer-events: none;
222220
overflow: hidden;
223221
white-space: nowrap;

src/components/Site/Site.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ class Site extends React.Component {
6262
toggleSidebar={ this._toggleSidebar }
6363
links={[
6464
{
65-
title: 'Documentation',
65+
content: 'Documentation',
6666
url: '/concepts',
6767
isActive: url => /^\/(api|concepts|configuration|guides|loaders|plugins)/.test(url),
6868
children: this._strip(
6969
sections.filter(item => item.name !== 'contribute')
7070
)
7171
},
72-
{ title: 'Contribute', url: '/contribute' },
73-
{ title: 'Vote', url: '/vote' },
74-
{ title: 'Blog', url: '//medium.com/webpack' }
72+
{ content: 'Contribute', url: '/contribute' },
73+
{ content: 'Vote', url: '/vote' },
74+
{ content: 'Blog', url: '//medium.com/webpack' }
7575
]} />
7676

7777
{ window.document !== undefined ? (
@@ -165,6 +165,7 @@ class Site extends React.Component {
165165
_strip = array => {
166166
return array.map(({ title, name, url, group, sort, anchors, children }) => ({
167167
title: title || name,
168+
content: title || name,
168169
url,
169170
group,
170171
sort,

0 commit comments

Comments
 (0)