mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: adjust styling for search filters (#5587)
This commit is contained in:
		
							parent
							
								
									9bae14a2cc
								
							
						
					
					
						commit
						ba50d1ef69
					
				| @ -67,6 +67,19 @@ describe('FilterItem Component', () => { | ||||
|         ]); | ||||
|     }); | ||||
| 
 | ||||
|     it('renders explicit and extra options', async () => { | ||||
|         const mockState = { | ||||
|             operator: 'IS_ANY_OF', | ||||
|             values: ['1', '3', '2'], | ||||
|         }; | ||||
| 
 | ||||
|         const recordedChanges = setup(mockState); | ||||
| 
 | ||||
|         const valuesElement = await screen.findByText('1, 3 +1'); | ||||
|         await screen.findByText('is any of'); | ||||
|         expect(valuesElement).toBeInTheDocument(); | ||||
|     }); | ||||
| 
 | ||||
|     it('adjusts operator to match singular item', async () => { | ||||
|         const mockState = { | ||||
|             operator: 'IS_ANY_OF', | ||||
|  | ||||
| @ -40,6 +40,13 @@ const StyledCategoryIconWrapper = styled('div')(({ theme }) => ({ | ||||
| const StyledOptions = styled('span')(({ theme }) => ({ | ||||
|     color: theme.palette.text.primary, | ||||
|     fontWeight: theme.typography.fontWeightRegular, | ||||
|     textOverflow: 'ellipsis', | ||||
|     whiteSpace: 'nowrap', | ||||
|     overflow: 'hidden', | ||||
|     maxWidth: '200px', | ||||
|     [theme.breakpoints.up('md')]: { | ||||
|         maxWidth: '800px', | ||||
|     }, | ||||
| })); | ||||
| 
 | ||||
| const StyledIconButton = styled(IconButton)(({ theme }) => ({ | ||||
| @ -78,6 +85,9 @@ export const FilterItemChip: FC<IFilterItemChipProps> = ({ | ||||
|     onDelete, | ||||
| }) => { | ||||
|     const hasSelectedOptions = selectedOptions.length > 0; | ||||
|     const maxExplicitOptions = 2; | ||||
|     const explicitOptions = selectedOptions.slice(0, maxExplicitOptions); | ||||
|     const remainingOptions = selectedOptions.length - maxExplicitOptions; | ||||
| 
 | ||||
|     return ( | ||||
|         <StyledChip | ||||
| @ -99,7 +109,10 @@ export const FilterItemChip: FC<IFilterItemChipProps> = ({ | ||||
|                                     onChange={onChangeOperator} | ||||
|                                 /> | ||||
|                                 <StyledOptions> | ||||
|                                     {selectedOptions.join(', ')} | ||||
|                                     {explicitOptions.join(', ')} | ||||
|                                     {remainingOptions > 0 | ||||
|                                         ? ` +${remainingOptions}` | ||||
|                                         : ''} | ||||
|                                 </StyledOptions> | ||||
|                             </> | ||||
|                         )} | ||||
|  | ||||
| @ -15,6 +15,7 @@ const StyledBox = styled(Box)(({ theme }) => ({ | ||||
|     display: 'flex', | ||||
|     padding: theme.spacing(2, 3), | ||||
|     gap: theme.spacing(1), | ||||
|     flexWrap: 'wrap', | ||||
| })); | ||||
| 
 | ||||
| export type FeatureTogglesListFilters = { | ||||
| @ -122,8 +123,8 @@ export const FeatureToggleFilters: VFC<IFeatureToggleFiltersProps> = ({ | ||||
|                 filterKey: 'segment', | ||||
|                 singularOperators: ['INCLUDE', 'DO_NOT_INCLUDE'], | ||||
|                 pluralOperators: [ | ||||
|                     'INCLUDE_ALL_OF', | ||||
|                     'INCLUDE_ANY_OF', | ||||
|                     'INCLUDE_ALL_OF', | ||||
|                     'EXCLUDE_IF_ANY_OF', | ||||
|                     'EXCLUDE_ALL', | ||||
|                 ], | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user