Improve disabled button UX with custom message and no hover effect
All checks were successful
Deploy / Deploy to Production (push) Successful in 6s

- Disable hover animation on disabled add-to-cart button
- Display "Choisissez une option" message when button is disabled
- Add cursor: not-allowed and opacity styling for disabled state
- Format SCSS for better code consistency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2025-12-19 17:05:00 +01:00
parent a961ade257
commit ee5eed49e6
4 changed files with 82 additions and 74 deletions

View file

@ -1,79 +1,76 @@
.btn__default{
.btn__default {
--size: calc(var(--h-block) - 8px);
font-size: var(--fs-normal);
font-weight: var(--fw-normal);
height: var(--size);
padding-right: 1.5ch;
--size: calc(var(--h-block) - 8px);
font-size: var(--fs-normal);
font-weight: var(--fw-normal);
position: relative;
display: flex;
align-items: center;
gap: 0ch;
// padding-right: 0.5ch;
color: var(--color-accent);
font-weight: var(--fw-medium);
text-decoration: none;
cursor: pointer;
.icon,
.txt {
z-index: 10;
}
.icon {
width: var(--size);
height: var(--size);
padding-right: 1.5ch;
position: relative;
display: flex;
align-items: center;
gap: 0ch;
// padding-right: 0.5ch;
justify-content: center;
color: var(--color-bg);
text-align: center;
svg {
fill: var(--color-bg);
width: 80%;
}
}
.txt {
font-family: var(--font-title);
color: var(--color-accent);
font-weight: var(--fw-medium);
text-decoration: none;
font-size: var(--fs-normal);
font-weight: var(--fw-bold);
padding-left: 1ch;
}
cursor: pointer;
&::after {
content: "";
display: block;
background-color: var(--color-accent);
border-radius: calc(var(--size) / 2);
width: var(--size);
height: var(--size);
position: absolute;
left: 0;
z-index: 0;
transition: width 0.2s;
}
.icon, .txt{ z-index: 10; }
.icon{
width: var(--size);
height: var(--size);
display: flex;
align-items: center;
justify-content: center;
color: var(--color-bg);
text-align: center;
svg{
fill: var(--color-bg);
width: 80%;
}
&:hover:not(:disabled) {
//
.txt {
color: var(--color-bg);
display: block;
}
.txt{
font-family: var(--font-title);
color: var(--color-accent);
font-size: var(--fs-normal);
font-weight: var(--fw-bold);
padding-left: 1ch;
&::after {
width: 100%;
}
}
&::after{
content: '';
display: block;
background-color: var(--color-accent);
border-radius: calc(var(--size)/2);
width: var(--size);
height: var(--size);
position: absolute;
left: 0;
z-index: 0;
transition: width .2s
}
&:hover{
//
.txt{
color: var(--color-bg);
display: block;
}
&::after{
width: 100%;
}
}
&:disabled {
cursor: not-allowed;
opacity: 0.6;
}
}

View file

@ -125,7 +125,8 @@ main {
text-decoration: none;
cursor: pointer;
}
.btn__default .icon, .btn__default .txt {
.btn__default .icon,
.btn__default .txt {
z-index: 10;
}
.btn__default .icon {
@ -160,13 +161,17 @@ main {
z-index: 0;
transition: width 0.2s;
}
.btn__default:hover .txt {
.btn__default:hover:not(:disabled) .txt {
color: var(--color-bg);
display: block;
}
.btn__default:hover::after {
.btn__default:hover:not(:disabled)::after {
width: 100%;
}
.btn__default:disabled {
cursor: not-allowed;
opacity: 0.6;
}
#btn--don__mobile {
width: 100%;

File diff suppressed because one or more lines are too long

View file

@ -59,10 +59,16 @@
>
<span class="icon">
<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path d="m14.523 18.787s4.501-4.505 6.255-6.26c.146-.146.219-.338.219-.53s-.073-.383-.219-.53c-1.753-1.754-6.255-6.258-6.255-6.258-.144-.145-.334-.217-.524-.217-.193 0-.385.074-.532.221-.293.292-.295.766-.004 1.056l4.978 4.978h-14.692c-.414 0-.75.336-.75.75s.336.75.75.75h14.692l-4.979 4.979c-.289.289-.286.762.006 1.054.148.148.341.222.533.222.19 0 .378-.072.522-.215z" fill-rule="nonzero" />
<path d="m14.523 18.787s4.501-4.505 6.255-6.26c.146-.146.219-.338.219-.53s-.073-.383-.219-.530c-1.753-1.754-6.255-6.258-6.255-6.258-.144-.145-.334-.217-.524-.217-.193 0-.385.074-.532.221-.293.292-.295.766-.004 1.056l4.978 4.978h-14.692c-.414 0-.75.336-.75.75s.336.75.75.75h14.692l-4.979 4.979c-.289.289-.286.762.006 1.054.148.148.341.222.533.222.19 0 .378-.072.522-.215z" fill-rule="nonzero" />
</svg>
</span>
<div class="txt"><?= t('addToCart', 'Ajouter au panier') ?></div>
<div class="txt">
<?php if($page->hasOptions()->toBool() && $page->optionValues()->isNotEmpty()): ?>
<?= t('chooseOption', 'Choisissez une option') ?>
<?php else: ?>
<?= t('addToCart', 'Ajouter au panier') ?>
<?php endif ?>
</div>
</button>
</div>
</div>