PackageDetail: keep "Compare" label in both states, move tick to right
Label stays "Compare" regardless of inCart. Only change between default and added: a trailing check icon (endIcon) appears when the package is in the basket. aria-pressed + aria-label still carry the state for screen readers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -220,22 +220,22 @@ export const PackageDetail = React.forwardRef<HTMLDivElement, PackageDetailProps
|
|||||||
{arrangeLabel}
|
{arrangeLabel}
|
||||||
</Button>
|
</Button>
|
||||||
{onCompare && (
|
{onCompare && (
|
||||||
// Same soft/secondary chrome in both states; when the package
|
// Same soft/secondary chrome + "Compare" label in both states;
|
||||||
// is in the basket a leading check icon appears and the label
|
// when the package is in the basket a trailing check icon
|
||||||
// changes to "Added". Click is a toggle — caller decides to
|
// appears. Click is a toggle — caller decides to add or remove
|
||||||
// add or remove based on the `inCart` it's passing in.
|
// based on the `inCart` it's passing in.
|
||||||
<Button
|
<Button
|
||||||
variant="soft"
|
variant="soft"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
size="large"
|
size="large"
|
||||||
loading={compareLoading}
|
loading={compareLoading}
|
||||||
startIcon={inCart ? <CheckRoundedIcon /> : undefined}
|
endIcon={inCart ? <CheckRoundedIcon /> : undefined}
|
||||||
onClick={onCompare}
|
onClick={onCompare}
|
||||||
aria-pressed={inCart}
|
aria-pressed={inCart}
|
||||||
aria-label={inCart ? 'Remove from comparison' : 'Add to comparison'}
|
aria-label={inCart ? 'Remove from comparison' : 'Add to comparison'}
|
||||||
sx={{ flexShrink: 0 }}
|
sx={{ flexShrink: 0 }}
|
||||||
>
|
>
|
||||||
{inCart ? 'Added' : 'Compare'}
|
Compare
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in New Issue
Block a user