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

Release 7.3.0 #220

Merged
merged 7 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions .svgo.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
multipass: true
plugins:
- removeTitle: true
- removeViewBox: false
Expand All @@ -20,3 +21,4 @@ plugins:
- removeEditorsNSData: true
- removeEmptyAttrs: true
- removeHiddenElems: true
- collapseGroups: true
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
### HEAD
# 7.3.0

* Fix for heart icon https://github.com/primer/octicons/pull/211

* Adding an archive icon created by @colinkeany
Fixes https://github.com/primer/octicons/issues/182

* Fixed versioning strategy https://github.com/primer/octicons/pull/#208


### Octicons_node 7.0.0

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"lib/octicons_helper",
"lib/jekyll-octicons"
],
"version": "independent"
"version": "7.2.0"
}
2 changes: 1 addition & 1 deletion script/export
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Promise.resolve(fs.removeSync(outputDir))
dCount++
return svgo.optimize(svg, {})
.then(optimized => {
icon.path = /<svg.+>(.+)<\/svg>/g.exec(optimized.data).pop()
icon.path = optimized.data.slice(optimized.data.indexOf('>') + 1).slice(0, -6)

return fs.ensureDir(path.join(outputDir, "/svg"))
.then(() => fs.writeFileSync(path.resolve(outputDir, `svg/${icon.name}.svg`), optimized.data, "utf8"))
Expand Down
55 changes: 1 addition & 54 deletions script/utils.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,5 @@
const got = require('got')

// Translates a path based on the xy array passed in
const translatePath = (p, xy) => {

let ds = p.match(/([A-Z]{1,2}[\s0-9\.\-e]+)/g)
let [x, y] = xy

let dd = ds.map((d) => {
var darr = d.split(" ").reverse()
for(let i = 0; i < darr.length; i += 2) {
if(darr[i+1]) {
darr[i] = parseFloat(darr[i]) + y
darr[i+1] = parseFloat(darr[i+1]) + x
}
}

return darr.reverse().join(" ")
}).join("") + "Z"

return dd
}

// Gets the sum of all the `translate(x y)` and reduces it
// <g transform="translate(-238 -286)"><g transform="translate(238 290)">
// becomes [0, 4]
const reduceTranslate = (t) => {
if(t == null) {
return [0, 0]
}
if(t.length == 1) {
return t[0].replace(/translate|[\(\)]/g,"").split(" ").map((v) => Math.round(parseFloat(v)))
}
return t.reduce((p,c) => {
p = p.replace(/translate|[\(\)]/g,"").split(" ")
c = c.replace(/translate|[\(\)]/g,"").split(" ")
for(let i = 0; i < c.length; i++) {
c[i] = Math.round(parseFloat(p[i])) + Math.round(parseFloat(c[i]))
}
return c
})
}

Copy link
Member Author

Choose a reason for hiding this comment

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

A lot of this removal was taken care of in the svgo file changes above ☝️

module.exports = {
progress: (current, total) => {
let percentage = Math.ceil((current * 10) / total)
Expand All @@ -60,19 +19,7 @@ module.exports = {
headers: { "Content-Type": "images/svg+xml" }
}).on('downloadProgress', downloadProgress)

let svg = response.body

let d = svg.match(/ d=["']([a-z\s0-9\.\-]+)["']/i).pop()
let translate = reduceTranslate(svg.match(/translate\([0-9\-\s\.e]+\)/g))
let d2 = translatePath(d, translate)

// Clean and replace svg elements
svg = svg.replace(`d="${d}"`, `d="${d2}"`)
.replace(/<\/?defs>/g,"")
.replace(/<use[^>]*>/g, "")

resolve(svg)
// .catch(err => reject(`There was trouble downloading ${url}\n${err}`))
resolve(response.body)
})
}
}