mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-29 05:54:55 +03:00
fix: center toast in main content (#1683)
This commit is contained in:
parent
40903a9070
commit
6d13716e97
@ -201,7 +201,7 @@ export const WorkspaceLayoutInner: React.FC<React.PropsWithChildren> = ({
|
||||
currentPath={router.asPath}
|
||||
paths={isPublicWorkspace ? publicPathGenerator : pathGenerator}
|
||||
/>
|
||||
<StyledWrapper>
|
||||
<StyledWrapper className="main-container">
|
||||
<AffineWorkspaceEffect />
|
||||
{children}
|
||||
<StyledToolWrapper>
|
||||
|
@ -24,9 +24,9 @@ const htmlToElement = <T extends ChildNode>(html: string | TemplateResult) => {
|
||||
return template.content.firstChild as T;
|
||||
};
|
||||
|
||||
const createToastContainer = () => {
|
||||
const createToastContainer = (portalQuery?: string) => {
|
||||
const styles = css`
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
z-index: 9999;
|
||||
top: 16px;
|
||||
left: 16px;
|
||||
@ -39,12 +39,14 @@ const createToastContainer = () => {
|
||||
`;
|
||||
const template = html`<div style="${styles}"></div>`;
|
||||
const element = htmlToElement<HTMLDivElement>(template);
|
||||
document.body.appendChild(element);
|
||||
const portal = portalQuery && document.querySelector(portalQuery);
|
||||
(portal || document.body).appendChild(element);
|
||||
return element;
|
||||
};
|
||||
|
||||
export type ToastOptions = {
|
||||
duration: number;
|
||||
portalQuery?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -55,10 +57,12 @@ export type ToastOptions = {
|
||||
*/
|
||||
export const toast = (
|
||||
message: string,
|
||||
{ duration }: ToastOptions = { duration: 2500 }
|
||||
{ duration, portalQuery = '.main-container' }: ToastOptions = {
|
||||
duration: 2500,
|
||||
}
|
||||
) => {
|
||||
if (!ToastContainer) {
|
||||
ToastContainer = createToastContainer();
|
||||
ToastContainer = createToastContainer(portalQuery);
|
||||
}
|
||||
|
||||
const styles = css`
|
||||
|
Loading…
Reference in New Issue
Block a user