mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-13 04:42:56 +08:00
chore: update filter style (#2625)
This commit is contained in:
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { Menu, MenuItem } from '../../../ui/menu';
|
import { Menu, MenuItem } from '../../../ui/menu';
|
||||||
|
import * as styles from './index.css';
|
||||||
import { literalMatcher } from './literal-matcher';
|
import { literalMatcher } from './literal-matcher';
|
||||||
import type { TFunction, TType } from './logical/typesystem';
|
import type { TFunction, TType } from './logical/typesystem';
|
||||||
import type { Filter, Literal } from './vars';
|
import type { Filter, Literal } from './vars';
|
||||||
@@ -33,16 +34,15 @@ export const Condition = ({
|
|||||||
trigger="click"
|
trigger="click"
|
||||||
content={<VariableSelect selected={[]} onSelect={onChange} />}
|
content={<VariableSelect selected={[]} onSelect={onChange} />}
|
||||||
>
|
>
|
||||||
<div data-testid="variable-name">{ast.left.name}</div>
|
<div data-testid="variable-name" className={styles.filterTypeStyle}>
|
||||||
|
{ast.left.name}
|
||||||
|
</div>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu
|
<Menu
|
||||||
trigger="click"
|
trigger="click"
|
||||||
content={<FunctionSelect value={value} onChange={onChange} />}
|
content={<FunctionSelect value={value} onChange={onChange} />}
|
||||||
>
|
>
|
||||||
<div
|
<div className={styles.switchStyle} data-testid="filter-name">
|
||||||
style={{ marginLeft: 4, color: 'gray' }}
|
|
||||||
data-testid="filter-name"
|
|
||||||
>
|
|
||||||
{ast.funcName}
|
{ast.funcName}
|
||||||
</div>
|
</div>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { CloseIcon, PlusIcon } from '@blocksuite/icons';
|
||||||
|
|
||||||
import { Menu } from '../../..';
|
import { Menu } from '../../..';
|
||||||
import { Condition } from './condition';
|
import { Condition } from './condition';
|
||||||
import * as styles from './index.css';
|
import * as styles from './index.css';
|
||||||
@@ -24,12 +26,12 @@ export const FilterList = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
style={{ marginLeft: 8, cursor: 'pointer' }}
|
className={styles.filterItemCloseStyle}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onChange(value.filter((_, index) => i !== index));
|
onChange(value.filter((_, index) => i !== index));
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
x
|
<CloseIcon />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -47,7 +49,7 @@ export const FilterList = ({
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
+
|
<PlusIcon />
|
||||||
</div>
|
</div>
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -27,7 +27,26 @@ export const filterItemStyle = style({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
border: '1px solid var(--affine-border-color)',
|
border: '1px solid var(--affine-border-color)',
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
padding: '2px 6px',
|
|
||||||
margin: 4,
|
|
||||||
background: 'var(--affine-white)',
|
background: 'var(--affine-white)',
|
||||||
|
margin: '4px',
|
||||||
|
padding: '4px 8px',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const filterItemCloseStyle = style({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
cursor: 'pointer',
|
||||||
|
marginLeft: '4px',
|
||||||
|
});
|
||||||
|
export const inputStyle = style({
|
||||||
|
fontSize: 'var(--affine-font-xs)',
|
||||||
|
});
|
||||||
|
export const switchStyle = style({
|
||||||
|
fontSize: 'var(--affine-font-xs)',
|
||||||
|
color: 'var(--affine-text-secondary-color)',
|
||||||
|
marginLeft: '4px',
|
||||||
|
});
|
||||||
|
export const filterTypeStyle = style({
|
||||||
|
fontSize: 'var(--affine-font-sm)',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
|
import { inputStyle } from './index.css';
|
||||||
import { tBoolean, tDate } from './logical/custom-type';
|
import { tBoolean, tDate } from './logical/custom-type';
|
||||||
import { Matcher } from './logical/matcher';
|
import { Matcher } from './logical/matcher';
|
||||||
import type { TType } from './logical/typesystem';
|
import type { TType } from './logical/typesystem';
|
||||||
@@ -20,6 +21,7 @@ export const literalMatcher = new Matcher<{
|
|||||||
literalMatcher.register(tBoolean.create(), {
|
literalMatcher.register(tBoolean.create(), {
|
||||||
render: ({ value, onChange }) => (
|
render: ({ value, onChange }) => (
|
||||||
<div
|
<div
|
||||||
|
className={inputStyle}
|
||||||
style={{ cursor: 'pointer' }}
|
style={{ cursor: 'pointer' }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onChange({ type: 'literal', value: !value.value });
|
onChange({ type: 'literal', value: !value.value });
|
||||||
@@ -32,6 +34,7 @@ literalMatcher.register(tBoolean.create(), {
|
|||||||
literalMatcher.register(tDate.create(), {
|
literalMatcher.register(tDate.create(), {
|
||||||
render: ({ value, onChange }) => (
|
render: ({ value, onChange }) => (
|
||||||
<input
|
<input
|
||||||
|
className={inputStyle}
|
||||||
value={dayjs(value.value as number).format('YYYY-MM-DD')}
|
value={dayjs(value.value as number).format('YYYY-MM-DD')}
|
||||||
type="date"
|
type="date"
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { SaveIcon } from '@blocksuite/icons';
|
||||||
import { uuidv4 } from '@blocksuite/store';
|
import { uuidv4 } from '@blocksuite/store';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
@@ -5,6 +6,7 @@ import { Button, Input, Modal, ModalWrapper } from '../../..';
|
|||||||
import { FilterList } from '../filter';
|
import { FilterList } from '../filter';
|
||||||
import type { Filter } from '../filter/vars';
|
import type { Filter } from '../filter/vars';
|
||||||
import type { View } from '../use-all-page-setting';
|
import type { View } from '../use-all-page-setting';
|
||||||
|
import * as styles from './view-list.css';
|
||||||
|
|
||||||
type CreateViewProps = {
|
type CreateViewProps = {
|
||||||
init: Filter[];
|
init: Filter[];
|
||||||
@@ -68,7 +70,18 @@ export const SaveViewButton = ({ init, onConfirm }: CreateViewProps) => {
|
|||||||
const [show, changeShow] = useState(false);
|
const [show, changeShow] = useState(false);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button onClick={() => changeShow(true)}>Save view</Button>
|
<Button
|
||||||
|
className={styles.saveButton}
|
||||||
|
onClick={() => changeShow(true)}
|
||||||
|
size="middle"
|
||||||
|
>
|
||||||
|
<div className={styles.saveButtonContainer}>
|
||||||
|
<div className={styles.saveIcon}>
|
||||||
|
<SaveIcon />
|
||||||
|
</div>
|
||||||
|
<div className={styles.saveText}>Save View</div>
|
||||||
|
</div>
|
||||||
|
</Button>
|
||||||
<Modal open={show} onClose={() => changeShow(false)}>
|
<Modal open={show} onClose={() => changeShow(false)}>
|
||||||
<ModalWrapper width={560} style={{ padding: '40px' }}>
|
<ModalWrapper width={560} style={{ padding: '40px' }}>
|
||||||
<CreateView
|
<CreateView
|
||||||
|
|||||||
@@ -29,3 +29,33 @@ export const viewDivider = style({
|
|||||||
margin: '0 1px',
|
margin: '0 1px',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
export const saveButton = style({
|
||||||
|
marginTop: '4px',
|
||||||
|
borderRadius: '8px',
|
||||||
|
padding: '8px 0',
|
||||||
|
':hover': {
|
||||||
|
background: 'var(--affine-hover-color)',
|
||||||
|
color: 'var(--affine-text-primary-color)',
|
||||||
|
border: '1px solid var(--affine-border-color)',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
export const saveButtonContainer = style({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
cursor: 'pointer',
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
padding: '8px',
|
||||||
|
});
|
||||||
|
export const saveIcon = style({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
fontSize: 'var(--affine-font-sm)',
|
||||||
|
marginRight: '8px',
|
||||||
|
});
|
||||||
|
export const saveText = style({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
fontSize: 'var(--affine-font-sm)',
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user