Skip to content

Commit bacb714

Browse files
Colin MackayColin Mackay
authored andcommitted
Make icons styleable
1 parent c1cb14a commit bacb714

File tree

9,074 files changed

+59725
-9078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

9,074 files changed

+59725
-9078
lines changed

helpers/PhosphorIcons/StyleSvg.ps1

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,52 @@ foreach ($file in $svgFiles) {
1313
# Add a class="Stravaig" attribute to the <svg> element, if one does not already exist
1414
# Save the file back to disk
1515
[xml]$svgXml = Get-Content -Path $file.FullName
16-
$svgElement = $svgXml.DocumentElement
1716

17+
# Add the class to the SVG element
18+
$svgElement = $svgXml.DocumentElement
1819
if (-not $svgElement.HasAttribute("class")) {
1920
$svgElement.SetAttribute("class", "Stravaig")
20-
$svgXml.Save($file.FullName)
21-
Write-Host "Updated file: $($file.FullName)"
22-
} else {
23-
Write-Host "File already has class attribute: $($file.FullName)"
21+
Write-Host "Added <svg ... class=`"Stravaig`"> attribute to: $($file.FullName)"
22+
}
23+
24+
# All circle elements should get the fill="currentColor" attribute
25+
$circleElements = $svgXml.GetElementsByTagName("circle")
26+
foreach ($circle in $circleElements) {
27+
if (-not $circle.HasAttribute("fill")) {
28+
$circle.SetAttribute("fill", "currentColor")
29+
Write-Host "Added <circle ... fill=`"currentColor`"> in: $($file.FullName)"
30+
}
31+
}
32+
33+
# All path elements with an opacity attribute should get fill="currentColor"
34+
$pathElements = $svgXml.GetElementsByTagName("path")
35+
foreach ($path in $pathElements) {
36+
if ($path.HasAttribute("opacity") -and -not $path.HasAttribute("fill")) {
37+
$path.SetAttribute("fill", "currentColor")
38+
Write-Host "Added <path ... fill=`"currentColor`"> in: $($file.FullName)"
39+
}
2440
}
41+
42+
# All rect elements with an opacity attribute should get fill="currentColor"
43+
$pathElements = $svgXml.GetElementsByTagName("rect")
44+
foreach ($path in $pathElements) {
45+
if ($path.HasAttribute("opacity") -and -not $path.HasAttribute("fill")) {
46+
$path.SetAttribute("fill", "currentColor")
47+
Write-Host "Added <rect ... fill=`"currentColor`"> in: $($file.FullName)"
48+
}
49+
}
50+
51+
# All polygon elements with an opacity attribute should get fill="currentColor"
52+
$pathElements = $svgXml.GetElementsByTagName("polygon")
53+
foreach ($path in $pathElements) {
54+
if ($path.HasAttribute("opacity") -and -not $path.HasAttribute("fill")) {
55+
$path.SetAttribute("fill", "currentColor")
56+
Write-Host "Added <polygon ... fill=`"currentColor`"> in: $($file.FullName)"
57+
}
58+
}
59+
60+
$svgXml.Save($file.FullName)
61+
Write-Host "Updated file: $($file.FullName)"
2562
}
2663

2764
Write-Host "Completed updating SVG files."
Lines changed: 6 additions & 1 deletion
Loading
Lines changed: 9 additions & 1 deletion
Loading
Lines changed: 9 additions & 1 deletion
Loading
Lines changed: 8 additions & 1 deletion
Loading
Lines changed: 4 additions & 1 deletion
Loading
Lines changed: 5 additions & 1 deletion
Loading
Lines changed: 5 additions & 1 deletion
Loading
Lines changed: 5 additions & 1 deletion
Loading
Lines changed: 6 additions & 1 deletion
Loading

0 commit comments

Comments
 (0)