Create Grid for show instructions of recipe
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
@model Francesco.Recipes.World.Models.InstructionViewModel
|
||||
|
||||
<div class="recipe-instructions-section">
|
||||
<h3>Instructions</h3>
|
||||
|
||||
<div class="instructions-grid">
|
||||
@{
|
||||
var groupedInstructions = Model.Instructions.OrderBy(i => i.Number).ToList();
|
||||
var rows = (int)Math.Ceiling(groupedInstructions.Count / 3.0);
|
||||
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
<div class="instruction-row">
|
||||
@for (int col = 0; col < 3 && (row * 3 + col < groupedInstructions.Count); col++)
|
||||
{
|
||||
var instruction = groupedInstructions[row * 3 + col];
|
||||
<div class="instruction-card">
|
||||
<div class="instruction-image">
|
||||
@if (instruction.MediaFiles != null && instruction.MediaFiles.Any())
|
||||
{
|
||||
var mediaFile = instruction.MediaFiles.First();
|
||||
@if (mediaFile.Data != null && mediaFile.Data.Length > 0)
|
||||
{
|
||||
<img src="data:@mediaFile.MimeType;base64,@Convert.ToBase64String(mediaFile.Data)" alt="Step @instruction.Number" />
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
<div class="placeholder-image">
|
||||
<i class="bi bi-image"></i>
|
||||
</div>
|
||||
}
|
||||
<span class="step-number">@instruction.Number</span>
|
||||
</div>
|
||||
<p class="instruction-text">@instruction.Description</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user