Skip to content

Commit 3f2cab1

Browse files
authored
replace icon font with svg (#4192)
* add @svgr/webpack * replace gitter icon * replace icons in Navigation * replace close icon * replace edit icon * replace bar icon * replace icons in sidebarItem * replace close icon * update gitter icon * clean icon.font.js * bye fontgen-loader
1 parent 25894d2 commit 3f2cab1

File tree

18 files changed

+926
-281
lines changed

18 files changed

+926
-281
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"@mdx-js/loader": "^1.6.16",
8888
"@octokit/rest": "^18.0.5",
8989
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.2",
90+
"@svgr/webpack": "^5.5.0",
9091
"alex": "^5.1.0",
9192
"autoprefixer": "^9.8.6",
9293
"babel-loader": "^8.1.0",
@@ -103,7 +104,6 @@
103104
"eslint-plugin-cypress": "^2.10.3",
104105
"eslint-plugin-markdown": "^1.0.2",
105106
"file-loader": "^6.1.0",
106-
"fontgen-loader": "git://github.com/chenxsan/fontgen-loader.git#bugfix/fix-this-exec",
107107
"front-matter": "^4.0.2",
108108
"gh-pages": "^3.1.0",
109109
"html-loader": "^1.3.0",

src/components/Gitter/Gitter.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import isClient from '../../utilities/is-client';
77
// Load Styling
88
import '../Gitter/Gitter.scss';
99

10+
import GitterIcon from '../../styles/icons/gitter.svg';
11+
1012
let sidecar = null;
1113
let sidecarLoadTriggered = false;
1214

@@ -18,7 +20,7 @@ export default class Gitter extends React.Component {
1820
<div
1921
className="gitter__button"
2022
onClick={this._handleIconClick}>
21-
<i className="gitter__icon icon-gitter" />
23+
<GitterIcon className="gitter__icon" fill="#fff" />
2224
</div>
2325
</div>
2426
);

src/components/Navigation/Navigation.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import 'docsearch.js/dist/cdn/docsearch.css';
1515
import './Navigation.scss';
1616
import './Search.scss';
1717

18+
import GithubIcon from '../../styles/icons/github.svg';
19+
import TwitterIcon from '../../styles/icons/twitter.svg';
20+
import StackOverflowIcon from '../../styles/icons/stack-overflow.svg';
21+
1822
const onSearch = () => {};
1923

2024
export default class Navigation extends React.Component {
@@ -33,19 +37,19 @@ export default class Navigation extends React.Component {
3337
title: 'GitHub Repository',
3438
url: 'https://github.com/webpack/webpack',
3539
className: 'navigation__item--icon',
36-
content: <i aria-hidden="true" className="icon-github" />
40+
content: <GithubIcon aria-hidden="true" fill="#fff" width={16} />
3741
},
3842
{
3943
title: 'webpack on Twitter',
4044
url: 'https://twitter.com/webpack',
4145
className: 'navigation__item--icon',
42-
content: <i aria-hidden="true" className="icon-twitter" />
46+
content: <TwitterIcon aria-hidden="true" fill="#fff" width={16} />
4347
},
4448
{
4549
title: 'webpack on Stack Overflow',
4650
url: 'https://stackoverflow.com/questions/tagged/webpack',
4751
className: 'navigation__item--icon',
48-
content: <i aria-hidden="true" className="icon-stack-overflow" />
52+
content: <StackOverflowIcon aria-hidden="true" fill="#fff" width={16} />
4953
},
5054
{
5155
className: 'navigation__item--icon',

src/components/Navigation/Navigation.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161

6262
.navigation__item {
6363
position: relative;
64-
display: inline-block;
64+
display: inline-flex;
65+
align-items: center;
6566
font-size: getFontSize(-1);
6667
padding-bottom: 0.1em;
6768
margin-right: 18px;
@@ -77,8 +78,8 @@
7778

7879
&--icon {
7980
font-size: 16px;
80-
margin-top: 2px;
8181
-webkit-font-smoothing: antialiased;
82+
padding-bottom: 0;
8283
}
8384

8485
&--active {

src/components/NotificationBar/NotificationBar.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import Container from '../Container/Container';
33
import testLocalStorage from '../../utilities/test-local-storage';
44
import './NotificationBar.scss';
5+
import CloseIcon from '../../styles/icons/cross.svg';
56

67
const version = '3';
78
const localStorageIsEnabled = testLocalStorage() !== false;
@@ -22,11 +23,14 @@ class MessageBar extends React.Component {
2223
Webpack 5 has been officially released. Read our <a href="/blog/2020-10-10-webpack-5-release/">announcement</a>. Not ready yet? Read <a href="https://v4.webpack.js.org/">webpack 4 documentation here</a>.
2324
</p>
2425
{localStorageIsEnabled ? (
25-
<button
26+
<CloseIcon
2627
aria-label="Dismiss"
27-
className="notification-bar__close icon-cross"
28+
className="notification-bar__close"
29+
fill="#fff"
30+
width={16}
2831
onClick={this.close.bind(this)}
29-
/>
32+
role="button"
33+
/>
3034
) : null}
3135
</Container>
3236
</div>

src/components/PageLinks/PageLinks.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import Url from 'url';
33
import './PageLinks.scss';
44
import icon from '../../assets/icon-print.svg';
5+
import EditIcon from '../../styles/icons/edit.svg';
56

67
const baseURL = 'https://github.com/webpack/webpack.js.org/edit/master/';
78

@@ -26,12 +27,12 @@ export default ({
2627

2728
<a className="page-links__link" href={ editLink }>
2829
Edit Document
29-
<i className="page-links__icon icon-edit" />
30+
<EditIcon className="page-links__icon" width={12} fill="#1a6bac" />
3031
</a>
3132
<span className="page-links__gap">|</span>
3233
<button className="page-links__link page-links__print as-link" onClick={_handlePrintClick} title="Print this page">
3334
Print Document
34-
<img src={icon} />
35+
<img src={icon} alt="" />
3536
</button>
3637
</div>
3738
);

src/components/Print/Print.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
// Load Styling
33
import './Print.scss';
44
import icon from '../../assets/icon-print.svg';
5+
import BarIcon from '../../styles/icons/vertical-bar.svg';
56

67
const PRINTABLE_SECTIONS = [
78
'api',
@@ -25,7 +26,7 @@ export default function Print (props) {
2526

2627
return (
2728
<div className="sidebar-item sidebar-item--disabled`">
28-
<i className="sidebar-item__toggle icon-vertical-bar" />
29+
<BarIcon className="sidebar-item__toggle" width={15} fill="#175d96" />
2930
<a className="sidebar-item__title sidebar-link__print"
3031
href={printUrl}
3132
rel="nofollow"

src/components/SidebarItem/SidebarItem.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react';
22
import Link from '../Link/Link';
33
import './SidebarItem.scss';
44
import list2Tree from '../../utilities/list2Tree';
5+
import ChevronRightIcon from '../../styles/icons/chevron-right.svg';
6+
import BarIcon from '../../styles/icons/vertical-bar.svg';
57

68
const block = 'sidebar-item';
79

@@ -42,11 +44,13 @@ export default class SidebarItem extends React.Component {
4244
return (
4345
<div className={`${block} ${openMod} ${disabledMod}`}>
4446
{anchors.length > 0 ? (
45-
<i
46-
className={`${block}__toggle icon-chevron-right`}
47+
<ChevronRightIcon
48+
width={15}
49+
fill="#175d96"
50+
className={`${block}__toggle`}
4751
onClick={this._toggle.bind(this)} />
4852
) : (
49-
<i className={`${block}__toggle icon-vertical-bar`} />
53+
<BarIcon className={`${block}__toggle`} width={15} fill="#175d96" />
5054
)}
5155

5256
<Link

src/components/SidebarMobile/SidebarMobile.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Link from '../Link/Link';
33
import './SidebarMobile.scss';
4+
import CloseIcon from '../../styles/icons/cross.svg';
45

56
// TODO: Check to make sure all pages are shown and properly sorted
67
export default class SidebarMobile extends React.Component {
@@ -29,9 +30,12 @@ export default class SidebarMobile extends React.Component {
2930
onTouchEnd={this._handleTouchEnd} />
3031

3132
<div className="sidebar-mobile__content">
32-
<i
33-
className="sidebar-mobile__close icon-cross"
34-
onClick={toggle.bind(null, false)} />
33+
<span
34+
role="button"
35+
className="sidebar-mobile__close"
36+
onClick={toggle.bind(null, false)}>
37+
<CloseIcon fill="#fff" width={20} />
38+
</span>
3539

3640
{this._getSections()}
3741
</div>

src/components/Site/Site.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import StarterKits from '../StarterKits/StarterKits';
2626

2727
// Load Styling
2828
import '../../styles/index';
29-
import '../../styles/icon.font.js';
3029
import './Site.scss';
3130

3231
// Load Content Tree

src/styles/icon.font.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/styles/icon.template.hbs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/styles/icons/github.svg

Lines changed: 1 addition & 1 deletion
Loading

src/styles/icons/gitter.svg

Lines changed: 1 addition & 1 deletion
Loading

src/styles/icons/stack-overflow.svg

Lines changed: 1 addition & 1 deletion
Loading

src/styles/icons/twitter.svg

Lines changed: 1 addition & 1 deletion
Loading

webpack.common.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,6 @@ module.exports = (env = {}) => ({
7979
}
8080
]
8181
},
82-
{
83-
test: /\.font.js$/,
84-
use: [
85-
MiniCssExtractPlugin.loader,
86-
'css-loader',
87-
{
88-
loader: 'fontgen-loader',
89-
options: { embed: true }
90-
}
91-
]
92-
},
9382
{
9483
test: /\.jsx?$/,
9584
exclude: /node_modules/,
@@ -141,8 +130,18 @@ module.exports = (env = {}) => ({
141130
}
142131
},
143132
{
144-
test: /\.(jpg|jpeg|png|svg|ico)$/i,
133+
test: /\.(jpg|jpeg|png|ico)$/i,
145134
type: 'asset/resource'
135+
},
136+
{
137+
test: /\.svg$/i,
138+
type: 'asset/resource',
139+
exclude: [path.resolve(__dirname, 'src/styles/icons')]
140+
},
141+
{
142+
test: /\.svg$/i,
143+
use: ['@svgr/webpack'],
144+
include: [path.resolve(__dirname, 'src/styles/icons')]
146145
}
147146
]
148147
},

0 commit comments

Comments
 (0)