Add PNG icon support for shifts with sample coffee cup icon

Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-08-21 19:00:13 +00:00
parent 775d26906f
commit 8885c8d57f
5 changed files with 38 additions and 3 deletions

View file

@ -40,7 +40,14 @@ else
} }
else else
{ {
@shift.Icon @if (shift.IsPngIcon)
{
<img src="@shift.Icon" alt="@shift.Name" style="width: 24px; height: 24px;" />
}
else
{
@shift.Icon
}
} }
</button> </button>
<span class="tooltip">@shift.Name</span> <span class="tooltip">@shift.Name</span>

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

View file

@ -28,6 +28,12 @@
"MorningTime": "", "MorningTime": "",
"AfternoonTime": "" "AfternoonTime": ""
}, },
{
"Name": "Pause",
"Icon": "break-icon.png",
"MorningTime": "10:00-10:15",
"AfternoonTime": "15:00-15:15"
},
{ {
"Name": "Früh", "Name": "Früh",
"Icon": "🌅", "Icon": "🌅",

View file

@ -98,8 +98,28 @@ namespace ShiftScheduler.Services
foreach (var day in Enumerable.Range(0, dayInWeek)) foreach (var day in Enumerable.Range(0, dayInWeek))
{ {
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day)); var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
var icon = shiftWithTransport?.Shift.Icon ?? ""; var shift = shiftWithTransport?.Shift;
table.Cell().Element(CellStyleMiddle).Text(icon);
if (shift != null && shift.IsPngIcon)
{
// For PNG icons, embed the image
var iconPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", shift.Icon);
if (File.Exists(iconPath))
{
table.Cell().Element(CellStyleMiddle).Image(iconPath).FitArea();
}
else
{
// Fallback to shift name if PNG not found
table.Cell().Element(CellStyleMiddle).Text(shift.Name);
}
}
else
{
// For text/emoji icons, render as text
var icon = shift?.Icon ?? "";
table.Cell().Element(CellStyleMiddle).Text(icon);
}
} }
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek)) foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
{ {

View file

@ -6,5 +6,7 @@ namespace ShiftScheduler.Shared.Models
public string Icon { get; set; } = string.Empty; public string Icon { get; set; } = string.Empty;
public string MorningTime { get; set; } = string.Empty; public string MorningTime { get; set; } = string.Empty;
public string AfternoonTime { get; set; } = string.Empty; public string AfternoonTime { get; set; } = string.Empty;
public bool IsPngIcon => Icon.EndsWith(".png", StringComparison.OrdinalIgnoreCase);
} }
} }