Add small icon size for Cancel icon
Feature request summary
Consider adding another size for the cancel icon.
Rationale
In Discounts, we have the following UI allowing merchants to add products or collections to their discount. Once added, products or collections can also be removed using the X icon.
Originally, we came up with our own HTML button wrapping the Icon component. We added some CSS to force the Icon size.
<button
type="button"
className={styles.RemoveButton}
onClick={this.handleRemoveItem}
onTouchStart={this.handleRemoveItem}
>
<Icon source="cancel" color="skyDark" />
</button>
.RemoveButton {
@include unstyled-button;
width: 1.25rem;
height: 1.25rem;
margin-top: spacing(extra-tight);
}
To improve accessibility, we switched to the Polaris Button with an icon. But the icon size is too big, even when using cancelSmall.
<div className={styles.RemoveButton}>
<Button
id={`remove-btn-${id}`}
icon="cancelSmall"
plain
onClick={this.handleRemoveItem}
/>
</div>
We've decided to keep the Polaris Button and added some CSS to force the size/position of the icon:
.RemoveButton {
display: flex;
svg {
position: absolute;
top: 50%;
right: 0;
left: 0;
width: 1.5rem;
height: 1.5rem;
margin: auto;
transform: translateY(-50%);
text-align: center;
color: color('sky', 'dark');
}
}
Another solution would be to just add another icon size.
🌟 Feature requests that are not yet planned will be closed. We then use the issue’s :+1: upvotes to track and set priorities. See the contribution guidelines for more information.
👋 Thanks for opening your first issue. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines. You can also join #polaris on the Shopify Partners Slack.
But the icon size is too big, even when using
cancelSmall.
Can you attach a screenshot? The small cancel icon is meant for this use case.
As discussed in Slack, it seems like the right thing to do is to use cancelSmall.
Closing this issue for now.