mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-30 00:29:46 +08:00
feat(core): adjust filter area style (#12534)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -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 type { FilterParams } from '@affine/core/modules/collection-rules';
|
||||||
import { WorkspacePropertyService } from '@affine/core/modules/workspace-property';
|
import { WorkspacePropertyService } from '@affine/core/modules/workspace-property';
|
||||||
import { useI18n } from '@affine/i18n';
|
import { useI18n } from '@affine/i18n';
|
||||||
@@ -142,9 +148,12 @@ export const AddFilterMenu = ({
|
|||||||
|
|
||||||
export const AddFilter = ({
|
export const AddFilter = ({
|
||||||
onAdd,
|
onAdd,
|
||||||
|
variant = 'icon-button',
|
||||||
}: {
|
}: {
|
||||||
onAdd: (params: FilterParams) => void;
|
onAdd: (params: FilterParams) => void;
|
||||||
|
variant?: 'icon-button' | 'button';
|
||||||
}) => {
|
}) => {
|
||||||
|
const t = useI18n();
|
||||||
return (
|
return (
|
||||||
<Menu
|
<Menu
|
||||||
items={<AddFilterMenu onAdd={onAdd} />}
|
items={<AddFilterMenu onAdd={onAdd} />}
|
||||||
@@ -152,9 +161,15 @@ export const AddFilter = ({
|
|||||||
className: styles.addFilterMenuContent,
|
className: styles.addFilterMenuContent,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconButton size="16">
|
{variant === 'icon-button' ? (
|
||||||
<PlusIcon />
|
<IconButton size="16">
|
||||||
</IconButton>
|
<PlusIcon />
|
||||||
|
</IconButton>
|
||||||
|
) : (
|
||||||
|
<Button prefix={<PlusIcon />} className={styles.addFilterButton}>
|
||||||
|
{t['com.affine.filter.add-filter']()}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export const Condition = ({
|
|||||||
styles.filterValueStyle,
|
styles.filterValueStyle,
|
||||||
styles.ellipsisTextStyle
|
styles.ellipsisTextStyle
|
||||||
)}
|
)}
|
||||||
data-testid="filter-method"
|
data-testid="filter-value"
|
||||||
>
|
>
|
||||||
<Value
|
<Value
|
||||||
filter={filter}
|
filter={filter}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const filterTypeStyle = style({
|
|||||||
fontSize: cssVar('fontSm'),
|
fontSize: cssVar('fontSm'),
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
padding: '0px 4px',
|
padding: '0px 4px 0 0',
|
||||||
lineHeight: '22px',
|
lineHeight: '22px',
|
||||||
color: cssVar('textPrimaryColor'),
|
color: cssVar('textPrimaryColor'),
|
||||||
});
|
});
|
||||||
@@ -25,6 +25,9 @@ export const filterValueStyle = style({
|
|||||||
background: cssVar('hoverColor'),
|
background: cssVar('hoverColor'),
|
||||||
borderRadius: '4px',
|
borderRadius: '4px',
|
||||||
},
|
},
|
||||||
|
'&:empty': {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,14 @@ export const Filters = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<AddFilter onAdd={handleAdd} />
|
<AddFilter
|
||||||
|
variant={
|
||||||
|
filters.length === 0 && draftFilter === null
|
||||||
|
? 'button'
|
||||||
|
: 'icon-button'
|
||||||
|
}
|
||||||
|
onAdd={handleAdd}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,3 +68,7 @@ export const filterTypeItemName = style({
|
|||||||
export const addFilterMenuContent = style({
|
export const addFilterMenuContent = style({
|
||||||
width: '230px',
|
width: '230px',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const addFilterButton = style({
|
||||||
|
height: '32px',
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||||
import { style } from '@vanilla-extract/css';
|
import { style } from '@vanilla-extract/css';
|
||||||
export const scrollContainer = style({
|
export const scrollContainer = style({
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -55,11 +56,8 @@ export const pinnedCollection = style({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const filterArea = style({
|
export const filterArea = style({
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'row',
|
|
||||||
gap: 8,
|
|
||||||
padding: '0 24px',
|
padding: '0 24px',
|
||||||
paddingTop: '24px',
|
paddingTop: '12px',
|
||||||
'@container': {
|
'@container': {
|
||||||
'docs-body (width <= 500px)': {
|
'docs-body (width <= 500px)': {
|
||||||
padding: '0 20px',
|
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({
|
export const filters = style({
|
||||||
flex: 1,
|
flex: 1,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -302,27 +302,29 @@ export const AllPage = () => {
|
|||||||
hiddenAdd={tempFilters !== null}
|
hiddenAdd={tempFilters !== null}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{tempFilters !== null && (
|
<div className={styles.filterArea}>
|
||||||
<div className={styles.filterArea}>
|
{tempFilters !== null && (
|
||||||
<Filters
|
<div className={styles.filterInnerArea}>
|
||||||
// When the selected collection changes, the filters internal state should be reset
|
<Filters
|
||||||
key={selectedCollectionId ?? 'all'}
|
// When the selected collection changes, the filters internal state should be reset
|
||||||
className={styles.filters}
|
key={selectedCollectionId ?? 'all'}
|
||||||
filters={tempFilters}
|
className={styles.filters}
|
||||||
onChange={handleFilterChange}
|
filters={tempFilters}
|
||||||
defaultDraftFilter={tempFiltersInitial}
|
onChange={handleFilterChange}
|
||||||
/>
|
defaultDraftFilter={tempFiltersInitial}
|
||||||
<Button
|
/>
|
||||||
variant="plain"
|
<Button
|
||||||
onClick={() => {
|
variant="plain"
|
||||||
setTempFilters(null);
|
onClick={() => {
|
||||||
}}
|
setTempFilters(null);
|
||||||
>
|
}}
|
||||||
{t['Cancel']()}
|
>
|
||||||
</Button>
|
{t['Cancel']()}
|
||||||
<Button onClick={handleSaveFilters}>{t['save']()}</Button>
|
</Button>
|
||||||
</div>
|
<Button onClick={handleSaveFilters}>{t['save']()}</Button>
|
||||||
)}
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div className={styles.scrollArea}>
|
<div className={styles.scrollArea}>
|
||||||
<DocsExplorer />
|
<DocsExplorer />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,26 +1,26 @@
|
|||||||
{
|
{
|
||||||
"ar": 94,
|
"ar": 93,
|
||||||
"ca": 4,
|
"ca": 4,
|
||||||
"da": 4,
|
"da": 4,
|
||||||
"de": 94,
|
"de": 93,
|
||||||
"el-GR": 94,
|
"el-GR": 93,
|
||||||
"en": 100,
|
"en": 100,
|
||||||
"es-AR": 94,
|
"es-AR": 93,
|
||||||
"es-CL": 95,
|
"es-CL": 94,
|
||||||
"es": 94,
|
"es": 93,
|
||||||
"fa": 94,
|
"fa": 93,
|
||||||
"fr": 94,
|
"fr": 93,
|
||||||
"hi": 2,
|
"hi": 2,
|
||||||
"it-IT": 94,
|
"it-IT": 93,
|
||||||
"it": 1,
|
"it": 1,
|
||||||
"ja": 94,
|
"ja": 93,
|
||||||
"ko": 54,
|
"ko": 54,
|
||||||
"pl": 94,
|
"pl": 93,
|
||||||
"pt-BR": 94,
|
"pt-BR": 93,
|
||||||
"ru": 94,
|
"ru": 93,
|
||||||
"sv-SE": 94,
|
"sv-SE": 93,
|
||||||
"uk": 94,
|
"uk": 93,
|
||||||
"ur": 2,
|
"ur": 2,
|
||||||
"zh-Hans": 94,
|
"zh-Hans": 93,
|
||||||
"zh-Hant": 94
|
"zh-Hant": 93
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2073,6 +2073,10 @@ export function useAFFiNEI18N(): {
|
|||||||
* `Filter`
|
* `Filter`
|
||||||
*/
|
*/
|
||||||
["com.affine.filter"](): string;
|
["com.affine.filter"](): string;
|
||||||
|
/**
|
||||||
|
* `Add Filter Rule`
|
||||||
|
*/
|
||||||
|
["com.affine.filter.add-filter"](): string;
|
||||||
/**
|
/**
|
||||||
* `after`
|
* `after`
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -517,6 +517,7 @@
|
|||||||
"com.affine.favoritePageOperation.add": "Add to favourites",
|
"com.affine.favoritePageOperation.add": "Add to favourites",
|
||||||
"com.affine.favoritePageOperation.remove": "Remove from favourites",
|
"com.affine.favoritePageOperation.remove": "Remove from favourites",
|
||||||
"com.affine.filter": "Filter",
|
"com.affine.filter": "Filter",
|
||||||
|
"com.affine.filter.add-filter": "Add Filter Rule",
|
||||||
"com.affine.filter.after": "after",
|
"com.affine.filter.after": "after",
|
||||||
"com.affine.filter.before": "before",
|
"com.affine.filter.before": "before",
|
||||||
"com.affine.filter.contains all": "contains all",
|
"com.affine.filter.contains all": "contains all",
|
||||||
|
|||||||
Reference in New Issue
Block a user