File tree Expand file tree Collapse file tree 5 files changed +28
-11
lines changed
packages/frontend/core/src/modules/peek-view Expand file tree Collapse file tree 5 files changed +28
-11
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,7 @@ function resolvePeekInfoFromPeekTarget(
184184}
185185
186186export type PeekViewAnimation = 'fade' | 'zoom' | 'none' ;
187+ export type PeekViewMode = 'full' | 'fit' | 'max' ;
187188
188189export class PeekViewEntity extends Entity {
189190 private readonly _active$ = new LiveData < ActivePeekView | null > ( null ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export const root = style({
77
88export const editor = style ( {
99 vars : {
10- '--affine-editor-side-padding' : '160px ' ,
10+ '--affine-editor-side-padding' : '96px ' ,
1111 } ,
1212 minHeight : '100%' ,
1313} ) ;
Original file line number Diff line number Diff line change @@ -24,17 +24,16 @@ export const modalContentWrapper = style({
2424} ) ;
2525
2626export const modalContentContainer = style ( {
27- width : '100%' ,
28- height : '100%' ,
2927 position : 'relative' ,
3028 display : 'flex' ,
3129 alignItems : 'center' ,
3230 justifyContent : 'center' ,
3331 borderRadius : 12 ,
3432 '@media' : {
33+ // mobile:
3534 'screen and (width <= 640px)' : {
3635 selectors : {
37- '[ data-padding="true"] &' : {
36+ [ ` ${ modalContentWrapper } :is([ data-mode="max"], [data-mode="fit"]) &` ] : {
3837 height : '60%' ,
3938 width : 'calc(100% - 32px)' ,
4039 paddingRight : 0 ,
@@ -45,11 +44,21 @@ export const modalContentContainer = style({
4544 } ,
4645 } ,
4746 selectors : {
48- '[ data-padding="true "] &' : {
47+ [ ` ${ modalContentWrapper } [ data-mode="max "] &` ] : {
4948 width : 'calc(100% - 64px)' ,
5049 height : 'calc(100% - 64px)' ,
5150 paddingRight : 48 ,
5251 } ,
52+ [ `${ modalContentWrapper } [data-mode="full"] &` ] : {
53+ width : '100%' ,
54+ height : '100%' ,
55+ } ,
56+ [ `${ modalContentWrapper } [data-mode="fit"] &` ] : {
57+ width : '90%' ,
58+ height : '90%' ,
59+ paddingRight : 48 ,
60+ maxWidth : 1248 ,
61+ } ,
5362 '&[data-anime-state="animating"]' : {
5463 opacity : 0 ,
5564 } ,
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import {
1414} from 'react' ;
1515
1616import { EditorSettingService } from '../../editor-settting' ;
17- import type { PeekViewAnimation } from '../entities/peek-view' ;
17+ import type { PeekViewAnimation , PeekViewMode } from '../entities/peek-view' ;
1818import * as styles from './modal-container.css' ;
1919
2020const contentOptions : Dialog . DialogContentProps = {
@@ -55,7 +55,7 @@ export type PeekViewModalContainerProps = PropsWithChildren<{
5555 controls ?: React . ReactNode ;
5656 onAnimationStart ?: ( ) => void ;
5757 onAnimateEnd ?: ( ) => void ;
58- padding ?: boolean ;
58+ mode ?: PeekViewMode ;
5959 animation ?: PeekViewAnimation ;
6060 testId ?: string ;
6161 /** Whether to apply shadow & bg */
@@ -77,7 +77,7 @@ export const PeekViewModalContainer = forwardRef<
7777 onAnimationStart,
7878 onAnimateEnd,
7979 animation = 'zoom' ,
80- padding = true ,
80+ mode = 'fit' ,
8181 dialogFrame = true ,
8282 } ,
8383 ref
@@ -318,9 +318,9 @@ export const PeekViewModalContainer = forwardRef<
318318 />
319319 < div
320320 ref = { ref }
321- data-padding = { padding }
321+ data-mode = { mode }
322322 data-peek-view-wrapper
323- className = { clsx ( styles . modalContentWrapper ) }
323+ className = { styles . modalContentWrapper }
324324 >
325325 < div
326326 data-anime-state = { animeState }
Original file line number Diff line number Diff line change @@ -66,6 +66,13 @@ const renderControls = ({ info }: ActivePeekView) => {
6666 return < DefaultPeekViewControls /> ;
6767} ;
6868
69+ const getMode = ( info : ActivePeekView [ 'info' ] ) => {
70+ if ( info . type === 'image' ) {
71+ return 'full' ;
72+ }
73+ return 'fit' ;
74+ } ;
75+
6976const getRendererProps = (
7077 activePeekView ?: ActivePeekView
7178) : Partial < PeekViewModalContainerProps > | undefined => {
@@ -82,7 +89,7 @@ const getRendererProps = (
8289 activePeekView ?. target instanceof HTMLElement
8390 ? activePeekView . target
8491 : undefined ,
85- padding : activePeekView . info . type !== 'image' ,
92+ mode : getMode ( activePeekView . info ) ,
8693 dialogFrame : activePeekView . info . type !== 'image' ,
8794 } ;
8895} ;
You can’t perform that action at this time.
0 commit comments