Make the code more readable and easier with some style

This commit is contained in:
Francesco Lorenzo D'Amico
2025-05-27 13:48:39 +02:00
parent 5c9f6c8120
commit 907e19e398
2 changed files with 48 additions and 63 deletions
@@ -4,31 +4,18 @@
<h3>Instructions</h3>
<div class="instructions-grid">
@{
var groupedInstructions = Model.Instructions.OrderBy(i => i.Number).ToList();
var instructionRows = groupedInstructions
.Select((instruction, index) => new { Instruction = instruction, Index = index })
.GroupBy(x => x.Index / 3)
.Select(g => g.Select(x => x.Instruction).ToList())
.ToList();
foreach (var row in instructionRows)
@foreach (var instruction in Model.Instructions.OrderBy(i => i.Number))
{
<div class="instruction-row">
@for (var instruction in row)
{
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)
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">
@@ -41,7 +28,4 @@
</div>
}
</div>
}
}
</div>
</div>
+30 -29
View File
@@ -89,38 +89,36 @@ textarea.form-control {
/* Recipe Instructions Grid Layout */
.instructions-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1rem;
margin-top: 2rem;
margin-bottom: 2rem;
}
.instruction-row {
display: flex;
justify-content: space-between;
margin-bottom: 2.5rem;
flex-wrap: wrap;
}
.instruction-card {
width: calc(33.333% - 20px);
margin-bottom: 1.5rem;
}
@media (max-width: 992px) {
.instruction-card {
width: calc(50% - 15px);
.instructions-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (max-width: 576px) {
.instruction-card {
width: 100%;
.instructions-grid {
grid-template-columns: 1fr;
}
}
.instruction-card {
border: 1px solid #ccc;
padding: 1rem;
border-radius: 8px;
background-color: white;
}
.instruction-image {
position: relative;
width: 100%;
aspect-ratio: 1/1;
aspect-ratio: 1 / 1;
border: 1px solid #ddd;
border-radius: 4px;
overflow: hidden;
@@ -129,36 +127,38 @@ textarea.form-control {
align-items: center;
justify-content: center;
background-color: #f8f9fa;
text-align: center;
}
.instruction-image img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 4px;
}
.placeholder-image {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
color: #aaa;
}
.placeholder-image i {
display: flex;
justify-content: center;
align-items: center;
font-size: 2rem;
}
color: #999;
background-color: #f0f0f0;
border-radius: 4px;
}
.step-number {
position: absolute;
bottom: 5px;
right: 10px;
background-color: rgba(0, 0, 0, 0.5);
bottom: 8px;
right: 8px;
background: rgba(0, 0, 0, 0.6);
color: white;
font-weight: bold;
padding: 3px 8px;
border-radius: 50%;
font-size: 0.875rem;
font-weight: bold;
}
.instruction-text {
@@ -183,3 +183,4 @@ textarea.form-control {
background-color: #007bff;
}