feat: modernize search filters & intelligent label shortening

- Introduced shortenCategory utility to strip redundant terms from labels
- Refactored BottleGrid filters into a compact, collapsible layout
- Added filter count indicator and improved chip styling
- Fully localized new filter UI elements
This commit is contained in:
2025-12-18 16:46:39 +01:00
parent 9464d56055
commit 7f600698e4
6 changed files with 174 additions and 88 deletions

33
src/lib/format.ts Normal file
View File

@@ -0,0 +1,33 @@
/**
* Shortens a whisky category label by removing redundant common terms.
* Example: "Single Malt Scotch Whisky" -> "Single Malt"
*/
export const shortenCategory = (label: string): string => {
if (!label) return '';
const replacements: [string, string][] = [
['Single Malt Scotch Whisky', 'Single Malt'],
['Blended Malt Scotch Whisky', 'Blended Malt'],
['Single Grain Scotch Whisky', 'Single Grain'],
['Blended Scotch Whisky', 'Blended'],
['Kentucky Straight Bourbon Whiskey', 'Bourbon'],
['Straight Bourbon Whiskey', 'Bourbon'],
['Tennessee Whiskey', 'Tennessee'],
['Japanese Whisky', 'Japanese'],
['Irish Whiskey', 'Irish'],
['Canadian Whisky', 'Canadian'],
['American Whiskey', 'American'],
['Rye Whiskey', 'Rye'],
];
for (const [full, short] of replacements) {
if (label === full) return short;
}
return label
.replace(/ Scotch Whisky/gi, '')
.replace(/ Scotch/gi, '')
.replace(/ Whisky/gi, '')
.replace(/ Whiskey/gi, '')
.trim();
};