mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +08:00
fix(editor): improve menu content UX on toolbar (#11491)
* Added scrollbar style  * Used `padding` instead of `offset`
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
import { panelBaseStyle } from '@blocksuite/affine-shared/styles';
|
import {
|
||||||
|
panelBaseStyle,
|
||||||
|
scrollbarStyle,
|
||||||
|
} from '@blocksuite/affine-shared/styles';
|
||||||
import {
|
import {
|
||||||
type ButtonPopperOptions,
|
type ButtonPopperOptions,
|
||||||
createButtonPopper,
|
createButtonPopper,
|
||||||
@@ -44,8 +47,7 @@ export class EditorMenuButton extends WithDisposable(LitElement) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
mainAxis: 12,
|
mainAxis: 0,
|
||||||
ignoreShift: true,
|
|
||||||
offsetHeight: 6 * 4,
|
offsetHeight: 6 * 4,
|
||||||
...this.popperOptions,
|
...this.popperOptions,
|
||||||
});
|
});
|
||||||
@@ -111,15 +113,21 @@ export class EditorMenuButton extends WithDisposable(LitElement) {
|
|||||||
export class EditorMenuContent extends LitElement {
|
export class EditorMenuContent extends LitElement {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
|
padding: 12px 0;
|
||||||
display: none;
|
display: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
overscroll-behavior: contain;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
${panelBaseStyle(':host([data-show])')}
|
|
||||||
:host([data-show]) {
|
:host([data-show]) {
|
||||||
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
${panelBaseStyle('.content-wrapper')}
|
||||||
|
${scrollbarStyle('.content-wrapper')}
|
||||||
|
.content-wrapper {
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
overflow-y: auto;
|
||||||
padding: var(--content-padding, 0 6px);
|
padding: var(--content-padding, 0 6px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +160,7 @@ export class EditorMenuContent extends LitElement {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
override render() {
|
override render() {
|
||||||
return html`<slot></slot>`;
|
return html`<div class="content-wrapper"><slot></slot></div>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ export type ButtonPopperOptions = {
|
|||||||
crossAxis?: number;
|
crossAxis?: number;
|
||||||
allowedPlacements?: Placement[];
|
allowedPlacements?: Placement[];
|
||||||
rootBoundary?: Rect | (() => Rect | undefined);
|
rootBoundary?: Rect | (() => Rect | undefined);
|
||||||
ignoreShift?: boolean;
|
|
||||||
offsetHeight?: number;
|
offsetHeight?: number;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@@ -68,7 +67,6 @@ export function createButtonPopper(options: ButtonPopperOptions) {
|
|||||||
crossAxis,
|
crossAxis,
|
||||||
allowedPlacements = ['top', 'bottom'],
|
allowedPlacements = ['top', 'bottom'],
|
||||||
rootBoundary,
|
rootBoundary,
|
||||||
ignoreShift,
|
|
||||||
offsetHeight,
|
offsetHeight,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
@@ -102,11 +100,7 @@ export function createButtonPopper(options: ButtonPopperOptions) {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.then(({ x, y, middlewareData: data }) => {
|
.then(({ x, y }) => {
|
||||||
if (!ignoreShift) {
|
|
||||||
x += data.shift?.x ?? 0;
|
|
||||||
y += data.shift?.y ?? 0;
|
|
||||||
}
|
|
||||||
Object.assign(popperElement.style, {
|
Object.assign(popperElement.style, {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user