-
Notifications
You must be signed in to change notification settings - Fork 10
Nimble chip #2689
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
base: main
Are you sure you want to change the base?
Nimble chip #2689
Conversation
There was a problem hiding this 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.
} | ||
.remove-button { | ||
height: 16px; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.

There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.

Co-authored-by: Jesse Attas <jattasNI@users.noreply.github.com>
Co-authored-by: Jesse Attas <jattasNI@users.noreply.github.com>
ChipAppearance.block, | ||
css` | ||
:host { | ||
background-image: linear-gradient( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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;'] |
There was a problem hiding this comment.
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?

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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.

active: [] | ||
}) | ||
); | ||
export const textCustomized: StoryFn = createMatrixThemeStory( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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}`; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
:host([disabled])::before { | ||
box-shadow: none; | ||
} |
There was a problem hiding this comment.
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 @@ | |||
{ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Pull Request
🤨 Rationale
Creating the
nimble-chip
component for the immediate requirement of adding attachments to thespright-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