Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format availability for the new style #159

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions _dev/css/components/products.scss
Original file line number Diff line number Diff line change
Expand Up @@ -621,20 +621,20 @@
margin-top: 0.625rem;
font-weight: 700;

.material-icons {
line-height: inherit;
}

.product-available {
color: $brand-success;
.alert {
font-size: 1rem;
}

.product-unavailable {
color: $brand-warning;
.alert-content-wrapper {
display: flex;
gap: 0.75rem;
}

.product-last-items {
color: $brand-warning;
/* Reset some of the general styles on alert warning */
.alert-warning .material-icons {
padding-top: 0;
margin-right: 0;
font-size: 24px;
}
}

Expand Down
33 changes: 25 additions & 8 deletions templates/catalog/_partials/product-add-to-cart.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,35 @@
{/block}

{block name='product_availability'}
<span id="product-availability" class="js-product-availability">
<div id="product-availability" class="product-availability js-product-availability">
{if $product.show_availability && $product.availability_message}
{if $product.availability == 'available'}
<i class="material-icons rtl-no-flip product-available">&#xE5CA;</i>
{elseif $product.availability == 'last_remaining_items'}
<i class="material-icons product-last-items">&#xE002;</i>

{** First, we prepare the icons and colors we want to use *}
{if $product.availability == 'in_stock'}
{assign 'availability_icon' 'E5CA'}
{assign 'availability_color' 'success'}
{elseif $product.availability == 'available' || $product.availability == 'last_remaining_items'}
{assign 'availability_icon' 'E002'}
{assign 'availability_color' 'warning'}
{else}
<i class="material-icons product-unavailable">&#xE14B;</i>
{assign 'availability_icon' 'E14B'}
{assign 'availability_color' 'danger'}
{/if}
{$product.availability_message}

{** And render the availability message with icon *}
<div class="alert alert-{$availability_color}" role="alert">
<div class="alert-content-wrapper">
<div><i class="material-icons rtl-no-flip">&#x{$availability_icon};</i></div>
<div>
<div>{$product.availability_message}</div>
{if !empty($product.availability_submessage)}
<div><small>{$product.availability_submessage}</small></div>
{/if}
</div>
</div>
</div>
{/if}
</span>
</div>
{/block}

{block name='product_minimal_quantity'}
Expand Down
Loading