Skip to content

Conversation

atmgrifter00
Copy link
Contributor

Pull Request

🤨 Rationale

Creating the nimble-chip component for the immediate requirement of adding attachments to the spright-chat-input component.

👩‍💻 Implementation

Typical Nimble implementation. Adding a new label provider for the 'Remove' text for the remove button.

🧪 Testing

Unit and chromatic tests.

✅ Checklist

  • I have updated the project documentation to reflect my changes or determined no changes are needed.

@atmgrifter00 atmgrifter00 marked this pull request as ready for review August 14, 2025 17:45
@atmgrifter00 atmgrifter00 marked this pull request as draft August 14, 2025 19:39
Copy link
Contributor

@jattasNI jattasNI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly reviewed docs / behavior / style, not much of the implementation.

@atmgrifter00 atmgrifter00 marked this pull request as ready for review August 18, 2025 15:26
}
.remove-button {
height: 16px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the design really call for a 16x16 button? That seems too small for accessibility and mobile reasons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does. I'll let @NIbokeefe offer his reasoning here, but for my part, I do like the look of this over the other standard options (ignoring the accessibility concerns). I'll note that there are at least other design systems that have a similar small hit area for the remove button on chips.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mollykreis, For mobile accessibility it requires a 48x48 touchpoint which is larger than our largest controls. We won't technically be accessible for mobile without restructuring our sizing ramp. Often we use 24px buttons in 32px controls, and 18px buttons in 24px controls. That being said, those dimensions only pertaining to the controls visual representation, that doesn't mean the "hotspot" touch area can't or shouldn't be larger. In most cases increasing the size of the hotspot area would improve the interaction, so long as it doesn't interfere with the bounds of another touchpoint.

In a chip, I'm calling for a 16x16 button (which is a standard sized button) but the hotspot-clickable region can be most of the right surrounding area. This sized button counter balances and maintain symmetry with the icon.

Screenshot 2025-08-18 at 11 34 53 AM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't currently have a way for the touchpoint to be larger than the button, so we'd need to be fine with 16x16 touch point for now.

Also, we never added conditional styling to the button to change the focus-visible styling of the button when it got smaller (shouldn't have the double focus rings when small). Are we fine having the double ring on the 16x16 button until if/when that button styling gets updated?
image

Copy link

@NIbokeefe NIbokeefe Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mollykreis In my spec I drew it up with one 2px ring just like a Rollover state. Due to its small size and likelihood of covering the icon, I skipped the inner ring. But, I don't mind your mockup with the two rings, I could go either way.

Screenshot 2025-08-25 at 1 32 43 PM

ChipAppearance.block,
css`
:host {
background-image: linear-gradient(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you need to set a background-image to achieve a solid background color?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what the button does. From what I can this is done to remove the border?

With background-image:
image

Using background-color = :
image

Design:
image

I'll try a different route, however, and just have a transparent border, so we don't see that fuzziness at the corners.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is still some background-image related styling in the component. Can you take a pass at making sure it's all been converted to background colors?

return await fixture<Chip>(html`<${chipTag}></${chipTag}>`);
}

describe('Chip', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some tests for the tab index behavior?

<${buttonTag}
class="remove-button"
content-hidden
appearance="ghost"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use ButtonAppearance.ghost here?


const widthStates = [
['Default Width', ''],
['Custom Width', 'width: 250px;']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you haven't already, can you confirm with @NIbokeefe that when the chip is wider than the default "fit-text" width, that the remove button should stick to the text rather than the edge of the chip?

image

FWIW - in my opinion, the remove button should always be right-aligned in the chip rather than floating in the middle next text. I also wonder if the text & icon should always be left aligned rather than centered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NIbokeefe, can you provide guidance here. While this may be an atypical scenario, it's certainly something a user could easily do, so we should style this as expected.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atmgrifter00 @mollykreis,

I don't see the use case for wanting to expand a chip's width. We do allow that with buttons. However, with chips anywhere in the short or long term they should be nested within a control and not a stand alone selection element that would require modified margins to fill spaces.

If it makes sense to build that functionality into the control regardless, I agree with @mollykreis, the text and icon should left align, and the close button should right align as shown in example "A." We should prevent this from happening until we have a use case that warrants it.

Screenshot 2025-08-25 at 12 11 07 PM

active: []
})
);
export const textCustomized: StoryFn = createMatrixThemeStory(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The italic text looks clipped in the Text Customized story.

Copy link
Contributor Author

@atmgrifter00 atmgrifter00 Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is, and I talked with @jattasNI about this, but it's unclear to me what's causing it. The button doesn't exhibit this behavior, and even if I align the styles for the chip and the button (for the content part), I can't get rid of the cut-off. Interested in suggestions here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some posts on stackoverflow seem to show this as a known issue that italics break out of their computed size on layout. This post says that synthetic italics seem to do it more. We ship bold fonts to avoid synthetic bold / cross browser issues so if we were inclined to fix this I think we should try shipping actual italic fonts. I don't think I'm inclined to try the other workarounds in those posts (extra fake padding, changing letter spacing, etc).

Also thought maybe the new CSS text-box-trim and text-box-edge properties may help. They actually may fix alignment issues we have had with buttons, see the centering and alignment sections: https://developer.chrome.com/blog/css-text-box-trim#what_can_i_build_with_it_or_what_problems_does_it_solve
But playing around they seem to truncate the text-box even more while in this case we want to grow it :P

Inclined to treat it as a known issue for now unless there is a reasonable non-hacky fix

- chips are arranged horizontally and wrap to new lines when there is
insufficient horizontal space
- all chips have the same appearance
- use the medium-padding token to create space between chips
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming medium padding token is intended to be used for the horizontal and vertical spacing between chips, can you explicitly state that to avoid confusion?

ViewTemplate<Chip>,
ChipOptions
> = (context, definition) => html<Chip>`
<template>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need the outer wrapping template if it has no bindings on it (represents binding to the host itself, i.e. nimble-chip)

${x => x.removeButtonContent}
</${buttonTag}>
`)}
</template>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the endSlotTemplate as well since the mixin includes both. It should just be styled dispaly:none;

scrollBackward: scrollBackwardLabel,
scrollForward: scrollForwardLabel
scrollForward: scrollForwardLabel,
chipRemove: chipRemoveLabel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just go with remove as the name. I think that label will be generic enough for multiple contexts and we don't need an explicit remove label just for chip. If done make sure to update corresponding attributes, etc


/** @internal */
public get removeButtonContent(): string {
return `${chipRemoveLabel.getValueFor(this)} ${this.elementTextContent}`;
Copy link
Member

@rajsite rajsite Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the <Remove> <Label Text> string concatenation apply across languages?
Wondering if we should just keep it as "Remove" for now unless we have confidence in the l10n and aria design for chip/pill/badge concepts

cursor: default;
color: ${bodyDisabledFontColor};
border-color: rgba(${borderRgbPartialColor}, 0.3);
box-shadow: none;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like box-shadow is always none? do we need this style?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajsite I can't currently think of a reason we would use a box shadow (elevation) on a chip to date. Maybe a future iteration we use elevate a control with a box-shadow on rollover, but this would become a universal rule not just for chips alone.

Comment on lines +47 to +49
:host([disabled])::before {
box-shadow: none;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like box-shadow is always none? do we need this style?

@@ -0,0 +1,7 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atmgrifter00 still intend to get this pushed through?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try and find some downtime to resolve the remaining issues, and get it pushed in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants