To redesign your Angular component into a horizontal, wider card, you'll need to rearrange the HTML structure to place the image and product details side by side. Additionally, adjust the CSS to reflect the new layout.
Modified HTML:
<main [ngClass]="buttons ? 'listing-length' : 'ad-length'">
<div class="card h-100 product-card d-flex flex-row">
<!-- Image Section -->
<div class="imgContainer">
<img [src]="redirectUrl + 'api/productImage/' + product.imgGuid" alt="{{product.productName}} termék képe" (click)="!clickToNavigate && navigateToProductInfo()">
</div>
<!-- Product Details Section -->
<div class="card-body d-flex flex-column justify-content-between">
<!-- Product Name -->
<div (click)="!clickToNavigate && navigateToProductInfo()" class="mb-2">
<div class="card-title fs-4 fw-bold text-secondary">{{product.productName}}</div>
</div>
<!-- Price and Availability -->
<div class="card-text fs-5 mb-4 text-secondary">
<span>{{product.price | hufCurrencyPipe}}</span>
<div [ngClass]="{
'productAvailable': product.productAvailability === 'Keszleten',
'productUnavailable': product.productAvailability === 'Rendelheto'
}">{{product.productAvailability | productAvailabilityPipe}}</div>
</div>
<!-- Buttons -->
<div *ngIf="buttons">
<button class="btn btn-primary d-flex align-items-center px-4 py-2 rounded-4" (click)="!clickToNavigate && addToCart()">
<span class="me-2 text-uppercase">Kosárba</span>
<img class="basketIcon" src="./assets/icons/kosar.svg" alt="Kosár">
</button>
</div>
</div>
</div>
</main>
Modified SCSS:
main {
font-family: 'Gotham';
font-weight: 500;
font-style: normal;
transition: transform 0.3s ease-in-out;
cursor: pointer;
.card {
display: flex;
flex-direction: row;
border: none;
.imgContainer {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
img {
width: 100%;
height: auto;
object-fit: contain;
object-position: center;
}
}
.card-body {
flex: 2;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 1rem;
.card-title {
font-family: 'Gotham';
font-weight: 300;
font-size: 19px !important;
}
.card-text {
font-family: 'Gotham Book';
font-size: 16px !important;
margin-bottom: 1rem;
span {
display: block;
margin-bottom: 0.5rem;
}
}
.btn {
align-self: flex-start;
}
}
}
}
Key Changes:
-
HTML Structure:
- Wrapped the image and product details inside a
.card with d-flex flex-row classes to align them horizontally.
- Moved the image and product details into separate divs (
.imgContainer and .card-body) side by side.
- Adjusted the button section to be within the
.card-body.
-
CSS Adjustments:
- Set
.card to display: flex; flex-direction: row; to arrange child elements horizontally.
- Assigned flex values to
.imgContainer and .card-body to control their widths (flex: 1 and flex: 2 respectively).
- Styled
.imgContainer to center the image and ensure it scales appropriately.
- Adjusted padding and margins to suit the horizontal layout.
Result:
The component will now display as a wide card with the product image on the left and the product details (name, price, availability, and buttons) on the right, arranged horizontally.
Note: Ensure that you test the modified component across different screen sizes to make it responsive. You might need to add media queries or additional Bootstrap classes to handle responsiveness.