mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
@@ -184,6 +184,7 @@ function resolvePeekInfoFromPeekTarget(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type PeekViewAnimation = 'fade' | 'zoom' | 'none';
|
export type PeekViewAnimation = 'fade' | 'zoom' | 'none';
|
||||||
|
export type PeekViewMode = 'full' | 'fit' | 'max';
|
||||||
|
|
||||||
export class PeekViewEntity extends Entity {
|
export class PeekViewEntity extends Entity {
|
||||||
private readonly _active$ = new LiveData<ActivePeekView | null>(null);
|
private readonly _active$ = new LiveData<ActivePeekView | null>(null);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export const root = style({
|
|||||||
|
|
||||||
export const editor = style({
|
export const editor = style({
|
||||||
vars: {
|
vars: {
|
||||||
'--affine-editor-side-padding': '160px',
|
'--affine-editor-side-padding': '96px',
|
||||||
},
|
},
|
||||||
minHeight: '100%',
|
minHeight: '100%',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,17 +24,16 @@ export const modalContentWrapper = style({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const modalContentContainer = style({
|
export const modalContentContainer = style({
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
borderRadius: 12,
|
borderRadius: 12,
|
||||||
'@media': {
|
'@media': {
|
||||||
|
// mobile:
|
||||||
'screen and (width <= 640px)': {
|
'screen and (width <= 640px)': {
|
||||||
selectors: {
|
selectors: {
|
||||||
'[data-padding="true"] &': {
|
[`${modalContentWrapper}:is([data-mode="max"], [data-mode="fit"]) &`]: {
|
||||||
height: '60%',
|
height: '60%',
|
||||||
width: 'calc(100% - 32px)',
|
width: 'calc(100% - 32px)',
|
||||||
paddingRight: 0,
|
paddingRight: 0,
|
||||||
@@ -45,11 +44,21 @@ export const modalContentContainer = style({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
selectors: {
|
selectors: {
|
||||||
'[data-padding="true"] &': {
|
[`${modalContentWrapper}[data-mode="max"] &`]: {
|
||||||
width: 'calc(100% - 64px)',
|
width: 'calc(100% - 64px)',
|
||||||
height: 'calc(100% - 64px)',
|
height: 'calc(100% - 64px)',
|
||||||
paddingRight: 48,
|
paddingRight: 48,
|
||||||
},
|
},
|
||||||
|
[`${modalContentWrapper}[data-mode="full"] &`]: {
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
},
|
||||||
|
[`${modalContentWrapper}[data-mode="fit"] &`]: {
|
||||||
|
width: '90%',
|
||||||
|
height: '90%',
|
||||||
|
paddingRight: 48,
|
||||||
|
maxWidth: 1248,
|
||||||
|
},
|
||||||
'&[data-anime-state="animating"]': {
|
'&[data-anime-state="animating"]': {
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
} from 'react';
|
} from 'react';
|
||||||
|
|
||||||
import { EditorSettingService } from '../../editor-settting';
|
import { EditorSettingService } from '../../editor-settting';
|
||||||
import type { PeekViewAnimation } from '../entities/peek-view';
|
import type { PeekViewAnimation, PeekViewMode } from '../entities/peek-view';
|
||||||
import * as styles from './modal-container.css';
|
import * as styles from './modal-container.css';
|
||||||
|
|
||||||
const contentOptions: Dialog.DialogContentProps = {
|
const contentOptions: Dialog.DialogContentProps = {
|
||||||
@@ -55,7 +55,7 @@ export type PeekViewModalContainerProps = PropsWithChildren<{
|
|||||||
controls?: React.ReactNode;
|
controls?: React.ReactNode;
|
||||||
onAnimationStart?: () => void;
|
onAnimationStart?: () => void;
|
||||||
onAnimateEnd?: () => void;
|
onAnimateEnd?: () => void;
|
||||||
padding?: boolean;
|
mode?: PeekViewMode;
|
||||||
animation?: PeekViewAnimation;
|
animation?: PeekViewAnimation;
|
||||||
testId?: string;
|
testId?: string;
|
||||||
/** Whether to apply shadow & bg */
|
/** Whether to apply shadow & bg */
|
||||||
@@ -77,7 +77,7 @@ export const PeekViewModalContainer = forwardRef<
|
|||||||
onAnimationStart,
|
onAnimationStart,
|
||||||
onAnimateEnd,
|
onAnimateEnd,
|
||||||
animation = 'zoom',
|
animation = 'zoom',
|
||||||
padding = true,
|
mode = 'fit',
|
||||||
dialogFrame = true,
|
dialogFrame = true,
|
||||||
},
|
},
|
||||||
ref
|
ref
|
||||||
@@ -318,9 +318,9 @@ export const PeekViewModalContainer = forwardRef<
|
|||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
data-padding={padding}
|
data-mode={mode}
|
||||||
data-peek-view-wrapper
|
data-peek-view-wrapper
|
||||||
className={clsx(styles.modalContentWrapper)}
|
className={styles.modalContentWrapper}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
data-anime-state={animeState}
|
data-anime-state={animeState}
|
||||||
|
|||||||
@@ -66,6 +66,13 @@ const renderControls = ({ info }: ActivePeekView) => {
|
|||||||
return <DefaultPeekViewControls />;
|
return <DefaultPeekViewControls />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getMode = (info: ActivePeekView['info']) => {
|
||||||
|
if (info.type === 'image') {
|
||||||
|
return 'full';
|
||||||
|
}
|
||||||
|
return 'fit';
|
||||||
|
};
|
||||||
|
|
||||||
const getRendererProps = (
|
const getRendererProps = (
|
||||||
activePeekView?: ActivePeekView
|
activePeekView?: ActivePeekView
|
||||||
): Partial<PeekViewModalContainerProps> | undefined => {
|
): Partial<PeekViewModalContainerProps> | undefined => {
|
||||||
@@ -82,7 +89,7 @@ const getRendererProps = (
|
|||||||
activePeekView?.target instanceof HTMLElement
|
activePeekView?.target instanceof HTMLElement
|
||||||
? activePeekView.target
|
? activePeekView.target
|
||||||
: undefined,
|
: undefined,
|
||||||
padding: activePeekView.info.type !== 'image',
|
mode: getMode(activePeekView.info),
|
||||||
dialogFrame: activePeekView.info.type !== 'image',
|
dialogFrame: activePeekView.info.type !== 'image',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user