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:
parent
775d26906f
commit
8885c8d57f
5 changed files with 38 additions and 3 deletions
|
|
@ -39,9 +39,16 @@ else
|
|||
<span class="loading-spinner">⏳</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (shift.IsPngIcon)
|
||||
{
|
||||
<img src="@shift.Icon" alt="@shift.Name" style="width: 24px; height: 24px;" />
|
||||
}
|
||||
else
|
||||
{
|
||||
@shift.Icon
|
||||
}
|
||||
}
|
||||
</button>
|
||||
<span class="tooltip">@shift.Name</span>
|
||||
</div>
|
||||
|
|
|
|||
BIN
Client/wwwroot/break-icon.png
Normal file
BIN
Client/wwwroot/break-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 186 B |
|
|
@ -28,6 +28,12 @@
|
|||
"MorningTime": "",
|
||||
"AfternoonTime": ""
|
||||
},
|
||||
{
|
||||
"Name": "Pause",
|
||||
"Icon": "break-icon.png",
|
||||
"MorningTime": "10:00-10:15",
|
||||
"AfternoonTime": "15:00-15:15"
|
||||
},
|
||||
{
|
||||
"Name": "Früh",
|
||||
"Icon": "🌅",
|
||||
|
|
|
|||
|
|
@ -98,9 +98,29 @@ namespace ShiftScheduler.Services
|
|||
foreach (var day in Enumerable.Range(0, dayInWeek))
|
||||
{
|
||||
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
|
||||
var icon = shiftWithTransport?.Shift.Icon ?? "";
|
||||
var shift = shiftWithTransport?.Shift;
|
||||
|
||||
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))
|
||||
{
|
||||
RenderEmptyCell(table);
|
||||
|
|
|
|||
|
|
@ -6,5 +6,7 @@ namespace ShiftScheduler.Shared.Models
|
|||
public string Icon { get; set; } = string.Empty;
|
||||
public string MorningTime { get; set; } = string.Empty;
|
||||
public string AfternoonTime { get; set; } = string.Empty;
|
||||
|
||||
public bool IsPngIcon => Icon.EndsWith(".png", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue