Skip to content

Commit c1cb14a

Browse files
Colin MackayColin Mackay
authored andcommitted
WIP
1 parent 2b94b64 commit c1cb14a

File tree

6 files changed

+33
-6
lines changed

6 files changed

+33
-6
lines changed

helpers/PhosphorIcons/ConvertToEnum.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Path to the selection.json from the Phosphor Icons repository
1+
# Path to the Phosphor Icons
22
$iconPath = "$PSScriptRoot/../../src/Stravaig.Avalonia.Controls.Icons/Assets/PhosphorIcons"
33

44
# Output C# file path

helpers/PhosphorIcons/StyleSvg.ps1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env pwsh
2+
# Script to add a class attribute to all SVG files in the Phosphor Icons folder
3+
# Ensure you have a backup of the SVG files before running this script,
4+
# e.g. via source control.
5+
6+
# Path to the Phosphor Icons
7+
$iconPath = "$PSScriptRoot/../../src/Stravaig.Avalonia.Controls.Icons/Assets/PhosphorIcons"
8+
9+
$svgFiles = Get-ChildItem -Path $iconPath -Filter "*.svg" -Recurse -File
10+
11+
foreach ($file in $svgFiles) {
12+
# Open the file as XML
13+
# Add a class="Stravaig" attribute to the <svg> element, if one does not already exist
14+
# Save the file back to disk
15+
[xml]$svgXml = Get-Content -Path $file.FullName
16+
$svgElement = $svgXml.DocumentElement
17+
18+
if (-not $svgElement.HasAttribute("class")) {
19+
$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)"
24+
}
25+
}
26+
27+
Write-Host "Completed updating SVG files."
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading

src/Stravaig.Avalonia.Controls.Icons/PhosphorIcon/PhosphorIcon.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void UpdateImageSource()
9090
private string BuildCss()
9191
{
9292
var rgb = Color.ToRgb();
93-
var css = $"svg {{ fill: rgb({rgb.R}, {rgb.G}, {rgb.B}); }}";
93+
var css = $".Stravaig {{ color: rgb({rgb.R}, {rgb.G}, {rgb.B}); }}";
9494
return css;
9595
}
9696
}

src/Stravaig.Icons.Example/ViewModels/PhosphorIconDemoViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public PhosphorIconDemoViewModel()
3333
{
3434
// In design mode, expand the tree by default so that is open in the designer.
3535
_isExpanded = Design.IsDesignMode;
36-
_selectedIconTypeIndex = 0;
37-
_selectedIconType = IconTypes[0].Key;
36+
_selectedIconTypeIndex = 2;
37+
_selectedIconType = IconTypes[2].Key;
3838
_iconSize = 24;
3939
_colour = new HsvColor(Color.FromRgb(0xFF, 0x00, 0x00));
4040
_rgbColour = _colour.ToRgb().ToString();

0 commit comments

Comments
 (0)