1use std::{cell::Cell, rc::Rc};
2
3use gpui::{
4 AnyElement, App, BorderStyle, Corners, Div, ElementId, Hsla, InteractiveElement, IntoElement,
5 ParentElement, Pixels, RenderOnce, SharedString, Stateful, Styled, Window, canvas, div, point,
6 prelude::FluentBuilder, px, quad,
7};
8use gpui_material_foundation::{
9 InteractionSource, InteractionState, InteractionTracker, animate, color,
10 current_material_theme, elevation_shadow_pair,
11};
12use gpui_material_theme::{
13 ColorRole, CornerRole, Direction, Elevation, MotionKind, MotionSpeed, TypeRole,
14 TypographyEmphasis,
15};
16
17use crate::action::{
18 Action, ActionControl, ActionLayout, ActionStyle, Activate, DisabledStyle, SegmentShape,
19 icon_slot, interpolated_corners,
20};
21use crate::button_style::{
22 ButtonBorder, ButtonColors, ButtonElevations, ButtonPadding, ButtonShapes, ButtonStyle,
23 finite_length,
24};
25use crate::{Icon, IconName, SemanticTone};
26
27use super::{Chip, ChipColors, ChipElevations, ChipVariant};
28
29#[derive(Clone, Copy, Debug, Eq, PartialEq)]
30struct ChipToneRoles {
31 foreground: ColorRole,
32 leading: ColorRole,
33 trailing: ColorRole,
34 selected_container: ColorRole,
35 border: ColorRole,
36}
37
38fn chip_tone_roles(
39 variant: ChipVariant,
40 selected: bool,
41 tonal: bool,
42 tone: SemanticTone,
43) -> ChipToneRoles {
44 use ColorRole::*;
45 if let Some((role, _, container, on_container)) = tone.roles() {
46 let fg = if selected { on_container } else { role };
47 ChipToneRoles {
48 foreground: fg,
49 leading: fg,
50 trailing: fg,
51 selected_container: container,
52 border: role,
53 }
54 } else {
55 ChipToneRoles {
56 foreground: if selected {
57 OnSecondaryContainer
58 } else if variant == ChipVariant::Assist {
59 OnSurface
60 } else {
61 OnSurfaceVariant
62 },
63 leading: match (variant, selected, tonal) {
64 (ChipVariant::Input, false, _) | (ChipVariant::Filter, false, true) => {
65 OnSurfaceVariant
66 }
67 (ChipVariant::Filter, true, _) => OnSecondaryContainer,
68 _ => Primary,
69 },
70 trailing: if selected {
71 OnSecondaryContainer
72 } else {
73 OnSurfaceVariant
74 },
75 selected_container: SecondaryContainer,
76 border: OutlineVariant,
77 }
78 }
79}
80
81#[derive(Clone, Copy)]
82struct ChipPalette {
83 foreground: ColorRole,
84 label: Hsla,
85 leading: Hsla,
86 trailing: Hsla,
87 container: Hsla,
88 border_color: Hsla,
89 border_width: Pixels,
90 selection: f32,
91}
92
93#[allow(clippy::too_many_arguments)]
94fn resolve_palette(
95 id: &ElementId,
96 variant: ChipVariant,
97 selectable: bool,
98 selected: bool,
99 tonal: bool,
100 tone: SemanticTone,
101 elevated: bool,
102 disabled: bool,
103 chip_colors: ChipColors,
104 border: Option<ButtonBorder>,
105 window: &mut Window,
106 cx: &mut App,
107) -> ChipPalette {
108 use ColorRole::*;
109 let colors = chip_colors.for_state(disabled, selected);
110 let roles = chip_tone_roles(variant, selected, tonal, tone);
111 let foreground = roles.foreground;
112 let (on_surface, label, leading, trailing, idle, checked, border_color, effects) = {
113 let theme = current_material_theme(window, cx);
114 let theme_color = |role| color(theme.colors.color(role));
115 let on_surface = theme_color(OnSurface);
116 let label = colors.label.unwrap_or_else(|| {
117 if disabled {
118 on_surface.opacity(0.38)
119 } else {
120 theme_color(foreground)
121 }
122 });
123 let leading = colors.leading.unwrap_or_else(|| {
124 if disabled {
125 on_surface.opacity(0.38)
126 } else {
127 theme_color(roles.leading)
128 }
129 });
130 let trailing = colors.trailing.unwrap_or_else(|| {
131 if disabled {
132 on_surface.opacity(0.38)
133 } else {
134 theme_color(roles.trailing)
135 }
136 });
137 let idle = chip_colors.enabled.container.unwrap_or_else(|| {
138 if elevated {
139 theme_color(SurfaceContainerLow)
140 } else {
141 theme_color(roles.selected_container).opacity(0.)
142 }
143 });
144 let checked = chip_colors
145 .selected
146 .container
147 .unwrap_or_else(|| theme_color(roles.selected_container));
148 let border_color = colors
149 .border
150 .or(border.map(|border| border.color))
151 .unwrap_or_else(|| {
152 if disabled {
153 on_surface.opacity(0.12)
154 } else {
155 theme_color(roles.border)
156 }
157 });
158 let effects = theme.motion.spec(
159 MotionKind::Effects,
160 MotionSpeed::Fast,
161 cx.reduce_motion() || disabled,
162 );
163 (
164 on_surface,
165 label,
166 leading,
167 trailing,
168 idle,
169 checked,
170 border_color,
171 effects,
172 )
173 };
174 let selection = if selectable {
175 animate(
176 (id.clone(), "chip-tint"),
177 f32::from(selected),
178 effects,
179 window,
180 cx,
181 )
182 .clamp(0., 1.)
183 } else {
184 0.
185 };
186 let container = if disabled {
187 colors
188 .container
189 .unwrap_or_else(|| on_surface.opacity(if selected || elevated { 0.12 } else { 0. }))
190 } else if selection == 0. {
191 idle
192 } else if selection == 1. {
193 checked
194 } else {
195 crate::motion::mix(idle, checked, selection)
196 };
197 let border_width = border.map_or(px(f32::from(!elevated && !selected)), |border| {
198 finite_length(border.width)
199 });
200 ChipPalette {
201 foreground,
202 label,
203 leading,
204 trailing,
205 container,
206 border_color,
207 border_width,
208 selection,
209 }
210}
211
212#[allow(clippy::too_many_arguments)]
213fn build_chip_style(
214 variant: ChipVariant,
215 selectable: bool,
216 selected: bool,
217 tonal: bool,
218 elevated: bool,
219 shapes: ButtonShapes,
220 foreground: ColorRole,
221) -> ActionStyle {
222 ActionStyle {
223 background: None,
224 background_color: None,
225 foreground,
226 disabled: DisabledStyle {
227 foreground: ColorRole::OnSurface,
228 background: None,
229 outline: (ColorRole::OnSurface, 0.12),
230 },
231 height: 32.,
232 min_width: 0.,
233 corner: if tonal {
234 CornerRole::Medium
235 } else {
236 CornerRole::Small
237 },
238 pressed_corner: CornerRole::Small,
239 selected_corner: if tonal {
240 Some(CornerRole::Full)
241 } else if selectable && shapes.checked.is_some() {
242 Some(CornerRole::Small)
243 } else {
244 None
245 },
246 corner_motion: (MotionKind::Spatial, MotionSpeed::Fast),
247 outline: 0.,
248 outline_role: ColorRole::OutlineVariant,
249 elevation: if elevated {
250 Elevation::Level1
251 } else {
252 Elevation::Level0
253 },
254 hover_elevation: if elevated {
255 Elevation::Level2
256 } else if selected && variant == ChipVariant::Filter {
257 Elevation::Level1
258 } else {
259 Elevation::Level0
260 },
261 }
262}
263
264fn build_chip_layout(
265 split: bool,
266 tab_stop: bool,
267 dragged: bool,
268 shapes: ButtonShapes,
269 elevations: ChipElevations,
270 dragged_elevation: Option<Elevation>,
271 palette: ChipPalette,
272) -> ActionLayout {
273 ActionLayout {
274 tab_stop,
275 dragged,
276 dragged_elevation: (!split).then_some(dragged_elevation).flatten(),
277 appearance: ButtonStyle {
278 shapes,
279 colors: action_colors(
280 palette.label,
281 if split {
282 gpui::transparent_black()
283 } else {
284 palette.container
285 },
286 ),
287 border: (!split).then_some(ButtonBorder {
288 width: palette.border_width,
289 color: palette.border_color,
290 }),
291 elevations: if split {
292 ButtonElevations::default()
293 } else {
294 elevations.button()
295 },
296 },
297 ..Default::default()
298 }
299}
300
301#[allow(clippy::too_many_arguments)]
302fn build_leading_slot(
303 avatar: Option<AnyElement>,
304 leading: Option<AnyElement>,
305 filter_mark: f32,
306 spacing: Pixels,
307 leading_color: Hsla,
308 direction: Direction,
309) -> Option<AnyElement> {
310 avatar
311 .map(|avatar| {
312 div()
313 .size(px(24.))
314 .flex_none()
315 .rounded_full()
316 .overflow_hidden()
317 .text_color(leading_color)
318 .child(icon_slot(avatar, 24.))
319 .into_any_element()
320 })
321 .or_else(|| {
322 leading.map(|leading| {
323 div()
324 .flex_none()
325 .text_color(leading_color)
326 .child(icon_slot(leading, 18.))
327 .into_any_element()
328 })
329 })
330 .or_else(|| {
331 (filter_mark > 0.).then(|| {
332 div()
333 .w((px(18.) + spacing) * filter_mark)
334 .flex_none()
335 .overflow_hidden()
336 .opacity(filter_mark)
337 .text_color(leading_color)
338 .when(direction == Direction::Rtl, |slot| {
339 slot.flex().justify_end()
340 })
341 .child(icon_slot(
342 Icon::new(IconName::Check).into_any_element(),
343 18.,
344 ))
345 .into_any_element()
346 })
347 })
348}
349
350#[allow(clippy::too_many_arguments)]
351fn build_primary_content(
352 leading: Option<AnyElement>,
353 trailing: Option<AnyElement>,
354 label: AnyElement,
355 padding: ButtonPadding,
356 spacing: Pixels,
357 filter_mark: f32,
358 split: bool,
359 direction: Direction,
360 visual_height: &Rc<Cell<Pixels>>,
361) -> AnyElement {
362 let content = div()
363 .relative()
364 .flex()
365 .items_center()
366 .min_w_0()
367 .text_size(px(14.))
368 .when(direction == Direction::Rtl, Styled::flex_row_reverse)
369 .pt(padding.top)
370 .pb(padding.bottom);
371 let mut content = logical_edges(
372 content,
373 padding.start,
374 if split { spacing } else { padding.end },
375 direction,
376 )
377 .children(leading)
378 .when(filter_mark == 0., |row| row.gap(spacing))
379 .child(label)
380 .children(trailing.map(|trailing| {
381 if filter_mark > 0. {
382 logical_edges(div(), spacing, px(0.), direction)
383 .child(trailing)
384 .into_any_element()
385 } else {
386 trailing
387 }
388 }));
389 if split {
390 content = content.child(measure_height(visual_height.clone()));
391 }
392 content.into_any_element()
393}
394
395#[allow(clippy::too_many_arguments)]
396fn render_split_chip(
397 id: ElementId,
398 row: Stateful<Div>,
399 primary: ActionControl,
400 remove_label: SharedString,
401 on_remove: Activate,
402 remove_content: Option<AnyElement>,
403 disabled: bool,
404 dragged: bool,
405 selected: bool,
406 direction: Direction,
407 padding: ButtonPadding,
408 explicit_padding: Option<ButtonPadding>,
409 style: ActionStyle,
410 layout: ActionLayout,
411 palette: ChipPalette,
412 elevations: ButtonElevations,
413 dragged_elevation: Option<Elevation>,
414 visual_height: Rc<Cell<Pixels>>,
415 tracker: Option<InteractionTracker>,
416 window: &mut Window,
417 cx: &mut App,
418) -> Stateful<Div> {
419 let remove = ActionControl {
420 id: ElementId::from((id.clone(), "remove")),
421 label: remove_label,
422 focus: None,
423 disabled,
424 action: Action::Invoke(Some(on_remove)),
425 style: split_action_style(style, 32.),
426 content: logical_edges(
427 div().relative().pt(padding.top).pb(padding.bottom),
428 px(0.),
429 explicit_padding.map_or(px(0.), |padding| padding.end),
430 direction,
431 )
432 .child(remove_content.unwrap_or_else(|| {
433 icon_slot(Icon::new(IconName::Close).into_any_element(), 18.).into_any_element()
434 }))
435 .child(measure_height(visual_height.clone()))
436 .into_any_element(),
437 };
438 let primary_state = primary.interaction_snapshot(dragged, window, cx);
439 let remove_state = remove.interaction_snapshot(dragged, window, cx);
440 let mut interaction = primary_state;
441 interaction.hovered |= remove_state.hovered;
442 interaction.pressed |= remove_state.pressed;
443 interaction.focus_visible |= remove_state.focus_visible;
444 let surface = SplitSurface {
445 id,
446 style,
447 layout,
448 direction,
449 selected,
450 container: palette.container,
451 border: ButtonBorder {
452 width: palette.border_width,
453 color: palette.border_color,
454 },
455 elevations,
456 dragged_elevation,
457 visual_height,
458 }
459 .render(interaction, window, cx);
460 let primary_layout = ActionLayout {
461 segment: Some(SegmentShape {
462 leading: true,
463 trailing: false,
464 outer: style.corner,
465 inner: CornerRole::None,
466 pressed: CornerRole::None,
467 }),
468 ..layout
469 };
470 let remove_layout = ActionLayout {
471 segment: Some(SegmentShape {
472 leading: false,
473 trailing: true,
474 outer: style.corner,
475 inner: CornerRole::None,
476 pressed: CornerRole::None,
477 }),
478 presentation_selected: Some(selected),
479 appearance: ButtonStyle {
480 shapes: layout.appearance.shapes,
481 colors: action_colors(palette.trailing, gpui::transparent_black()),
482 ..Default::default()
483 },
484 ..layout
485 };
486 row.child(surface)
487 .child(primary.render_with_tracker(1., primary_layout, tracker, window, cx))
488 .child(remove.render_with_tracker(1., remove_layout, None, window, cx))
489}
490
491impl RenderOnce for Chip {
492 fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
493 let selectable = matches!(self.variant, ChipVariant::Filter | ChipVariant::Input);
494 let selected = selectable && self.selected;
495 let tonal = selectable && self.tonal;
496 let elevated = self.elevated && self.variant != ChipVariant::Input;
497 let split = selectable && self.remove.is_some();
498 let (direction, density) = {
499 let theme = current_material_theme(window, cx);
500 (theme.layout.direction, theme.layout.density)
501 };
502 let palette = resolve_palette(
503 &self.id,
504 self.variant,
505 selectable,
506 selected,
507 tonal,
508 self.tone,
509 elevated,
510 self.disabled,
511 self.colors,
512 self.border,
513 window,
514 cx,
515 );
516 let style = build_chip_style(
517 self.variant,
518 selectable,
519 selected,
520 tonal,
521 elevated,
522 self.shapes,
523 palette.foreground,
524 );
525 let dragged_elevation = self.elevations.dragged.or(Some(Elevation::Level4));
526 let layout = build_chip_layout(
527 split,
528 self.tab_stop,
529 self.dragged,
530 self.shapes,
531 self.elevations,
532 dragged_elevation,
533 palette,
534 );
535
536 let avatar = (self.variant == ChipVariant::Input)
537 .then_some(self.avatar)
538 .flatten();
539 let has_avatar = avatar.is_some();
540 let filter_mark = if self.variant == ChipVariant::Filter && self.leading.is_none() {
541 palette.selection
542 } else {
543 0.
544 };
545 let leading = build_leading_slot(
546 avatar,
547 self.leading,
548 filter_mark,
549 self.spacing,
550 palette.leading,
551 direction,
552 );
553 let trailing = self
554 .trailing
555 .filter(|_| self.variant != ChipVariant::Suggestion)
556 .map(|content| {
557 div()
558 .flex_none()
559 .text_color(palette.trailing)
560 .text_size(px(18.))
561 .child(content)
562 .into_any_element()
563 });
564 let padding = self.padding.unwrap_or_else(|| ButtonPadding {
565 start: px(if has_avatar {
566 4.
567 } else if filter_mark > 0. {
568 16. - 8. * filter_mark
569 } else if leading.is_some() {
570 8.
571 } else {
572 16.
573 }),
574 end: if split {
575 self.spacing
576 } else if trailing.is_some() {
577 px(8.)
578 } else {
579 px(16.)
580 },
581 ..Default::default()
582 });
583 let label = self.content.unwrap_or_else(|| {
584 crate::text::single_line(
585 self.label.clone(),
586 TypeRole::LabelLarge.style(TypographyEmphasis::Baseline),
587 1.,
588 palette.label,
589 (None, 1., 1.),
590 window,
591 cx,
592 )
593 .into_any_element()
594 });
595 let row = div()
596 .id(self.id.clone())
597 .relative()
598 .flex()
599 .min_w_0()
600 .items_center()
601 .when(direction == Direction::Rtl, Styled::flex_row_reverse);
602 let (trailing, remove_content) = if split {
603 (None, trailing)
604 } else {
605 (trailing, None)
606 };
607 let visual_height = Rc::new(Cell::new(px(density.visual_size(style.height))));
608 let content = build_primary_content(
609 leading,
610 trailing,
611 label,
612 padding,
613 self.spacing,
614 filter_mark,
615 split,
616 direction,
617 &visual_height,
618 );
619 let primary = ActionControl {
620 id: ElementId::from((self.id.clone(), "activate")),
621 label: self.label,
622 focus: self.focus,
623 disabled: self.disabled,
624 action: if selectable {
625 Action::Toggle {
626 selected,
627 on_change: self.on_change,
628 }
629 } else {
630 Action::Invoke(self.on_activate)
631 },
632 style: if split {
633 split_action_style(style, 0.)
634 } else {
635 style
636 },
637 content,
638 };
639 let tracker = self
640 .interaction_source
641 .as_ref()
642 .map(|source| InteractionSource::track(source, &self.id, window, cx));
643 if let Some((label, on_remove)) = self.remove.filter(|_| selectable) {
644 render_split_chip(
645 self.id,
646 row,
647 primary,
648 label,
649 on_remove,
650 remove_content,
651 self.disabled,
652 self.dragged,
653 selected,
654 direction,
655 padding,
656 self.padding,
657 style,
658 layout,
659 palette,
660 self.elevations.button(),
661 dragged_elevation,
662 visual_height,
663 tracker,
664 window,
665 cx,
666 )
667 } else {
668 row.child(primary.render_with_tracker(1., layout, tracker, window, cx))
669 }
670 }
671}
672
673fn logical_edges(element: Div, start: Pixels, end: Pixels, direction: Direction) -> Div {
674 if direction == Direction::Rtl {
675 element.pl(end).pr(start)
676 } else {
677 element.pl(start).pr(end)
678 }
679}
680
681fn action_colors(label: Hsla, container: Hsla) -> ButtonColors {
682 ButtonColors {
683 container: Some(container),
684 content: Some(label),
685 disabled_container: Some(container),
686 disabled_content: Some(label),
687 checked_container: Some(container),
688 checked_content: Some(label),
689 }
690}
691
692fn split_action_style(style: ActionStyle, min_width: f32) -> ActionStyle {
693 ActionStyle {
694 min_width,
695 elevation: Elevation::Level0,
696 hover_elevation: Elevation::Level0,
697 ..style
698 }
699}
700
701fn measure_height(height: Rc<Cell<Pixels>>) -> gpui::Canvas<()> {
702 canvas(
703 move |bounds, _, _| height.set(height.get().max(bounds.size.height)),
704 |_, (), _, _| {},
705 )
706 .absolute()
707 .inset_0()
708}
709
710struct SplitSurface {
712 id: ElementId,
713 style: ActionStyle,
714 layout: ActionLayout,
715 direction: Direction,
716 selected: bool,
717 container: Hsla,
718 border: ButtonBorder,
719 elevations: ButtonElevations,
720 dragged_elevation: Option<Elevation>,
721 visual_height: Rc<Cell<Pixels>>,
722}
723
724impl SplitSurface {
725 fn render(
726 self,
727 state: InteractionState,
728 window: &mut Window,
729 cx: &mut App,
730 ) -> impl IntoElement {
731 let theme = current_material_theme(window, cx);
732 let shadow = color(theme.colors.color(ColorRole::Shadow));
733 let effects = theme
734 .motion
735 .spec(MotionKind::Effects, MotionSpeed::Fast, cx.reduce_motion());
736 let spatial = theme
737 .motion
738 .spec(MotionKind::Spatial, MotionSpeed::Fast, cx.reduce_motion());
739 let pressed = animate(
740 (self.id.clone(), "chip-press"),
741 f32::from(state.pressed),
742 spatial,
743 window,
744 cx,
745 )
746 .clamp(0., 1.);
747 let selected = if self.style.selected_corner.is_some() {
748 animate(
749 (self.id.clone(), "chip-selection"),
750 f32::from(self.selected),
751 spatial,
752 window,
753 cx,
754 )
755 .clamp(0., 1.)
756 } else {
757 0.
758 };
759 let default_elevation = if state.disabled {
760 Elevation::Level0
761 } else if state.hovered && !state.pressed {
762 self.style.hover_elevation
763 } else {
764 self.style.elevation
765 };
766 let elevation = if state.dragged {
767 self.dragged_elevation
768 } else {
769 self.elevations.for_state(state)
770 }
771 .unwrap_or(default_elevation);
772 let elevation = animate(
773 (self.id.clone(), "chip-elevation"),
774 elevation.dp(),
775 effects,
776 window,
777 cx,
778 )
779 .max(0.);
780 let outline = animate(
781 (self.id.clone(), "chip-outline"),
782 f32::from(self.border.width),
783 effects,
784 window,
785 cx,
786 )
787 .max(0.);
788 canvas(
789 |_, _, _| (),
790 move |mut bounds, (), window, _| {
791 let height = self.visual_height.get().min(bounds.size.height);
792 bounds.origin += point(px(0.), (bounds.size.height - height) / 2.);
793 bounds.size.height = height;
794 let shape =
795 interpolated_corners(bounds, self.style, selected, pressed, 1., self.layout);
796 let [top_left, top_right, bottom_right, bottom_left] = shape
797 .radii(
798 f32::from(bounds.size.width),
799 f32::from(bounds.size.height),
800 self.direction,
801 )
802 .map(px);
803 let radii = Corners {
804 top_left,
805 top_right,
806 bottom_right,
807 bottom_left,
808 };
809 if let Some(shadows) = elevation_shadow_pair(elevation, 1., shadow) {
810 window.paint_drop_shadows(bounds, radii, &shadows);
811 }
812 if self.container.a > 0. || outline > 0. {
813 window.paint_quad(quad(
814 bounds,
815 radii,
816 self.container,
817 px(outline),
818 if outline > 0. {
819 self.border.color
820 } else {
821 gpui::transparent_black()
822 },
823 BorderStyle::Solid,
824 ));
825 }
826 },
827 )
828 .absolute()
829 .inset_0()
830 }
831}
832
833#[cfg(test)]
834mod tests {
835 use super::*;
836
837 #[test]
838 fn chip_tone_roles_map_semantic_tones_and_preserve_defaults() {
839 use ColorRole::*;
840 let default_assist =
841 chip_tone_roles(ChipVariant::Assist, false, false, SemanticTone::Default);
842 assert_eq!(default_assist.foreground, OnSurface);
843 assert_eq!(default_assist.border, OutlineVariant);
844 assert_eq!(default_assist.selected_container, SecondaryContainer);
845
846 let default_selected =
847 chip_tone_roles(ChipVariant::Filter, true, false, SemanticTone::Default);
848 assert_eq!(default_selected.foreground, OnSecondaryContainer);
849 assert_eq!(default_selected.leading, OnSecondaryContainer);
850 assert_eq!(default_selected.trailing, OnSecondaryContainer);
851
852 for (tone, role, container, on_container) in [
853 (
854 SemanticTone::Danger,
855 Error,
856 ErrorContainer,
857 OnErrorContainer,
858 ),
859 (
860 SemanticTone::Success,
861 Success,
862 SuccessContainer,
863 OnSuccessContainer,
864 ),
865 (
866 SemanticTone::Warning,
867 Warning,
868 WarningContainer,
869 OnWarningContainer,
870 ),
871 (SemanticTone::Info, Info, InfoContainer, OnInfoContainer),
872 ] {
873 let unselected = chip_tone_roles(ChipVariant::Filter, false, false, tone);
874 assert_eq!(unselected.foreground, role);
875 assert_eq!(unselected.leading, role);
876 assert_eq!(unselected.trailing, role);
877 assert_eq!(unselected.border, role);
878 assert_eq!(unselected.selected_container, container);
879
880 let selected = chip_tone_roles(ChipVariant::Filter, true, false, tone);
881 assert_eq!(selected.foreground, on_container);
882 assert_eq!(selected.leading, on_container);
883 assert_eq!(selected.trailing, on_container);
884 assert_eq!(selected.selected_container, container);
885 }
886 }
887}