ui: responsive dialog size for portrait screens (#473)

* fix: handle network error in sync API

* fix: reasonable default column width for iPad

* ui: responsive dialog size for portrait screens
This commit is contained in:
Huang Xin
2025-03-01 17:57:29 +01:00
committed by GitHub
parent 2f29295c6c
commit 2db83b8569
16 changed files with 76 additions and 46 deletions
+25
View File
@@ -0,0 +1,25 @@
import { ViewSettings } from '@/types/book';
export const getMaxInlineSize = (viewSettings: ViewSettings) => {
const isScrolled = viewSettings.scrolled!;
const maxColumnCount = viewSettings.maxColumnCount!;
const screenWidth = window.innerWidth;
return maxColumnCount === 1 || isScrolled ? screenWidth : viewSettings.maxInlineSize!;
};
export const getDefaultMaxInlineSize = () => {
if (typeof window === 'undefined') return 720;
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
return screenWidth < screenHeight ? screenWidth : 720;
};
export const getDefaultMaxBlockSize = () => {
if (typeof window === 'undefined') return 1440;
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
return Math.max(screenWidth, screenHeight);
};