Skip to content

Commit

Permalink
Remove the fill attribute from all icons
Browse files Browse the repository at this point in the history
The fill attribute prevents the icon from receiving the proper coloring. This wasn't an issue in the symbolset version because svg-symbols strips the attribute.
  • Loading branch information
Windvis committed Mar 27, 2024
1 parent 7922aab commit e0691b1
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 19 deletions.
10 changes: 10 additions & 0 deletions lib/generate-icon-components.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const COMPONENT_ICON_FOLDER = join(
"icons",
);

const iconsWithFill = [];

const files = await readdir(ICON_FOLDER);
const icons = files
.filter((file) => extname(file) === ".svg")
Expand All @@ -27,6 +29,10 @@ const promises = icons.map((svg) => {
});
await Promise.all(promises);

if (iconsWithFill.length > 0) {
throw new Error(`The following icons have a fill attribute which might cause issues: ${iconsWithFill.join(', ')}`)
}

async function generateComponent(iconName) {
const componentName = pascalCase(iconName, {
mergeAmbiguousCharacters: true,
Expand All @@ -36,6 +42,10 @@ async function generateComponent(iconName) {
.toString()
.replace(">", " ...attributes>"); // We assume the first closing bracket belongs to the svg element

if (iconContent.includes('fill="')) {
iconsWithFill.push(iconName);
}

const componentContent = `// THIS FILE IS GENERATED. ANY CHANGES TO THIS FILE WILL BE LOST.
import type { TOC } from '@ember/component/template-only';
Expand Down
2 changes: 1 addition & 1 deletion public/icons/caret-up-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions public/icons/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/html-dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions public/icons/image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/link-broken.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/users-one-of-four.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/users-three-of-four.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/users-two-of-four.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/icons/visible.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e0691b1

Please sign in to comment.