Skip to content

Commit 67123c5

Browse files
authored
Merge pull request #29 from opendevise/load-required-icons
load required icons
2 parents 03ae1ad + 2254d72 commit 67123c5

16 files changed

+64
-506
lines changed

gulp.d/tasks/build-preview-pages.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ module.exports = (src, previewSrc, previewDest, sink = () => map()) => (done) =>
123123
}
124124
},
125125
// NOTE parallel build overwrites default fontawesome-icon-defs.js, so we must use an alternate path
126-
() => writeIconDefs(iconDefs, ospath.join(previewDest, 'fontawesome-icon-defs.js'))
126+
() =>
127+
fs
128+
.readFile(ospath.join(src, 'js/vendor/fontawesome-icon-defs.js'), 'utf8')
129+
.then((contents) => registerIconDefs(iconDefs, { contents }))
130+
.then(() => writeIconDefs(iconDefs, ospath.join(previewDest, 'fontawesome-icon-defs.js')))
127131
)
128132
)
129133
.pipe(vfs.dest(previewDest))
@@ -223,9 +227,14 @@ function findNavPath (currentUrl, node = [], current_path = [], root = true) {
223227

224228
function registerIconDefs (iconDefs, file) {
225229
const contents = file.contents
226-
if (!contents.includes('<i class="fa')) return
227-
const stringContents = contents.toString()
228-
const iconNames = stringContents.match(/<i class="fa[brs]? fa-[^" ]+/g).map((it) => it.substr(10))
230+
let iconNames = []
231+
if (!file.path) {
232+
try {
233+
iconNames = JSON.parse(contents.match(/\biconNames: *(\[.*?\])/)[1].replace(/'/g, '"'))
234+
} catch (e) {}
235+
} else if (contents.includes('<i class="fa')) {
236+
iconNames = contents.toString().match(/<i class="fa[brs]? fa-[^" ]+/g).map((it) => it.substr(10))
237+
}
229238
if (!iconNames.length) return
230239
;[...new Set(iconNames)].reduce((accum, iconKey) => {
231240
if (!accum.has(iconKey)) {

src/css/clipboard.css

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
.view-source-button {
22
color: var(--color-brand-gray4);
3-
font-family: "Source Code Pro", sans-serif;
4-
background: url(../img/awesome-github.svg) no-repeat center center;
5-
background-size: cover;
63
display: inline-block;
7-
width: 16px;
8-
height: 15.5px;
9-
font-size: 0;
104
margin-left: 0.5rem;
115
}
126

@@ -34,8 +28,6 @@
3428
}
3529

3630
.view-source-button:hover::before {
37-
width: 0;
38-
height: 0;
3931
border-left: 7px solid transparent;
4032
border-right: 7px solid transparent;
4133
border-bottom: 10px solid var(--color-brand-white);
@@ -48,16 +40,15 @@
4840
}
4941

5042
.copy-code-button {
51-
background: url(../img/copy.png) no-repeat center right/contain;
52-
width: 13px;
53-
height: 16px;
54-
cursor: pointer;
55-
font-family: "Source Sans Pro", sans-serif;
5643
color: var(--color-brand-gray4);
44+
cursor: pointer;
45+
display: inline-block;
5746
margin-left: 0.5rem;
5847
margin-right: 0.5rem;
5948
}
6049

50+
a.view-source-button:focus,
51+
a.view-source-button:hover,
6152
a.copy-code-button:focus,
6253
a.copy-code-button:hover {
6354
color: var(--color-brand-gray4);
@@ -87,8 +78,6 @@ a.copy-code-button:hover {
8778
}
8879

8980
.copy-code-button:hover::before {
90-
width: 0;
91-
height: 0;
9281
border-left: 7px solid transparent;
9382
border-right: 7px solid transparent;
9483
border-bottom: 10px solid var(--color-brand-white);

src/css/doc.css

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,13 @@
7474
.doc h5 > a.anchor,
7575
.doc h6 > a.anchor {
7676
color: var(--color-brand-blue-secondary);
77-
/* background-image: linear-gradient(-45deg, var(--color-brand-purple), var(--color-brand-red) 75%);
78-
background-clip: text;
79-
-webkit-text-fill-color: transparent; */
80-
font-weight: var(--weight-normal);
8177
position: absolute;
8278
text-decoration: none;
83-
width: 2ex;
84-
margin-left: -2ex;
79+
width: 3ex;
80+
margin-left: -2.5ex;
8581
visibility: hidden;
86-
transform: scale(0.75);
8782
text-align: center;
88-
font-size: 30px;
89-
}
90-
91-
.doc h1 a.anchor::before,
92-
.doc h2 a.anchor::before,
93-
.doc h3 a.anchor::before,
94-
.doc h4 a.anchor::before,
95-
.doc h5 a.anchor::before,
96-
.doc h6 a.anchor::before {
97-
content: "\f0c1";
98-
font-family: "Font Awesome 5 Free", sans-serif;
99-
font-weight: 900;
83+
transform: scale(0.75);
10084
}
10185

10286
.doc h1:hover a.anchor,

src/img/awesome-github.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/img/back-arrow.png

-441 Bytes
Binary file not shown.

src/img/back.svg

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

src/img/caret-down.svg

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

src/img/close.svg

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

src/img/copy.png

-314 Bytes
Binary file not shown.

src/img/database-icon.svg

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

0 commit comments

Comments
 (0)