Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
fix: missing icons - close #1156 (#1157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Stay authored Aug 14, 2021
1 parent f0dfdc4 commit 39c3f2d
Show file tree
Hide file tree
Showing 6 changed files with 550 additions and 45 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "file-icons/font-awesome"]
path = file-icons/font-awesome
url = https://github.com/FortAwesome/Font-Awesome.git
[submodule "file-icons/bytesize-icons"]
path = file-icons/bytesize-icons
url = [email protected]:danklammer/bytesize-icons.git
25 changes: 24 additions & 1 deletion file-icons-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fs.readdirSync(path.join(__dirname, "file-icons", "devopicons", "svg")).forEach(
svg
};
});
// Get file icons from file-icons/devopicons
// Get file icons from file-icons/mfixx
fs.readdirSync(path.join(__dirname, "file-icons", "mfixx", "svg")).forEach(icon => {
if (!icon.endsWith(".svg")) return;
let iconName = icon.toLowerCase().replace(".svg", "").replace("-1", "");
Expand All @@ -101,6 +101,28 @@ fs.readdirSync(path.join(__dirname, "file-icons", "mfixx", "svg")).forEach(icon
svg
};
});
// Get file icons from file-icons/bytesize-icons
fs.readdirSync(path.join(__dirname, "file-icons", "bytesize-icons", "dist", "icons")).forEach(icon => {
if (!icon.endsWith(".svg")) return;
let iconName = icon.toLowerCase().replace(".svg", "");

let text = fs.readFileSync(path.join(__dirname, "file-icons", "bytesize-icons", "dist", "icons", icon), {encoding: "utf8"});

let dimensions = text.match(/viewBox="0 0 (\d+) (\d+)"/);
let width = dimensions[1];
let height = dimensions[2];

let svg = text.substr(text.indexOf(">")+1);
svg = svg.replace("</svg>", "");

if (width === null || height === null) console.log(icon);

fileIconsObject[iconName] = {
width,
height,
svg
};
});
// Override with eDEX-specific icons
fileIconsObject.showDisks = {
width: 24,
Expand Down Expand Up @@ -147,6 +169,7 @@ fileIconsObject.usb = {
height: 24,
svg: '<path d="M 14.9994,6.99807L 14.9994,10.9981L 15.9994,10.9981L 15.9994,12.9981L 12.9994,12.9981L 12.9994,4.99807L 14.9994,4.99807L 11.9994,0.998068L 8.9994,4.99807L 10.9994,4.99807L 10.9994,12.9981L 7.9994,12.9981L 7.9994,10.9281C 8.7034,10.5611 9.1994,9.84707 9.1994,8.99807C 9.1994,7.78307 8.2144,6.79807 6.9994,6.79807C 5.7844,6.79807 4.7994,7.78307 4.7994,8.99807C 4.7994,9.84707 5.2954,10.5611 5.9994,10.9281L 5.9994,12.9981C 5.9994,14.1031 6.8934,14.9981 7.9994,14.9981L 10.9994,14.9981L 10.9994,18.0491C 10.2894,18.4141 9.7994,19.1451 9.7994,19.9981C 9.7994,21.2131 10.7844,22.1981 11.9994,22.1981C 13.2144,22.1981 14.1994,21.2131 14.1994,19.9981C 14.1994,19.1451 13.7084,18.4141 12.9994,18.0491L 12.9994,14.9981L 15.9994,14.9981C 17.1044,14.9981 17.9994,14.1031 17.9994,12.9981L 17.9994,10.9981L 18.9994,10.9981L 18.9994,6.99807L 14.9994,6.99807 Z"/>'
};
fileIconsObject.audio = fileIconsObject.volume;
// Write the file
fs.writeFileSync(path.join(__dirname, "src", "assets", "icons", "file-icons.json"), JSON.stringify(fileIconsObject, "", 4));
console.log("Wrote file-icons.json");
Expand Down
1 change: 1 addition & 0 deletions file-icons/bytesize-icons
Submodule bytesize-icons added at 210d2f
Loading

0 comments on commit 39c3f2d

Please sign in to comment.