From 18da2fe4e68dec729e0529dadd93a9ca6aec4c9a Mon Sep 17 00:00:00 2001 From: EYHN Date: Tue, 27 May 2025 07:46:27 +0000 Subject: [PATCH] feat(core): adjust filter area style (#12534) ## Summary by CodeRabbit - **New Features** - Added support for displaying the "Add Filter" action as either an icon button or a labeled button, depending on the filter state. - Introduced a localized label for the "Add Filter" button. - **Style** - Improved filter area layout and styling for better visual consistency. - Adjusted padding and added styles to hide empty filter values. - **Bug Fixes** - Updated test identifiers for filter value elements to improve test reliability. - **Documentation** - Added a new English localization string for the "Add Filter" button. - **Chores** - Updated translation completeness percentages for various locales. --- .../core/src/components/filter/add-filter.tsx | 23 ++++++++-- .../filter/conditions/condition.tsx | 2 +- .../filter/conditions/styles.css.ts | 5 ++- .../core/src/components/filter/filters.tsx | 9 +++- .../core/src/components/filter/styles.css.ts | 4 ++ .../pages/workspace/all-page/all-page.css.ts | 15 +++++-- .../pages/workspace/all-page/all-page.tsx | 44 ++++++++++--------- .../i18n/src/i18n-completenesses.json | 34 +++++++------- packages/frontend/i18n/src/i18n.gen.ts | 4 ++ packages/frontend/i18n/src/resources/en.json | 1 + 10 files changed, 92 insertions(+), 49 deletions(-) diff --git a/packages/frontend/core/src/components/filter/add-filter.tsx b/packages/frontend/core/src/components/filter/add-filter.tsx index b431d2969d..c61866e457 100644 --- a/packages/frontend/core/src/components/filter/add-filter.tsx +++ b/packages/frontend/core/src/components/filter/add-filter.tsx @@ -1,4 +1,10 @@ -import { IconButton, Menu, MenuItem, MenuSeparator } from '@affine/component'; +import { + Button, + IconButton, + Menu, + MenuItem, + MenuSeparator, +} from '@affine/component'; import type { FilterParams } from '@affine/core/modules/collection-rules'; import { WorkspacePropertyService } from '@affine/core/modules/workspace-property'; import { useI18n } from '@affine/i18n'; @@ -142,9 +148,12 @@ export const AddFilterMenu = ({ export const AddFilter = ({ onAdd, + variant = 'icon-button', }: { onAdd: (params: FilterParams) => void; + variant?: 'icon-button' | 'button'; }) => { + const t = useI18n(); return ( } @@ -152,9 +161,15 @@ export const AddFilter = ({ className: styles.addFilterMenuContent, }} > - - - + {variant === 'icon-button' ? ( + + + + ) : ( + + )} ); }; diff --git a/packages/frontend/core/src/components/filter/conditions/condition.tsx b/packages/frontend/core/src/components/filter/conditions/condition.tsx index a9dab73a4d..98fd367829 100644 --- a/packages/frontend/core/src/components/filter/conditions/condition.tsx +++ b/packages/frontend/core/src/components/filter/conditions/condition.tsx @@ -87,7 +87,7 @@ export const Condition = ({ styles.filterValueStyle, styles.ellipsisTextStyle )} - data-testid="filter-method" + data-testid="filter-value" > )} - + ); }; diff --git a/packages/frontend/core/src/components/filter/styles.css.ts b/packages/frontend/core/src/components/filter/styles.css.ts index a5e678a862..73392f498d 100644 --- a/packages/frontend/core/src/components/filter/styles.css.ts +++ b/packages/frontend/core/src/components/filter/styles.css.ts @@ -68,3 +68,7 @@ export const filterTypeItemName = style({ export const addFilterMenuContent = style({ width: '230px', }); + +export const addFilterButton = style({ + height: '32px', +}); diff --git a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.css.ts b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.css.ts index 5e58607bae..7d445feac5 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.css.ts +++ b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.css.ts @@ -1,3 +1,4 @@ +import { cssVarV2 } from '@toeverything/theme/v2'; import { style } from '@vanilla-extract/css'; export const scrollContainer = style({ flex: 1, @@ -55,11 +56,8 @@ export const pinnedCollection = style({ }); export const filterArea = style({ - display: 'flex', - flexDirection: 'row', - gap: 8, padding: '0 24px', - paddingTop: '24px', + paddingTop: '12px', '@container': { 'docs-body (width <= 500px)': { padding: '0 20px', @@ -70,6 +68,15 @@ export const filterArea = style({ }, }); +export const filterInnerArea = style({ + display: 'flex', + flexDirection: 'row', + gap: 8, + padding: '8px', + background: cssVarV2('layer/background/secondary'), + borderRadius: '12px', +}); + export const filters = style({ flex: 1, }); diff --git a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.tsx b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.tsx index 39eeb10eb8..3f198a4e30 100644 --- a/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.tsx +++ b/packages/frontend/core/src/desktop/pages/workspace/all-page/all-page.tsx @@ -302,27 +302,29 @@ export const AllPage = () => { hiddenAdd={tempFilters !== null} /> - {tempFilters !== null && ( -
- - - -
- )} +
+ {tempFilters !== null && ( +
+ + + +
+ )} +
diff --git a/packages/frontend/i18n/src/i18n-completenesses.json b/packages/frontend/i18n/src/i18n-completenesses.json index 5326f926c8..82fc0df8b9 100644 --- a/packages/frontend/i18n/src/i18n-completenesses.json +++ b/packages/frontend/i18n/src/i18n-completenesses.json @@ -1,26 +1,26 @@ { - "ar": 94, + "ar": 93, "ca": 4, "da": 4, - "de": 94, - "el-GR": 94, + "de": 93, + "el-GR": 93, "en": 100, - "es-AR": 94, - "es-CL": 95, - "es": 94, - "fa": 94, - "fr": 94, + "es-AR": 93, + "es-CL": 94, + "es": 93, + "fa": 93, + "fr": 93, "hi": 2, - "it-IT": 94, + "it-IT": 93, "it": 1, - "ja": 94, + "ja": 93, "ko": 54, - "pl": 94, - "pt-BR": 94, - "ru": 94, - "sv-SE": 94, - "uk": 94, + "pl": 93, + "pt-BR": 93, + "ru": 93, + "sv-SE": 93, + "uk": 93, "ur": 2, - "zh-Hans": 94, - "zh-Hant": 94 + "zh-Hans": 93, + "zh-Hant": 93 } diff --git a/packages/frontend/i18n/src/i18n.gen.ts b/packages/frontend/i18n/src/i18n.gen.ts index bd0c665a0c..67fe2fb231 100644 --- a/packages/frontend/i18n/src/i18n.gen.ts +++ b/packages/frontend/i18n/src/i18n.gen.ts @@ -2073,6 +2073,10 @@ export function useAFFiNEI18N(): { * `Filter` */ ["com.affine.filter"](): string; + /** + * `Add Filter Rule` + */ + ["com.affine.filter.add-filter"](): string; /** * `after` */ diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.json index cd5605d7cd..bda0dfc528 100644 --- a/packages/frontend/i18n/src/resources/en.json +++ b/packages/frontend/i18n/src/resources/en.json @@ -517,6 +517,7 @@ "com.affine.favoritePageOperation.add": "Add to favourites", "com.affine.favoritePageOperation.remove": "Remove from favourites", "com.affine.filter": "Filter", + "com.affine.filter.add-filter": "Add Filter Rule", "com.affine.filter.after": "after", "com.affine.filter.before": "before", "com.affine.filter.contains all": "contains all",